]> git.proxmox.com Git - mirror_frr.git/blobdiff - pbrd/pbr_vty.c
Merge pull request #4765 from opensourcerouting/defaults-v2
[mirror_frr.git] / pbrd / pbr_vty.c
index bc4aa947a9c07922566af576d3d0e9ddfff361ef..53248f5aaf4c7cba672b0d0748927a881df74fb2 100644 (file)
@@ -127,11 +127,16 @@ DEFPY(pbr_map_match_src, pbr_map_match_src_cmd,
        pbrms->family = prefix->family;
 
        if (!no) {
-               if (prefix_same(pbrms->src, prefix))
-                       return CMD_SUCCESS;
+               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;
+               }
 
-               if (!pbrms->src)
-                       pbrms->src = prefix_new();
+               pbrms->src = prefix_new();
                prefix_copy(pbrms->src, prefix);
        } else
                prefix_free(&pbrms->src);
@@ -145,7 +150,7 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
        "[no] match dst-ip <A.B.C.D/M|X:X::X:X/M>$prefix",
        NO_STR
        "Match the rest of the command\n"
-       "Choose the src ip or ipv6 prefix to use\n"
+       "Choose the dst ip or ipv6 prefix to use\n"
        "v4 Prefix\n"
        "v6 Prefix\n")
 {
@@ -154,11 +159,16 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
        pbrms->family = prefix->family;
 
        if (!no) {
-               if (prefix_same(pbrms->dst, prefix))
-                       return CMD_SUCCESS;
+               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;
+               }
 
-               if (!pbrms->dst)
-                       pbrms->dst = prefix_new();
+               pbrms->dst = prefix_new();
                prefix_copy(pbrms->dst, prefix);
        } else
                prefix_free(&pbrms->dst);
@@ -183,12 +193,18 @@ DEFPY(pbr_map_match_mark, pbr_map_match_mark_cmd,
 #endif
 
        if (!no) {
-               if (pbrms->mark == (uint32_t) mark)
-                       return CMD_SUCCESS;
-               pbrms->mark = (uint32_t) mark;
-       } else {
+               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;
+               }
+
+               pbrms->mark = (uint32_t)mark;
+       } else
                pbrms->mark = 0;
-       }
 
        pbr_map_check(pbrms);
 
@@ -232,7 +248,7 @@ DEFPY(pbr_map_nexthop_group, pbr_map_nexthop_group_cmd,
                        pbr_map_delete_nexthops(pbrms);
                else {
                        vty_out(vty,
-                               "Nexthop Group specified: %s does not exist to remove",
+                               "Nexthop Group specified: %s does not exist to remove\n",
                                name);
                        return CMD_WARNING_CONFIG_FAILED;
                }
@@ -240,7 +256,7 @@ DEFPY(pbr_map_nexthop_group, pbr_map_nexthop_group_cmd,
                if (pbrms->nhgrp_name) {
                        if (strcmp(name, pbrms->nhgrp_name) != 0) {
                                vty_out(vty,
-                                       "Please delete current nexthop group before modifying current one");
+                                       "Please delete current nexthop group before modifying current one\n");
                                return CMD_WARNING_CONFIG_FAILED;
                        }
 
@@ -277,7 +293,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
 
        if (pbrms->nhgrp_name) {
                vty_out(vty,
-                       "Please unconfigure the nexthop group before adding an individual nexthop");
+                       "Please unconfigure the nexthop group before adding an individual nexthop\n");
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -359,7 +375,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
 
                if (pbrms->nhg->nexthop) {
                        vty_out(vty,
-                               "If you would like more than one nexthop please use nexthop-groups");
+                               "If you would like more than one nexthop please use nexthop-groups\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }