From f25cb0ef9f6341648513e793a3162b32fc250d2b Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 11 Nov 2010 10:03:02 +0100 Subject: Implements link state detection. Also changes some symbol names (IFF_ADMIN_DOWN -> IFF_SHUTDOWN, IFF_LINK_UP -> IFF_ADMIN_UP). --- sysdep/linux/netlink/netlink.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sysdep/linux') diff --git a/sysdep/linux/netlink/netlink.c b/sysdep/linux/netlink/netlink.c index 2dd0359b..79f7210a 100644 --- a/sysdep/linux/netlink/netlink.c +++ b/sysdep/linux/netlink/netlink.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include "conf/conf.h" #include +#include #include #include @@ -34,6 +34,10 @@ #define MSG_TRUNC 0x20 #endif +#ifndef IFF_LOWER_UP +#define IFF_LOWER_UP 0x10000 +#endif + /* * Synchronous Netlink interface */ @@ -281,6 +285,8 @@ nl_parse_link(struct nlmsghdr *h, int scan) u32 mtu; unsigned int fl; + debug("nl_parse_link %d\n", new); + if (!(i = nl_checkin(h, sizeof(*i))) || !nl_parse_attrs(IFLA_RTA(i), a, sizeof(a))) return; if (!a[IFLA_IFNAME] || RTA_PAYLOAD(a[IFLA_IFNAME]) < 2 || @@ -293,6 +299,8 @@ nl_parse_link(struct nlmsghdr *h, int scan) name = RTA_DATA(a[IFLA_IFNAME]); memcpy(&mtu, RTA_DATA(a[IFLA_MTU]), sizeof(u32)); + debug("nl_parse_link name %s index %d flags %x\n", name, i->ifi_index, i->ifi_flags); + ifi = if_find_by_index(i->ifi_index); if (!new) { @@ -300,7 +308,7 @@ nl_parse_link(struct nlmsghdr *h, int scan) if (ifi && !scan) { memcpy(&f, ifi, sizeof(struct iface)); - f.flags |= IF_ADMIN_DOWN; + f.flags |= IF_SHUTDOWN; if_update(&f); } } @@ -319,6 +327,8 @@ nl_parse_link(struct nlmsghdr *h, int scan) f.flags = 0; fl = i->ifi_flags; if (fl & IFF_UP) + f.flags |= IF_ADMIN_UP; + if (fl & IFF_LOWER_UP) f.flags |= IF_LINK_UP; if (fl & IFF_LOOPBACK) /* Loopback */ f.flags |= IF_MULTIACCESS | IF_LOOPBACK | IF_IGNORE; -- cgit v1.2.3