mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 20:21:02 +00:00
zebra: fix detection of interface renames
Restore the original logic in netlink_link_change() which works like this:
* once an interface event is detected, lookup the associated interface
by its name;
* call the set_ifindex() function;
* set_ifindex() will lookup the interface again but now by its ifindex. If
the lookups by name and ifindex yield to different results, then the
interface was renamed and set_ifindex() will take care of that.
In the future, zns->if_table will be split into two different data
structures to allow faster lookups by both name and ifindex.
Fixes Issue #397.
Regression introduced by commit 12f6fb9
.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
d5414843c2
commit
b8af3fbbaf
@ -746,7 +746,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* See if interface is present. */
|
/* See if interface is present. */
|
||||||
ifp = if_lookup_by_index_per_ns (zns, ifi->ifi_index);
|
ifp = if_lookup_by_name_per_ns (zns, name);
|
||||||
|
|
||||||
if (h->nlmsg_type == RTM_NEWLINK)
|
if (h->nlmsg_type == RTM_NEWLINK)
|
||||||
{
|
{
|
||||||
|
@ -211,6 +211,23 @@ if_lookup_by_index_per_ns (struct zebra_ns *ns, u_int32_t ifindex)
|
|||||||
return ifp;
|
return ifp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Look up an interface by name within a NS */
|
||||||
|
struct interface *
|
||||||
|
if_lookup_by_name_per_ns (struct zebra_ns *ns, const char *ifname)
|
||||||
|
{
|
||||||
|
struct route_node *rn;
|
||||||
|
struct interface *ifp;
|
||||||
|
|
||||||
|
for (rn = route_top (ns->if_table); rn; rn = route_next (rn))
|
||||||
|
{
|
||||||
|
ifp = (struct interface *)rn->info;
|
||||||
|
if (ifp && strcmp (ifp->name, ifname) == 0)
|
||||||
|
return (ifp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
ifindex2ifname_per_ns (struct zebra_ns *zns, unsigned int ifindex)
|
ifindex2ifname_per_ns (struct zebra_ns *zns, unsigned int ifindex)
|
||||||
{
|
{
|
||||||
|
@ -236,6 +236,7 @@ struct zebra_if
|
|||||||
|
|
||||||
|
|
||||||
extern struct interface *if_lookup_by_index_per_ns (struct zebra_ns *, u_int32_t);
|
extern struct interface *if_lookup_by_index_per_ns (struct zebra_ns *, u_int32_t);
|
||||||
|
extern struct interface *if_lookup_by_name_per_ns (struct zebra_ns *, const char *);
|
||||||
extern struct interface *if_link_per_ns (struct zebra_ns *, struct interface *);
|
extern struct interface *if_link_per_ns (struct zebra_ns *, struct interface *);
|
||||||
extern const char *ifindex2ifname_per_ns (struct zebra_ns *, unsigned int);
|
extern const char *ifindex2ifname_per_ns (struct zebra_ns *, unsigned int);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user