From 9c25eb1f4876a399919782c97e116732ea2ee628 Mon Sep 17 00:00:00 2001 From: Filip Varga Date: Thu, 21 Oct 2021 13:00:27 +0200 Subject: 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 --- src/plugins/nat/nat44-ed/nat44_ed_api.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/plugins/nat/nat44-ed') diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c index 15059752ee7..6123544087b 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_api.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c @@ -552,24 +552,25 @@ vl_api_nat44_ed_add_del_output_interface_t_handler ( { vl_api_nat44_ed_add_del_output_interface_reply_t *rmp; snat_main_t *sm = &snat_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; + } if (mp->is_add) { - rv = nat44_ed_add_output_interface (sw_if_index); + rv = nat44_ed_add_output_interface (mp->sw_if_index); } else { - rv = nat44_ed_del_output_interface (sw_if_index); + rv = nat44_ed_del_output_interface (mp->sw_if_index); } - BAD_SW_IF_INDEX_LABEL; - REPLY_MACRO (VL_API_NAT44_ED_ADD_DEL_OUTPUT_INTERFACE_REPLY); +bad_sw_if_index: + REPLY_MACRO_END (VL_API_NAT44_ED_ADD_DEL_OUTPUT_INTERFACE_REPLY); } #define vl_endianfun -- cgit 1.2.3-korg