]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: ability to set maximum of neighbors from lldpcli
authorVincent Bernat <vincent@bernat.ch>
Sat, 6 Apr 2019 10:13:24 +0000 (12:13 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 6 Apr 2019 11:22:35 +0000 (13:22 +0200)
NEWS
src/client/conf-lldp.c
src/client/display.c
src/client/lldpcli.8.in
src/daemon/client.c
src/lib/atoms/config.c
src/lib/lldpctl.h
tests/lldpcli.conf

diff --git a/NEWS b/NEWS
index cd6062155cda35ddebb15f72b1da2877e132001f..41c44e6b387bb1fecf7f2d15dd86c5d411c93b90 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+lldpd (1.0.4)
+  * Changes:
+    + Add "set system lldp max-neighbors XX" command to modify maximum
+      of neighbors accepted per port.
+
 lldpd (1.0.3)
   * Fix:
     + Fix creation of chroot directory.
index 8523f3cc5a405193edb5d95f2f56fb559bc0423b..94f397e4f80fa243b2dd67ee3648903396110a3b 100644 (file)
@@ -70,6 +70,30 @@ cmd_txhold(struct lldpctl_conn_t *conn, struct writer *w,
        return 1;
 }
 
+static int
+cmd_maxneighs(struct lldpctl_conn_t *conn, struct writer *w,
+    struct cmd_env *env, void *arg)
+{
+       log_debug("lldpctl", "set maximum neighbors");
+
+       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_str(config,
+               lldpctl_k_config_max_neighbors, cmdenv_get(env, "max-neighbors")) == NULL) {
+               log_warnx("lldpctl", "unable to set maximum of neighbors. %s",
+                   lldpctl_last_strerror(conn));
+               lldpctl_atom_dec_ref(config);
+               return 0;
+       }
+       log_info("lldpctl", "maximum neighbors set to new value %s", cmdenv_get(env, "max-neighbors"));
+       lldpctl_atom_dec_ref(config);
+       return 1;
+}
+
 static int
 cmd_status(struct lldpctl_conn_t *conn, struct writer *w,
     struct cmd_env *env, void *arg)
@@ -536,6 +560,16 @@ register_commands_configure_lldp(struct cmd_node *configure,
                NEWLINE, "Set LLDP transmit hold",
                NULL, cmd_txhold, NULL);
 
+        commands_new(
+               commands_new(
+                       commands_new(configure_lldp,
+                           "max-neighbors", "Set maximum number of neighbors per port",
+                           cmd_check_no_env, NULL, "ports"),
+                       NULL, "Maximum number of neighbors",
+                       NULL, cmd_store_env_value, "max-neighbors"),
+               NEWLINE, "Set maximum number of neighbors per port",
+               NULL, cmd_maxneighs, NULL);
+
        struct cmd_node *status = commands_new(configure_lldp,
            "status", "Set administrative status",
            NULL, NULL, NULL);
index f452fc5239585f5ff2a57d67eb7487b4c64d277b..312091dec5b96ee308dcbdad9a971cfdad1ff6db 100644 (file)
@@ -886,6 +886,8 @@ display_configuration(lldpctl_conn_t *conn, struct writer *w)
            lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_interval));
        tag_datatag(w, "tx-hold", "Transmit hold",
            lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_hold));
+       tag_datatag(w, "max-neighbors", "Maximum number of neighbors",
+           lldpctl_atom_get_str(configuration, lldpctl_k_config_max_neighbors));
        tag_datatag(w, "rx-only", "Receive mode",
            lldpctl_atom_get_int(configuration, lldpctl_k_config_receiveonly)?
            "yes":"no");
index ff2a8828db3b9a36bc09c2f522d19370a3506164..68de74e6d3c8f80cfce84473a97538b6c4e68276 100644 (file)
@@ -506,6 +506,14 @@ value and of the transmit delay. The default value is 4 and therefore
 the default TTL is 120 seconds.
 .Ed
 
