summaryrefslogtreecommitdiffstats
path: root/bgpd/rfapi/rfapi_import.h
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2016-05-07 20:18:56 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-10-03 14:17:02 +0200
commit65efcfce427e2abb548874ebb1a11a3b2ee7bc17 (patch)
tree7e1f42c135a093e0e11557fcc991bbf42e5dd208 /bgpd/rfapi/rfapi_import.h
parentlib: add skiplist (diff)
downloadfrr-65efcfce427e2abb548874ebb1a11a3b2ee7bc17.tar.xz
frr-65efcfce427e2abb548874ebb1a11a3b2ee7bc17.zip
bgpd: add L3/L2VPN Virtual Network Control feature
This feature adds an L3 & L2 VPN application that makes use of the VPN and Encap SAFIs. This code is currently used to support IETF NVO3 style operation. In NVO3 terminology it provides the Network Virtualization Authority (NVA) and the ability to import/export IP prefixes and MAC addresses from Network Virtualization Edges (NVEs). The code supports per-NVE tables. The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2 (L2) forwarding information between NVAs and NVEs is referred to as the Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For general background on NVO3 and RFP concepts see [1]. For information on Openflow see [2]. RFPs are integrated with BGP via the RF API contained in the new "rfapi" BGP sub-directory. Currently, only a simple example RFP is included in Quagga. Developers may use this example as a starting point to integrate Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code also supports the ability import/export of routing information between VNC and customer edge routers (CEs) operating within a virtual network. Import/export may take place between BGP views or to the default zebera VRF. BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN information between NVAs. BGP based IP VPN support is defined in RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659, BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use of both the Encapsulation Subsequent Address Family Identifier (SAFI) and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation Subsequent Address Family Identifier (SAFI) and the BGP Tunnel Encapsulation Attribute, are supported. MAC address distribution does not follow any standard BGB encoding, although it was inspired by the early IETF EVPN concepts. The feature is conditionally compiled and disabled by default. Use the --enable-bgp-vnc configure option to enable. The majority of this code was authored by G. Paul Ziemba <paulz@labn.net>. [1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req [2] https://www.opennetworking.org/sdn-resources/technical-library Now includes changes needed to merge with cmaster-next.
Diffstat (limited to 'bgpd/rfapi/rfapi_import.h')
-rw-r--r--bgpd/rfapi/rfapi_import.h283
1 files changed, 283 insertions, 0 deletions
diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h
new file mode 100644
index 000000000..9e88b52f5
--- /dev/null
+++ b/bgpd/rfapi/rfapi_import.h
@@ -0,0 +1,283 @@
+/*
+ *
+ * Copyright 2009-2016, LabN Consulting, L.L.C.
+ *
+ *
+ * This program 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+/*
+ * File: rfapi_import.h
+ * Purpose: Handle import of routes from BGP to RFAPI
+ */
+
+#ifndef QUAGGA_HGP_RFAPI_IMPORT_H
+#define QUAGGA_HGP_RFAPI_IMPORT_H
+
+#include "thread.h"
+
+/*
+ * These are per-rt-import-list
+ *
+ * routes are not segregated by RD - the RD is stored in bgp_info_extra
+ * and is needed to determine if two prefixes are the same.
+ */
+struct rfapi_import_table
+{
+ struct rfapi_import_table *next;
+ struct ecommunity *rt_import_list; /* copied from nve grp */
+ int refcount; /* nve grps and nves */
+ uint32_t l2_logical_net_id; /* L2 only: EVPN Eth Seg Id */
+ struct route_table *imported_vpn[AFI_MAX];
+ struct rfapi_monitor_vpn *vpn0_queries[AFI_MAX];
+ struct rfapi_monitor_eth *eth0_queries;
+ struct route_table *imported_encap[AFI_MAX];
+ struct skiplist *monitor_exterior_orphans;
+ int local_count[AFI_MAX];
+ int remote_count[AFI_MAX];
+ int holddown_count[AFI_MAX];
+ int imported_count[AFI_MAX];
+};
+
+#define RFAPI_LOCAL_BI(bi) \
+ (((bi)->type == ZEBRA_ROUTE_BGP) && ((bi)->sub_type == BGP_ROUTE_RFP))
+
+#define RFAPI_DIRECT_IMPORT_BI(bi) \
+ (((bi)->type == ZEBRA_ROUTE_BGP_DIRECT) || ((bi)->type == ZEBRA_ROUTE_BGP_DIRECT_EXT))
+
+#define RFAPI_UPDATE_ITABLE_COUNT(bi, itable, afi, cnt) \
+ if (RFAPI_LOCAL_BI(bi)) { \
+ (itable)->local_count[(afi)] += (cnt); \
+ } else { \
+ if (RFAPI_DIRECT_IMPORT_BI(bi)) \
+ (itable)->imported_count[(afi)] += (cnt); \
+ else \
+ (itable)->remote_count[(afi)] += (cnt); \
+ }
+
+extern uint8_t
+rfapiRfpCost (struct attr *attr);
+
+extern void
+rfapiDebugBacktrace (void);
+
+extern void
+rfapiCheckRouteCount (void);
+
+/*
+ * Print BI in an Import Table
+ */
+extern void
+rfapiPrintBi (void *stream, struct bgp_info *bi);
+
+extern void
+rfapiShowImportTable (
+ void *stream,
+ const char *label,
+ struct route_table *rt,
+ int isvpn);
+
+
+extern void
+rfapiImportTableRefDelByIt (
+ struct bgp *bgp,
+ struct rfapi_import_table *it_target);
+
+
+/*
+ * Construct an rfapi nexthop list based on the routes attached to
+ * the specified node.
+ *
+ * If there are any routes that do NOT have BGP_INFO_REMOVED set,
+ * return those only. If there are ONLY routes with BGP_INFO_REMOVED,
+ * then return those, and also include all the non-removed routes from the
+ * next less-specific node (i.e., this node's parent) at the end.
+ */
+extern struct rfapi_next_hop_entry *
+rfapiRouteNode2NextHopList (
+ struct route_node *rn,
+ uint32_t lifetime, /* put into nexthop entries */
+ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
+ struct route_table *rfd_rib_table, /* preload this NVE rib table */
+ struct prefix *pfx_target_original); /* query target */
+
+extern struct rfapi_next_hop_entry *
+rfapiRouteTable2NextHopList (
+ struct route_table *rt,
+ uint32_t lifetime, /* put into nexthop entries */
+ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
+ struct route_table *rfd_rib_table, /* preload this NVE rib table */
+ struct prefix *pfx_target_original); /* query target */
+
+extern struct rfapi_next_hop_entry *
+rfapiEthRouteTable2NextHopList (
+ uint32_t logical_net_id,
+ struct rfapi_ip_prefix *rprefix,
+ uint32_t lifetime, /* put into nexthop entries */
+ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
+ struct route_table *rib_route_table,/* preload NVE rib node */
+ struct prefix *pfx_target_original); /* query target */
+
+extern int
+rfapiEcommunitiesIntersect (struct ecommunity *e1, struct ecommunity *e2);
+
+extern void
+rfapiCheckRefcount (struct route_node *rn, safi_t safi, int lockoffset);
+
+extern int
+rfapiHasNonRemovedRoutes (struct route_node *rn);
+
+extern int
+rfapiProcessDeferredClose (struct thread *t);
+
+extern int
+rfapiGetUnAddrOfVpnBi (struct bgp_info *bi, struct prefix *p);
+
+extern void
+rfapiNexthop2Prefix (struct attr *attr, struct prefix *p);
+
+extern void
+rfapiUnicastNexthop2Prefix (
+ afi_t afi,
+ struct attr *attr,
+ struct prefix *p);
+
+/* Filtered Import Function actions */
+#define FIF_ACTION_UPDATE 0
+#define FIF_ACTION_WITHDRAW 1
+#define FIF_ACTION_KILL 2
+
+extern void
+rfapiBgpInfoFilteredImportVPN (
+ struct rfapi_import_table *import_table,
+ int action,
+ struct peer *peer,
+ void *rfd, /* set for looped back routes */
+ struct prefix *p,
+ struct prefix *aux_prefix, /* AFI_ETHER: optional IP */
+ afi_t afi,
+ struct prefix_rd *prd,
+ struct attr *attr, /* part of bgp_info */
+ u_char type, /* part of bgp_info */
+ u_char sub_type, /* part of bgp_info */
+ uint32_t *label); /* part of bgp_info */
+
+extern struct rfapi_next_hop_entry *
+rfapiEthRouteNode2NextHopList (
+ struct route_node *rn,
+ struct rfapi_ip_prefix *rprefix,
+ uint32_t lifetime, /* put into nexthop entries */
+ struct rfapi_ip_addr *exclude_vnaddr, /* omit routes to same NVE */
+ struct route_table *rib_route_table,/* preload NVE rib table */
+ struct prefix *pfx_target_original); /* query target */
+
+extern struct rfapi_import_table *
+rfapiMacImportTableGetNoAlloc (
+ struct bgp *bgp,
+ uint32_t lni);
+
+extern struct rfapi_import_table *
+rfapiMacImportTableGet (
+ struct bgp *bgp,
+ uint32_t lni);
+
+extern int
+rfapiGetL2o (
+ struct attr *attr,
+ struct rfapi_l2address_option *l2o);
+
+extern int rfapiEcommunityGetLNI (
+ struct ecommunity *ecom,
+ uint32_t *lni);
+
+
+/* enable for debugging; disable for performance */
+#if 0
+#define RFAPI_CHECK_REFCOUNT(rn, safi, lo) rfapiCheckRefcount((rn),(safi),(lo))
+#else
+#define RFAPI_CHECK_REFCOUNT(rn, safi, lo) {}
+#endif
+
+/*------------------------------------------
+ * rfapiDeleteRemotePrefixes
+ *
+ * UI helper: For use by the "clear vnc prefixes" command
+ *
+ * input:
+ * un if set, tunnel must match this prefix
+ * vn if set, nexthop prefix must match this prefix
+ * p if set, prefix must match this prefix
+ *
+ * output
+ * pARcount number of active routes deleted
+ * pAHcount number of active nves deleted
+ * pHRcount number of holddown routes deleted
+ * pHHcount number of holddown nves deleted
+ *
+ * return value:
+ * void
+ --------------------------------------------*/
+extern void
+rfapiDeleteRemotePrefixes (
+ struct prefix *un,
+ struct prefix *vn,
+ struct prefix *p,
+ int delete_active,
+ int delete_holddown,
+ uint32_t *pARcount, /* active routes */
+ uint32_t *pAHcount, /* active nves */
+ uint32_t *pHRcount, /* holddown routes */
+ uint32_t *pHHcount); /* holddown nves */
+
+/*------------------------------------------
+ * rfapiCountAllItRoutes
+ *
+ * UI helper: count VRF routes from BGP side
+ *
+ * input:
+ *
+ * output
+ * pARcount count of active routes
+ * pHRcount count of holddown routes
+ * pIRcount count of holddown routes
+ *
+ * return value:
+ * void
+ --------------------------------------------*/
+extern void
+rfapiCountAllItRoutes (
+ int *pALRcount, /* active local routes */
+ int *pARRcount, /* active remote routes */
+ int *pHRcount, /* holddown routes */
+ int *pIRcount); /* direct imported routes */
+
+/*------------------------------------------
+ * rfapiGetHolddownFromLifetime
+ *
+ * calculate holddown value based on lifetime
+ *
+ * input:
+ * lifetime lifetime
+ *
+ * return value:
+ * Holddown value based on lifetime, holddown_factor,
+ * and RFAPI_LIFETIME_INFINITE_WITHDRAW_DELAY
+ *
+ --------------------------------------------*/
+extern uint32_t
+rfapiGetHolddownFromLifetime (uint32_t lifetime);
+
+#endif /* QUAGGA_HGP_RFAPI_IMPORT_H */