]> git.puffer.fish Git - mirror/frr.git/commitdiff
pbrd: don't silently fail on atomic match IP change attempts
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 25 Nov 2019 19:45:02 +0000 (14:45 -0500)
committerStephen Worley <sworley@cumulusnetworks.com>
Tue, 3 Dec 2019 20:56:00 +0000 (15:56 -0500)
Currently pbrd does not support the abilitity to make atomic
changes to a config.

ex)
`match src-ip 1.1.1.1/32`
`match src-ip 1.1.1.0/24`

We would overwrite the first one but never actually install it.

In the `set nexthop commands` we explicitly fail if there is
already a `set nexthop` config present. This patch extends the
match src/dest-ip configs to do the same.

In the future we should make all these commands atomic but for
now its better to not fail silently at the very least.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
pbrd/pbr_vty.c

index bc4aa947a9c07922566af576d3d0e9ddfff361ef..5bc94a2b336826f43e56a29e7c580b1f5be6be03 100644 (file)
@@ -127,10 +127,13 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
        pbrms->family = prefix->family;
 
        if (!no) {
-               if (prefix_same(pbrms->src, prefix))
+               if (pbrms->src && prefix_same(pbrms->src, prefix))
                        return CMD_SUCCESS;
-
-               if (!pbrms->src)
+               else if (pbrms->src) {
+                       vty_out(vty,
+                               "A `match src-ip XX` command already exists, please remove that first\n");
+                       return CMD_WARNING_CONFIG_FAILED;
+               } else
                        pbrms->src = prefix_new();
                prefix_copy(pbrms->src, prefix);
        } else
@@ -154,10 +157,13 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
        pbrms->family = prefix->family;
 
        if (!no) {
-               if (prefix_same(pbrms->dst, prefix))
+               if (pbrms->dst && prefix_same(pbrms->dst, prefix))
                        return CMD_SUCCESS;
-
-               if (!pbrms->dst)
+               else if (pbrms->dst) {
+                       vty_out(vty,
+                               "A `match dst-ip XX` command already exists, please remove that first\n");
+                       return CMD_WARNING_CONFIG_FAILED;
+               } else
                        pbrms->dst = prefix_new();
                prefix_copy(pbrms->dst, prefix);
        } else