diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2012-01-23 01:26:40 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2012-01-23 01:26:40 +0100 |
commit | 732a0a257d180a95a02587203555b8552b6128ac (patch) | |
tree | 298d92b6fd7c7c59f4c58f60692ecdf592cd9ba3 /sysdep/linux/netlink | |
parent | 5c78e0e386d4c770b646cab4a8adc3c87987f50f (diff) |
Fixes problems with creating/removing/renaming ifaces on BSD.
Diffstat (limited to 'sysdep/linux/netlink')
-rw-r--r-- | sysdep/linux/netlink/netlink.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c index cf808231..17c369ea 100644 --- a/sysdep/linux/netlink/netlink.c +++ b/sysdep/linux/netlink/netlink.c @@ -386,7 +386,7 @@ nl_parse_link(struct nlmsghdr *h, int scan) struct ifinfomsg *i; struct rtattr *a[IFLA_WIRELESS+1]; int new = h->nlmsg_type == RTM_NEWLINK; - struct iface f; + struct iface f = {}; struct iface *ifi; char *name; u32 mtu; @@ -408,26 +408,21 @@ nl_parse_link(struct nlmsghdr *h, int scan) if (!new) { DBG("KIF: IF%d(%s) goes down\n", i->ifi_index, name); - if (ifi && !scan) - { - memcpy(&f, ifi, sizeof(struct iface)); - f.flags |= IF_SHUTDOWN; - if_update(&f); - } + if (!ifi) + return; + + if_delete(ifi); } else { DBG("KIF: IF%d(%s) goes up (mtu=%d,flg=%x)\n", i->ifi_index, name, mtu, i->ifi_flags); - if (ifi) - memcpy(&f, ifi, sizeof(f)); - else - { - bzero(&f, sizeof(f)); - f.index = i->ifi_index; - } - strncpy(f.name, RTA_DATA(a[IFLA_IFNAME]), sizeof(f.name)-1); + if (ifi && strncmp(ifi->name, name, sizeof(ifi->name)-1)) + if_delete(ifi); + + strncpy(f.name, name, sizeof(f.name)-1); + f.index = i->ifi_index; f.mtu = mtu; - f.flags = 0; + fl = i->ifi_flags; if (fl & IFF_UP) f.flags |= IF_ADMIN_UP; |