bgpd: add srv6 vpn base code (step4)

This commit add base-lines for BGP SRv6 VPN support.
srv6_locator_chunks property of struct bgp is used
to store BGPd's own SRv6 locator chunk getting with
ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK api.
And srv6_functions is used to store BGP's srv6
localsids. It's mainly used when new SID reservation
from locator chunks.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>

base
This commit is contained in:
Hiroki Shirokura 2020-12-19 17:45:26 +09:00 committed by Mark Stapp
parent bc65dfafbc
commit 92a9e6f296
5 changed files with 41 additions and 0 deletions

View File

@ -142,3 +142,5 @@ DEFINE_MTYPE(BGPD, BGP_FLOWSPEC_INDEX, "BGP flowspec index");
DEFINE_MTYPE(BGPD, BGP_SRV6_L3VPN, "BGP prefix-sid srv6 l3vpn servcie"); DEFINE_MTYPE(BGPD, BGP_SRV6_L3VPN, "BGP prefix-sid srv6 l3vpn servcie");
DEFINE_MTYPE(BGPD, BGP_SRV6_VPN, "BGP prefix-sid srv6 vpn service"); DEFINE_MTYPE(BGPD, BGP_SRV6_VPN, "BGP prefix-sid srv6 vpn service");
DEFINE_MTYPE(BGPD, BGP_SRV6_SID, "BGP srv6 segment-id");
DEFINE_MTYPE(BGPD, BGP_SRV6_FUNCTION, "BGP srv6 function");

View File

@ -139,5 +139,7 @@ DECLARE_MTYPE(BGP_FLOWSPEC_INDEX);
DECLARE_MTYPE(BGP_SRV6_L3VPN); DECLARE_MTYPE(BGP_SRV6_L3VPN);
DECLARE_MTYPE(BGP_SRV6_VPN); DECLARE_MTYPE(BGP_SRV6_VPN);
DECLARE_MTYPE(BGP_SRV6_SID);
DECLARE_MTYPE(BGP_SRV6_FUNCTION);
#endif /* _QUAGGA_BGP_MEMORY_H */ #endif /* _QUAGGA_BGP_MEMORY_H */

View File

@ -9865,6 +9865,7 @@ DEFUN_NOSH (bgp_segment_routing_srv6,
"Segment-Routing SRv6 configuration\n") "Segment-Routing SRv6 configuration\n")
{ {
VTY_DECLVAR_CONTEXT(bgp, bgp); VTY_DECLVAR_CONTEXT(bgp, bgp);
bgp->srv6_enabled = true;
vty->node = BGP_SRV6_NODE; vty->node = BGP_SRV6_NODE;
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -1327,6 +1327,20 @@ int bgp_peer_gr_init(struct peer *peer)
return BGP_GR_SUCCESS; return BGP_GR_SUCCESS;
} }
static void bgp_srv6_init(struct bgp *bgp)
{
bgp->srv6_enabled = false;
memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name));
bgp->srv6_locator_chunks = list_new();
bgp->srv6_functions = list_new();
}
static void bgp_srv6_cleanup(struct bgp *bgp)
{
list_delete(&bgp->srv6_locator_chunks);
list_delete(&bgp->srv6_functions);
}
/* Allocate new peer object, implicitely locked. */ /* Allocate new peer object, implicitely locked. */
struct peer *peer_new(struct bgp *bgp) struct peer *peer_new(struct bgp *bgp)
{ {
@ -3238,6 +3252,7 @@ static struct bgp *bgp_create(as_t *as, const char *name,
bgp_evpn_init(bgp); bgp_evpn_init(bgp);
bgp_evpn_vrf_es_init(bgp); bgp_evpn_vrf_es_init(bgp);
bgp_pbr_init(bgp); bgp_pbr_init(bgp);
bgp_srv6_init(bgp);
/*initilize global GR FSM */ /*initilize global GR FSM */
bgp_global_gr_init(bgp); bgp_global_gr_init(bgp);
@ -3754,6 +3769,7 @@ void bgp_free(struct bgp *bgp)
bgp_evpn_cleanup(bgp); bgp_evpn_cleanup(bgp);
bgp_pbr_cleanup(bgp); bgp_pbr_cleanup(bgp);
bgp_srv6_cleanup(bgp);
XFREE(MTYPE_BGP_EVPN_INFO, bgp->evpn_info); XFREE(MTYPE_BGP_EVPN_INFO, bgp->evpn_info);
for (afi = AFI_IP; afi < AFI_MAX; afi++) { for (afi = AFI_IP; afi < AFI_MAX; afi++) {

View File

@ -29,6 +29,7 @@
#include "lib/json.h" #include "lib/json.h"
#include "vrf.h" #include "vrf.h"
#include "vty.h" #include "vty.h"
#include "srv6.h"
#include "iana_afi.h" #include "iana_afi.h"
/* For union sockunion. */ /* For union sockunion. */
@ -222,6 +223,7 @@ struct vpn_policy {
#define BGP_VPN_POLICY_TOVPN_LABEL_AUTO (1 << 0) #define BGP_VPN_POLICY_TOVPN_LABEL_AUTO (1 << 0)
#define BGP_VPN_POLICY_TOVPN_RD_SET (1 << 1) #define BGP_VPN_POLICY_TOVPN_RD_SET (1 << 1)
#define BGP_VPN_POLICY_TOVPN_NEXTHOP_SET (1 << 2) #define BGP_VPN_POLICY_TOVPN_NEXTHOP_SET (1 << 2)
#define BGP_VPN_POLICY_TOVPN_SID_AUTO (1 << 3)
/* /*
* If we are importing another vrf into us keep a list of * If we are importing another vrf into us keep a list of
@ -234,6 +236,13 @@ struct vpn_policy {
* vrf names that we are being exported to. * vrf names that we are being exported to.
*/ */
struct list *export_vrf; struct list *export_vrf;
/*
* Segment-Routing SRv6 Mode
*/
uint32_t tovpn_sid_index; /* unset => set to 0 */
struct in6_addr *tovpn_sid;
struct in6_addr *tovpn_zebra_vrf_sid_last_sent;
}; };
/* /*
@ -322,6 +331,11 @@ struct bgp_snmp_stats {
uint32_t routes_deleted; uint32_t routes_deleted;
}; };
struct bgp_srv6_function {
struct in6_addr sid;
char locator_name[SRV6_LOCNAME_SIZE];
};
/* BGP instance structure. */ /* BGP instance structure. */
struct bgp { struct bgp {
/* AS number of this BGP instance. */ /* AS number of this BGP instance. */
@ -718,6 +732,12 @@ struct bgp {
/* BGP route flap dampening configuration */ /* BGP route flap dampening configuration */
struct bgp_damp_config damp[AFI_MAX][SAFI_MAX]; struct bgp_damp_config damp[AFI_MAX][SAFI_MAX];
/* BGP VPN SRv6 backend */
bool srv6_enabled;
char srv6_locator_name[SRV6_LOCNAME_SIZE];
struct list *srv6_locator_chunks;
struct list *srv6_functions;
QOBJ_FIELDS; QOBJ_FIELDS;
}; };
DECLARE_QOBJ_TYPE(bgp); DECLARE_QOBJ_TYPE(bgp);