]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: Show `ip ospf network ...` even if it's not the same as the interface type
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 23 Apr 2024 14:13:46 +0000 (17:13 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 29 Apr 2024 13:34:22 +0000 (16:34 +0300)
ospfv3 shows this unconditionally, and ospfv2 does not show `ip ospf network ...` if the type of the interface matches the specified network.

Fixes: https://github.com/FRRouting/frr/issues/15817
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
ospfd/ospf_interface.c
ospfd/ospf_interface.h
ospfd/ospf_vty.c

index 9e6acdbf0de2c77fe91f6b24253da7529eaaa996..86c597cb415f34733f9873cc38f28f4a977473e5 100644 (file)
@@ -1369,7 +1369,8 @@ static int ospf_ifp_create(struct interface *ifp)
            (!OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS(ifp), type) ||
             if_is_loopback(ifp))) {
                SET_IF_PARAM(IF_DEF_PARAMS(ifp), type);
-               IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
+               if (!IF_DEF_PARAMS(ifp)->type_cfg)
+                       IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
        }
 
        ospf = ifp->vrf->info;
index ec1afa1b8bfef462e91a4ebea2e33e55de8f093c..baa505b64ad2158af233c89c5eb40ce120379917 100644 (file)
@@ -56,6 +56,7 @@ struct ospf_if_params {
        DECLARE_IF_PARAM(struct in_addr, if_area);
        uint32_t if_area_id_fmt;
 
+       bool type_cfg;
        DECLARE_IF_PARAM(uint8_t, type); /* type of interface */
 #define OSPF_IF_ACTIVE                  0
 #define OSPF_IF_PASSIVE                        1
index 52e9cbcfbf4ddcd53a0081d0862627904de52b71..3daf6e7b6c1e4a47943594c93f4268e675698a19 100644 (file)
@@ -8366,6 +8366,8 @@ DEFUN(ip_ospf_network, ip_ospf_network_cmd,
                        IF_DEF_PARAMS(ifp)->ptp_dmvpn = 1;
        }
 
+       IF_DEF_PARAMS(ifp)->type_cfg = true;
+
        if (IF_DEF_PARAMS(ifp)->type == old_type &&
            IF_DEF_PARAMS(ifp)->ptp_dmvpn == old_ptp_dmvpn &&
            IF_DEF_PARAMS(ifp)->p2mp_delay_reflood == old_p2mp_delay_reflood)
@@ -8429,6 +8431,7 @@ DEFUN (no_ip_ospf_network,
        struct route_node *rn;
 
        IF_DEF_PARAMS(ifp)->type = ospf_default_iftype(ifp);
+       IF_DEF_PARAMS(ifp)->type_cfg = false;
        IF_DEF_PARAMS(ifp)->ptp_dmvpn = 0;
        IF_DEF_PARAMS(ifp)->p2mp_delay_reflood =
                OSPF_P2MP_DELAY_REFLOOD_DEFAULT;
@@ -11843,25 +11846,21 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
 
                do {
                        /* Interface Network print. */
-                       if (OSPF_IF_PARAM_CONFIGURED(params, type)
-                           && params->type != OSPF_IFTYPE_LOOPBACK) {
-                               if (params->type != ospf_default_iftype(ifp)) {
-                                       vty_out(vty, " ip ospf network %s",
-                                               ospf_int_type_str
-                                                       [params->type]);
-                                       if (params->type
-                                                   == OSPF_IFTYPE_POINTOPOINT
-                                           && params->ptp_dmvpn)
-                                               vty_out(vty, " dmvpn");
-                                       if (params->type ==
-                                                   OSPF_IFTYPE_POINTOMULTIPOINT &&
-                                           params->p2mp_delay_reflood)
-                                               vty_out(vty, " delay-reflood");
-                                       if (params != IF_DEF_PARAMS(ifp) && rn)
-                                               vty_out(vty, " %pI4",
-                                                       &rn->p.u.prefix4);
-                                       vty_out(vty, "\n");
-                               }
+                       if (OSPF_IF_PARAM_CONFIGURED(params, type) &&
+                           params->type != OSPF_IFTYPE_LOOPBACK &&
+                           params->type_cfg) {
+                               vty_out(vty, " ip ospf network %s",
+                                       ospf_int_type_str[params->type]);
+                               if (params->type == OSPF_IFTYPE_POINTOPOINT &&
+                                   params->ptp_dmvpn)
+                                       vty_out(vty, " dmvpn");
+                               if (params->type ==
+                                           OSPF_IFTYPE_POINTOMULTIPOINT &&
+                                   params->p2mp_delay_reflood)
+                                       vty_out(vty, " delay-reflood");
+                               if (params != IF_DEF_PARAMS(ifp) && rn)
+                                       vty_out(vty, " %pI4", &rn->p.u.prefix4);
+                               vty_out(vty, "\n");
                        }
 
                        /* OSPF interface authentication print */