zebra: Add command to configure default for link-state, and make it sticky
* Provide a way for the user to specify their own preference for the default
behaviour of link-detect, independent of the compiled in default.
Add a global "default link-detect (on|off)" command to zebra, to set
the default policy for link-detect accordingly. The command is "sticky" -
when set it will stay set and always be written out, regardless of how it
compares to the baked-in, compile-time default.
The per-interface "link-detect" command is similarly made sticky.
* zebra/interface.h: (zebra_if_linkdetect;) enum for link-detect configured
state.
(struct zebra_if_defaults) Global link-detect default
(struct zebra_if) Add field for per-iface link-detect default.
* lib/if.c: (if_create_vrf) Remove the default flag setting on if-create
here, it's a zebra flag so do it in zebra's if_zebra_new_hook
* zebra/interface.c: Add static storage for global defaults.
(if_zebra_new_hook) Set the link-detect flag on new ifaces according to the
baked in default or else the configured global default.
(config_write_zebra_if_defaults,default_linkdetect_cmd) global link-detect
command and config write out machinery.
(linkdetect_cmd) Set the configuration state rather than the flag.
The new hook will then set the interface flag when the if comes up.
(if_config_write) Write config according to configured state, not the
low-level flag.
(zebra_if_init) add new commands.
diff --git a/zebra/interface.h b/zebra/interface.h
index 8baf186..223caf8 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -38,6 +38,19 @@
#define IF_ZEBRA_SHUTDOWN_OFF 0
#define IF_ZEBRA_SHUTDOWN_ON 1
+/* Global user-configured default for interface link-detect */
+typedef enum {
+ IF_LINKDETECT_UNSPEC = 0,
+ IF_LINKDETECT_ON,
+ IF_LINKDETECT_OFF,
+} zebra_if_linkdetect;
+
+/* Global defaults for interfaces */
+struct zebra_if_defaults {
+ /* Link-detect default configuration */
+ zebra_if_linkdetect linkdetect;
+};
+
#if defined (HAVE_RTADV)
/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
struct rtadvconf
@@ -185,7 +198,10 @@
/* Router advertise configuration. */
u_char rtadv_enable;
-
+
+ /* Interface specific link-detect configuration state */
+ zebra_if_linkdetect linkdetect;
+
/* Installed addresses chains tree. */
struct route_table *ipv4_subnets;