summaryrefslogtreecommitdiffstats
path: root/if.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-12-03 09:34:45 +0000
committerRoy Marples <roy@marples.name>2014-12-03 09:34:45 +0000
commit90a69ba576627cba52cee6526607d9dacc9368b6 (patch)
treef4f19377089d2cd811f36ec4cfae98ccce309baa /if.c
parent24b0516e3128200a936fa51c1d08482e92069c6f (diff)
downloaddhcpcd-90a69ba576627cba52cee6526607d9dacc9368b6.tar.xz
IFT type does not cleanly match to ARP type so we have to check in each.
Diffstat (limited to 'if.c')
-rw-r--r--if.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/if.c b/if.c
index 8f012521..315f8b76 100644
--- a/if.c
+++ b/if.c
@@ -184,7 +184,6 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
struct ifaddrs *ifaddrs, *ifa;
char *p;
int i;
- sa_family_t sdl_type;
struct if_head *ifs;
struct interface *ifp;
#ifdef __linux__
@@ -318,7 +317,6 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
ifp->flags = ifa->ifa_flags;
ifp->carrier = if_carrier(ifp);
- sdl_type = 0;
if (ifa->ifa_addr != NULL) {
#ifdef AF_LINK
sdl = (const struct sockaddr_dl *)(void *)ifa->ifa_addr;
@@ -343,7 +341,6 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
memcpy(&ifp->linkaddr, sdl, sdl->sdl_len);
#endif
ifp->index = sdl->sdl_index;
- sdl_type = sdl->sdl_type;
switch(sdl->sdl_type) {
#ifdef IFT_BRIDGE
case IFT_BRIDGE:
@@ -376,6 +373,21 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
ifp->family = ARPHRD_INFINIBAND;
break;
#endif
+ default:
+ /* Don't allow unless explicit */
+ if ((argc == 0 || argc == -1) &&
+ ctx->ifac == 0 &&
+ !if_hasconf(ctx, ifp->name))
+ {
+ if_free(ifp);
+ continue;
+ }
+ syslog(LOG_WARNING,
+ "%s: unsupported interface type %.2x",
+ ifp->name, ifp->family);
+ /* Pretend it's ethernet */
+ ifp->family = ARPHRD_ETHER;
+ break;
}
ifp->hwlen = sdl->sdl_alen;
#ifndef CLLADDR
@@ -385,7 +397,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
#elif AF_PACKET
sll = (const struct sockaddr_ll *)(void *)ifa->ifa_addr;
ifp->index = (unsigned int)sll->sll_ifindex;
- ifp->family = sdl_type = sll->sll_hatype;
+ ifp->family = sll->sll_hatype;
ifp->hwlen = sll->sll_halen;
if (ifp->hwlen != 0)
memcpy(ifp->hwaddr, sll->sll_addr, ifp->hwlen);
@@ -406,7 +418,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
continue;
}
switch (ifp->family) {
- case ARPHRD_IEEE1394: /* FALLTHROUGH */
+ case ARPHRD_IEEE1394:
case ARPHRD_INFINIBAND:
#ifdef ARPHRD_LOOPBACK
case ARPHRD_LOOPBACK:
@@ -416,12 +428,15 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
#endif
/* We don't warn for supported families */
break;
+
+/* IFT already checked */
+#ifndef AF_LINK
default:
syslog(LOG_WARNING,
- "%s: unsupported interface type %.2x, "
- "family %.2x",
- ifp->name, sdl_type, ifp->family);
+ "%s: unsupported interface family %.2x",
+ ifp->name, ifp->family);
break;
+#endif
}
}