diff options
| author | Roy Marples <roy@marples.name> | 2019-10-09 13:34:34 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-10-09 13:34:34 +0100 |
| commit | 53167b780e7dd46cc59dc8ea820eefe476bd5c5f (patch) | |
| tree | 2f916b502e2dc69c44e787acfbfcb0500b119c45 /src/if-bsd.c | |
| parent | 53228e9540e7a3bc22bac03371b617fd49856a4b (diff) | |
| download | dhcpcd-53167b780e7dd46cc59dc8ea820eefe476bd5c5f.tar.xz | |
BSD: Ignore interface groups as we would the interface name
Incase someone renames tap0 to foo4.
Diffstat (limited to 'src/if-bsd.c')
| -rw-r--r-- | src/if-bsd.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/if-bsd.c b/src/if-bsd.c index 476a3fe2..5de892e3 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -214,8 +214,8 @@ if_closesockets_os(struct dhcpcd_ctx *ctx) close(priv->pf_inet6_fd); } -bool -if_ignore(const char *drvname) +static bool +if_ignore1(const char *drvname) { const char * const *p; @@ -226,6 +226,45 @@ if_ignore(const char *drvname) return false; } +bool +if_ignore(struct dhcpcd_ctx *ctx, const char *ifname) +{ + struct if_spec spec; + + if (if_nametospec(ifname, &spec) != 0) + return false; + + if (if_ignore1(spec.drvname)) + return true; + +#ifdef SIOCGIFGROUP + struct ifgroupreq ifgr = { .ifgr_len = 0 }; + struct ifg_req *ifg; + size_t ifg_len; + + strlcpy(ifgr.ifgr_name, ifname, sizeof(ifgr.ifgr_name)); + if (ioctl(ctx->pf_inet_fd, SIOCGIFGROUP, &ifgr) == -1 || + (ifgr.ifgr_groups = malloc(ifgr.ifgr_len)) == NULL || + ioctl(ctx->pf_inet_fd, SIOCGIFGROUP, &ifgr) == -1) + { + logerr(__func__); + return false; + } + + for (ifg = ifgr.ifgr_groups, ifg_len = ifgr.ifgr_len; + ifg && ifg_len >= sizeof(*ifg); + ifg++, ifg_len -= sizeof(*ifg)) + { + if (if_ignore1(ifg->ifgrq_group)) + return true; + } +#else + UNUSED(ctx); +#endif + + return false; +} + int if_carrier(struct interface *ifp) { |
