|
44 | 44 | #include "../nfp_net.h" |
45 | 45 | #include "../nfp_port.h" |
46 | 46 |
|
| 47 | +#define NFP_FLOWER_SUPPORTED_TCPFLAGS \ |
| 48 | + (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \ |
| 49 | + TCPHDR_PSH | TCPHDR_URG) |
| 50 | + |
47 | 51 | #define NFP_FLOWER_WHITELIST_DISSECTOR \ |
48 | 52 | (BIT(FLOW_DISSECTOR_KEY_CONTROL) | \ |
49 | 53 | BIT(FLOW_DISSECTOR_KEY_BASIC) | \ |
50 | 54 | BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | \ |
51 | 55 | BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | \ |
| 56 | + BIT(FLOW_DISSECTOR_KEY_TCP) | \ |
52 | 57 | BIT(FLOW_DISSECTOR_KEY_PORTS) | \ |
53 | 58 | BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | \ |
54 | 59 | BIT(FLOW_DISSECTOR_KEY_VLAN) | \ |
@@ -288,6 +293,35 @@ nfp_flower_calculate_key_layers(struct nfp_app *app, |
288 | 293 | } |
289 | 294 | } |
290 | 295 |
|
| 296 | + if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_TCP)) { |
| 297 | + struct flow_dissector_key_tcp *tcp; |
| 298 | + u32 tcp_flags; |
| 299 | + |
| 300 | + tcp = skb_flow_dissector_target(flow->dissector, |
| 301 | + FLOW_DISSECTOR_KEY_TCP, |
| 302 | + flow->key); |
| 303 | + tcp_flags = be16_to_cpu(tcp->flags); |
| 304 | + |
| 305 | + if (tcp_flags & ~NFP_FLOWER_SUPPORTED_TCPFLAGS) |
| 306 | + return -EOPNOTSUPP; |
| 307 | + |
| 308 | + /* We only support PSH and URG flags when either |
| 309 | + * FIN, SYN or RST is present as well. |
| 310 | + */ |
| 311 | + if ((tcp_flags & (TCPHDR_PSH | TCPHDR_URG)) && |
| 312 | + !(tcp_flags & (TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST))) |
| 313 | + return -EOPNOTSUPP; |
| 314 | + |
| 315 | + /* We need to store TCP flags in the IPv4 key space, thus |
| 316 | + * we need to ensure we include a IPv4 key layer if we have |
| 317 | + * not done so already. |
| 318 | + */ |
| 319 | + if (!(key_layer & NFP_FLOWER_LAYER_IPV4)) { |
| 320 | + key_layer |= NFP_FLOWER_LAYER_IPV4; |
| 321 | + key_size += sizeof(struct nfp_flower_ipv4); |
| 322 | + } |
| 323 | + } |
| 324 | + |
291 | 325 | ret_key_ls->key_layer = key_layer; |
292 | 326 | ret_key_ls->key_layer_two = key_layer_two; |
293 | 327 | ret_key_ls->key_size = key_size; |
|
0 commit comments