[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <6c976cc538f1f565b74bd2c750639af91a93adc1.1548285996.git.mleitner@redhat.com>
Date: Fri, 25 Jan 2019 00:32:31 -0200
From: Marcelo Ricardo Leitner <mleitner@...hat.com>
To: Guy Shattah <sguy@...lanox.com>,
Marcelo Leitner <mleitner@...hat.com>,
Aaron Conole <aconole@...hat.com>,
John Hurley <john.hurley@...ronome.com>,
Simon Horman <simon.horman@...ronome.com>,
Justin Pettit <jpettit@....org>,
Gregory Rose <gvrose8192@...il.com>,
Eelco Chaudron <echaudro@...hat.com>,
Flavio Leitner <fbl@...hat.com>,
Florian Westphal <fwestpha@...hat.com>,
Jiri Pirko <jiri@...nulli.us>, Rashid Khan <rkhan@...hat.com>,
Sushil Kulkarni <sukulkar@...hat.com>,
Andy Gospodarek <andrew.gospodarek@...adcom.com>,
Roi Dayan <roid@...lanox.com>,
Yossi Kuperman <yossiku@...lanox.com>,
Or Gerlitz <ogerlitz@...lanox.com>,
Rony Efraim <ronye@...lanox.com>,
"davem@...emloft.net" <davem@...emloft.net>
Cc: netdev@...r.kernel.org
Subject: [RFC PATCH 2/6] net/sched: flower: add support for matching on ConnTrack
Hook on flow dissector's new interface on ConnTrack from previous patch.
Signed-off-by: Marcelo Ricardo Leitner <mleitner@...hat.com>
---
include/uapi/linux/pkt_cls.h | 9 +++++++++
net/sched/cls_flower.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 95d0db2a8350dffb1dd20816591f3b179913fb2e..ba1f3bc01b2fdfd810e37a2b3853a1da1f838acf 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -490,6 +490,15 @@ enum {
TCA_FLOWER_KEY_PORT_DST_MIN, /* be16 */
TCA_FLOWER_KEY_PORT_DST_MAX, /* be16 */
+ TCA_FLOWER_KEY_CT_ZONE, /* u16 */
+ TCA_FLOWER_KEY_CT_ZONE_MASK, /* u16 */
+ TCA_FLOWER_KEY_CT_STATE, /* u8 */
+ TCA_FLOWER_KEY_CT_STATE_MASK, /* u8 */
+ TCA_FLOWER_KEY_CT_MARK, /* u32 */
+ TCA_FLOWER_KEY_CT_MARK_MASK, /* u32 */
+ TCA_FLOWER_KEY_CT_LABEL, /* 128 bits */
+ TCA_FLOWER_KEY_CT_LABEL_MASK, /* 128 bits */
+
__TCA_FLOWER_MAX,
};
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 85e9f8e1da10aa7b01b0f51768edfefbe63d6a10..430b7fceeca0998b8c904acd91f8de53571814ff 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -57,6 +57,7 @@ struct fl_flow_key {
struct flow_dissector_key_enc_opts enc_opts;
struct flow_dissector_key_ports tp_min;
struct flow_dissector_key_ports tp_max;
+ struct flow_dissector_key_ct ct;
} __aligned(BITS_PER_LONG / 8); /* Ensure that we can do comparisons as longs. */
struct fl_flow_mask_range {
@@ -1079,6 +1080,22 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
fl_set_key_ip(tb, true, &key->enc_ip, &mask->enc_ip);
+ fl_set_key_val(tb, &key->ct.mark, TCA_FLOWER_KEY_CT_MARK,
+ &mask->ct.mark, TCA_FLOWER_KEY_CT_MARK_MASK,
+ sizeof(key->ct.mark));
+
+ fl_set_key_val(tb, &key->ct.zone, TCA_FLOWER_KEY_CT_ZONE,
+ &mask->ct.zone, TCA_FLOWER_KEY_CT_ZONE_MASK,
+ sizeof(key->ct.zone));
+
+ fl_set_key_val(tb, &key->ct.state, TCA_FLOWER_KEY_CT_STATE,
+ &mask->ct.state, TCA_FLOWER_KEY_CT_STATE_MASK,
+ sizeof(key->ct.state));
+
+ fl_set_key_val(tb, &key->ct.label, TCA_FLOWER_KEY_CT_LABEL,
+ &mask->ct.label, TCA_FLOWER_KEY_CT_LABEL_MASK,
+ sizeof(key->ct.label));
+
if (tb[TCA_FLOWER_KEY_ENC_OPTS]) {
ret = fl_set_enc_opt(tb, key, mask, extack);
if (ret)
@@ -1183,6 +1200,8 @@ static void fl_init_dissector(struct flow_dissector *dissector,
FLOW_DISSECTOR_KEY_ENC_IP, enc_ip);
FL_KEY_SET_IF_MASKED(mask, keys, cnt,
FLOW_DISSECTOR_KEY_ENC_OPTS, enc_opts);
+ FL_KEY_SET_IF_MASKED(mask, keys, cnt,
+ FLOW_DISSECTOR_KEY_CT, ct);
skb_flow_dissector_init(dissector, keys, cnt);
}
@@ -1994,6 +2013,20 @@ static int fl_dump_key(struct sk_buff *skb, struct net *net,
fl_dump_key_enc_opt(skb, &key->enc_opts, &mask->enc_opts))
goto nla_put_failure;
+ if (fl_dump_key_val(skb, &key->ct.zone, TCA_FLOWER_KEY_CT_ZONE,
+ &mask->ct.zone, TCA_FLOWER_KEY_CT_ZONE_MASK,
+ sizeof(key->ct.zone)) ||
+ fl_dump_key_val(skb, &key->ct.mark, TCA_FLOWER_KEY_CT_MARK,
+ &mask->ct.mark, TCA_FLOWER_KEY_CT_MARK_MASK,
+ sizeof(key->ct.mark)) ||
+ fl_dump_key_val(skb, &key->ct.state, TCA_FLOWER_KEY_CT_STATE,
+ &mask->ct.state, TCA_FLOWER_KEY_CT_STATE_MASK,
+ sizeof(key->ct.state)) ||
+ fl_dump_key_val(skb, &key->ct.label, TCA_FLOWER_KEY_CT_LABEL,
+ &mask->ct.label, TCA_FLOWER_KEY_CT_LABEL_MASK,
+ sizeof(key->ct.label)))
+ goto nla_put_failure;
+
if (fl_dump_key_flags(skb, key->control.flags, mask->control.flags))
goto nla_put_failure;
--
2.20.1
Powered by blists - more mailing lists