Skip to content

Commit

Permalink
lib: fix next vrf interface lookup avoid loopback interface
Browse files Browse the repository at this point in the history
When the default vrf is submitted, the returned interface
may be the loopback interface, which may not be valid.
Actually, on vrfs, the vrf interface is bypassed. When
being on default vrf, the 'lo' interface should be
bypassed too.
Fix this by avoiding returning the lo interface too.

Fixes: 0760a74 ("lib: add utility to get the next index in a vrf")

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Jun 7, 2023
1 parent 967f02b commit 830c8f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,17 @@ struct interface *if_vrf_lookup_by_index_next(ifindex_t ifindex,

if (ifindex == 0) {
tmp_ifp = RB_MIN(if_index_head, &vrf->ifaces_by_index);
/* skip the vrf interface */
if (tmp_ifp && if_is_vrf(tmp_ifp))
/* skip the vrf interface or the lo interface */
if (tmp_ifp && if_is_loopback(tmp_ifp))
ifindex = tmp_ifp->ifindex;
else
return tmp_ifp;
}

RB_FOREACH (tmp_ifp, if_index_head, &vrf->ifaces_by_index) {
if (found) {
/* skip the vrf interface */
if (tmp_ifp && if_is_vrf(tmp_ifp))
/* skip the vrf interface or the lo interface */
if (tmp_ifp && if_is_loopback(tmp_ifp))
continue;
else
return tmp_ifp;
Expand Down

0 comments on commit 830c8f7

Please sign in to comment.