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 74bc8f2 commit 859f4b1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
4 changes: 0 additions & 4 deletions dp-core/vr_interface.c
Expand Up @@ -231,10 +231,6 @@ vif_xconnect(struct vr_interface *vif, struct vr_packet *pkt,
return 0;
}

/* agent driver */
#define AGENT_PKT_HEAD_SPACE (sizeof(struct vr_eth) + \
sizeof(struct agent_hdr))

static unsigned char *
agent_set_rewrite(struct vr_interface *vif, struct vr_packet *pkt,
struct vr_forwarding_md *fmd, unsigned char *rewrite,
Expand Down
25 changes: 22 additions & 3 deletions dp-core/vr_nexthop.c
Expand Up @@ -699,12 +699,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 @@ -760,7 +764,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 @@ -773,12 +777,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 @@ -562,6 +562,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
3 changes: 3 additions & 0 deletions include/vr_defs.h
Expand Up @@ -55,6 +55,9 @@ enum rt_type{
#define VR_BE_LABEL_VALID_FLAG 0x02
#define VR_BE_FLOOD_DHCP_FLAG 0x04

#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 @@ -265,6 +265,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 859f4b1

Please sign in to comment.