Skip to content

Commit

Permalink
bgpd: support for policy-routing context used with flowspec
Browse files Browse the repository at this point in the history
BGP flowspec will be able to inject or remove policy-routing contexts,
thanks to some protocols like flowspec. This commit adds some the APIS
necessary to create/delete policy routing contexts that will be injected
then into zebra.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
  • Loading branch information
pguibert6WIND committed Apr 30, 2018
1 parent 3971233 commit bbe6ffd
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bgpd/Makefile.am
Expand Up @@ -87,7 +87,7 @@ libbgp_a_SOURCES = \
bgp_encap_tlv.c $(BGP_VNC_RFAPI_SRC) bgp_attr_evpn.c \
bgp_evpn.c bgp_evpn_vty.c bgp_vpn.c bgp_label.c bgp_rd.c \
bgp_keepalives.c bgp_io.c bgp_flowspec.c bgp_flowspec_util.c \
bgp_flowspec_vty.c bgp_labelpool.c
bgp_flowspec_vty.c bgp_labelpool.c bgp_pbr.c

noinst_HEADERS = \
bgp_memory.h \
Expand All @@ -101,7 +101,7 @@ noinst_HEADERS = \
$(BGP_VNC_RFAPI_HD) bgp_attr_evpn.h bgp_evpn.h bgp_evpn_vty.h \
bgp_vpn.h bgp_label.h bgp_rd.h bgp_evpn_private.h bgp_keepalives.h \
bgp_io.h bgp_flowspec.h bgp_flowspec_private.h bgp_flowspec_util.h \
bgp_labelpool.h
bgp_labelpool.h bgp_pbr.h

bgpd_SOURCES = bgp_main.c
bgpd_LDADD = libbgp.a $(BGP_VNC_RFP_LIB) ../lib/libfrr.la @LIBCAP@ @LIBM@
Expand Down
44 changes: 44 additions & 0 deletions bgpd/bgp_pbr.c
@@ -0,0 +1,44 @@
/*
* BGP pbr
* Copyright (C) 6WIND
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "zebra.h"
#include "prefix.h"
#include "zclient.h"

#include "bgpd/bgp_pbr.h"


struct bgp_pbr_action *bgp_pbr_action_rule_lookup(uint32_t unique)
{
return NULL;
}

struct bgp_pbr_match *bgp_pbr_match_ipset_lookup(vrf_id_t vrf_id,
uint32_t unique)
{
return NULL;
}

struct bgp_pbr_match_entry *bgp_pbr_match_ipset_entry_lookup(vrf_id_t vrf_id,
char *ipset_name,
uint32_t unique)
{
return NULL;
}

81 changes: 81 additions & 0 deletions bgpd/bgp_pbr.h
@@ -0,0 +1,81 @@
/*
* BGP pbr
* Copyright (C) 6WIND
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __BGP_PBR_H__
#define __BGP_PBR_H__

#include "nexthop.h"
#include "zclient.h"

struct bgp_pbr_match {
char ipset_name[ZEBRA_IPSET_NAME_SIZE];

/* mapped on enum ipset_type
*/
uint32_t type;

uint32_t unique;

bool installed;
};

struct bgp_pbr_match_entry {
struct bgp_pbr_match *backpointer;

uint32_t unique;

struct prefix src;
struct prefix dst;

bool installed;
bool install_in_progress;
};

struct bgp_pbr_action {

/*
* The Unique identifier of this specific pbrms
*/
uint32_t unique;

uint32_t fwmark;

uint32_t table_id;

/*
* nexthop information, or drop information
* contains src vrf_id and nh contains dest vrf_id
*/
vrf_id_t vrf_id;
struct nexthop nh;

bool installed;
bool install_in_progress;

struct bgp_pbr_match *match;
};

extern struct bgp_pbr_action *bgp_pbr_action_rule_lookup(uint32_t unique);

extern struct bgp_pbr_match *bgp_pbr_match_ipset_lookup(vrf_id_t vrf_id,
uint32_t unique);

extern struct bgp_pbr_match_entry *bgp_pbr_match_ipset_entry_lookup(
vrf_id_t vrf_id, char *name,
uint32_t unique);
#endif /* __BGP_PBR_H__ */

0 comments on commit bbe6ffd

Please sign in to comment.