From: Vincent Bernat Date: Sat, 12 Apr 2014 10:11:21 +0000 (+0200) Subject: osx: blacklist p2pX interfaces X-Git-Tag: 0.7.8~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67d43beb08343e11ead9bd4c8dea37927942bce8;p=thirdparty%2Flldpd.git osx: blacklist p2pX interfaces They are related to AirDrop and transmitting anything on it will broke the wireless network. This should fix #61. --- diff --git a/src/daemon/interfaces-bsd.c b/src/daemon/interfaces-bsd.c index fda887c2..03d80942 100644 --- a/src/daemon/interfaces-bsd.c +++ b/src/daemon/interfaces-bsd.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -330,6 +331,32 @@ ifbsd_check_physical(struct lldpd *cfg, iface->type |= IFACE_PHYSICAL_T; } +/* Blacklist any dangerous interface. Currently, only p2p0 is blacklisted as it + * triggers some AirDrop functionality when we send something on it. + * See: https://github.com/vincentbernat/lldpd/issues/61 + */ +static void +ifbsd_blacklist(struct lldpd *cfg, + struct interfaces_device_list *interfaces) +{ +#ifdef HOST_OS_OSX + struct interfaces_device *iface = NULL; + TAILQ_FOREACH(iface, interfaces, next) { + int i; + if (strncmp(iface->name, "p2p", 3)) continue; + if (strlen(iface->name) < 4) continue; + for (i = 3; + iface->name[i] != '\0' && isdigit(iface->name[i]); + i++); + if (iface->name[i] == '\0') { + log_debug("interfaces", "skip %s: AirDrop interface", + iface->name); + iface->flags = 0; + } + } +#endif +} + static struct interfaces_device* ifbsd_extract_device(struct lldpd *cfg, struct ifaddrs *ifaddr) @@ -616,6 +643,7 @@ interfaces_update(struct lldpd *cfg) ifbsd_check_physical(cfg, interfaces, iface); } + ifbsd_blacklist(cfg, interfaces); interfaces_helper_whitelist(cfg, interfaces); interfaces_helper_physical(cfg, interfaces, &bpf_ops, ifbpf_phys_init);