mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
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>
This commit is contained in:
parent
acf31ef73b
commit
e7192e9d24
14
lib/if.c
14
lib/if.c
@ -564,6 +564,20 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz,
|
|||||||
return count;
|
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
|
/* Get interface by name if given name interface doesn't exist create
|
||||||
one. */
|
one. */
|
||||||
|
1
lib/if.h
1
lib/if.h
@ -532,6 +532,7 @@ static inline bool if_address_is_local(const void *matchaddr, int family,
|
|||||||
struct vrf;
|
struct vrf;
|
||||||
extern struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf);
|
extern struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf);
|
||||||
extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id);
|
extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id);
|
||||||
|
extern struct interface *if_get_vrf_loopback(vrf_id_t vrf_id);
|
||||||
extern struct interface *if_get_by_name(const char *ifname, vrf_id_t vrf_id,
|
extern struct interface *if_get_by_name(const char *ifname, vrf_id_t vrf_id,
|
||||||
const char *vrf_name);
|
const char *vrf_name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user