mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
lib: Make if_lookup_by_index understand if VRF is backed by netns or not
FRR has two implementations of VRF, one backed by netns and the other by the proper VRF implementation in the Linux kernel. In certain places, the code assumes that a VRF is netns and so lookups fail. One example of this is in IPv6 RA code. This causes functionality such as Unnumbered BGP to fail. To fix this, this patch makes if_lookup_by_index handle the behavior based on the backend, similar to if_get_by_index. For the two places in if.c that were calling if_lookup_by_index to be specific to the VRF, I renamed the existing code, if_lookup_by_ifindex and made it a static function that is never exposed or called by any routine outside of if.c. Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
This commit is contained in:
parent
3eb0d26717
commit
47b474b57e
24
lib/if.c
24
lib/if.c
@ -45,6 +45,8 @@ DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected")
|
|||||||
DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
|
DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
|
||||||
DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
|
DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
|
||||||
|
|
||||||
|
static struct interface *if_lookup_by_ifindex(ifindex_t ifindex,
|
||||||
|
vrf_id_t vrf_id);
|
||||||
static int if_cmp_func(const struct interface *, const struct interface *);
|
static int if_cmp_func(const struct interface *, const struct interface *);
|
||||||
static int if_cmp_index_func(const struct interface *ifp1,
|
static int if_cmp_index_func(const struct interface *ifp1,
|
||||||
const struct interface *ifp2);
|
const struct interface *ifp2);
|
||||||
@ -257,8 +259,9 @@ void if_delete(struct interface *ifp)
|
|||||||
XFREE(MTYPE_IF, ifp);
|
XFREE(MTYPE_IF, ifp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interface existance check by index. */
|
/* Used only internally to check within VRF only */
|
||||||
struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
|
static struct interface *if_lookup_by_ifindex(ifindex_t ifindex,
|
||||||
|
vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
struct interface if_tmp;
|
struct interface if_tmp;
|
||||||
@ -271,6 +274,19 @@ struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
|
|||||||
return RB_FIND(if_index_head, &vrf->ifaces_by_index, &if_tmp);
|
return RB_FIND(if_index_head, &vrf->ifaces_by_index, &if_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Interface existance check by index. */
|
||||||
|
struct interface *if_lookup_by_index(ifindex_t ifindex, vrf_id_t vrf_id)
|
||||||
|
{
|
||||||
|
switch (vrf_get_backend()) {
|
||||||
|
case VRF_BACKEND_UNKNOWN:
|
||||||
|
case VRF_BACKEND_NETNS:
|
||||||
|
return(if_lookup_by_ifindex(ifindex, vrf_id));
|
||||||
|
case VRF_BACKEND_VRF_LITE:
|
||||||
|
return(if_lookup_by_index_all_vrf(ifindex));
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const char *ifindex2ifname(ifindex_t ifindex, vrf_id_t vrf_id)
|
const char *ifindex2ifname(ifindex_t ifindex, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
@ -329,7 +345,7 @@ struct interface *if_lookup_by_index_all_vrf(ifindex_t ifindex)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
|
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) {
|
||||||
ifp = if_lookup_by_index(ifindex, vrf->vrf_id);
|
ifp = if_lookup_by_ifindex(ifindex, vrf->vrf_id);
|
||||||
if (ifp)
|
if (ifp)
|
||||||
return ifp;
|
return ifp;
|
||||||
}
|
}
|
||||||
@ -489,7 +505,7 @@ struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id)
|
|||||||
switch (vrf_get_backend()) {
|
switch (vrf_get_backend()) {
|
||||||
case VRF_BACKEND_UNKNOWN:
|
case VRF_BACKEND_UNKNOWN:
|
||||||
case VRF_BACKEND_NETNS:
|
case VRF_BACKEND_NETNS:
|
||||||
ifp = if_lookup_by_index(ifindex, vrf_id);
|
ifp = if_lookup_by_ifindex(ifindex, vrf_id);
|
||||||
if (ifp)
|
if (ifp)
|
||||||
return ifp;
|
return ifp;
|
||||||
return if_create_ifindex(ifindex, vrf_id);
|
return if_create_ifindex(ifindex, vrf_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user