diff options
author | sudhanshukumar22 <sudhanshu.kumar@broadcom.com> | 2020-11-01 12:50:35 +0100 |
---|---|---|
committer | sudhanshukumar22 <sudhanshu.kumar@broadcom.com> | 2021-04-01 11:43:51 +0200 |
commit | 0b6d35324ef3fd2b4d5997103795cad73eb72954 (patch) | |
tree | 2b05fa31f3446dba4a575ba38a597f6da5faa940 | |
parent | Merge pull request #7419 from patrasar/routemap_nb (diff) | |
download | frr-0b6d35324ef3fd2b4d5997103795cad73eb72954.tar.xz frr-0b6d35324ef3fd2b4d5997103795cad73eb72954.zip |
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>
-rw-r--r-- | bgpd/bgp_network.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 3 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/__init__.py | 0 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/r1/bgpd.conf | 4 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/r1/zebra.conf | 7 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/r2/bgpd.conf | 4 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/r2/zebra.conf | 7 | ||||
-rwxr-xr-x | tests/topotests/bgp_vrf_ipv6_link_local/test_bgp_vrf_ipv6_ll_func.py | 126 |
8 files changed, 155 insertions, 0 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 4821ce8dd..0cfffc599 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -660,6 +660,10 @@ static int bgp_update_address(struct interface *ifp, const union sockunion *dst, return 1; prefix2sockunion(sel, addr); + + if (IN6_IS_ADDR_LINKLOCAL(&addr->sin6.sin6_addr)) + addr->sin6.sin6_scope_id = ifp->ifindex; + return 0; } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index d1912db01..97d467d8f 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -748,6 +748,9 @@ bool bgp_zebra_nexthop_set(union sockunion *local, union sockunion *remote, ? peer->conf_if : peer->ifname, peer->bgp->vrf_id); + else if (peer->update_if) + ifp = if_lookup_by_name(peer->update_if, + peer->bgp->vrf_id); } else if (peer->update_if) ifp = if_lookup_by_name(peer->update_if, peer->bgp->vrf_id); diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/__init__.py b/tests/topotests/bgp_vrf_ipv6_link_local/__init__.py new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/__init__.py diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/r1/bgpd.conf b/tests/topotests/bgp_vrf_ipv6_link_local/r1/bgpd.conf new file mode 100755 index 000000000..044767bd0 --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/r1/bgpd.conf @@ -0,0 +1,4 @@ +router bgp 65001 vrf blue + neighbor fe80:1::2 remote-as 65002 + neighbor fe80:1::2 timers 3 10 + neighbor fe80:1::2 interface r1-eth1 diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/r1/zebra.conf b/tests/topotests/bgp_vrf_ipv6_link_local/r1/zebra.conf new file mode 100755 index 000000000..e24db8db9 --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/r1/zebra.conf @@ -0,0 +1,7 @@ +! +interface r1-eth1 vrf blue + ipv6 address fe80:1::1/64 +! +ip forwarding +ipv6 forwarding +! diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/r2/bgpd.conf b/tests/topotests/bgp_vrf_ipv6_link_local/r2/bgpd.conf new file mode 100755 index 000000000..d485da258 --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/r2/bgpd.conf @@ -0,0 +1,4 @@ +router bgp 65002 vrf blue + neighbor fe80:1::1 remote-as 65001 + neighbor fe80:1::1 timers 3 10 + neighbor fe80:1::1 interface r2-eth1 diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/r2/zebra.conf b/tests/topotests/bgp_vrf_ipv6_link_local/r2/zebra.conf new file mode 100755 index 000000000..be15aa177 --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/r2/zebra.conf @@ -0,0 +1,7 @@ +! +interface r2-eth1 vrf blue + ipv6 address fe80:1::2/64 +! +ip forwarding +ipv6 forwarding +! diff --git a/tests/topotests/bgp_vrf_ipv6_link_local/test_bgp_vrf_ipv6_ll_func.py b/tests/topotests/bgp_vrf_ipv6_link_local/test_bgp_vrf_ipv6_ll_func.py new file mode 100755 index 000000000..99568068b --- /dev/null +++ b/tests/topotests/bgp_vrf_ipv6_link_local/test_bgp_vrf_ipv6_ll_func.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python +# +# Copyright 2021 Broadcom. The term Broadcom refers to Broadcom Inc. and/or +# its subsidiaries. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +""" +Test link-local address as a BGP peer over VRF. +""" + +import os +import sys +import json +import pytest +import functools + +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +from lib import topotest +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.topolog import logger +from lib.topotest import iproute2_is_vrf_capable +from mininet.topo import Topo + + +class TemplateTopo(Topo): + def build(self, *_args, **_opts): + tgen = get_topogen(self) + + for routern in range(1, 3): + tgen.add_router("r{}".format(routern)) + switch = tgen.add_switch("s1") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + + # r1-r2 2 + switch = tgen.add_switch("s2") + switch.add_link(tgen.gears["r1"]) + switch.add_link(tgen.gears["r2"]) + + +def setup_module(mod): + # iproute2 needs to support VRFs for this suite to run. + if not iproute2_is_vrf_capable(): + pytest.skip("Installed iproute2 version does not support VRFs") + + tgen = Topogen(TemplateTopo, mod.__name__) + tgen.start_topology() + + r1 = tgen.gears["r1"] + r2 = tgen.gears["r2"] + + # blue vrf + r1.run("ip link add blue type vrf table 1001") + r1.run("ip link set up dev blue") + r2.run("ip link add blue type vrf table 1001") + r2.run("ip link set up dev blue") + + r1.run("ip link add lo1 type dummy") + r1.run("ip link set lo1 master blue") + r1.run("ip link set up dev lo1") + r2.run("ip link add lo1 type dummy") + r2.run("ip link set up dev lo1") + r2.run("ip link set lo1 master blue") + + r1.run("ip link set r1-eth1 master blue") + r2.run("ip link set r2-eth1 master blue") + + r1.run("ip link set up dev r1-eth1") + r2.run("ip link set up dev r2-eth1") + router_list = tgen.routers() + + for i, (rname, router) in enumerate(router_list.items(), 1): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) + ) + tgen.start_router() + + +def teardown_module(mod): + tgen = get_topogen() + tgen.stop_topology() + + +def test_bgp_vrf_link_local(): + tgen = get_topogen() + + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + def _bgp_ll_neighbor_configured(): + output = json.loads( + tgen.gears["r1"].vtysh_cmd("show ip bgp vrf blue neighbor json") + ) + expected = { + "fe80:1::2": {"bgpState": "Established"}, + } + return topotest.json_cmp(output, expected) + + test_func = functools.partial(_bgp_ll_neighbor_configured) + success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) + + assert result is None, 'Failed bgp convergence in "{}"'.format(tgen.gears["r1"]) + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) + |