diff options
| author | Roy Marples <roy@marples.name> | 2019-10-10 12:00:46 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-10-10 12:00:46 +0100 |
| commit | 55cbb64bfd7a60830db5e5f97a9792e6751cd6bb (patch) | |
| tree | 2166ae1b6b21cbca0e8d029483c41b1e7b9d5947 /src/if.c | |
| parent | cc414bf33a0039a507f8a40528425c07808cab72 (diff) | |
| download | dhcpcd-55cbb64bfd7a60830db5e5f97a9792e6751cd6bb.tar.xz | |
Minor optimisation and fix to prior.
Diffstat (limited to 'src/if.c')
| -rw-r--r-- | src/if.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -312,6 +312,7 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, struct if_head *ifs; struct interface *ifp; struct if_spec spec; + bool if_noconf; #ifdef AF_LINK const struct sockaddr_dl *sdl; #ifdef IFLR_ACTIVE @@ -412,12 +413,12 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, continue; } -#define IF_NOCONF ((argc == 0 || argc == -1) && ctx->ifac == 0 && \ - !if_hasconf(ctx, spec.devname)) + if_noconf = ((argc == 0 || argc == -1) && ctx->ifac == 0 && + !if_hasconf(ctx, spec.devname)); /* Don't allow loopback or pointopoint unless explicit. * Don't allow some reserved interface names unless explicit. */ - if (IF_NOCONF) { + if (if_noconf) { if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT) || if_ignore(ctx, spec.devname)) active = IF_INACTIVE; @@ -465,16 +466,14 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #endif case IFT_PPP: /* Don't allow unless explicit */ - if ((argc == 0 || argc == -1) && - ctx->ifac == 0 && active && - !if_hasconf(ctx, ifp->name)) - { + if (if_noconf) { logdebugx("%s: ignoring due to" " interface type and" " no config", ifp->name); active = IF_INACTIVE; } + __fallthrough; /* appease gcc */ /* FALLTHROUGH */ #ifdef IFT_L2VLAN case IFT_L2VLAN: /* FALLTHROUGH */ @@ -482,7 +481,6 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #ifdef IFT_L3IPVLAN case IFT_L3IPVLAN: /* FALLTHROUGH */ #endif - /* FALLTHROUGH */ case IFT_ETHER: ifp->family = ARPHRD_ETHER; break; @@ -498,11 +496,11 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #endif default: /* Don't allow unless explicit */ - if (IF_NOCONF) + if (if_noconf) active = IF_INACTIVE; if (active) logwarnx("%s: unsupported" - " interface type %.2x", + " interface type 0x%.2x", ifp->name, sdl->sdl_type); /* Pretend it's ethernet */ ifp->family = ARPHRD_ETHER; @@ -565,7 +563,7 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, default: if (active) logwarnx("%s: unsupported" - " interface family %.2x", + " interface family 0x%.2x", ifp->name, ifp->family); break; #endif |
