Add error handling for unlikely case where getting IP address of an
interface fails.
Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ief8642af79fb1d25f061357cd716b93cfdf23fc8
* this is the first address on the interface.
*/
src4 = ip_interface_get_first_ip (vr->config.sw_if_index, 1);
* this is the first address on the interface.
*/
src4 = ip_interface_get_first_ip (vr->config.sw_if_index, 1);
+ if (!src4)
+ {
+ return -1;
+ }
ip4->src_address.as_u32 = src4->as_u32;
ip4->length = clib_host_to_net_u16 (sizeof (*ip4) +
vrrp_adv_payload_len (vr));
ip4->src_address.as_u32 = src4->as_u32;
ip4->length = clib_host_to_net_u16 (sizeof (*ip4) +
vrrp_adv_payload_len (vr));
else
vrrp_adv_l2_build_multicast (vr, b);
else
vrrp_adv_l2_build_multicast (vr, b);
- vrrp_adv_l3_build (vr, b, dst);
+ if (-1 == vrrp_adv_l3_build (vr, b, dst))
+ {
+ vlib_frame_free (vm, vlib_node_get_runtime (vm, node_index),
+ to_frame);
+ vlib_buffer_free (vm, bi, n_buffers);
+ return -1;
+ }
vrrp_adv_payload_build (vr, b, shutdown);
vlib_buffer_reset (b);
vrrp_adv_payload_build (vr, b, shutdown);
vlib_buffer_reset (b);
.dst_address = {.as_u8 = IGMP4_MCAST_ADDR_AS_U8,},
};
.dst_address = {.as_u8 = IGMP4_MCAST_ADDR_AS_U8,},
};
-static void
-vrrp_igmp_pkt_build (vrrp_vr_t * vr, vlib_buffer_t * b)
+static int
+vrrp_igmp_pkt_build (vrrp_vr_t *vr, vlib_buffer_t *b)
{
ip4_header_t *ip4;
u8 *ip4_options;
{
ip4_header_t *ip4;
u8 *ip4_options;
/* Use the source address advertisements will use to join mcast group */
src4 = ip_interface_get_first_ip (vr->config.sw_if_index, 1);
/* Use the source address advertisements will use to join mcast group */
src4 = ip_interface_get_first_ip (vr->config.sw_if_index, 1);
+ if (!src4)
+ {
+ return -1;
+ }
ip4->src_address.as_u32 = src4->as_u32;
vlib_buffer_chain_increase_length (b, b, sizeof (*ip4));
ip4->src_address.as_u32 = src4->as_u32;
vlib_buffer_chain_increase_length (b, b, sizeof (*ip4));
~ip_csum_fold (ip_incremental_checksum (0, report, payload_len));
vlib_buffer_reset (b);
~ip_csum_fold (ip_incremental_checksum (0, report, payload_len));
vlib_buffer_reset (b);
}
/* multicast listener report packet format for ethernet. */
}
/* multicast listener report packet format for ethernet. */
- vrrp_igmp_pkt_build (vr, b);
+ if (-1 == vrrp_igmp_pkt_build (vr, b))
+ {
+ clib_warning ("IGMP packet build failed for %U", format_vrrp_vr_key,
+ vr);
+ vlib_buffer_free (vm, &bi, 1);
+ return -1;
+ }
node_index = ip4_rewrite_mcast_node.index;
}
node_index = ip4_rewrite_mcast_node.index;
}