diff options
author | Filip Varga <fivarga@cisco.com> | 2021-10-21 13:00:27 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-11-10 10:48:19 +0000 |
commit | 9c25eb1f4876a399919782c97e116732ea2ee628 (patch) | |
tree | 82ec5f326d2ebb326983abe6b4d2595729af46d1 /src/plugins/nat/nat44-ei/nat44_ei_api.c | |
parent | 603231f447f197e7bc45bdb75bf5d77420e682b9 (diff) |
nat: api autoendian fix
Fixed bad use of macros for autoendian API calls
and updated tests for the new API. Removed sw_if_index
check macro because of ntol conversion. Changed
REPLY_MACRO to REPLY_MACRO_END to fix ntohl conversions.
Type: fix
Change-Id: I878a07b3f80fe03179feab60f0abc662f408a2c8
Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44-ei/nat44_ei_api.c')
-rw-r--r-- | src/plugins/nat/nat44-ei/nat44_ei_api.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/plugins/nat/nat44-ei/nat44_ei_api.c b/src/plugins/nat/nat44-ei/nat44_ei_api.c index c6d17c94205..b67bc7dfb88 100644 --- a/src/plugins/nat/nat44-ei/nat44_ei_api.c +++ b/src/plugins/nat/nat44-ei/nat44_ei_api.c @@ -533,18 +533,22 @@ vl_api_nat44_ei_interface_add_del_feature_t_handler ( nat44_ei_main_t *nm = &nat44_ei_main; vl_api_nat44_ei_interface_add_del_feature_reply_t *rmp; u32 sw_if_index = ntohl (mp->sw_if_index); - u8 is_del; int rv = 0; - is_del = !mp->is_add; - VALIDATE_SW_IF_INDEX (mp); - rv = nat44_ei_add_del_interface (sw_if_index, mp->flags & NAT44_EI_IF_INSIDE, - is_del); + if (mp->is_add) + { + rv = + nat44_ei_add_interface (sw_if_index, mp->flags & NAT44_EI_IF_INSIDE); + } + else + { + rv = + nat44_ei_del_interface (sw_if_index, mp->flags & NAT44_EI_IF_INSIDE); + } BAD_SW_IF_INDEX_LABEL; - REPLY_MACRO (VL_API_NAT44_EI_INTERFACE_ADD_DEL_FEATURE_REPLY); } @@ -648,7 +652,14 @@ vl_api_nat44_ei_interface_add_del_output_feature_t_handler ( if (!(mp->flags & NAT44_EI_IF_INSIDE)) { - rv = nat44_ei_add_del_output_interface (sw_if_index, !mp->is_add); + if (mp->is_add) + { + rv = nat44_ei_add_output_interface (sw_if_index); + } + else + { + rv = nat44_ei_del_output_interface (sw_if_index); + } } BAD_SW_IF_INDEX_LABEL; @@ -702,17 +713,25 @@ vl_api_nat44_ei_add_del_output_interface_t_handler ( { vl_api_nat44_ei_add_del_output_interface_reply_t *rmp; nat44_ei_main_t *nm = &nat44_ei_main; - u32 sw_if_index; int rv = 0; - VALIDATE_SW_IF_INDEX (mp); - - sw_if_index = ntohl (mp->sw_if_index); + if (!vnet_sw_if_index_is_api_valid (mp->sw_if_index)) + { + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; + goto bad_sw_if_index; + } - rv = nat44_ei_add_del_output_interface (sw_if_index, !mp->is_add); + if (mp->is_add) + { + rv = nat44_ei_add_output_interface (mp->sw_if_index); + } + else + { + rv = nat44_ei_del_output_interface (mp->sw_if_index); + } - BAD_SW_IF_INDEX_LABEL; - REPLY_MACRO (VL_API_NAT44_EI_ADD_DEL_OUTPUT_INTERFACE_REPLY); +bad_sw_if_index: + REPLY_MACRO_END (VL_API_NAT44_EI_ADD_DEL_OUTPUT_INTERFACE_REPLY); } #define vl_endianfun |