From: Stephen Worley Date: Mon, 25 Nov 2019 19:45:02 +0000 (-0500) Subject: pbrd: don't silently fail on atomic match IP change attempts X-Git-Tag: base_7.3~105^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=0dcff6f46397c4d7d5acbf9b71f63d2528c60300;p=mirror%2Ffrr.git pbrd: don't silently fail on atomic match IP change attempts 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 --- diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index bc4aa947a9..5bc94a2b33 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -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