]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: do not print vrf name for interface config when using vrf-lite
authorIgor Ryzhov <iryzhov@nfware.com>
Sun, 23 Jan 2022 21:07:20 +0000 (00:07 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Mon, 24 Jan 2022 11:44:05 +0000 (14:44 +0300)
VRF name should not be printed in the config since 574445ec. The update
was done for NB config output but I missed it for regular vty output.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
babeld/babel_interface.c
isisd/isis_circuit.c
lib/if.c
lib/if.h
nhrpd/nhrp_vty.c
ospf6d/ospf6_interface.c
ospfd/ospf_vty.c
pbrd/pbr_vty.c
pimd/pim_vty.c
tests/topotests/lib/common_config.py
zebra/interface.c

index e725fbffe9e2d5b63c3f67b8049abfcd0a7ab316..98c5d21196ccd5cd11979b57f6f721698d3b3701 100644 (file)
@@ -1308,7 +1308,7 @@ interface_config_write (struct vty *vty)
     int write = 0;
 
     FOR_ALL_INTERFACES (vrf, ifp) {
-        vty_frame (vty, "interface %s\n",ifp->name);
+        if_vty_config_start(vty, ifp);
         if (ifp->desc)
             vty_out (vty, " description %s\n",ifp->desc);
         babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp);
@@ -1385,7 +1385,7 @@ interface_config_write (struct vty *vty)
                 write++;
             }
         }
-        vty_endframe (vty, "exit\n!\n");
+        if_vty_config_end(vty);
         write++;
     }
     return write;
index 0ad6190ba402a07d2a47835b09e4c58ab9b517b3..1b0447226d975dde895dc5fe76427f27359e5d7e 100644 (file)
@@ -1069,7 +1069,7 @@ static int isis_interface_config_write(struct vty *vty)
 
        FOR_ALL_INTERFACES (vrf, ifp) {
                /* IF name */
-               vty_frame(vty, "interface %s\n", ifp->name);
+               if_vty_config_start(vty, ifp);
                write++;
                /* IF desc */
                if (ifp->desc) {
@@ -1277,7 +1277,7 @@ static int isis_interface_config_write(struct vty *vty)
                        write += hook_call(isis_circuit_config_write,
                                           circuit, vty);
                } while (0);
-               vty_endframe(vty, "exit\n!\n");
+               if_vty_config_end(vty);
        }
 
        return write;
index 99fa83719a25536c78327456bfa2d218adc4ad9e..158303a3879fb9adc7e48728caf7ab4fd2ff2ec3 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1285,6 +1285,22 @@ static void cli_show_interface_end(struct vty *vty,
        vty_out(vty, "exit\n");
 }
 
+void if_vty_config_start(struct vty *vty, struct interface *ifp)
+{
+       vty_frame(vty, "!\n");
+       vty_frame(vty, "interface %s", ifp->name);
+
+       if (vrf_is_backend_netns() && strcmp(ifp->vrf->name, VRF_DEFAULT_NAME))
+               vty_frame(vty, " vrf %s", ifp->vrf->name);
+
+       vty_frame(vty, "\n");
+}
+
+void if_vty_config_end(struct vty *vty)
+{
+       vty_endframe(vty, "exit\n!\n");
+}
+
 /*
  * XPath: /frr-interface:lib/interface/description
  */
index c8f4d9ab9d0957eca7fe1f3de06ddbaeaa0d7c23..53cd01946432ea128a75bbf9dc4f5ee412aee879 100644 (file)
--- a/lib/if.h
+++ b/lib/if.h
@@ -592,6 +592,8 @@ void if_link_params_free(struct interface *);
 
 /* Northbound. */
 struct vty;
+extern void if_vty_config_start(struct vty *vty, struct interface *ifp);
+extern void if_vty_config_end(struct vty *vty);
 extern void if_cmd_init(int (*config_write)(struct vty *));
 extern void if_cmd_init_default(void);
 extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
index 0dfabcf6ae2bccf87fb74ac7dcb684f6abff8709..97290ca84f81c2dc9c2e74d470877abaa2ef7bbe 100644 (file)
@@ -1150,7 +1150,7 @@ static int interface_config_write(struct vty *vty)
        int i;
 
        FOR_ALL_INTERFACES (vrf, ifp) {
-               vty_frame(vty, "interface %s\n", ifp->name);
+               if_vty_config_start(vty, ifp);
                if (ifp->desc)
                        vty_out(vty, " description %s\n", ifp->desc);
 
@@ -1221,7 +1221,7 @@ static int interface_config_write(struct vty *vty)
                        }
                }
 
-               vty_endframe(vty, "exit\n!\n");
+               if_vty_config_end(vty);
        }
 
        return 0;
index ae9f13bc10db7e077798c9bcfa5fd3882f182a3f..0d9f15d08f580d7d5c904833889aa45914e0405e 100644 (file)
@@ -2522,11 +2522,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
                if (oi == NULL)
                        continue;
 
