Skip to content

Commit 92e2c40

Browse files
shorman-netronomedavem330
authored andcommitted
flow_dissector: allow dissection of tunnel options from metadata
Allow the existing 'dissection' of tunnel metadata to 'dissect' options already present in tunnel metadata. This dissection is controlled by a new dissector key, FLOW_DISSECTOR_KEY_ENC_OPTS. This dissection only occurs when skb_flow_dissect_tunnel_info() is called, currently only the Flower classifier makes that call. So there should be no impact on other users of the flow dissector. This is in preparation for allowing the flower classifier to match on Geneve options. Signed-off-by: Simon Horman <[email protected]> Signed-off-by: Pieter Jansen van Vuuren <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d7ff7ec commit 92e2c40

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

include/net/flow_dissector.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ struct flow_dissector_key_mpls {
5757
mpls_label:20;
5858
};
5959

60+
#define FLOW_DIS_TUN_OPTS_MAX 255
61+
/**
62+
* struct flow_dissector_key_enc_opts:
63+
* @data: tunnel option data
64+
* @len: length of tunnel option data
65+
* @dst_opt_type: tunnel option type
66+
*/
67+
struct flow_dissector_key_enc_opts {
68+
u8 data[FLOW_DIS_TUN_OPTS_MAX]; /* Using IP_TUNNEL_OPTS_MAX is desired
69+
* here but seems difficult to #include
70+
*/
71+
u8 len;
72+
__be16 dst_opt_type;
73+
};
74+
6075
struct flow_dissector_key_keyid {
6176
__be32 keyid;
6277
};
@@ -208,6 +223,8 @@ enum flow_dissector_key_id {
208223
FLOW_DISSECTOR_KEY_IP, /* struct flow_dissector_key_ip */
209224
FLOW_DISSECTOR_KEY_CVLAN, /* struct flow_dissector_key_flow_vlan */
210225
FLOW_DISSECTOR_KEY_ENC_IP, /* struct flow_dissector_key_ip */
226+
FLOW_DISSECTOR_KEY_ENC_OPTS, /* struct flow_dissector_key_enc_opts */
227+
211228
FLOW_DISSECTOR_KEY_MAX,
212229
};
213230

net/core/flow_dissector.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
154154
!dissector_uses_key(flow_dissector,
155155
FLOW_DISSECTOR_KEY_ENC_PORTS) &&
156156
!dissector_uses_key(flow_dissector,
157-
FLOW_DISSECTOR_KEY_ENC_IP))
157+
FLOW_DISSECTOR_KEY_ENC_IP) &&
158+
!dissector_uses_key(flow_dissector,
159+
FLOW_DISSECTOR_KEY_ENC_OPTS))
158160
return;
159161

160162
info = skb_tunnel_info(skb);
@@ -224,6 +226,21 @@ skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
224226
ip->tos = key->tos;
225227
ip->ttl = key->ttl;
226228
}
229+
230+
if (dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_ENC_OPTS)) {
231+
struct flow_dissector_key_enc_opts *enc_opt;
232+
233+
enc_opt = skb_flow_dissector_target(flow_dissector,
234+
FLOW_DISSECTOR_KEY_ENC_OPTS,
235+
target_container);
236+
237+
if (info->options_len) {
238+
enc_opt->len = info->options_len;
239+
ip_tunnel_info_opts_get(enc_opt->data, info);
240+
enc_opt->dst_opt_type = info->key.tun_flags &
241+
TUNNEL_OPTIONS_PRESENT;
242+
}
243+
}
227244
}
228245
EXPORT_SYMBOL(skb_flow_dissect_tunnel_info);
229246

0 commit comments

Comments
 (0)