mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 14:29:47 +00:00
Merge pull request #431 from opensourcerouting/fix-iface-renames
Fix interface renames
This commit is contained in:
commit
20abb742ed
@ -209,7 +209,7 @@ if_addr_add(struct kaddr *ka)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iface = if_lookup(leconf, ka->ifindex);
|
iface = if_lookup_name(leconf, ka->ifname);
|
||||||
if (iface) {
|
if (iface) {
|
||||||
if (ka->af == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&ka->addr.v6))
|
if (ka->af == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&ka->addr.v6))
|
||||||
iface->linklocal = ka->addr.v6;
|
iface->linklocal = ka->addr.v6;
|
||||||
@ -229,7 +229,7 @@ if_addr_del(struct kaddr *ka)
|
|||||||
struct if_addr *if_addr;
|
struct if_addr *if_addr;
|
||||||
struct nbr *nbr;
|
struct nbr *nbr;
|
||||||
|
|
||||||
iface = if_lookup(leconf, ka->ifindex);
|
iface = if_lookup_name(leconf, ka->ifname);
|
||||||
if (iface) {
|
if (iface) {
|
||||||
if (ka->af == AF_INET6 &&
|
if (ka->af == AF_INET6 &&
|
||||||
IN6_ARE_ADDR_EQUAL(&iface->linklocal, &ka->addr.v6))
|
IN6_ARE_ADDR_EQUAL(&iface->linklocal, &ka->addr.v6))
|
||||||
|
@ -73,6 +73,7 @@ static void
|
|||||||
ifc2kaddr(struct interface *ifp, struct connected *ifc, struct kaddr *ka)
|
ifc2kaddr(struct interface *ifp, struct connected *ifc, struct kaddr *ka)
|
||||||
{
|
{
|
||||||
memset(ka, 0, sizeof(*ka));
|
memset(ka, 0, sizeof(*ka));
|
||||||
|
strlcpy(ka->ifname, ifp->name, sizeof(ka->ifname));
|
||||||
ka->ifindex = ifp->ifindex;
|
ka->ifindex = ifp->ifindex;
|
||||||
ka->af = ifc->address->family;
|
ka->af = ifc->address->family;
|
||||||
ka->prefixlen = ifc->address->prefixlen;
|
ka->prefixlen = ifc->address->prefixlen;
|
||||||
@ -232,6 +233,7 @@ ldp_interface_delete(int command, struct zclient *zclient, zebra_size_t length,
|
|||||||
vrf_id_t vrf_id)
|
vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
|
struct kif kif;
|
||||||
|
|
||||||
/* zebra_interface_state_read() updates interface structure in iflist */
|
/* zebra_interface_state_read() updates interface structure in iflist */
|
||||||
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
|
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
|
||||||
@ -243,7 +245,10 @@ ldp_interface_delete(int command, struct zclient *zclient, zebra_size_t length,
|
|||||||
|
|
||||||
/* To support pseudo interface do not free interface structure. */
|
/* To support pseudo interface do not free interface structure. */
|
||||||
/* if_delete(ifp); */
|
/* if_delete(ifp); */
|
||||||
ifp->ifindex = IFINDEX_INTERNAL;
|
ifp->ifindex = IFINDEX_DELETED;
|
||||||
|
|
||||||
|
ifp2kif(ifp, &kif);
|
||||||
|
main_imsg_compose_both(IMSG_IFSTATUS, &kif, sizeof(kif));
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -307,8 +312,8 @@ ldp_interface_address_add(int command, struct zclient *zclient,
|
|||||||
if (bad_addr(ka.af, &ka.addr))
|
if (bad_addr(ka.af, &ka.addr))
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
debug_zebra_in("address add %s/%u", log_addr(ka.af, &ka.addr),
|
debug_zebra_in("address add %s/%u interface %s",
|
||||||
ka.prefixlen);
|
log_addr(ka.af, &ka.addr), ka.prefixlen, ifp->name);
|
||||||
|
|
||||||
/* notify ldpe about new address */
|
/* notify ldpe about new address */
|
||||||
main_imsg_compose_ldpe(IMSG_NEWADDR, 0, &ka, sizeof(ka));
|
main_imsg_compose_ldpe(IMSG_NEWADDR, 0, &ka, sizeof(ka));
|
||||||
@ -336,8 +341,8 @@ ldp_interface_address_delete(int command, struct zclient *zclient,
|
|||||||
if (bad_addr(ka.af, &ka.addr))
|
if (bad_addr(ka.af, &ka.addr))
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
debug_zebra_in("address delete %s/%u", log_addr(ka.af, &ka.addr),
|
debug_zebra_in("address delete %s/%u interface %s",
|
||||||
ka.prefixlen);
|
log_addr(ka.af, &ka.addr), ka.prefixlen, ifp->name);
|
||||||
|
|
||||||
/* notify ldpe about removed address */
|
/* notify ldpe about removed address */
|
||||||
main_imsg_compose_ldpe(IMSG_DELADDR, 0, &ka, sizeof(ka));
|
main_imsg_compose_ldpe(IMSG_DELADDR, 0, &ka, sizeof(ka));
|
||||||
|
@ -541,6 +541,7 @@ struct kpw {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct kaddr {
|
struct kaddr {
|
||||||
|
char ifname[IF_NAMESIZE];
|
||||||
unsigned short ifindex;
|
unsigned short ifindex;
|
||||||
int af;
|
int af;
|
||||||
union ldpd_addr addr;
|
union ldpd_addr addr;
|
||||||
|
@ -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