diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-10-16 08:44:20 +0200 | 
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2020-08-21 13:37:08 +0200 | 
| commit | 4088180002478f772332aefbac54f9148f20018f (patch) | |
| tree | c6812a338a22003d3b58eea932bd00db65788831 /bgpd/bgp_flowspec_util.c | |
| parent | 9cec4121623c18eb5d826420e2078e2a78242362 (diff) | |
bgpd, lib: support for flow_label flowspec type
in ipv6 flowspec, a new type is defined to be able to do filtering rules
based on 20 bits flow label field as depicted in [0]. The change include
the decoding by flowspec, and the addition of a new attribute in policy
routing rule, so that the data is ready to be sent to zebra.
The commit also includes a check on fragment option, since dont fragment
bit does not exist in ipv6, the value should always be set to 0,
otherwise the flowspec rule becomes invalid.
[0] https://tools.ietf.org/html/draft-ietf-idr-flow-spec-v6-09
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_flowspec_util.c')
| -rw-r--r-- | bgpd/bgp_flowspec_util.c | 27 | 
1 files changed, 26 insertions, 1 deletions
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c index 2dd35696d0..0115d7af1e 100644 --- a/bgpd/bgp_flowspec_util.c +++ b/bgpd/bgp_flowspec_util.c @@ -118,6 +118,16 @@ bool bgp_flowspec_contains_prefix(const struct prefix *pfs,  					   &compare.u.prefix6.s6_addr))  				return true;  			break; +		case FLOWSPEC_FLOW_LABEL: +			if (afi == AFI_IP) { +				error = -1; +				continue; +			} +			ret = bgp_flowspec_op_decode(BGP_FLOWSPEC_VALIDATE_ONLY, +						     nlri_content+offset, +						     len - offset, +						     NULL, &error); +			break;  		case FLOWSPEC_IP_PROTOCOL:  		case FLOWSPEC_PORT:  		case FLOWSPEC_DEST_PORT: @@ -499,6 +509,20 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,  			}  			offset += ret;  			break; +		case FLOWSPEC_FLOW_LABEL: +			if (afi == AFI_IP) { +				error = -1; +				continue; +			} +			match_num = &(bpem->match_flowlabel_num); +			mval = (struct bgp_pbr_match_val *) +				&(bpem->flow_label); +			offset += bgp_flowspec_call_non_opaque_decode( +							nlri_content + offset, +							len - offset, +							mval, match_num, +							&error); +			break;  		case FLOWSPEC_IP_PROTOCOL:  			match_num = &(bpem->match_protocol_num);  			mval = (struct bgp_pbr_match_val *) @@ -621,7 +645,8 @@ int bgp_flowspec_match_rules_fill(uint8_t *nlri_content, int len,  	    bpem->match_packet_length_num || bpem->match_icmp_code_num ||  	    bpem->match_icmp_type_num || bpem->match_port_num ||  	    bpem->match_src_port_num || bpem->match_dst_port_num || -	    bpem->match_protocol_num || bpem->match_bitmask) +	    bpem->match_protocol_num || bpem->match_bitmask || +	    bpem->match_flowlabel_num)  		bpem->type = BGP_PBR_IPSET;  	else if ((bpem->match_bitmask_iprule & PREFIX_SRC_PRESENT) ||  		 (bpem->match_bitmask_iprule & PREFIX_DST_PRESENT))  | 
