From 30519e3ee90acc47609a7df2807f2fc0fb9e595f Mon Sep 17 00:00:00 2001 From: "Anand H. Krishnan" Date: Thu, 28 Jul 2016 13:58:43 +0530 Subject: [PATCH] Trap & Flood neighbor advertisements Change-Id: I822e1f1d4ca8f43bd648383a46f3f5bb30d0274a Closes-Bug: #1592119 --- dp-core/vr_nexthop.c | 25 ++++++++++++++++++++++--- dp-core/vr_proto_ip6.c | 2 ++ include/vr_defs.h | 1 + include/vr_packet.h | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/dp-core/vr_nexthop.c b/dp-core/vr_nexthop.c index 10ad1c52a..5462c6635 100644 --- a/dp-core/vr_nexthop.c +++ b/dp-core/vr_nexthop.c @@ -799,12 +799,16 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_eth *eth, { int handled = 1; unsigned char eth_dmac[VR_ETHER_ALEN]; + bool flood = false; unsigned short trap, rt_flags, drop_reason, pull_len = 0; + l4_pkt_type_t l4_type = L4_TYPE_UNKNOWN; struct vr_arp *sarp; struct vr_nexthop *src_nh; struct vr_ip6 *ip6; + struct vr_packet *pkt_c = NULL; + /* * The vlan tagged packets are meant to be handled only by VM's */ @@ -860,7 +864,7 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_eth *eth, /* * If packet is identified as known packet, we always trap - * it to Agentm with the exception of DHCP. DHCP can be flooded + * it to agent with the exception of DHCP. DHCP can be flooded * depending on the configuration on VMI or L2 route flags */ if (l4_type != L4_TYPE_UNKNOWN) { @@ -873,12 +877,27 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_eth *eth, trap = false; } else if (l4_type == L4_TYPE_NEIGHBOUR_SOLICITATION) { trap = false; + } else if (l4_type == L4_TYPE_NEIGHBOUR_ADVERTISEMENT) { + flood = true; } + if (trap && flood) { + pkt_c = nh_mcast_clone(pkt, AGENT_PKT_HEAD_SPACE); + if (!pkt_c) { + trap = false; + } + } if (trap) { - vr_trap(pkt, fmd->fmd_dvrf, AGENT_TRAP_L3_PROTOCOLS, NULL); - return handled; + if (flood) { + vr_trap(pkt_c, fmd->fmd_dvrf, + AGENT_TRAP_L3_PROTOCOLS, NULL); + goto unhandled; + } else { + vr_trap(pkt, fmd->fmd_dvrf, + AGENT_TRAP_L3_PROTOCOLS, NULL); + return handled; + } } } } diff --git a/dp-core/vr_proto_ip6.c b/dp-core/vr_proto_ip6.c index 7f6304699..fb7a25e7f 100644 --- a/dp-core/vr_proto_ip6.c +++ b/dp-core/vr_proto_ip6.c @@ -575,6 +575,8 @@ vr_ip6_well_known_packet(struct vr_packet *pkt) return L4_TYPE_ROUTER_SOLICITATION; if (icmph && (icmph->icmp_type == VR_ICMP6_TYPE_NEIGH_SOL)) return L4_TYPE_NEIGHBOUR_SOLICITATION; + if (icmph && (icmph->icmp_type == VR_ICMP6_TYPE_NEIGH_AD)) + return L4_TYPE_NEIGHBOUR_ADVERTISEMENT; } if (ip6->ip6_nxt == VR_IP_PROTO_UDP) { diff --git a/include/vr_defs.h b/include/vr_defs.h index 7e08f4757..4fdff11e6 100644 --- a/include/vr_defs.h +++ b/include/vr_defs.h @@ -57,6 +57,7 @@ enum rt_type{ #define AGENT_PKT_HEAD_SPACE (sizeof(struct vr_eth) + \ sizeof(struct agent_hdr)) + struct agent_hdr { unsigned short hdr_ifindex; unsigned short hdr_vrf; diff --git a/include/vr_packet.h b/include/vr_packet.h index f0096d1f1..4b9141c9a 100644 --- a/include/vr_packet.h +++ b/include/vr_packet.h @@ -275,6 +275,7 @@ typedef enum { L4_TYPE_DHCP_REQUEST, L4_TYPE_ROUTER_SOLICITATION, L4_TYPE_NEIGHBOUR_SOLICITATION, + L4_TYPE_NEIGHBOUR_ADVERTISEMENT, } l4_pkt_type_t; struct vr_eth {