]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
code: remove use of blacklist/whitelist
authorVincent Bernat <vincent@bernat.ch>
Sat, 27 Jun 2020 08:20:55 +0000 (10:20 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 27 Jun 2020 08:20:55 +0000 (10:20 +0200)
Use allowlist and denylist and adapt the documentation.

src/client/lldpcli.8.in
src/daemon/interfaces-bsd.c
src/daemon/interfaces-linux.c
src/daemon/interfaces-solaris.c
src/daemon/interfaces.c
src/daemon/lldpd.8.in
src/daemon/lldpd.h
src/daemon/pattern.c
tests/check_pattern.c

index f5aa5379504cb3a284889fcd507a35f63aa015d4..08b25d852b52a9c779d8c4c7bbbfdff8aeb41653 100644 (file)
@@ -275,10 +275,10 @@ option,
 .Nm lldpd
 will use all available physical interfaces. This option can use
 wildcards. Several interfaces can be specified separated by commas.
-It is also possible to blacklist an interface by prefixing it with an
-exclamation mark. It is possible to whitelist an interface by
-prefixing it with two exclamation marks. A whitelisted interface beats
-a blacklisted interfaces which beats a simple matched interface. For
+It is also possible to remove an interface by prefixing it with an
+exclamation mark. It is possible to allow an interface by
+prefixing it with two exclamation marks. An allowed interface beats
+a forbidden interfaces which beats a simple matched interface. For
 example, with
 .Em eth*,!eth1,!eth2
 .Nm lldpd
@@ -389,7 +389,7 @@ Without this option, the first IPv4 and the first IPv6 are used. If an
 exact IP address is provided, it is used as a management address
 without any check. If only negative patterns are provided, only one
 IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be
-selected. If you want to blacklist IPv6 addresses, you can use
+selected. If you want to remove IPv6 addresses, you can use
 .Em !*:* .
 If an interface name is matched, the first IPv4 address and the first
 IPv6 address associated to this interface will be chosen.
index ee35fc2630f5397874140e510e51b38e1ac103fa..e8c93038e621a8d716c180f4394717dfd2de2a0e 100644 (file)
@@ -331,12 +331,12 @@ ifbsd_check_physical(struct lldpd *cfg,
        iface->type |= IFACE_PHYSICAL_T;
 }
 
-/* Blacklist any dangerous interface. Currently, only p2p0 is blacklisted as it
+/* Remove any dangerous interface. Currently, only p2p0 is removed 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,
+ifbsd_denylist(struct lldpd *cfg,
     struct interfaces_device_list *interfaces)
 {
 #ifdef HOST_OS_OSX
@@ -665,8 +665,8 @@ interfaces_update(struct lldpd *cfg)
                ifbsd_check_physical(cfg, interfaces, iface);
        }
 
-       ifbsd_blacklist(cfg, interfaces);
-       interfaces_helper_whitelist(cfg, interfaces);
+       ifbsd_denylist(cfg, interfaces);
+       interfaces_helper_allowlist(cfg, interfaces);
        interfaces_helper_physical(cfg, interfaces,
            &bpf_ops, ifbpf_phys_init);
 #ifdef ENABLE_DOT1
index c9e1647f9c9f0c02e37696cd4d57b2d6665d86c8..72863f9e380c46609cef563b0e4ee0a2ca173443 100644 (file)
@@ -952,9 +952,9 @@ iflinux_add_physical(struct lldpd *cfg,
     struct interfaces_device_list *interfaces)
 {
        struct interfaces_device *iface;
-       /* Blacklist some drivers */
+       /* Deny some drivers */
        const char * const *rif;
-       const char * const blacklisted_drivers[] = {
+       const char * const denied_drivers[] = {
                "cdc_mbim",
                "vxlan",
                NULL
@@ -975,12 +975,12 @@ iflinux_add_physical(struct lldpd *cfg,
                        continue;
                }
 
-               /* Check if the driver is not blacklisted */
+               /* Check if the driver is not denied */
                if (iface->driver) {
                        int skip = 0;
-                       for (rif = blacklisted_drivers; *rif; rif++) {
+                       for (rif = denied_drivers; *rif; rif++) {
                                if (strcmp(iface->driver, *rif) == 0) {
-                                       log_debug("interfaces", "skip %s: blacklisted driver",
+                                       log_debug("interfaces", "skip %s: denied driver",
                                            iface->name);
                                        skip = 1;
                                        break;
@@ -1029,7 +1029,7 @@ interfaces_update(struct lldpd *cfg)
        iflinux_add_vlan(cfg, interfaces);
        iflinux_add_physical(cfg, interfaces);
 
-       interfaces_helper_whitelist(cfg, interfaces);
+       interfaces_helper_allowlist(cfg, interfaces);
 #ifdef ENABLE_OLDIES
        iflinux_handle_bond(cfg, interfaces);
 #endif
index f9d8bc5232132b9f3b767eeece97b4243b466907..fd61d38809a5ea1632ffc0d3e52f80ab8093e74f 100644 (file)
@@ -161,7 +161,7 @@ interfaces_update(struct lldpd *cfg) {
        for (int n = 0; n < num; n++, lifrp++)
                ifsolaris_extract(cfg, interfaces, addresses, lifrp);
 
-       interfaces_helper_whitelist(cfg, interfaces);
+       interfaces_helper_allowlist(cfg, interfaces);
        interfaces_helper_physical(cfg, interfaces,
            &bpf_ops, ifbpf_phys_init);
        interfaces_helper_mgmt(cfg, addresses, interfaces);
index b9521f6a4e7dba121cbe8a8217d07109c9ac8f51..df7d55ba70d5c62ba69d9c28778e00b80233df18 100644 (file)
@@ -177,7 +177,7 @@ interfaces_indextointerface(struct interfaces_device_list *interfaces,
 }
 
 void
-interfaces_helper_whitelist(struct lldpd *cfg,
+interfaces_helper_allowlist(struct lldpd *cfg,
     struct interfaces_device_list *interfaces)
 {
        struct interfaces_device *iface;
@@ -189,11 +189,11 @@ interfaces_helper_whitelist(struct lldpd *cfg,
                int m = pattern_match(iface->name, cfg->g_config.c_iface_pattern, 0);
                switch (m) {
                case 0:
-                       log_debug("interfaces", "blacklist %s", iface->name);
+                       log_debug("interfaces", "deny %s", iface->name);
                        iface->ignore = 1;
                        continue;
                case 2:
-                       log_debug("interfaces", "whitelist %s (consider it as a physical interface)",
+                       log_debug("interfaces", "allow %s (consider it as a physical interface)",
                            iface->name);
                        iface->type |= IFACE_PHYSICAL_T;
                        continue;
@@ -411,7 +411,7 @@ interfaces_helper_chassis(struct lldpd *cfg,
 
 /* Add management addresses for the given family. We only take one of each
    address family, unless a pattern is provided and is not all negative. For
-   example !*:*,!10.* will only blacklist addresses. We will pick the first IPv4
+   example !*:*,!10.* will only deny addresses. We will pick the first IPv4
    address not matching 10.*.
 */
 static int
index 697514d277214f071b0bebffe330d1a8f275cb19..a0f188e23a004a738caf365dd75c52992fc2d0ce 100644 (file)
@@ -196,7 +196,7 @@ Without this option, the first IPv4 and the first IPv6 are used. If an
 exact IP address is provided, it is used as a management address
 without any check. If only negative patterns are provided, only one
 IPv4 and one IPv6 addresses are chosen. Otherwise, many of them can be
-selected. If you want to blacklist IPv6 addresses, you can use
+selected. If you want to remove IPv6 addresses, you can use
 .Em !*:* .
 If an interface name is matched, the first IPv4 address and the first
 IPv6 address associated to this interface will be chosen.
@@ -209,10 +209,10 @@ option,
 .Nm
 will use all available physical interfaces. This option can use
 wildcards. Several interfaces can be specified separated by commas.
-It is also possible to blacklist an interface by prefixing it with an
-exclamation mark. It is possible to whitelist an interface by
-prefixing it with two exclamation marks. A whitelisted interface beats
-a blacklisted interface which beats a simple matched interface. For
+It is also possible to remove an interface by prefixing it with an
+exclamation mark. It is possible to allow an interface by
+prefixing it with two exclamation marks. An allowed interface beats
+a forbidden interface which beats a simple matched interface. For
 example, with
 .Em eth*,!eth1,!eth2
 .Nm
@@ -241,7 +241,7 @@ to compute the chassis ID. The logic of this option is the same as for
 .Fl I
 flag: you can exclude interfaces with an exclamation mark and use
 globbing to specify several interfaces. If all interfaces are
-blacklisted (with
+removed (with
 .Em !* ) ,
 the system name is used as a chassis ID instead.
 .It Fl M Ar class
index 3dad7dca091db9fbd6e4567253aa27846a380ae2..98977ed4d7561c6242527b24d275040a2b82851b 100644 (file)
@@ -314,7 +314,7 @@ struct interfaces_device {
        char *name;             /* Name */
        char *alias;            /* Alias */
        char *address;          /* MAC address */
-       char *driver;           /* Driver (for whitelisting purpose) */
+       char *driver;           /* Driver */
        int   flags;            /* Flags (IFF_*) */
        int   mtu;              /* MTU */
        int   type;             /* Type (see IFACE_*_T) */
@@ -353,7 +353,7 @@ struct interfaces_device* interfaces_nametointerface(
 
 void interfaces_helper_promisc(struct lldpd *,
     struct lldpd_hardware *);
-void interfaces_helper_whitelist(struct lldpd *,
+void interfaces_helper_allowlist(struct lldpd *,
     struct interfaces_device_list *);
 void interfaces_helper_chassis(struct lldpd *,
     struct interfaces_device_list *);
index 11e69a8ce5f4f5d73f274a24e773a6f43c6f0e0b..a13817b8cdf51ab805a323ac1346f90206053c27 100644 (file)
  * @param string   String to match against the list of patterns
  * @param patterns List of comma separated patterns. A pattern may
  *                 begin by `!` to negate it. In this case, it is
- *                 blacklisted. A pattern may begin with `!!`. In this
- *                 case, it is whitelisted. Each pattern will then be
+ *                 denied. A pattern may begin with `!!`. In this
+ *                 case, it is allowed back. Each pattern will then be
  *                 matched against `fnmatch()` function.
  * @param found    Value to return if the pattern isn't found. Should be either 0
  *                 or 1.
  *
- * If a pattern is found matching and blacklisted at the same time, it
- * will be blacklisted. If it is both whitelisted and blacklisted, it
- * will be whitelisted.
+ * If a pattern is found matching and denied at the same time, it
+ * will be denied. If it is both allowed and denied, it
+ * will be allowed.
  *
- * @return 0 if the string matches a blacklisted pattern which is not
- *         whitelisted or if the pattern wasn't found and `found` was set to
+ * @return 0 if the string matches a denied pattern which is not
+ *         allowed or if the pattern wasn't found and `found` was set to
  *         0. Otherwise, return 1 unless the interface match is exact, in this
  *         case return 2.
  */
@@ -45,7 +45,7 @@ int
 pattern_match(char *string, char *patterns, int found)
 {
        char *pattern;
-       int blacklisted = 0;
+       int denied = 0;
        found = !!found;
 
        if ((patterns = strdup(patterns)) == NULL) {
@@ -58,15 +58,15 @@ pattern_match(char *string, char *patterns, int found)
             pattern = strtok(NULL, ",")) {
                if ((pattern[0] == '!') && (pattern[1] == '!') &&
                    (fnmatch(pattern + 2, string, 0) == 0)) {
-                       /* Whitelisted. No need to search further. */
+                       /* Allowed. No need to search further. */
                        found = (strcmp(pattern + 2, string))?1:2;
                        break;
                }
                if ((pattern[0] == '!') &&
                    (fnmatch(pattern + 1, string, 0) == 0)) {
-                       blacklisted = 1;
+                       denied = 1;
                        found = 0;
-               } else if (!blacklisted && fnmatch(pattern, string, 0) == 0) {
+               } else if (!denied && fnmatch(pattern, string, 0) == 0) {
                        if (!strcmp(pattern, string)) {
                                found = 2;
                        } else if (found < 2) {
index 197c228c0e0c7dfa40d1114058931c48b1ff8d9b..8d332deb8eaab0b384db832d878b11c558618693 100644 (file)
@@ -59,7 +59,7 @@ START_TEST(test_match_list_with_wildcards) {
 }
 END_TEST
 
-START_TEST(test_simple_blacklist) {
+START_TEST(test_simple_denylist) {
        ck_assert_int_eq(pattern_match("eth0", "!eth0", 0), 0);
        ck_assert_int_eq(pattern_match("eth0", "!eth0", 1), 0);
        ck_assert_int_eq(pattern_match("eth1", "!eth0", 0), 0);
@@ -67,7 +67,7 @@ START_TEST(test_simple_blacklist) {
 }
 END_TEST
 
-START_TEST(test_match_and_blacklist) {
+START_TEST(test_match_and_denylist) {
        ck_assert_int_eq(pattern_match("eth0", "eth0,!eth0", 0), 0);
        ck_assert_int_eq(pattern_match("eth0", "eth0,!eth0", 1), 0);
        ck_assert_int_eq(pattern_match("eth1", "eth0,!eth0", 0), 0);
@@ -75,7 +75,7 @@ START_TEST(test_match_and_blacklist) {
 }
 END_TEST
 
-START_TEST(test_blacklist_wildcard) {
+START_TEST(test_denylist_wildcard) {
        ck_assert_int_eq(pattern_match("eth0", "!eth*", 0), 0);
        ck_assert_int_eq(pattern_match("eth0", "!eth*", 1), 0);
        ck_assert_int_eq(pattern_match("eth1", "!eth*", 0), 0);
@@ -87,7 +87,7 @@ START_TEST(test_blacklist_wildcard) {
 }
 END_TEST
 
-START_TEST(test_whitelist) {
+START_TEST(test_allowlist) {
        ck_assert_int_eq(pattern_match("eth0", "!!eth0", 0), 2);
        ck_assert_int_eq(pattern_match("eth0", "!!eth0", 1), 2);
        ck_assert_int_eq(pattern_match("eth1", "!!eth0", 1), 1);
@@ -117,10 +117,10 @@ pattern_suite(void)
        tcase_add_test(tc_pattern, test_wildcard);
        tcase_add_test(tc_pattern, test_match_list);
        tcase_add_test(tc_pattern, test_match_list_with_wildcards);
-       tcase_add_test(tc_pattern, test_simple_blacklist);
-       tcase_add_test(tc_pattern, test_match_and_blacklist);
-       tcase_add_test(tc_pattern, test_blacklist_wildcard);
-       tcase_add_test(tc_pattern, test_whitelist);
+       tcase_add_test(tc_pattern, test_simple_denylist);
+       tcase_add_test(tc_pattern, test_match_and_denylist);
+       tcase_add_test(tc_pattern, test_denylist_wildcard);
+       tcase_add_test(tc_pattern, test_allowlist);
        suite_add_tcase(s, tc_pattern);
 
        return s;