]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: make management addresses advertisement optional
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Thu, 2 Apr 2015 10:03:02 +0000 (13:03 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Thu, 9 Apr 2015 12:27:00 +0000 (15:27 +0300)
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
src/client/conf-lldp.c
src/daemon/client.c
src/daemon/interfaces.c
src/daemon/lldpd.c
src/lib/atoms/config.c
src/lib/lldpctl.h
src/lldpd-structs.h

index b23313af2a058d27451ca9b874dfc7bb7737bb89..dae43817b75ec5bffc245d16aa7f42ca4dc30530 100644 (file)
@@ -170,6 +170,32 @@ cmd_chassis_cap_advertise(struct lldpctl_conn_t *conn, struct writer *w,
        return 1;
 }
 
+/* FIXME: see about compressing this with other functions */
+static int
+cmd_chassis_mgmt_advertise(struct lldpctl_conn_t *conn, struct writer *w,
+    struct cmd_env *env, void *arg)
+{
+       lldpctl_atom_t *config = lldpctl_get_configuration(conn);
+       if (config == NULL) {
+               log_warnx("lldpctl", "unable to get configuration from lldpd. %s",
+                   lldpctl_last_strerror(conn));
+               return 0;
+       }
+       if (lldpctl_atom_set_int(config,
+               lldpctl_k_config_chassis_mgmt_advertise,
+               arg?1:0) == NULL) {
+               log_warnx("lldpctl", "unable to %s management addresses advertisement: %s",
+                   arg?"enable":"disable",
+                   lldpctl_last_strerror(conn));
+               lldpctl_atom_dec_ref(config);
+               return 0;
+       }
+       log_info("lldpctl", "management addresses advertisement %s",
+           arg?"enabled":"disabled");
+       lldpctl_atom_dec_ref(config);
+       return 1;
+}
+
 /**
  * Register `configure lldp` commands.
  *
@@ -272,4 +298,19 @@ register_commands_configure_lldp(struct cmd_node *configure,
                    NULL, NULL, NULL),
                NEWLINE, "Don't enable chassis capabilities advertisement",
                NULL, cmd_chassis_cap_advertise, NULL);
+
+       commands_new(
+               commands_new(configure_lldp,
+                   "management-addresses-advertisements",
+                   "Enable management addresses advertisement",
+                   NULL, NULL, NULL),
+               NEWLINE, "Enable management addresses advertisement",
+               NULL, cmd_chassis_mgmt_advertise, "enable");
+       commands_new(
+               commands_new(unconfigure_lldp,
+                   "management-addresses-advertisements",
+                   "Don't enable management addresses advertisement",
+                   NULL, NULL, NULL),
+               NEWLINE, "Don't enable management addresses advertisement",
+               NULL, cmd_chassis_mgmt_advertise, NULL);
 }
index a6cc4d2ba652c8a649f8542c86b90080fe992ad9..e4485e122c0472dd84ec06764df7882f79514dc2 100644 (file)
@@ -168,6 +168,12 @@ client_handle_set_configuration(struct lldpd *cfg, enum hmsg_type *type,
                cfg->g_config.c_cap_advertise = config->c_cap_advertise;
                levent_update_now(cfg);
        }
+       if (CHANGED(c_mgmt_advertise)) {
+               log_debug("rpc", "%s management addresses advertisement",
+                   config->c_promisc?"enable":"disable");
+               cfg->g_config.c_mgmt_advertise = config->c_mgmt_advertise;
+               levent_update_now(cfg);
+       }
        if (CHANGED(c_bond_slave_src_mac_type)) {
                if (config->c_bond_slave_src_mac_type >
                    LLDP_BOND_SLAVE_SRC_MAC_TYPE_UNKNOWN &&
index c16f218c5a44b240b9658aff17cf449232d4b528..73f949a5fc2104757c234cf60d2479f6ba164f3f 100644 (file)
@@ -439,6 +439,8 @@ interfaces_helper_mgmt(struct lldpd *cfg,
        const char *pattern = cfg->g_config.c_mgmt_pattern;
 
        lldpd_chassis_mgmt_cleanup(LOCAL_CHASSIS(cfg));
+       if (!cfg->g_config.c_mgmt_advertise)
+               return;
 
        /* Is the pattern provided an actual IP address? */
        if (pattern && strpbrk(pattern, "!,*?") == NULL) {
index 217435027df99890788b5307a0a07d0fe407c1b6..8ba2071017f5cb2a136ef3db3cc0480e1e55d02f 100644 (file)
@@ -1641,6 +1641,7 @@ lldpd_main(int argc, char *argv[], char *envp[])
        cfg->g_config.c_cap_advertise = 1;
        lchassis->c_cap_available = LLDP_CAP_BRIDGE | LLDP_CAP_WLAN |
            LLDP_CAP_ROUTER | LLDP_CAP_STATION;
+       cfg->g_config.c_mgmt_advertise = 1;
        TAILQ_INIT(&lchassis->c_mgmt);
 #ifdef ENABLE_LLDPMED
        if (lldpmed > 0) {
index 48af9d3cb566f515db807bb2d811dbcef674b083..023b5d5b93ae62ab46364c58d55ab4e8b12872d7 100644 (file)
@@ -203,6 +203,8 @@ _lldpctl_atom_get_int_config(lldpctl_atom_t *atom, lldpctl_key_t key)
                return c->config->c_promisc;
        case lldpctl_k_config_chassis_cap_advertise:
                return c->config->c_cap_advertise;
+       case lldpctl_k_config_chassis_mgmt_advertise:
+               return c->config->c_mgmt_advertise;
 #ifdef ENABLE_LLDPMED
        case lldpctl_k_config_lldpmed_noinventory:
                return c->config->c_noinventory;
@@ -246,6 +248,9 @@ _lldpctl_atom_set_int_config(lldpctl_atom_t *atom, lldpctl_key_t key,
        case lldpctl_k_config_chassis_cap_advertise:
                config.c_cap_advertise = c->config->c_cap_advertise = value;
                break;
+       case lldpctl_k_config_chassis_mgmt_advertise:
+               config.c_mgmt_advertise = c->config->c_mgmt_advertise = value;
+               break;
 #ifdef ENABLE_LLDPMED
        case lldpctl_k_config_fast_start_enabled:
                config.c_enable_fast_start = c->config->c_enable_fast_start = value;
index f74463baad3d0a2a0256734161e6fc6f56c3aa5a..9f1542338850f621a8865302fed055d17ab9f132 100644 (file)
@@ -613,6 +613,7 @@ typedef enum {
        lldpctl_k_config_ifdescr_update, /**< `(I,WO)` Enable or disable setting interface description */
        lldpctl_k_config_iface_promisc,  /**< `(I,WO)` Enable or disable promiscuous mode on interfaces */
        lldpctl_k_config_chassis_cap_advertise, /**< `(I,WO)` Enable or disable chassis capabilities advertisement */
+       lldpctl_k_config_chassis_mgmt_advertise, /**< `(I,WO)` Enable or disable management addresses advertisement */
 
        lldpctl_k_interface_name = 1000, /**< `(S)` The interface name. */
 
index d4b511f8edc5dad9c959b9641126d0db7000d2ed..93b435e45db668f9bc707d5c0c79e83fe1effd40 100644 (file)
@@ -332,6 +332,7 @@ struct lldpd_config {
        int c_set_ifdescr;       /* Set interface description */
        int c_promisc;           /* Interfaces should be in promiscuous mode */
        int c_cap_advertise;     /* Chassis capabilities advertisement */
+       int c_mgmt_advertise;    /* Management addresses advertisement */
 
 #ifdef ENABLE_LLDPMED
        int c_noinventory;      /* Don't send inventory with LLDP-MED */