-               if (vrf->vrf_id == VRF_DEFAULT)
-                       vty_frame(vty, "interface %s\n", oi->interface->name);
-               else
-                       vty_frame(vty, "interface %s vrf %s\n",
-                                 oi->interface->name, vrf->name);
+               if_vty_config_start(vty, ifp);
 
                if (ifp->desc)
                        vty_out(vty, " description %s\n", ifp->desc);
@@ -2581,7 +2577,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
 
                ospf6_bfd_write_config(vty, oi);
 
-               vty_endframe(vty, "exit\n!\n");
+               if_vty_config_end(vty);
        }
        return 0;
 }
index 3d0804b0188ebf30b930279f1917f5869a269b08..59fe89a6be57f62994a866d1e2be61bff0fac0e1 100644 (file)
@@ -11582,12 +11582,8 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
                if (memcmp(ifp->name, "VLINK", 5) == 0)
                        continue;
 
-               vty_frame(vty, "!\n");
-               if (ifp->vrf->vrf_id == VRF_DEFAULT)
-                       vty_frame(vty, "interface %s\n", ifp->name);
-               else
-                       vty_frame(vty, "interface %s vrf %s\n", ifp->name,
-                                 vrf->name);
+               if_vty_config_start(vty, ifp);
+
                if (ifp->desc)
                        vty_out(vty, " description %s\n", ifp->desc);
 
@@ -11797,7 +11793,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
 
                ospf_opaque_config_write_if(vty, ifp);
 
-               vty_endframe(vty, "exit\n!\n");
+               if_vty_config_end(vty);
        }
 
        return write;
index ebcbbb7205a67117e96055647a280dab5f0bd967..c9ec532bb92e616521f24025ff0338c4cf106cd7 100644 (file)
@@ -1197,18 +1197,14 @@ static int pbr_interface_config_write(struct vty *vty)
 
        RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
                FOR_ALL_INTERFACES (vrf, ifp) {
-                       if (vrf->vrf_id == VRF_DEFAULT)
-                               vty_frame(vty, "interface %s\n", ifp->name);
-                       else
-                               vty_frame(vty, "interface %s vrf %s\n",
-                                         ifp->name, vrf->name);
+                       if_vty_config_start(vty, ifp);
 
                        if (ifp->desc)
                                vty_out(vty, " description %s\n", ifp->desc);
 
                        pbr_map_write_interfaces(vty, ifp);
 
-                       vty_endframe(vty, "exit\n!\n");
+                       if_vty_config_end(vty);
                }
        }
 
index 81e1ac4e30dc4cf30d02ab9c0a571e5c7f4598c8..8c0132a9acaf7e201731ecdc98876ca79802ea49 100644 (file)
@@ -302,11 +302,8 @@ int pim_interface_config_write(struct vty *vty)
                                continue;
 
                        /* IF name */
-                       if (vrf->vrf_id == VRF_DEFAULT)
-                               vty_frame(vty, "interface %s\n", ifp->name);
-                       else
-                               vty_frame(vty, "interface %s vrf %s\n",
-                                         ifp->name, vrf->name);
+                       if_vty_config_start(vty, ifp);
+
                        ++writes;
 
                        if (ifp->desc) {
@@ -455,7 +452,7 @@ int pim_interface_config_write(struct vty *vty)
                                pim_bfd_write_config(vty, ifp);
                                ++writes;
                        }
-                       vty_endframe(vty, "exit\n!\n");
+                       if_vty_config_end(vty);
                        ++writes;
                }
        }
index c744e5bbbfe4fb656b1e24c8b24e89fb4684551d..f538b5a52b38029133f709ded22727b5ed61b087 100644 (file)
@@ -2083,15 +2083,7 @@ def create_interfaces_cfg(tgen, topo, build=False):
                 else:
                     interface_name = data["interface"]
 
-                # Include vrf if present
-                if "vrf" in data:
-                    interface_data.append(
-                        "interface {} vrf {}".format(
-                            str(interface_name), str(data["vrf"])
-                        )
-                    )
-                else:
-                    interface_data.append("interface {}".format(str(interface_name)))
+                interface_data.append("interface {}".format(str(interface_name)))
 
                 if "ipv4" in data:
                     intf_addr = c_data["links"][destRouterLink]["ipv4"]
index 534953d903ef29b2f31e8fb65c9741d31ae772a0..e4e80ec4e93e943b332256242deda2ceb53af729 100644 (file)
@@ -4213,11 +4213,7 @@ static int if_config_write(struct vty *vty)
 
                        if_data = ifp->info;
 
-                       if (ifp->vrf->vrf_id == VRF_DEFAULT)
-                               vty_frame(vty, "interface %s\n", ifp->name);
-                       else
-                               vty_frame(vty, "interface %s vrf %s\n",
-                                         ifp->name, vrf->name);
+                       if_vty_config_start(vty, ifp);
 
                        if (if_data) {
                                if (if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)
@@ -4283,7 +4279,7 @@ static int if_config_write(struct vty *vty)
                        zebra_evpn_mh_if_write(vty, ifp);
                        link_params_config_write(vty, ifp);
 
-                       vty_endframe(vty, "exit\n!\n");
+                       if_vty_config_end(vty);
                }
        return 0;
 }