diff options
| author | Louis Scalbert <louis.scalbert@6wind.com> | 2022-04-22 18:08:08 +0200 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-01-15 12:22:24 +0200 |
| commit | b2cfd204a8ec751c9c9ac00a27272f4b5c0721e3 (patch) | |
| tree | c1c4cef5c4b877bfc00b08b324a587d47fcede37 /lib/if.c | |
| parent | b4710d034dc84ad1dfd3023e736d43418231de8f (diff) | |
lib: add a function to get the VRF or loopback interface
Add a function to find the VRF or the loopback interface: the loopback
interface for the default VRF and the VRF master interface otherwise.
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -564,6 +564,20 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz, return count; } +/* Get the VRF loopback interface, i.e. the loopback on the default VRF + * or the VRF interface. + */ +struct interface *if_get_vrf_loopback(vrf_id_t vrf_id) +{ + struct interface *ifp = NULL; + struct vrf *vrf = vrf_lookup_by_id(vrf_id); + + FOR_ALL_INTERFACES (vrf, ifp) + if (if_is_loopback(ifp)) + return ifp; + + return NULL; +} /* Get interface by name if given name interface doesn't exist create one. */ |
