]> git.proxmox.com Git - mirror_frr.git/commit - tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py
lib: fix binding to a vrf
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 6 May 2021 23:49:40 +0000 (02:49 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Mon, 31 May 2021 19:12:55 +0000 (22:12 +0300)
commit36eef8586d80173a9d64e4b802584014b3780558
tree1f423b7d10f02c029f3a31c63510e3d75a9148c2
parent676847384b1ed65431ded346f8514d0dafddd630
lib: fix binding to a vrf

There are two possible use-cases for the `vrf_bind` function:
- bind socket to an interface in a vrf
- bind socket to a vrf device

For the former case, there's one problem - success is returned when the
interface is not found. In that case, the socket is left unbound without
throwing an error.

For the latter case, there are multiple possible problems:
- If the name is not set, then the socket is left unbound (zebra, vrrp).
- If the name is "default" and there's an interface with that name in the
  default VRF, then the socket is bound to that interface.
- In most daemons, if the router is configured before the VRF is actually
  created, we're trying to open and bind the socket right after the
  daemon receives a VRF registration from zebra. We may not receive the
  VRF-interface registration from zebra yet at that point. Therefore,
  `if_lookup_by_name` fails, and the socket is left unbound.

This commit fixes all the issues and updates the function description.

Suggested-by: Pat Ruddy <pat@voltanet.io>
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/vrf.c
lib/vrf.h
tests/topotests/bgp_vrf_lite_ipv6_rtadv/test_bgp_vrf_lite_ipv6_rtadv.py
tests/topotests/ospf6_topo1_vrf/test_ospf6_topo1_vrf.py