diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2021-06-03 19:46:47 -0400 | 
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2021-07-08 11:12:46 -0400 | 
| commit | a7f0e5c3e37812a6941bc09f9f77a4fa3d31d428 (patch) | |
| tree | 593afc6dbd4c6f7d8a88aebb31fe8668da398764 /pbrd | |
| parent | 0d7b939fd063ceb825c3aed9c9915c674f2922ac (diff) | |
pbrd: Add ability to set/unset src and dest ports
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>
Diffstat (limited to 'pbrd')
| -rw-r--r-- | pbrd/pbr_vty.c | 51 | 
1 files changed, 51 insertions, 0 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 3d56fc3daa..f13ed4d429 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -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);  | 
