summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/pnat/pnat_api.c
diff options
context:
space:
mode:
authorOle Troan <otroan@employees.org>2024-04-26 14:11:20 +0200
committerDamjan Marion <dmarion@0xa5.net>2024-05-07 09:59:31 +0000
commit1a319aadc68c218f741a7cb23acbe70c4addae92 (patch)
tree766211fc3f5b37de2626f2f7895094fc5c44f896 /src/plugins/nat/pnat/pnat_api.c
parent4013851e42b94ebfa0a2ae398c58ecc9ea9b5c95 (diff)
api: add to_net parameter to endian messages
The VPP API auto-generated endian conversion functions are intended to be symmetrical. They are used both by the API client and the API server. Called on send to convert from host endian to network endian and on receive to convert back. For variable length arrays, we have to iterate over the array and call a more specific handler for the array type. Unfortunately the length of the array is part of the api definition, and if it's endian swapped prior to the for loop, unexpected behaviour will ensue. There was an earlier fix, for some specific messages, but unfortunately that only fixed the problem from the VPP (server) side. This adds a new parameters to the endian handler, so the boundary argument to the loop can be treated differently depending on if this message is to the network or from the network. Type: fix Change-Id: I43011aed384e3b847579a1dd2c390867ae17a9ad Signed-off-by: Ole Troan <otroan@employees.org>
Diffstat (limited to 'src/plugins/nat/pnat/pnat_api.c')
-rw-r--r--src/plugins/nat/pnat/pnat_api.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/nat/pnat/pnat_api.c b/src/plugins/nat/pnat/pnat_api.c
index 02e61219d1e..a4e7ff192bf 100644
--- a/src/plugins/nat/pnat/pnat_api.c
+++ b/src/plugins/nat/pnat/pnat_api.c
@@ -116,7 +116,8 @@ static void send_bindings_details(u32 index, vl_api_registration_t *rp,
/* Endian hack until apigen registers _details
* endian functions */
- vl_api_pnat_bindings_details_t_endian(rmp);
+ vl_api_pnat_bindings_details_t_endian(
+ rmp, 1 /* to network */);
rmp->_vl_msg_id = htons(rmp->_vl_msg_id);
rmp->context = htonl(rmp->context);
}));
@@ -158,7 +159,7 @@ static void send_interfaces_details(u32 index, vl_api_registration_t *rp,
/* Endian hack until apigen registers _details
* endian functions */
- vl_api_pnat_interfaces_details_t_endian(rmp);
+ vl_api_pnat_interfaces_details_t_endian(rmp, 1 /* to network */);
rmp->_vl_msg_id = htons(rmp->_vl_msg_id);
rmp->context = htonl(rmp->context);
}));