]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools, vtysh: fix ldpd + frr-reload.py
authorEmanuele Di Pascale <emanuele@voltanet.io>
Fri, 11 Oct 2019 10:37:53 +0000 (12:37 +0200)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 29 Oct 2019 09:32:38 +0000 (10:32 +0100)
frr-reload.py has many special case rules that did not consider ldpd
at all. Specifically:

 1. The bulk of ldp configuration comes in a big 'mpls ldp' context, which was
    previously considered a single-line context as it started with 'mpls'. This
    rule should only apply to labels and lsps.
 2. ldp has a 'router-id' config line that fell into the same rule as the above
    one. It should not be considered a single-line context as more ldp
    configuration can follow.
 3. enabled interfaces should not end their context. A better fix
    would actually require popping a new context for each interface
    in case there is any interface-specific config, but at least this
    fix will address the most common use case.
 4. when declaring pseudowires, any line with 'member pseudowire XXX' should
    be considered a sub-context of the 'l2vpn YYY type ZZZ' context. Without
    this fix, changes in the first psuedowire declared would not correctly
    be processed (e.g. removing a 'control-word exclude' line would not
    be picked up).

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
tools/frr-reload.py
vtysh/vtysh.c

index 8a437e8ba378388be461ecf688ac2ce7443d017e..cf31da38b82177347484d7b2dd94f6a10d696de6 100755 (executable)
@@ -404,7 +404,8 @@ end
                                 "ip ",
                                 "ipv6 ",
                                 "log ",
-                                "mpls",
+                                "mpls lsp",
+                                "mpls label",
                                 "no ",
                                 "password ",
                                 "ptm-enable",
@@ -424,7 +425,12 @@ end
                 continue
 
             # one line contexts
-            if new_ctx is True and any(line.startswith(keyword) for keyword in oneline_ctx_keywords):
+            # there is one exception though: ldpd accepts a 'router-id' clause
+            # as part of its 'mpls ldp' config context. If we are processing
+            # ldp configuration and encounter a router-id we should NOT switch
+            # to a new context
+            if new_ctx is True and any(line.startswith(keyword) for keyword in oneline_ctx_keywords) and not (
+                ctx_keys and ctx_keys[0].startswith("mpls ldp") and line.startswith("router-id ")):
                 self.save_contexts(ctx_keys, current_context_lines)
 
                 # Start a new context
@@ -489,7 +495,8 @@ end
             elif (line.startswith("address-family ") or
                   line.startswith("vnc defaults") or
                   line.startswith("vnc l2-group") or
-                  line.startswith("vnc nve-group")):
+                  line.startswith("vnc nve-group") or
+                  line.startswith("member pseudowire")):
                 main_ctx_key = []
 
                 # Save old context first
@@ -498,9 +505,9 @@ end
                 main_ctx_key = copy.deepcopy(ctx_keys)
                 log.debug('LINE %-50s: entering sub-context, append to ctx_keys', line)
 
-                if line == "address-family ipv6":
+                if line == "address-family ipv6" and not ctx_keys[0].startswith("mpls ldp"):
                     ctx_keys.append("address-family ipv6 unicast")
-                elif line == "address-family ipv4":
+                elif line == "address-family ipv4" and not ctx_keys[0].startswith("mpls ldp"):
                     ctx_keys.append("address-family ipv4 unicast")
                 elif line == "address-family evpn":
                     ctx_keys.append("address-family l2vpn evpn")
index 643dcb7edc6cce2aa7b601599d47efdc039f6c1e..f8292c530f04aff2a3b3a3d3386a3babb8f7daa8 100644 (file)
@@ -725,19 +725,17 @@ int vtysh_mark_file(const char *filename)
                switch (vty->node) {
                case LDP_IPV4_IFACE_NODE:
                        if (strncmp(vty_buf_copy, "   ", 3)) {
-                               vty_out(vty, "  end\n");
                                vty->node = LDP_IPV4_NODE;
                        }
                        break;
                case LDP_IPV6_IFACE_NODE:
                        if (strncmp(vty_buf_copy, "   ", 3)) {
-                               vty_out(vty, "  end\n");
                                vty->node = LDP_IPV6_NODE;
                        }
                        break;
                case LDP_PSEUDOWIRE_NODE:
                        if (strncmp(vty_buf_copy, "  ", 2)) {
-                               vty_out(vty, " end\n");
+                               vty_out(vty, " exit\n");
                                vty->node = LDP_L2VPN_NODE;
                        }
                        break;