Skip to content

Commit 0b6d353

Browse files
bgpd: BGP session not established for ipv6 link local address with vrf config
Description: BGP session not established for ipv6 link local address with vrf config Problem Description/Summary : BGP session not established for ipv6 link local address with vrf configyy 1.Configure ipv6 link-local address fe80::1234/64 on dut1 and fe80::4567/64 on dut2 2.Configure BGP neighbors for ipv6 link-local on both dut1 and dut2 3.Verify BGP session is UP over link-local ipv6 address 4.Observed that bgp session not established for ipv6 link local address Expected Behavior : BGP session should be established for ipv6 link local address with vrf config Signed-off-by: sudhanshukumar22 <sudhanshu.kumar@broadcom.com>
1 parent fb63937 commit 0b6d353

8 files changed

Lines changed: 155 additions & 0 deletions

File tree

bgpd/bgp_network.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,10 @@ static int bgp_update_address(struct interface *ifp, const union sockunion *dst,
660660
return 1;
661661

662662
prefix2sockunion(sel, addr);
663+
664+
if (IN6_IS_ADDR_LINKLOCAL(&addr->sin6.sin6_addr))
665+
addr->sin6.sin6_scope_id = ifp->ifindex;
666+
663667
return 0;
664668
}
665669

bgpd/bgp_zebra.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,9 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote,
748748
? peer->conf_if
749749
: peer->ifname,
750750
peer->bgp->vrf_id);
751+
else if (peer->update_if)
752+
ifp = if_lookup_by_name(peer->update_if,
753+
peer->bgp->vrf_id);
751754
} else if (peer->update_if)
752755
ifp = if_lookup_by_name(peer->update_if,
753756
peer->bgp->vrf_id);

tests/topotests/bgp_vrf_ipv6_link_local/__init__.py

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
router bgp 65001 vrf blue
2+
neighbor fe80:1::2 remote-as 65002
3+
neighbor fe80:1::2 timers 3 10
4+
neighbor fe80:1::2 interface r1-eth1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!
2+
interface r1-eth1 vrf blue
3+
ipv6 address fe80:1::1/64
4+
!
5+
ip forwarding
6+
ipv6 forwarding
7+
!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
router bgp 65002 vrf blue
2+
neighbor fe80:1::1 remote-as 65001
3+
neighbor fe80:1::1 timers 3 10
4+
neighbor fe80:1::1 interface r2-eth1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!
2+
interface r2-eth1 vrf blue
3+
ipv6 address fe80:1::2/64
4+
!
5+
ip forwarding
6+
ipv6 forwarding
7+
!
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2021 Broadcom. The term Broadcom refers to Broadcom Inc. and/or
4+
# its subsidiaries.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
"""
20+
Test link-local address as a BGP peer over VRF.
21+
"""
22+
23+
import os
24+
import sys
25+
import json
26+
import pytest
27+
import functools
28+
29+
CWD = os.path.dirname(os.path.realpath(__file__))
30+
sys.path.append(os.path.join(CWD, "../"))
31+
32+
# pylint: disable=C0413
33+
from lib import topotest
34+
from lib.topogen import Topogen, TopoRouter, get_topogen
35+
from lib.topolog import logger
36+
from lib.topotest import iproute2_is_vrf_capable
37+
from mininet.topo import Topo
38+
39+
40+
class TemplateTopo(Topo):
41+
def build(self, *_args, **_opts):
42+
tgen = get_topogen(self)
43+
44+
for routern in range(1, 3):
45+
tgen.add_router("r{}".format(routern))
46+
switch = tgen.add_switch("s1")
47+
switch.add_link(tgen.gears["r1"])
48+
switch.add_link(tgen.gears["r2"])
49+
50+
# r1-r2 2
51+
switch = tgen.add_switch("s2")
52+
switch.add_link(tgen.gears["r1"])
53+
switch.add_link(tgen.gears["r2"])
54+
55+
56+
def setup_module(mod):
57+
# iproute2 needs to support VRFs for this suite to run.
58+
if not iproute2_is_vrf_capable():
59+
pytest.skip("Installed iproute2 version does not support VRFs")
60+
61+
tgen = Topogen(TemplateTopo, mod.__name__)
62+
tgen.start_topology()
63+
64+
r1 = tgen.gears["r1"]
65+
r2 = tgen.gears["r2"]
66+
67+
# blue vrf
68+
r1.run("ip link add blue type vrf table 1001")
69+
r1.run("ip link set up dev blue")
70+
r2.run("ip link add blue type vrf table 1001")
71+
r2.run("ip link set up dev blue")
72+
73+
r1.run("ip link add lo1 type dummy")
74+
r1.run("ip link set lo1 master blue")
75+
r1.run("ip link set up dev lo1")
76+
r2.run("ip link add lo1 type dummy")
77+
r2.run("ip link set up dev lo1")
78+
r2.run("ip link set lo1 master blue")
79+
80+
r1.run("ip link set r1-eth1 master blue")
81+
r2.run("ip link set r2-eth1 master blue")
82+
83+
r1.run("ip link set up dev r1-eth1")
84+
r2.run("ip link set up dev r2-eth1")
85+
router_list = tgen.routers()
86+
87+
for i, (rname, router) in enumerate(router_list.items(), 1):
88+
router.load_config(
89+
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
90+
)
91+
router.load_config(
92+
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
93+
)
94+
tgen.start_router()
95+
96+
97+
def teardown_module(mod):
98+
tgen = get_topogen()
99+
tgen.stop_topology()
100+
101+
102+
def test_bgp_vrf_link_local():
103+
tgen = get_topogen()
104+
105+
if tgen.routers_have_failure():
106+
pytest.skip(tgen.errors)
107+
108+
def _bgp_ll_neighbor_configured():
109+
output = json.loads(
110+
tgen.gears["r1"].vtysh_cmd("show ip bgp vrf blue neighbor json")
111+
)
112+
expected = {
113+
"fe80:1::2": {"bgpState": "Established"},
114+
}
115+
return topotest.json_cmp(output, expected)
116+
117+
test_func = functools.partial(_bgp_ll_neighbor_configured)
118+
success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
119+
120+
assert result is None, 'Failed bgp convergence in "{}"'.format(tgen.gears["r1"])
121+
122+
123+
if __name__ == "__main__":
124+
args = ["-s"] + sys.argv[1:]
125+
sys.exit(pytest.main(args))
126+

0 commit comments

Comments
 (0)