From 9c6fd897fdad825b83e2eb8ff68e6b8f03312f3e Mon Sep 17 00:00:00 2001 From: Stanislav Zaikin Date: Fri, 13 Oct 2023 17:48:53 +0200 Subject: bonding: add checks for sw_if_index in api Type: fix Signed-off-by: Stanislav Zaikin Change-Id: I16b48460b3fcd82bbb89c375402cb2455414d8bb --- src/vnet/bonding/bond_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/vnet') diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c index 3fd73d7995f..5087ff5dce3 100644 --- a/src/vnet/bonding/bond_api.c +++ b/src/vnet/bonding/bond_api.c @@ -43,8 +43,11 @@ vl_api_bond_delete_t_handler (vl_api_bond_delete_t * mp) vl_api_bond_delete_reply_t *rmp; u32 sw_if_index = ntohl (mp->sw_if_index); + VALIDATE_SW_IF_INDEX (mp); + rv = bond_delete_if (vm, sw_if_index); + BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_BOND_DELETE_REPLY); } @@ -168,6 +171,8 @@ static void vl_api_sw_interface_set_bond_weight_reply_t *rmp; int rv = 0; + VALIDATE_SW_IF_INDEX (mp); + clib_memset (ap, 0, sizeof (*ap)); ap->sw_if_index = ntohl (mp->sw_if_index); @@ -176,6 +181,7 @@ static void bond_set_intf_weight (vm, ap); rv = ap->rv; + BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_SW_INTERFACE_SET_BOND_WEIGHT_REPLY); } @@ -187,12 +193,15 @@ vl_api_bond_detach_slave_t_handler (vl_api_bond_detach_slave_t * mp) bond_detach_member_args_t _a, *ap = &_a; int rv = 0; + VALIDATE_SW_IF_INDEX (mp); + clib_memset (ap, 0, sizeof (*ap)); ap->member = ntohl (mp->sw_if_index); bond_detach_member (vm, ap); rv = ap->rv; + BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_BOND_DETACH_SLAVE_REPLY); } @@ -204,12 +213,15 @@ vl_api_bond_detach_member_t_handler (vl_api_bond_detach_member_t * mp) bond_detach_member_args_t _a, *ap = &_a; int rv = 0; + VALIDATE_SW_IF_INDEX (mp); + clib_memset (ap, 0, sizeof (*ap)); ap->member = ntohl (mp->sw_if_index); bond_detach_member (vm, ap); rv = ap->rv; + BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_BOND_DETACH_MEMBER_REPLY); } -- cgit 1.2.3-korg