]> git.puffer.fish Git - mirror/frr.git/commit
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>
Tue, 8 Jun 2021 17:46:05 +0000 (20:46 +0300)
commitcd899898eee0126547d2931d9de7db025151c653
treeb0739e14429b280aad0da588812c85e099d65cfe
parent0e99a6c9480ee8398cb9702bee951db0a99ab349
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