From: Joe Stringer <joestringer@nicira.com>
To: netdev@vger.kernel.org, pshelar@nicira.com
Cc: tgraf@suug.ch, jrajahalme@nicira.com
Subject: [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided
Date: Mon, 19 Oct 2015 19:19:00 -0700 [thread overview]
Message-ID: <1445307540-6786-4-git-send-email-joestringer@nicira.com> (raw)
In-Reply-To: <1445307540-6786-1-git-send-email-joestringer@nicira.com>
If userspace provides a ct action with no nested mark or label, then the
storage for these fields is zeroed. Later when actions are requested,
such zeroed fields are serialized even though userspace didn't
originally specify them. Fix the behaviour by ensuring that no action is
serialized in this case, and reject actions where userspace attempts to
set these fields with mask=0. This should make netlink marshalling
consistent across deserialization/reserialization.
Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
---
v2: Reuse labels_nonzero().
Don't check for labels support during execution.
v3: Acked.
---
net/openvswitch/conntrack.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 8ad121871834..a5ec34f8502f 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -224,9 +224,6 @@ static int ovs_ct_set_labels(struct sk_buff *skb, struct sw_flow_key *key,
struct nf_conn *ct;
int err;
- if (!IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS))
- return -ENOTSUPP;
-
/* The connection could be invalid, in which case set_label is no-op.*/
ct = nf_ct_get(skb, &ctinfo);
if (!ct)
@@ -587,6 +584,10 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
case OVS_CT_ATTR_MARK: {
struct md_mark *mark = nla_data(a);
+ if (!mark->mask) {
+ OVS_NLERR(log, "ct_mark mask cannot be 0");
+ return -EINVAL;
+ }
info->mark = *mark;
break;
}
@@ -595,6 +596,10 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
case OVS_CT_ATTR_LABELS: {
struct md_labels *labels = nla_data(a);
+ if (!labels_nonzero(&labels->mask)) {
+ OVS_NLERR(log, "ct_labels mask cannot be 0");
+ return -EINVAL;
+ }
info->labels = *labels;
break;
}
@@ -705,11 +710,12 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info,
if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id))
return -EMSGSIZE;
- if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
+ if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) && ct_info->mark.mask &&
nla_put(skb, OVS_CT_ATTR_MARK, sizeof(ct_info->mark),
&ct_info->mark))
return -EMSGSIZE;
if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
+ labels_nonzero(&ct_info->labels.mask) &&
nla_put(skb, OVS_CT_ATTR_LABELS, sizeof(ct_info->labels),
&ct_info->labels))
return -EMSGSIZE;
--
2.1.4
next prev parent reply other threads:[~2015-10-20 2:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 2:18 [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits Joe Stringer
2015-10-20 2:18 ` [PATCHv3 net 2/4] openvswitch: Clarify conntrack COMMIT behaviour Joe Stringer
2015-10-20 8:37 ` Thomas Graf
2015-10-20 21:53 ` Pravin Shelar
2015-10-22 2:34 ` David Miller
2015-10-20 2:18 ` [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed Joe Stringer
2015-10-20 8:41 ` Thomas Graf
2015-10-20 22:07 ` Pravin Shelar
2015-10-22 2:34 ` David Miller
2015-10-20 2:19 ` Joe Stringer [this message]
2015-10-22 2:34 ` [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided David Miller
2015-10-22 2:34 ` [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445307540-6786-4-git-send-email-joestringer@nicira.com \
--to=joestringer@nicira.com \
--cc=jrajahalme@nicira.com \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
--cc=tgraf@suug.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox