/* conf*.c */
void register_commands_configure(struct cmd_node *);
-void register_commands_configure_med(struct cmd_node *);
+void register_commands_configure_med(struct cmd_node *, struct cmd_node *);
void register_commands_configure_dot3(struct cmd_node *);
void register_commands_medpow(struct cmd_node *);
void register_commands_dot3pow(struct cmd_node *);
}
}
+static int
+cmd_faststart(struct lldpctl_conn_t *conn, struct writer *w,
+ struct cmd_env *env, void *arg)
+{
+ log_debug("lldpctl", "configure fast interval support");
+
+ 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;
+ }
+
+ char *action = arg;
+ if ((!strcmp(action, "enable") &&
+ (lldpctl_atom_set_int(config,
+ lldpctl_k_config_fast_start_enabled, 1) == NULL)) ||
+ (!strcmp(action, "disable") &&
+ (lldpctl_atom_set_int(config,
+ lldpctl_k_config_fast_start_enabled, 0) == NULL)) ||
+ (!strcmp(action, "delay") &&
+ (lldpctl_atom_set_str(config,
+ lldpctl_k_config_fast_start_interval,
+ cmdenv_get(env, "tx-interval")) == NULL))) {
+ log_warnx("lldpctl", "unable to setup fast start. %s",
+ lldpctl_last_strerror(conn));
+ lldpctl_atom_dec_ref(config);
+ return 0;
+ }
+ log_info("lldpctl", "configruation for fast start applied");
+ lldpctl_atom_dec_ref(config);
+ return 1;
+}
+
+/**
+ * Register "configure med fast-start *"
+ */
+static void
+register_commands_medfast(struct cmd_node *med, struct cmd_node *nomed)
+{
+ struct cmd_node *configure_fast = commands_new(
+ med,
+ "fast-start", "Fast start configuration",
+ cmd_check_no_env, NULL, "ports");
+ struct cmd_node *unconfigure_fast = commands_new(
+ nomed,
+ "fast-start", "Fast start configuration",
+ cmd_check_no_env, NULL, "ports");
+
+ /* Enable */
+ commands_new(
+ commands_new(
+ configure_fast,
+ "enable", "Enable fast start",
+ NULL, NULL, NULL),
+ NEWLINE, "Enable fast start",
+ NULL, cmd_faststart, "enable");
+
+ /* Set TX delay */
+ commands_new(
+ commands_new(
+ commands_new(configure_fast,
+ "tx-interval", "Set LLDP fast transmit delay",
+ NULL, NULL, NULL),
+ NULL, "LLDP fast transmit delay in seconds",
+ NULL, cmd_store_env_value, "tx-interval"),
+ NEWLINE, "Set LLDP fast transmit delay",
+ NULL, cmd_faststart, "delay");
+
+ /* Disable */
+ commands_new(
+ commands_new(
+ unconfigure_fast,
+ NEWLINE, "Disable fast start",
+ NULL, cmd_faststart, "disable"),
+ NEWLINE, "Disable fast start",
+ NULL, cmd_faststart, "disable");
+}
+
/**
* Register "configure med *"
*/
void
-register_commands_configure_med(struct cmd_node *configure)
+register_commands_configure_med(struct cmd_node *configure, struct cmd_node *unconfigure)
{
if (lldpctl_key_get_map(
lldpctl_k_med_policy_type)[0].string == NULL)
configure,
"med", "MED configuration",
NULL, NULL, NULL);
+ struct cmd_node *unconfigure_med = commands_new(
+ unconfigure,
+ "med", "MED configuration",
+ NULL, NULL, NULL);
register_commands_medloc(configure_med);
register_commands_medpol(configure_med);
register_commands_medpow(configure_med);
+ register_commands_medfast(configure_med, unconfigure_med);
}
"configure",
"Change system settings",
NULL, NULL, NULL);
+ struct cmd_node *unconfigure = commands_new(
+ root,
+ "unconfigure",
+ "Unconfigure system settings",
+ NULL, NULL, NULL);
cmd_restrict_ports(configure);
+ cmd_restrict_ports(unconfigure);
register_commands_configure_lldp(configure);
- register_commands_configure_med(configure);
+ register_commands_configure_med(configure, unconfigure);
register_commands_configure_dot3(configure);
}
tag_datatag(w, "lldpmed-no-inventory", "Disable LLDP-MED inventory",
(lldpctl_atom_get_int(configuration, lldpctl_k_config_lldpmed_noinventory) == 0)?
"no":"yes");
+ tag_datatag(w, "lldpmed-faststart", "LLDP-MED fast start mechanism",
+ (lldpctl_atom_get_int(configuration, lldpctl_k_config_fast_start_enabled) == 0)?
+ "no":"yes");
+ tag_datatag(w, "lldpmed-faststart-interval", "LLDP-MED fast start interval",
+ N(lldpctl_atom_get_str(configuration, lldpctl_k_config_fast_start_interval)));
tag_end(w);
tag_end(w);
value is 30 seconds.
.Ed
+.Cd configure med fast-start
+.Cd enable | tx-interval Ar interval
+.Bd -ragged -offset XXXXXX
+Configure LLDP-MED fast start mechanism. When a new LLDP-MED-enabled
+neighbor is detected, fast start allows
+.Nm lldpd
+to shorten the interval between two LLDPDU.
+.Cd enable
+should enable LLDP-MED fast start while
+.Cd tx-interval
+specifies the interval between two LLDPDU in seconds. The default
+interval is 1 second. Once 4 LLDPDU have been sent, the fast start
+mechanism is disabled until a new neighbor is detected.
+.Ed
+
+.Cd unconfigure med fast-start
+.Bd -ragged -offset XXXXXX
+Disable LLDP-MED fast start mechanism.
+.Ed
+
.Cd configure
.Op ports Ar ethX Op ,...
.Cd med location coordinate
levent_send_now(cfg);
}
+#ifdef ENABLE_LLDPMED
+ if (config->c_enable_fast_start) {
+ cfg->g_config.c_enable_fast_start = (config->c_enable_fast_start == 1);
+ log_debug("rpc", "client asked to %s fast start",
+ cfg->g_config.c_enable_fast_start?"enable":"disable");
+ }
+ if (config->c_tx_fast_interval) {
+ log_debug("rpc", "change fast interval to %d", config->c_tx_fast_interval);
+ cfg->g_config.c_tx_fast_interval = config->c_tx_fast_interval;
+ }
+#endif
+
lldpd_config_cleanup(config);
return 0;
cfg->g_config.c_receiveonly = receiveonly;
cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL;
cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS;
- cfg->g_config.c_enable_fast_start = enable_fast_start;
#ifdef ENABLE_LLDPMED
+ cfg->g_config.c_enable_fast_start = enable_fast_start;
cfg->g_config.c_tx_fast_init = LLDPD_FAST_INIT;
cfg->g_config.c_tx_fast_interval = LLDPD_FAST_TX_INTERVAL;
#endif
#ifdef ENABLE_LLDPMED
case lldpctl_k_config_lldpmed_noinventory:
return c->config->c_noinventory;
+ case lldpctl_k_config_fast_start_enabled:
+ return c->config->c_enable_fast_start;
+ case lldpctl_k_config_fast_start_interval:
+ return c->config->c_tx_fast_interval;
#endif
default:
return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
config.c_tx_interval = value;
if (value > 0) c->config->c_tx_interval = value;
break;
+#ifdef ENABLE_LLDPMED
+ case lldpctl_k_config_fast_start_enabled:
+ config.c_enable_fast_start = value?1:2;
+ c->config->c_enable_fast_start = value;
+ break;
+ case lldpctl_k_config_fast_start_interval:
+ config.c_tx_fast_interval = c->config->c_tx_fast_interval = value;
+ break;
+#endif
default:
SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
return NULL;
*/
typedef enum {
lldpctl_k_config_tx_interval, /**< `(I,WO)` Transmit interval. When set to -1, it is meant to transmit now. */
- lldpctl_k_config_receiveonly, /**< `(I)` Receive only mode */
+ lldpctl_k_config_receiveonly, /**< `(I,WO)` Receive only mode */
lldpctl_k_config_mgmt_pattern, /**< `(S)` Pattern to choose the management address */
lldpctl_k_config_iface_pattern, /**< `(S)` Pattern of enabled interfaces */
lldpctl_k_config_cid_pattern, /**< `(S)` Interface pattern to choose the chassis ID */
lldpctl_k_config_advertise_version, /**< `(I)` Advertise version */
lldpctl_k_config_lldpmed_noinventory, /**< `(I)` Disable LLDP-MED inventory */
lldpctl_k_config_paused, /**< `(I)` lldpd is paused */
+ lldpctl_k_config_fast_start_enabled, /**< `(I,WO)` Is fast start enabled */
+ lldpctl_k_config_fast_start_interval, /**< `(I,WO)` Start fast transmit interval */
lldpctl_k_interface_name, /**< `(S)` The interface name. */