Skip to content

Commit

Permalink
bgpd: add srv6 vpn base code (step4)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slankdev authored and Mark Stapp committed Jun 2, 2021
1 parent bc65dfa commit 92a9e6f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bgpd/bgp_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
2 changes: 2 additions & 0 deletions bgpd/bgp_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
1 change: 1 addition & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down
20 changes: 20 additions & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "lib/json.h"
#include "vrf.h"
#include "vty.h"
#include "srv6.h"
#include "iana_afi.h"

/* For union sockunion. */
Expand Down Expand Up @@ -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
Expand All @@ -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;
};

/*
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 92a9e6f

Please sign in to comment.