]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: retrofit the 'isis network' command
authorEmanuele Di Pascale <emanuele@voltanet.io>
Wed, 14 Nov 2018 13:35:43 +0000 (14:35 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:24:46 +0000 (15:24 +0100)
remove the return value and redundant validations from
isis_circuit_circ_type_set(), since they are no longer needed.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
isisd/isis_circuit.c
isisd/isis_circuit.h
isisd/isis_cli.c
isisd/isis_cli.h
isisd/isis_northbound.c
isisd/isis_vty_isisd.c

index e76e27a7dce636ba91468f7a6ff64edf3628777e..356cbde8121dc26c7fe4855be077fe2ace858b92 100644 (file)
@@ -1261,35 +1261,22 @@ struct cmd_node interface_node = {
        INTERFACE_NODE, "%s(config-if)# ", 1,
 };
 
-ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
+void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type)
 {
        if (circuit->circ_type == circ_type)
-               return ferr_ok();
-
-       /* Changing the network type to/of loopback or unknown interfaces
-        * is not supported. */
-       if (circ_type == CIRCUIT_T_UNKNOWN || circ_type == CIRCUIT_T_LOOPBACK
-           || circuit->circ_type == CIRCUIT_T_LOOPBACK) {
-               return ferr_cfg_invalid(
-                       "cannot change network type on unknown interface");
-       }
+               return;
 
        if (circuit->state != C_STATE_UP) {
                circuit->circ_type = circ_type;
                circuit->circ_type_config = circ_type;
        } else {
                struct isis_area *area = circuit->area;
-               if (circ_type == CIRCUIT_T_BROADCAST
-                   && !if_is_broadcast(circuit->interface))
-                       return ferr_cfg_reality(
-                               "cannot configure non-broadcast interface for broadcast operation");
 
                isis_csm_state_change(ISIS_DISABLE, circuit, area);
                circuit->circ_type = circ_type;
                circuit->circ_type_config = circ_type;
                isis_csm_state_change(ISIS_ENABLE, circuit, area);
        }
-       return ferr_ok();
 }
 
 int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid,
index 5a0d4ffbabba12268b5868dca2bd041ff5495aad..73ead8f7dab34abb0bf0aae7e69b086cfe1b2916 100644 (file)
@@ -184,7 +184,7 @@ void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router,
                         bool ipv6_router);
 ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive);
 void isis_circuit_is_type_set(struct isis_circuit *circuit, int is_type);
-ferr_r isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type);
+void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type);
 
 ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level,
                               int metric);
index 1102005d8c702fd85570afc4bba975a31c259003..4be87a791f8d83b2494f1a2d8e68c8a6768bf43f 100644 (file)
@@ -1799,6 +1799,31 @@ void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
        }
 }
 
+/*
+ * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type
+ */
+DEFPY(isis_network, isis_network_cmd, "[no] isis network point-to-point",
+      NO_STR
+      "IS-IS routing protocol\n"
+      "Set network type\n"
+      "point-to-point network type\n")
+{
+       nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type",
+                             NB_OP_MODIFY,
+                             no ? "broadcast" : "point-to-point");
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
+                                  bool show_defaults)
+{
+       if (yang_dnode_get_enum(dnode, NULL) != CIRCUIT_T_P2P)
+               vty_out(vty, " no");
+
+       vty_out(vty, " isis network point-to-point\n");
+}
+
 void isis_cli_init(void)
 {
        install_element(CONFIG_NODE, &router_isis_cmd);
@@ -1879,6 +1904,8 @@ void isis_cli_init(void)
 
        install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
        install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
+
+       install_element(INTERFACE_NODE, &isis_network_cmd);
 }
 
 #endif /* ifndef FABRICD */
index 6001f8bcaeaf496a2adae56bb2dfe552bd644d9c..0bc7e1c81ccc33778d605918f90ea9ee5e151c72 100644 (file)
@@ -115,5 +115,7 @@ void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
                                     bool show_defaults);
 void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
                                bool show_defaults);
+void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
+                                  bool show_defaults);
 
 #endif /* ISISD_ISIS_CLI_H_ */