+.Cd configure
+.Cd lldp max-neighbors Ar neighbors
+.Bd -ragged -offset XXXXXX
+Change the maximum number of neighbors accepted (for each protocol) on
+an interface. This is a global value. The default is 32. This setting
+only applies to future neighbors.
+.Ed
+
 .Cd configure
 .Op ports Ar ethX Op ,...
 .Cd lldp
index e2ca4ff29586ee2c5b0fe536a7f3397333093758..a95de9c10fc60f847964358171b45261c2891e73 100644 (file)
@@ -87,6 +87,11 @@ client_handle_set_configuration(struct lldpd *cfg, enum hmsg_type *type,
                cfg->g_config.c_ttl = cfg->g_config.c_tx_interval *
                    cfg->g_config.c_tx_hold;
        }
+       if (CHANGED(c_max_neighbors) && config->c_max_neighbors > 0) {
+               log_debug("rpc", "client change maximum neighbors to %d",
+                   config->c_max_neighbors);
+               cfg->g_config.c_max_neighbors = config->c_max_neighbors;
+       }
        if (CHANGED(c_lldp_portid_type) &&
            config->c_lldp_portid_type > LLDP_PORTID_SUBTYPE_UNKNOWN &&
            config->c_lldp_portid_type <= LLDP_PORTID_SUBTYPE_MAX) {
index 6971b40040c824a0e88e6e9bfccd49bcaccc9ae8..66374c695ee90472e2e986b3accf1e59eb8c7f12 100644 (file)
@@ -244,6 +244,8 @@ _lldpctl_atom_get_int_config(lldpctl_atom_t *atom, lldpctl_key_t key)
 #endif
        case lldpctl_k_config_tx_hold:
                return c->config->c_tx_hold;
+       case lldpctl_k_config_max_neighbors:
+               return c->config->c_max_neighbors;
        default:
                return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
        }
@@ -292,6 +294,10 @@ _lldpctl_atom_set_int_config(lldpctl_atom_t *atom, lldpctl_key_t key,
                config.c_tx_hold = value;
                if (value > 0) c->config->c_tx_hold = value;
                break;
+       case lldpctl_k_config_max_neighbors:
+               config.c_max_neighbors = value;
+               if (value > 0) c->config->c_max_neighbors = value;
+               break;
        case lldpctl_k_config_bond_slave_src_mac_type:
                config.c_bond_slave_src_mac_type = value;
                c->config->c_bond_slave_src_mac_type = value;
index e78d67efb90378599da1738c269ea4ddd7f99028..9c0c3c5d94ff7ca85214bbb92b613ae6c23a9845 100644 (file)
@@ -790,6 +790,7 @@ typedef enum {
        lldpctl_k_config_bond_slave_src_mac_type, /**< `(I,WO)` bond slave src mac type. */
        lldpctl_k_config_lldp_portid_type, /**< `(I,WO)` LLDP PortID TLV Subtype */
        lldpctl_k_config_lldp_agent_type, /**< `(I,WO)` LLDP agent type */
+       lldpctl_k_config_max_neighbors, /**< `(I,WO)`Maximum number of neighbors per port. */
 
        lldpctl_k_custom_tlvs = 5000,           /**< `(AL)` custom TLVs */
        lldpctl_k_custom_tlvs_clear,            /** `(I,WO)` clear list of custom TLVs */
index a74a4575c9bc628fc3ce80a27b339b74dad7bd97..30aacc1cfcb18ac4b2c7a020a142d0851f4d984a 100644 (file)
@@ -29,6 +29,7 @@ configure lldp portidsubtype local Batman
 configure lldp portidsubtype local Batman description Batman
 configure lldp tx-interval 30
 configure lldp tx-hold 4
+configure lldp max-neighbors 16
 configure lldp ports eth0 status tx-only
 configure lldp status rx-and-tx
 configure lldp custom-tlv oui 33,44,55 subtype 44