diff options
| author | Roy Marples <roy@marples.name> | 2014-11-18 11:07:37 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2014-11-18 11:07:37 +0000 |
| commit | e837cd2daf896b9795ae455f7ac363206a8400bd (patch) | |
| tree | de9c21545726df064de3abd093e96b40fdeed643 /if.c | |
| parent | dcf142a37165a42c5a822fe6b3022183c6db69bc (diff) | |
| download | dhcpcd-e837cd2daf896b9795ae455f7ac363206a8400bd.tar.xz | |
Check for IFF_LOOPBACK and IFF_POINTOPOINT early to avoid needless
malloc/free.
If family is not ARPHRD_ETHER, check if interface is allowed add
more tests to famlies we support.
Diffstat (limited to 'if.c')
| -rw-r--r-- | if.c | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -283,6 +283,13 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) if (!dev_initialized(ctx, p)) continue; + /* Don't allow loopback or pointopoint unless explicit */ + if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) { + if ((argc == 0 || argc == -1) && ctx->ifac == 0) + continue; + } + + if (if_vimaster(p) == 1) { syslog(argc ? LOG_ERR : LOG_DEBUG, "%s: is a Virtual Interface Master, skipping", p); @@ -300,13 +307,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) ifp->carrier = if_carrier(ifp); sdl_type = 0; - /* Don't allow loopback unless explicit */ - if (ifp->flags & IFF_LOOPBACK) { - if ((argc == 0 || argc == -1) && ctx->ifac == 0) { - if_free(ifp); - continue; - } - } else if (ifa->ifa_addr != NULL) { + if (ifa->ifa_addr != NULL) { #ifdef AF_LINK sdl = (const struct sockaddr_dl *)(void *)ifa->ifa_addr; @@ -384,9 +385,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) #endif /* We only work on ethernet by default */ - if (!(ifp->flags & IFF_POINTOPOINT) && - ifp->family != ARPHRD_ETHER) - { + if (ifp->family != ARPHRD_ETHER) { if ((argc == 0 || argc == -1) && ctx->ifac == 0) { if_free(ifp); continue; @@ -394,14 +393,19 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) switch (ifp->family) { case ARPHRD_IEEE1394: /* FALLTHROUGH */ case ARPHRD_INFINIBAND: +#ifdef ARPHRD_LOOPBACK + case ARPHRD_LOOPBACK: +#endif +#ifdef ARPHRD_PPP + case ARPHRD_PPP: +#endif /* We don't warn for supported families */ break; default: syslog(LOG_WARNING, "%s: unsupported interface type %.2x" - ", falling back to ethernet", - ifp->name, sdl_type); - ifp->family = ARPHRD_ETHER; + ", family %.2x", + ifp->name, sdl_type, ifp->family); break; } } |