index 562c77b9d0f60f893998b46009ea7adad796dd76..125b80aab4adb2f876eccfa36ff78f6b427951f9 100644 (file)
@@ -2092,14 +2092,48 @@ static int lib_interface_isis_network_type_modify(enum nb_event event,
                                                  const struct lyd_node *dnode,
                                                  union nb_resource *resource)
 {
-       /* TODO: implement me. */
+       struct isis_circuit *circuit;
+       int net_type = yang_dnode_get_enum(dnode, NULL);
+
+       switch (event) {
+       case NB_EV_VALIDATE:
+               circuit = yang_dnode_get_entry(dnode, false);
+               if (!circuit)
+                       break;
+               if (circuit->circ_type == CIRCUIT_T_LOOPBACK
+                   || circuit->circ_type == CIRCUIT_T_UNKNOWN) {
+                       flog_warn(
+                               EC_LIB_NB_CB_CONFIG_VALIDATE,
+                               "Cannot change network type on unknown or loopback interface");
+                       return NB_ERR_VALIDATION;
+               }
+               if (net_type == CIRCUIT_T_BROADCAST
+                   && circuit->state == C_STATE_UP
+                   && !if_is_broadcast(circuit->interface)) {
+                       flog_warn(
+                               EC_LIB_NB_CB_CONFIG_VALIDATE,
+                               "Cannot configure non-broadcast interface for broadcast operation");
+                       return NB_ERR_VALIDATION;
+               }
+               break;
+       case NB_EV_PREPARE:
+       case NB_EV_ABORT:
+               break;
+       case NB_EV_APPLY:
+               circuit = yang_dnode_get_entry(dnode, true);
+               isis_circuit_circ_type_set(circuit, net_type);
+               break;
+       }
+
        return NB_OK;
 }
 
 static int lib_interface_isis_network_type_delete(enum nb_event event,
                                                  const struct lyd_node *dnode)
 {
-       /* TODO: implement me. */
+       /* FIXME: This cannot be done in FRR. Not sure what the intended
+        * behavior is.
+        */
        return NB_OK;
 }
 
@@ -2813,6 +2847,7 @@ const struct frr_yang_module_info frr_isisd_info = {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/network-type",
                        .cbs.modify = lib_interface_isis_network_type_modify,
                        .cbs.delete = lib_interface_isis_network_type_delete,
+                       .cbs.cli_show = cli_show_ip_isis_network_type,
                },
                {
                        .xpath = "/frr-interface:lib/interface/frr-isisd:isis/passive",
index d114085f888019d532c4e6d60110721c4984062d..1208420272b46e76bc1256efafa6b4bae1a3ce8e 100644 (file)
@@ -43,47 +43,6 @@ static int level_for_arg(const char *arg)
                return IS_LEVEL_2;
 }
 
-DEFUN (isis_network,
-       isis_network_cmd,
-       "isis network point-to-point",
-       "IS-IS routing protocol\n"
-       "Set network type\n"
-       "point-to-point network type\n")
-{
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) {
-               vty_out(vty,
-                       "isis network point-to-point is valid only on broadcast interfaces\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       return CMD_SUCCESS;
-}
-
-DEFUN (no_isis_network,
-       no_isis_network_cmd,
-       "no isis network point-to-point",
-       NO_STR
-       "IS-IS routing protocol\n"
-       "Set network type for circuit\n"
-       "point-to-point network type\n")
-{
-       struct isis_circuit *circuit = isis_circuit_lookup(vty);
-       if (!circuit)
-               return CMD_ERR_NO_MATCH;
-
-       if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) {
-               vty_out(vty,
-                       "isis network point-to-point is valid only on broadcast interfaces\n");
-               return CMD_WARNING_CONFIG_FAILED;
-       }
-
-       return CMD_SUCCESS;
-}
-
 DEFUN (isis_priority,
        isis_priority_cmd,
        "isis priority (0-127)",
@@ -161,9 +120,6 @@ DEFUN (no_isis_priority_level,
 
 void isis_vty_daemon_init(void)
 {
-       install_element(INTERFACE_NODE, &isis_network_cmd);
-       install_element(INTERFACE_NODE, &no_isis_network_cmd);
-
        install_element(INTERFACE_NODE, &isis_priority_cmd);
        install_element(INTERFACE_NODE, &no_isis_priority_cmd);
        install_element(INTERFACE_NODE, &isis_priority_level_cmd);