diff --git a/bgpd/bgp_memory.c b/bgpd/bgp_memory.c index fc508496cc..eb85936f0f 100644 --- a/bgpd/bgp_memory.c +++ b/bgpd/bgp_memory.c @@ -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_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"); diff --git a/bgpd/bgp_memory.h b/bgpd/bgp_memory.h index 4080248038..c5ba371498 100644 --- a/bgpd/bgp_memory.h +++ b/bgpd/bgp_memory.h @@ -139,5 +139,7 @@ DECLARE_MTYPE(BGP_FLOWSPEC_INDEX); DECLARE_MTYPE(BGP_SRV6_L3VPN); DECLARE_MTYPE(BGP_SRV6_VPN); +DECLARE_MTYPE(BGP_SRV6_SID); +DECLARE_MTYPE(BGP_SRV6_FUNCTION); #endif /* _QUAGGA_BGP_MEMORY_H */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b8dad338b2..8067c33884 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9865,6 +9865,7 @@ DEFUN_NOSH (bgp_segment_routing_srv6, "Segment-Routing SRv6 configuration\n") { VTY_DECLVAR_CONTEXT(bgp, bgp); + bgp->srv6_enabled = true; vty->node = BGP_SRV6_NODE; return CMD_SUCCESS; } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 6f2f2c9f34..1b78be354b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1327,6 +1327,20 @@ int bgp_peer_gr_init(struct peer *peer) 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. */ 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_vrf_es_init(bgp); bgp_pbr_init(bgp); + bgp_srv6_init(bgp); /*initilize global GR FSM */ bgp_global_gr_init(bgp); @@ -3754,6 +3769,7 @@ void bgp_free(struct bgp *bgp) bgp_evpn_cleanup(bgp); bgp_pbr_cleanup(bgp); + bgp_srv6_cleanup(bgp); XFREE(MTYPE_BGP_EVPN_INFO, bgp->evpn_info); for (afi = AFI_IP; afi < AFI_MAX; afi++) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 4a17b72b7f..ffac20c218 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -29,6 +29,7 @@ #include "lib/json.h" #include "vrf.h" #include "vty.h" +#include "srv6.h" #include "iana_afi.h" /* For union sockunion. */ @@ -222,6 +223,7 @@ struct vpn_policy { #define BGP_VPN_POLICY_TOVPN_LABEL_AUTO (1 << 0) #define BGP_VPN_POLICY_TOVPN_RD_SET (1 << 1) #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 @@ -234,6 +236,13 @@ struct vpn_policy { * vrf names that we are being exported to. */ 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; }; +struct bgp_srv6_function { + struct in6_addr sid; + char locator_name[SRV6_LOCNAME_SIZE]; +}; + /* BGP instance structure. */ struct bgp { /* AS number of this BGP instance. */ @@ -718,6 +732,12 @@ struct bgp { /* BGP route flap dampening configuration */ 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; }; DECLARE_QOBJ_TYPE(bgp);