Skip to content

Commit d7ff7ec

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: allow matching on ipv4 UDP tunnel tos and ttl
The addition of FLOW_DISSECTOR_KEY_ENC_IP to TC flower means that the ToS and TTL of the tunnel header can now be matched on. Extend the NFP tunnel match function to include these new fields. Signed-off-by: John Hurley <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2a43747 commit d7ff7ec

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

drivers/net/ethernet/netronome/nfp/flower/cmsg.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ struct nfp_flower_ipv6 {
346346
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
347347
* | ipv4_addr_dst |
348348
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
349-
* | Reserved |
349+
* | Reserved | tos | ttl |
350350
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351351
* | Reserved |
352352
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -356,7 +356,10 @@ struct nfp_flower_ipv6 {
356356
struct nfp_flower_ipv4_udp_tun {
357357
__be32 ip_src;
358358
__be32 ip_dst;
359-
__be32 reserved[2];
359+
__be16 reserved1;
360+
u8 tos;
361+
u8 ttl;
362+
__be32 reserved2;
360363
__be32 tun_id;
361364
};
362365

drivers/net/ethernet/netronome/nfp/flower/match.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *frame,
270270
struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
271271
struct flow_dissector_key_ipv4_addrs *tun_ips;
272272
struct flow_dissector_key_keyid *vni;
273+
struct flow_dissector_key_ip *ip;
273274

274275
memset(frame, 0, sizeof(struct nfp_flower_ipv4_udp_tun));
275276

@@ -293,6 +294,14 @@ nfp_flower_compile_ipv4_udp_tun(struct nfp_flower_ipv4_udp_tun *frame,
293294
frame->ip_src = tun_ips->src;
294295
frame->ip_dst = tun_ips->dst;
295296
}
297+
298+
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_ENC_IP)) {
299+
ip = skb_flow_dissector_target(flow->dissector,
300+
FLOW_DISSECTOR_KEY_ENC_IP,
301+
target);
302+
frame->tos = ip->tos;
303+
frame->ttl = ip->ttl;
304+
}
296305
}
297306

298307
int nfp_flower_compile_flow_match(struct tc_cls_flower_offload *flow,

drivers/net/ethernet/netronome/nfp/flower/offload.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
BIT(FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) | \
6767
BIT(FLOW_DISSECTOR_KEY_ENC_CONTROL) | \
6868
BIT(FLOW_DISSECTOR_KEY_ENC_PORTS) | \
69+
BIT(FLOW_DISSECTOR_KEY_ENC_IP) | \
6970
BIT(FLOW_DISSECTOR_KEY_MPLS) | \
7071
BIT(FLOW_DISSECTOR_KEY_IP))
7172

@@ -74,7 +75,8 @@
7475
BIT(FLOW_DISSECTOR_KEY_ENC_KEYID) | \
7576
BIT(FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS) | \
7677
BIT(FLOW_DISSECTOR_KEY_ENC_IPV6_ADDRS) | \
77-
BIT(FLOW_DISSECTOR_KEY_ENC_PORTS))
78+
BIT(FLOW_DISSECTOR_KEY_ENC_PORTS) | \
79+
BIT(FLOW_DISSECTOR_KEY_ENC_IP))
7880

7981
#define NFP_FLOWER_WHITELIST_TUN_DISSECTOR_R \
8082
(BIT(FLOW_DISSECTOR_KEY_ENC_CONTROL) | \

0 commit comments

Comments
 (0)