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 Aug 1, 2016
1 parent 8887405 commit f48acc6
Show file tree
Hide file tree
Showing 5 changed files with 29 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
26 changes: 23 additions & 3 deletions dp-core/vr_nexthop.c
Expand Up @@ -773,13 +773,18 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_forwarding_md *fmd,
unsigned int pkt_src, bool *flood_to_vms)
{
int handled = 1;
bool flood = false;
unsigned short trap, rt_flags, drop_reason, pull_len = 0;

l4_pkt_type_t l4_type = L4_TYPE_UNKNOWN;

struct vr_eth *eth;
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 @@ -836,7 +841,7 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_forwarding_md *fmd,

/*
* 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 @@ -849,12 +854,27 @@ nh_handle_mcast_control_pkt(struct vr_packet *pkt, struct vr_forwarding_md *fmd,
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 @@ -569,6 +569,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 @@ -273,6 +273,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 f48acc6

Please sign in to comment.