Skip to content

Commit

Permalink
Trap & Flood neighbor advertisements
Browse files Browse the repository at this point in the history
Change-Id: I822e1f1d4ca8f43bd648383a46f3f5bb30d0274a
Closes-Bug: #1592119
  • Loading branch information
anandhk-juniper committed Sep 12, 2016
1 parent 0422158 commit 30519e3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
25 changes: 22 additions & 3 deletions dp-core/vr_nexthop.c
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions dp-core/vr_proto_ip6.c
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions include/vr_defs.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/vr_packet.h
Expand Up @@ -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 {
Expand Down

0 comments on commit 30519e3

Please sign in to comment.