diff options
author | Martin Mares <mj@ucw.cz> | 1999-03-02 17:28:06 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-03-02 17:28:06 +0000 |
commit | bcbd8cc3be670a96e1405b896cff4be0912ba379 (patch) | |
tree | 6cce0add45cddca117b0b34278f732482245e10d /sysdep/unix | |
parent | 25287d6f7e687c77704816e565529960c65e3250 (diff) |
Interface logic changes:
o Introduced IF_LINK_UP flag corresponding to real link state.
o Allowed addressless interfaces.
o IF_UP is now automatically calculated and set iff the interface
is administratively up, has link up and has an IP address assigned.
It may be IF_IGNORED, though (as in case of the loopback).
o Any changes which include up/down transition are considered small
enough to not provoke artificial upping and downing of the interface.
o When an interface disappears (i.e., it wasn't seen in the last scan),
we announce this change only once.
o IF_LOOPBACK implies IF_IGNORE.
Diffstat (limited to 'sysdep/unix')
-rw-r--r-- | sysdep/unix/sync-if.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sysdep/unix/sync-if.c b/sysdep/unix/sync-if.c index 077cb94a..ce54fc77 100644 --- a/sysdep/unix/sync-if.c +++ b/sysdep/unix/sync-if.c @@ -42,16 +42,18 @@ scan_ifs(struct ifreq *r, int cnt) bzero(&i, sizeof(i)); DBG("%s\n", r->ifr_ifrn.ifrn_name); strncpy(i.name, r->ifr_ifrn.ifrn_name, sizeof(i.name) - 1); - i.name[sizeof(i.name) - 1] = 0; get_sockaddr((struct sockaddr_in *) &r->ifr_addr, &i.ip, NULL); - l = ipa_classify(i.ip); - if (l < 0 || !(l & IADDR_HOST)) + if (ipa_nonzero(i.ip)) { - log(L_ERR "%s: Invalid interface address", i.name); - goto bad; + l = ipa_classify(i.ip); + if (l < 0 || !(l & IADDR_HOST)) + { + log(L_ERR "%s: Invalid interface address", i.name); + i.ip = IPA_NONE; + } + else if ((l & IADDR_SCOPE_MASK) == SCOPE_HOST) + i.flags |= IF_LOOPBACK | IF_IGNORE; } - if ((l & IADDR_SCOPE_MASK) == SCOPE_HOST) - i.flags |= IF_LOOPBACK | IF_IGNORE; if (ioctl(if_scan_sock, SIOCGIFFLAGS, r) < 0) { @@ -59,12 +61,12 @@ scan_ifs(struct ifreq *r, int cnt) faulty: log(L_ERR "%s(%s): %m", err, i.name); bad: - i.flags = (i.flags & ~IF_UP) | IF_ADMIN_DOWN; + i.flags = (i.flags & ~IF_LINK_UP) | IF_ADMIN_DOWN; continue; } fl = r->ifr_flags; if (fl & IFF_UP) - i.flags |= IF_UP; + i.flags |= IF_LINK_UP; if (ioctl(if_scan_sock, SIOCGIFNETMASK, r) < 0) { err = "SIOCGIFNETMASK"; goto faulty; } @@ -120,6 +122,8 @@ scan_ifs(struct ifreq *r, int cnt) DBG("SIOCGIFINDEX failed: %m\n"); else i.index = r->ifr_ifindex; +#else + /* FIXME: What else? Guess ifindex (we need it at least for OSPF on unnumbered links)? */ #endif if_update(&i); |