]> git.proxmox.com Git - mirror_frr.git/commitdiff
pbrd: Add ability to set/unset src and dest ports
authorDonald Sharp <sharpd@nvidia.com>
Thu, 3 Jun 2021 23:46:47 +0000 (19:46 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 8 Jul 2021 15:12:46 +0000 (11:12 -0400)
Add `match src-port (1-65535)` and `match dst-port (1-65535)`
commands to allow pbr to pass these values down to zebra.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
pbrd/pbr_vty.c

index 3d56fc3daa14ee09d89cc853b20b0e700a4becb3..f13ed4d429d40ba8085d1292994f3a7c910c57a8 100644 (file)
@@ -193,6 +193,50 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
        return CMD_SUCCESS;
 }
 
+DEFPY(pbr_map_match_src_port, pbr_map_match_src_port_cmd,
+      "[no] match src-port (1-65535)$port",
+      NO_STR
+      "Match the rest of the command\n"
+      "Choose the source port to use\n"
+      "The Source Port\n")
+{
+       struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+
+       if (!no) {
+               if (pbrms->src_prt == port)
+                       return CMD_SUCCESS;
+               else
+                       pbrms->src_prt = port;
+       } else
+               pbrms->src_prt = 0;
+
+       pbr_map_check(pbrms, true);
+
+       return CMD_SUCCESS;
+}
+
+DEFPY(pbr_map_match_dst_port, pbr_map_match_dst_port_cmd,
+      "[no] match dst-port (1-65535)$port",
+      NO_STR
+      "Match the rest of the command\n"
+      "Choose the destination port to use\n"
+      "The Destination Port\n")
+{
+       struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence);
+
+       if (!no) {
+               if (pbrms->dst_prt == port)
+                       return CMD_SUCCESS;
+               else
+                       pbrms->dst_prt = port;
+       } else
+               pbrms->dst_prt = 0;
+
+       pbr_map_check(pbrms, true);
+
+       return CMD_SUCCESS;
+}
+
 DEFPY(pbr_map_match_dscp, pbr_map_match_dscp_cmd,
       "[no] match dscp DSCP$dscp",
       NO_STR
@@ -1079,6 +1123,11 @@ static int pbr_vty_map_config_write_sequence(struct vty *vty,
        if (pbrms->dst)
                vty_out(vty, " match dst-ip %pFX\n", pbrms->dst);
 
+       if (pbrms->src_prt)
+               vty_out(vty, " match src-port %u\n", pbrms->src_prt);
+       if (pbrms->dst_prt)
+               vty_out(vty, " match dst-port %u\n", pbrms->dst_prt);
+
        if (pbrms->dsfield & PBR_DSFIELD_DSCP)
                vty_out(vty, " match dscp %u\n",
                        (pbrms->dsfield & PBR_DSFIELD_DSCP) >> 2);
@@ -1169,6 +1218,8 @@ void pbr_vty_init(void)
        install_element(CONFIG_NODE, &pbr_set_table_range_cmd);
        install_element(CONFIG_NODE, &no_pbr_set_table_range_cmd);
        install_element(INTERFACE_NODE, &pbr_policy_cmd);
+       install_element(PBRMAP_NODE, &pbr_map_match_src_port_cmd);
+       install_element(PBRMAP_NODE, &pbr_map_match_dst_port_cmd);
        install_element(PBRMAP_NODE, &pbr_map_match_src_cmd);
        install_element(PBRMAP_NODE, &pbr_map_match_dst_cmd);
        install_element(PBRMAP_NODE, &pbr_map_match_dscp_cmd);