Merge pull request #12856 from FRRouting/mergify/bp/dev/8.5/pr-12795

Vpnv6 nexthop encoding (backport #12795)
This commit is contained in:
Donatas Abraitis 2023-02-22 10:57:40 +02:00 committed by GitHub
commit a640b4a390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

View File

@ -4029,22 +4029,20 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
} break;
case SAFI_MPLS_VPN: {
if (attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
stream_putc(s, 48);
BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
stream_putc(s, attr->mp_nexthop_len);
else
stream_putc(s, BGP_ATTR_NHLEN_VPNV6_GLOBAL);
stream_putl(s, 0); /* RD = 0, per RFC */
stream_putl(s, 0);
stream_put(s, &attr->mp_nexthop_global,
IPV6_MAX_BYTELEN);
if (attr->mp_nexthop_len ==
BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL) {
stream_putl(s, 0); /* RD = 0, per RFC */
stream_putl(s, 0);
stream_put(s, &attr->mp_nexthop_local,
IPV6_MAX_BYTELEN);
} else {
stream_putc(s, 24);
stream_putl(s, 0); /* RD = 0, per RFC */
stream_putl(s, 0);
stream_put(s, &attr->mp_nexthop_global,
IPV6_MAX_BYTELEN);
}
} break;
case SAFI_ENCAP:

View File

@ -3576,17 +3576,29 @@ route_set_ipv6_nexthop_local(void *rule, const struct prefix *p, void *object)
{
struct in6_addr *address;
struct bgp_path_info *path;
struct bgp_dest *dest;
struct bgp_table *table = NULL;
/* Fetch routemap's rule information. */
address = rule;
path = object;
dest = path->net;
if (!dest)
return RMAP_OKAY;
table = bgp_dest_table(dest);
if (!table)
return RMAP_OKAY;
/* Set next hop value. */
path->attr->mp_nexthop_local = *address;
/* Set nexthop length. */
if (path->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL &&
path->attr->mp_nexthop_len != BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL)
if (table->safi == SAFI_MPLS_VPN || table->safi == SAFI_ENCAP ||
table->safi == SAFI_EVPN)
path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL;
else
path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
SET_FLAG(path->attr->rmap_change_flags,