struct ifa *a;
debug("IF%d: %s", i->index, i->name);
- if (i->flags & IF_ADMIN_DOWN)
- debug(" ADMIN-DOWN");
+ if (i->flags & IF_SHUTDOWN)
+ debug(" SHUTDOWN");
if (i->flags & IF_UP)
debug(" UP");
else
debug(" DOWN");
- if (i->flags & IF_LINK_UP)
+ if (i->flags & IF_ADMIN_UP)
debug(" LINK-UP");
if (i->flags & IF_MULTIACCESS)
debug(" MA");
{
unsigned c;
- if (((i->flags ^ j->flags) & ~(IF_UP | IF_ADMIN_DOWN | IF_UPDATED | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED))
+ if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_TMP_DOWN | IF_JUST_CREATED))
|| i->index != j->index)
return IF_CHANGE_TOO_MUCH;
c = 0;
if ((i->flags ^ j->flags) & IF_UP)
c |= (i->flags & IF_UP) ? IF_CHANGE_DOWN : IF_CHANGE_UP;
+ if ((i->flags ^ j->flags) & IF_LINK_UP)
+ c |= IF_CHANGE_LINK;
if (i->mtu != j->mtu)
c |= IF_CHANGE_MTU;
return c;
(c & IF_CHANGE_UP) ? "goes up" :
(c & IF_CHANGE_DOWN) ? "goes down" :
(c & IF_CHANGE_MTU) ? "changes MTU" :
+ (c & IF_CHANGE_LINK) ? "changes link" :
(c & IF_CHANGE_CREATE) ? "created" :
"sends unknown event");
p->if_notify(p, c, i);
static unsigned
if_recalc_flags(struct iface *i, unsigned flags)
{
- if ((flags & (IF_ADMIN_DOWN | IF_TMP_DOWN)) ||
- !(flags & IF_LINK_UP) ||
+ if ((flags & (IF_SHUTDOWN | IF_TMP_DOWN)) ||
+ !(flags & IF_ADMIN_UP) ||
!i->addr)
flags &= ~IF_UP;
else
WALK_LIST(i, iface_list)
{
if (!(i->flags & IF_UPDATED))
- if_change_flags(i, (i->flags & ~IF_LINK_UP) | IF_ADMIN_DOWN);
+ if_change_flags(i, (i->flags & ~IF_ADMIN_UP) | IF_SHUTDOWN);
else
{
WALK_LIST_DELSAFE(a, b, i->addrs)
j = NULL;
WALK_LIST(i, iface_list)
- if ((i->flags & IF_LINK_UP) &&
- !(i->flags & (IF_IGNORE | IF_ADMIN_DOWN)) &&
+ if ((i->flags & IF_ADMIN_UP) &&
+ !(i->flags & (IF_IGNORE | IF_SHUTDOWN)) &&
i->addr &&
!(i->addr->flags & IA_UNNUMBERED) &&
(!j || ipa_to_u32(i->addr->ip) < ipa_to_u32(j->addr->ip)))
WALK_LIST(i, iface_list)
{
+ if (i->flags & IF_SHUTDOWN)
+ continue;
+
cli_msg(-1001, "%s %s (index=%d)", i->name, (i->flags & IF_UP) ? "up" : "DOWN", i->index);
if (!(i->flags & IF_MULTIACCESS))
type = "PtP";
type,
(i->flags & IF_BROADCAST) ? " Broadcast" : "",
(i->flags & IF_MULTICAST) ? " Multicast" : "",
- (i->flags & IF_ADMIN_DOWN) ? "Down" : "Up",
+ (i->flags & IF_ADMIN_UP) ? "Up" : "Down",
(i->flags & IF_LINK_UP) ? "Up" : "Down",
(i->flags & IF_LOOPBACK) ? " Loopback" : "",
(i->flags & IF_IGNORE) ? " Ignored" : "",
list neighbors; /* All neighbors on this interface */
};
-#define IF_UP 1 /* IF_LINK_UP and IP address known */
+#define IF_UP 1 /* IF_ADMIN_UP and IP address known */
#define IF_MULTIACCESS 2
#define IF_BROADCAST 4
#define IF_MULTICAST 8
-#define IF_ADMIN_DOWN 0x10
+#define IF_SHUTDOWN 0x10 /* Interface disappeared */
#define IF_LOOPBACK 0x20
#define IF_IGNORE 0x40 /* Not to be used by routing protocols (loopbacks etc.) */
-#define IF_LINK_UP 0x80
+#define IF_ADMIN_UP 0x80 /* Administrative up (e.q. IFF_UP in Linux) */
+#define IF_LINK_UP 0x100 /* Link available (e.q. IFF_LOWER_UP in Linux) */
#define IA_PRIMARY 0x10000 /* This address is primary */
#define IA_SECONDARY 0x20000 /* This address has been reported as secondary by the kernel */
#define IF_CHANGE_DOWN 2
#define IF_CHANGE_MTU 4
#define IF_CHANGE_CREATE 8 /* Seen this interface for the first time */
+#define IF_CHANGE_LINK 0x10
#define IF_CHANGE_TOO_MUCH 0x40000000 /* Used internally */
void if_init(void);
#include <stdio.h>
#include <fcntl.h>
-#include <net/if.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <errno.h>
#include "conf/conf.h"
#include <asm/types.h>
+#include <linux/if.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#define MSG_TRUNC 0x20
#endif
+#ifndef IFF_LOWER_UP
+#define IFF_LOWER_UP 0x10000
+#endif
+
/*
* Synchronous Netlink interface
*/
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 ||
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)
{
if (ifi && !scan)
{
memcpy(&f, ifi, sizeof(struct iface));
- f.flags |= IF_ADMIN_DOWN;
+ f.flags |= IF_SHUTDOWN;
if_update(&f);
}
}
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;