Commit ac3ad139 authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

BGP: Add support for flowspec (RFC 5575)

parent b7605d5c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ const char *flow_type_str(enum flow_type type, int ipv6);

uint flow_write_length(byte *data, u16 len);

static inline u16 flow_hdr_length(const byte *data)
{ return ((*data & 0xf0) == 0xf0) ? 2 : 1; }

static inline u16 flow_read_length(const byte *data)
{ return ((*data & 0xf0) == 0xf0) ? get_u16(data) & 0x0fff : *data; }

+12 −4
Original line number Diff line number Diff line
@@ -1221,8 +1221,8 @@ bgp_init_prefix_table(struct bgp_channel *c)
{
  HASH_INIT(c->prefix_hash, c->pool, 8);

  c->prefix_slab = sl_new(c->pool, sizeof(struct bgp_prefix) +
			  net_addr_length[c->c.net_type]);
  uint alen = net_addr_length[c->c.net_type];
  c->prefix_slab = alen ? sl_new(c->pool, sizeof(struct bgp_prefix) + alen) : NULL;
}

static struct bgp_prefix *
@@ -1237,7 +1237,11 @@ bgp_get_prefix(struct bgp_channel *c, net_addr *net, u32 path_id)
    return px;
  }

  if (c->prefix_slab)
    px = sl_alloc(c->prefix_slab);
  else
    px = mb_alloc(c->pool, sizeof(struct bgp_prefix) + net->length);

  px->buck_node.next = NULL;
  px->buck_node.prev = NULL;
  px->hash = hash;
@@ -1254,7 +1258,11 @@ bgp_free_prefix(struct bgp_channel *c, struct bgp_prefix *px)
{
  rem_node(&px->buck_node);
  HASH_REMOVE2(c->prefix_hash, PXH, c->pool, px);

  if (c->prefix_slab)
    sl_free(c->prefix_slab, px);
  else
    mb_free(px);
}


+1 −1
Original line number Diff line number Diff line
@@ -1846,7 +1846,7 @@ struct protocol proto_bgp = {
  .template = 		"bgp%d",
  .attr_class = 	EAP_BGP,
  .preference = 	DEF_PREF_BGP,
  .channel_mask =	NB_IP,
  .channel_mask =	NB_IP | NB_FLOW4 | NB_FLOW6,
  .proto_size =		sizeof(struct bgp_proto),
  .config_size =	sizeof(struct bgp_config),
  .postconfig =		bgp_postconfig,
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ struct eattr;

#define BGP_SAFI_UNICAST	1
#define BGP_SAFI_MULTICAST	2
#define BGP_SAFI_FLOW		133

/* Internal AF codes */

@@ -42,6 +43,8 @@ struct eattr;
#define BGP_AF_IPV6		BGP_AF( BGP_AFI_IPV6, BGP_SAFI_UNICAST )
#define BGP_AF_IPV4_MC		BGP_AF( BGP_AFI_IPV4, BGP_SAFI_MULTICAST )
#define BGP_AF_IPV6_MC		BGP_AF( BGP_AFI_IPV6, BGP_SAFI_MULTICAST )
#define BGP_AF_FLOW4		BGP_AF( BGP_AFI_IPV4, BGP_SAFI_FLOW )
#define BGP_AF_FLOW6		BGP_AF( BGP_AFI_IPV6, BGP_SAFI_FLOW )


struct bgp_write_state;
+3 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE,
	BGP_CLUSTER_LIST, IGP, TABLE, GATEWAY, DIRECT, RECURSIVE, MED, TTL,
	SECURITY, DETERMINISTIC, SECONDARY, ALLOW, BFD, ADD, PATHS, RX, TX,
	GRACEFUL, RESTART, AWARE, CHECK, LINK, PORT, EXTENDED, MESSAGES, SETKEY,
	STRICT, BIND, CONFEDERATION, MEMBER, MULTICAST)
	STRICT, BIND, CONFEDERATION, MEMBER, MULTICAST, FLOW4, FLOW6)

%type <i32> bgp_afi

@@ -139,6 +139,8 @@ bgp_afi:
 | IPV6 { $$ = BGP_AF_IPV6; }
 | IPV4 MULTICAST { $$ = BGP_AF_IPV4_MC; }
 | IPV6 MULTICAST { $$ = BGP_AF_IPV6_MC; }
 | FLOW4 { $$ = BGP_AF_FLOW4; }
 | FLOW6 { $$ = BGP_AF_FLOW6; }
 ;

bgp_channel_start: bgp_afi
Loading