summaryrefslogtreecommitdiffstats
path: root/src/vnet/dhcp/dhcp6_pd_client_cp.c
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2018-06-12 10:21:05 +0200
committerOle Trøan <otroan@employees.org>2018-06-15 09:34:44 +0000
commitd9778c2b196ad624dd1bf7beda888e946a01fbcf (patch)
tree362cd5d297e009f3622c545bf1ce1894d99b9e01 /src/vnet/dhcp/dhcp6_pd_client_cp.c
parenta6110b6ea5a066b64005347850f61df9a2000fe9 (diff)
Update DHCPv6 DUID code and fix coverity warnings
- Generate client DUID only when DHCPv6 PD feature is enabled - Change client DUID type from DUID-LLT to DUID-LL - Fix coverity warnings Change-Id: I20e518fc9a1c5f3f7ea9add7e7e03a487c99e978 Signed-off-by: Juraj Sloboda <jsloboda@cisco.com>
Diffstat (limited to 'src/vnet/dhcp/dhcp6_pd_client_cp.c')
-rw-r--r--src/vnet/dhcp/dhcp6_pd_client_cp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/vnet/dhcp/dhcp6_pd_client_cp.c b/src/vnet/dhcp/dhcp6_pd_client_cp.c
index ecb85e1f5a6..a2a0618106c 100644
--- a/src/vnet/dhcp/dhcp6_pd_client_cp.c
+++ b/src/vnet/dhcp/dhcp6_pd_client_cp.c
@@ -658,7 +658,7 @@ cp_ip6_construct_address (ip6_address_info_t * address_info, u32 prefix_index,
clib_warning ("Prefix length is bigger that 64 bits");
return 1;
}
- mask = (1 << (64 - prefix->prefix_length)) - 1;
+ mask = ((u64) 1 << (64 - prefix->prefix_length)) - 1;
addr0 &= mask;
pref = clib_host_to_net_u64 (prefix->prefix.as_u64[0]);
pref &= ~mask;
@@ -871,10 +871,17 @@ cp_ip6_address_add_del (u32 sw_if_index, const u8 * prefix_group,
{
ip6_address_with_prefix_main_t *apm = &ip6_address_with_prefix_main;
+ vnet_main_t *vnm = vnet_get_main ();
ip6_address_info_t *address_info;
u32 prefix_group_index;
u32 n;
+ if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
+ {
+ clib_warning ("Invalid sw_if_index");
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+
if (prefix_group != 0 && prefix_group[0] != '\0')
{
if (strnlen ((const char *) prefix_group, 64) == 64)
@@ -927,12 +934,9 @@ static void
u8 prefix_length;
int rv = 0;
+ VALIDATE_SW_IF_INDEX (mp);
+
sw_if_index = ntohl (mp->sw_if_index);
- if (!vnet_sw_if_index_is_api_valid (sw_if_index))
- {
- rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
- goto bad_sw_if_index;
- }
memcpy (address.as_u8, mp->address, 16);
prefix_length = mp->prefix_length;