]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: support for policy-routing context used with flowspec
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 8 Mar 2018 14:37:06 +0000 (15:37 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 3 May 2018 13:15:07 +0000 (15:15 +0200)
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>
bgpd/Makefile.am
bgpd/bgp_pbr.c [new file with mode: 0644]
bgpd/bgp_pbr.h [new file with mode: 0644]

index a2880b7b94801d0e56f22950d9bc99dac8254333..8a410adca16f547446446d69c58b5e780346c3f7 100644 (file)
@@ -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 \
@@ -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@
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c
new file mode 100644 (file)
index 0000000..21f970c
--- /dev/null
@@ -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;
+}
+
diff --git a/bgpd/bgp_pbr.h b/bgpd/bgp_pbr.h
new file mode 100644 (file)
index 0000000..23735a3
--- /dev/null
@@ -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__ */