summaryrefslogtreecommitdiffstats
path: root/pbrd
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-12-03 22:59:21 +0100
committerStephen Worley <sworley@cumulusnetworks.com>2019-12-03 22:59:21 +0100
commit5d0e49c4fc4d53866bd8fac77acd4adcb7b100c0 (patch)
tree6381540ab6fc3cff1027b0215c8bf8c601c7dd72 /pbrd
parentpbrd: consolidate rule_notify debugs into one call (diff)
downloadfrr-5d0e49c4fc4d53866bd8fac77acd4adcb7b100c0.tar.xz
frr-5d0e49c4fc4d53866bd8fac77acd4adcb7b100c0.zip
pbrd: make vty `match *` code more readable
Make the vty match src|dst|mark code a bit more readable in its conditonal logic. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'pbrd')
-rw-r--r--pbrd/pbr_vty.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index 9f4e5e7fc..53248f5aa 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -127,14 +127,16 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
pbrms->family = prefix->family;
if (!no) {
- if (pbrms->src && prefix_same(pbrms->src, prefix))
- return CMD_SUCCESS;
- else if (pbrms->src) {
+ if (pbrms->src) {
+ if (prefix_same(pbrms->src, prefix))
+ return CMD_SUCCESS;
+
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();
+ }
+
+ pbrms->src = prefix_new();
prefix_copy(pbrms->src, prefix);
} else
prefix_free(&pbrms->src);
@@ -157,14 +159,16 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
pbrms->family = prefix->family;
if (!no) {
- if (pbrms->dst && prefix_same(pbrms->dst, prefix))
- return CMD_SUCCESS;
- else if (pbrms->dst) {
+ if (pbrms->dst) {
+ if (prefix_same(pbrms->dst, prefix))
+ return CMD_SUCCESS;
+
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();
+ }
+
+ pbrms->dst = prefix_new();
prefix_copy(pbrms->dst, prefix);
} else
prefix_free(&pbrms->dst);
@@ -189,17 +193,18 @@ DEFPY(pbr_map_match_mark, pbr_map_match_mark_cmd,
#endif
if (!no) {
- if (pbrms->mark && pbrms->mark == (uint32_t)mark)
- return CMD_SUCCESS;
- else if (pbrms->mark) {
+ if (pbrms->mark) {
+ if (pbrms->mark == (uint32_t)mark)
+ return CMD_SUCCESS;
+
vty_out(vty,
"A `match mark XX` command already exists, please remove that first\n");
return CMD_WARNING_CONFIG_FAILED;
- } else
- pbrms->mark = (uint32_t)mark;
- } else {
+ }
+
+ pbrms->mark = (uint32_t)mark;
+ } else
pbrms->mark = 0;
- }
pbr_map_check(pbrms);