Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: fix 6vpe nexthop #15368

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions bgpd/bgp_updgrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,16 @@ struct stream *bpacket_reformat_for_peer(struct bpacket *pkt,
gnh_modified = 1;
}

if (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg)) {
if (peer->nexthop.v4.s_addr != INADDR_ANY) {
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg,
peer->nexthop.v4);
}
if (peer->nexthop.v4.s_addr != INADDR_ANY &&
(IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) ||
(peer->connection->su.sa.sa_family == AF_INET &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it only be (IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) && (peer->connection->su.sa.sa_family == AF_INET && paf->afi == AFI_IP6)))

Copy link
Contributor Author

@louis-6wind louis-6wind Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is correct.

When it is an IPv6 prefix over an IPv4 BGP session and the outgoing interface to the peer has a standard IPv6 address, mod_v6nhg contains this standard IPv6 address.

IN6_IS_ADDR_UNSPECIFIED(mod_v6nhg) is for the case of an IPv4 prefix over an IPv6 unnumbered BGP session. See tests/topotests/bgp_ipv4_over_ipv6/test_rfc5549_ebgp_unnumbered_nbr.py -> def bgp_prefix_received_v4_mapped_v6_nh(router)

paf->afi == AFI_IP6))) {
/* set a IPv4 mapped IPv6 address if no global IPv6
* address is found or if announcing IPv6 prefix
* over an IPv4 BGP session.
*/
ipv4_to_ipv4_mapped_ipv6(mod_v6nhg, peer->nexthop.v4);
gnh_modified = 1;
}

if (IS_MAPPED_IPV6(&peer->nexthop.v6_global)) {
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/h1/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ipv6 route fd00:200::/64 fd00:100::2
interface eth-pe1
ipv6 address fd00:100::1/64
!
8 changes: 8 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/h2/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ipv6 route fd00:100::/64 fd00:200::5
interface eth-pe2
ipv6 address fd00:200::6/64
ipv6 address fd00:201::6/64
ipv6 address fd00:300::6/64
ipv6 address fd00:400::6/64
ipv6 address fd01:200::6/64
!
13 changes: 13 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/bgp_summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ipv6Vpn": {
"routerId": "198.51.100.2",
"as": 65500,
"peers": {
"192.0.2.5": {
"remoteAs": 65501,
"state": "Established",
"peerState": "OK"
}
}
}
}
116 changes: 116 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/bgp_vrf_ipv6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"vrfName": "vrf1",
"routerId": "198.51.100.2",
"defaultLocPrf": 100,
"localAS": 65500,
"routes": {
"fd00:100::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd00:100::/64",
"metric": 0,
"weight": 32768,
"path": "",
"nexthops": [
{
"ip": "::",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
],
"fd00:200::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd00:200::/64",
"metric": 0,
"weight": 0,
"path": "65501",
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
],
"fd00:201::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd00:201::/64",
"metric": 0,
"weight": 0,
"path": "65501",
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
],
"fd00:300::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd00:300::/64",
"metric": 0,
"weight": 0,
"path": "65501",
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
],
"fd00:400::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd00:400::/64",
"metric": 0,
"weight": 0,
"path": "65501",
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
],
"fd01:200::/64": [
{
"valid": true,
"bestpath": true,
"network": "fd01:200::/64",
"metric": 0,
"weight": 0,
"path": "65501",
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"scope": "global",
"used": true
}
]
}
]
}
}
32 changes: 32 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/bgpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
!
!debug bgp zebra
router bgp 65500
bgp router-id 198.51.100.2
no bgp ebgp-requires-policy
neighbor 192.0.2.5 remote-as 65501
neighbor 192.0.2.5 capability extended-nexthop
address-family ipv4 unicast
no neighbor 192.0.2.5 activate
exit-address-family
address-family ipv6 vpn
neighbor 192.0.2.5 activate
neighbor 192.0.2.5 route-map rmap in
exit-address-family
exit
router bgp 65500 vrf vrf1
bgp router-id 198.51.100.2
address-family ipv6 unicast
redistribute connected
label vpn export 101
rd vpn export 444:1
rt vpn both 52:100
export vpn
import vpn
exit-address-family
!
interface eth-pe2
mpls bgp forwarding
!
route-map rmap permit 1
set ipv6 next-hop prefer-global
!
142 changes: 142 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/ipv6_routes_vrf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"fd00:100::/64": [
{
"prefix": "fd00:100::/64",
"protocol": "connected",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 0,
"metric": 0,
"installed": true,
"nexthops": [
{
"fib": true,
"directlyConnected": true,
"interfaceName": "eth-h1",
"active": true
}
]
}
],
"fd00:200::/64": [
{
"prefix": "fd00:200::/64",
"protocol": "bgp",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 20,
"metric": 0,
"installed": true,
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"vrf": "default",
"active": true,
"labels": [
102
],
"weight": 1
}
]
}
],
"fd00:201::/64": [
{
"prefix": "fd00:201::/64",
"protocol": "bgp",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 20,
"metric": 0,
"installed": true,
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"vrf": "default",
"active": true,
"labels": [
102
],
"weight": 1
}
]
}
],
"fd00:300::/64": [
{
"prefix": "fd00:300::/64",
"protocol": "bgp",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 20,
"metric": 0,
"installed": true,
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"vrf": "default",
"active": true,
"labels": [
102
],
"weight": 1
}
]
}
],
"fd00:400::/64": [
{
"prefix": "fd00:400::/64",
"protocol": "bgp",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 20,
"metric": 0,
"installed": true,
"nexthops": [
{
"ip": "::ffff:c000:205",
ton31337 marked this conversation as resolved.
Show resolved Hide resolved
"afi": "ipv6",
"vrf": "default",
"active": true,
"labels": [
102
],
"weight": 1
}
]
}
],
"fd01:200::/64": [
{
"prefix": "fd01:200::/64",
"protocol": "bgp",
"vrfName": "vrf1",
"selected": true,
"destSelected": true,
"distance": 20,
"metric": 0,
"installed": true,
"nexthops": [
{
"ip": "::ffff:c000:205",
"afi": "ipv6",
"vrf": "default",
"active": true,
"labels": [
102
],
"weight": 1
}
]
}
]
}
23 changes: 23 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/isisd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
!
interface lo
ip router isis 1
isis hello-interval 1
isis hello-multiplier 3
!
interface eth-pe2
ip router isis 1
isis hello-interval 1
isis hello-multiplier 3
!
router isis 1
net 49.0000.0007.e901.2222.00
is-type level-1
lsp-gen-interval 1
mpls-te on
mpls-te router-address 198.51.100.2
segment-routing on
segment-routing node-msd 8
segment-routing global-block 1000 10000 local-block 30000 30999
segment-routing prefix 198.51.100.2/32 index 22
!

11 changes: 11 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe1/zebra.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
!
interface eth-h1
ipv6 address fd00:100::2/64
!
interface eth-pe2
ip address 192.0.2.2/24
ipv6 address ::ffff:192.0.2.2/120
!
interface lo
ip address 198.51.100.2/32
!
13 changes: 13 additions & 0 deletions tests/topotests/bgp_6vpe_ebgp_topo1/pe2/bgp_summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ipv6Vpn": {
"routerId": "198.51.100.5",
"as": 65501,
"peers": {
"192.0.2.2": {
"remoteAs": 65500,
"state": "Established",
"peerState": "OK"
}
}
}
}
Loading
Loading