Skip to content

Commit

Permalink
bgpd: extend make_prefix to form srv6-based prefix
Browse files Browse the repository at this point in the history
Enable the SRv6 SID prefix generation in make_prefix()
function of bgp_nht.c.

Signed-off-by: Dmytro Shytyi <[email protected]>
  • Loading branch information
dmytroshytyi-6WIND committed Nov 16, 2023
1 parent d83988e commit 2882301
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bgpd/bgp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ extern struct zclient *zclient;

static void register_zebra_rnh(struct bgp_nexthop_cache *bnc);
static void unregister_zebra_rnh(struct bgp_nexthop_cache *bnc);
static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p);
static int make_prefix(int afi, safi_t safi, struct bgp_path_info *pi,
struct prefix *p);
static void bgp_nht_ifp_initial(struct event *thread);

static int bgp_isvalid_nexthop(struct bgp_nexthop_cache *bnc)
Expand Down Expand Up @@ -315,7 +316,7 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop,

/* This will return true if the global IPv6 NH is a link local
* addr */
if (make_prefix(afi, pi, &p) < 0)
if (make_prefix(afi, safi, pi, &p) < 0)
return 1;

/*
Expand Down Expand Up @@ -994,7 +995,8 @@ void bgp_cleanup_nexthops(struct bgp *bgp)
* make_prefix - make a prefix structure from the path (essentially
* path's node.
*/
static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
static int make_prefix(int afi, safi_t safi, struct bgp_path_info *pi,
struct prefix *p)
{

int is_bgp_static = ((pi->type == ZEBRA_ROUTE_BGP)
Expand Down Expand Up @@ -1036,8 +1038,11 @@ static int make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p)
break;
case AFI_IP6:
p->family = AF_INET6;

if (is_bgp_static) {
if (pi && pi->attr && pi->attr->srv6_l3vpn) {
memcpy(&(p->u.prefix6), &(pi->attr->srv6_l3vpn->sid),
sizeof(struct in6_addr));
p->prefixlen = IPV6_MAX_BITLEN;
} else if (is_bgp_static) {
p->u.prefix6 = p_orig->u.prefix6;
p->prefixlen = p_orig->prefixlen;
} else {
Expand Down

0 comments on commit 2882301

Please sign in to comment.