bonding: enhance binary api handling
- check input sw_if_index to make sure it is sane. Coverity actually
complains about it.
- return rv. Some of the APIs handlers were not passing back the rv.
Type: improvement
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I8378ea948af561ba2bd9b02fb10bf4f9df2a2cd2
diff --git a/src/vnet/bonding/bond_api.c b/src/vnet/bonding/bond_api.c
index 2395a47..4306e3c 100644
--- a/src/vnet/bonding/bond_api.c
+++ b/src/vnet/bonding/bond_api.c
@@ -113,12 +113,15 @@
clib_memset (ap, 0, sizeof (*ap));
ap->group = ntohl (mp->bond_sw_if_index);
+ VALIDATE_SW_IF_INDEX (mp);
ap->member = ntohl (mp->sw_if_index);
ap->is_passive = mp->is_passive;
ap->is_long_timeout = mp->is_long_timeout;
bond_add_member (vm, ap);
+ rv = ap->rv;
+ BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_BOND_ADD_MEMBER_REPLY);
}
@@ -133,12 +136,15 @@
clib_memset (ap, 0, sizeof (*ap));
ap->group = ntohl (mp->bond_sw_if_index);
+ VALIDATE_SW_IF_INDEX (mp);
ap->member = ntohl (mp->sw_if_index);
ap->is_passive = mp->is_passive;
ap->is_long_timeout = mp->is_long_timeout;
bond_add_member (vm, ap);
+ rv = ap->rv;
+ BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_BOND_ENSLAVE_REPLY);
}
@@ -157,6 +163,7 @@
ap->weight = ntohl (mp->weight);
bond_set_intf_weight (vm, ap);
+ rv = ap->rv;
REPLY_MACRO (VL_API_SW_INTERFACE_SET_BOND_WEIGHT_REPLY);
}
@@ -173,6 +180,7 @@
ap->member = ntohl (mp->sw_if_index);
bond_detach_member (vm, ap);
+ rv = ap->rv;
REPLY_MACRO (VL_API_BOND_DETACH_SLAVE_REPLY);
}
@@ -189,6 +197,7 @@
ap->member = ntohl (mp->sw_if_index);
bond_detach_member (vm, ap);
+ rv = ap->rv;
REPLY_MACRO (VL_API_BOND_DETACH_MEMBER_REPLY);
}