* [PATCHv3 net 2/4] openvswitch: Clarify conntrack COMMIT behaviour
2015-10-20 2:18 [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits Joe Stringer
@ 2015-10-20 2:18 ` Joe Stringer
2015-10-20 8:37 ` Thomas Graf
` (2 more replies)
2015-10-20 2:18 ` [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed Joe Stringer
` (2 subsequent siblings)
3 siblings, 3 replies; 12+ messages in thread
From: Joe Stringer @ 2015-10-20 2:18 UTC (permalink / raw)
To: netdev, pshelar; +Cc: tgraf, jrajahalme
The presence of this attribute does not modify the ct_state for the
current packet, only future packets. Make this more clear in the header
definition.
Signed-off-by: Joe Stringer <joestringer@nicira.com>
---
v3: First post.
---
include/uapi/linux/openvswitch.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 036f73bc54cd..e663627a8ef3 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -620,7 +620,8 @@ struct ovs_action_hash {
* enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
* @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack
* table. This allows future packets for the same connection to be identified
- * as 'established' or 'related'.
+ * as 'established' or 'related'. The flow key for the current packet will
+ * retain the pre-commit connection state.
* @OVS_CT_ATTR_ZONE: u16 connection tracking zone.
* @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the
* mask, the corresponding bit in the value is copied to the connection
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCHv3 net 2/4] openvswitch: Clarify conntrack COMMIT behaviour
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
2 siblings, 0 replies; 12+ messages in thread
From: Thomas Graf @ 2015-10-20 8:37 UTC (permalink / raw)
To: Joe Stringer; +Cc: netdev, pshelar, jrajahalme
On 10/19/15 at 07:18pm, Joe Stringer wrote:
> The presence of this attribute does not modify the ct_state for the
> current packet, only future packets. Make this more clear in the header
> definition.
>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 net 2/4] openvswitch: Clarify conntrack COMMIT behaviour
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
2 siblings, 0 replies; 12+ messages in thread
From: Pravin Shelar @ 2015-10-20 21:53 UTC (permalink / raw)
To: Joe Stringer; +Cc: netdev, Thomas Graf, Jarno Rajahalme
On Mon, Oct 19, 2015 at 7:18 PM, Joe Stringer <joestringer@nicira.com> wrote:
> The presence of this attribute does not modify the ct_state for the
> current packet, only future packets. Make this more clear in the header
> definition.
>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 net 2/4] openvswitch: Clarify conntrack COMMIT behaviour
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
2 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-10-22 2:34 UTC (permalink / raw)
To: joestringer; +Cc: netdev, pshelar, tgraf, jrajahalme
From: Joe Stringer <joestringer@nicira.com>
Date: Mon, 19 Oct 2015 19:18:58 -0700
> The presence of this attribute does not modify the ct_state for the
> current packet, only future packets. Make this more clear in the header
> definition.
>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed.
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 2:18 ` Joe Stringer
2015-10-20 8:41 ` Thomas Graf
` (2 more replies)
2015-10-20 2:19 ` [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided Joe Stringer
2015-10-22 2:34 ` [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits David Miller
3 siblings, 3 replies; 12+ messages in thread
From: Joe Stringer @ 2015-10-20 2:18 UTC (permalink / raw)
To: netdev, pshelar; +Cc: tgraf, jrajahalme
New, related connections are marked as such as part of ovs_ct_lookup(),
but they are not marked as "new" if the commit flag is used. Make this
consistent by setting the "new" flag whenever !nf_ct_is_confirmed(ct).
Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
---
v2: Acked.
v3: Took a different approach to fixing the issue.
---
net/openvswitch/conntrack.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 80bf702715bb..8ad121871834 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -151,6 +151,8 @@ static void ovs_ct_update_key(const struct sk_buff *skb,
ct = nf_ct_get(skb, &ctinfo);
if (ct) {
state = ovs_ct_get_state(ctinfo);
+ if (!nf_ct_is_confirmed(ct))
+ state |= OVS_CS_F_NEW;
if (ct->master)
state |= OVS_CS_F_RELATED;
zone = nf_ct_zone(ct);
@@ -377,7 +379,7 @@ static bool skb_nfct_cached(const struct net *net, const struct sk_buff *skb,
return true;
}
-static int __ovs_ct_lookup(struct net *net, const struct sw_flow_key *key,
+static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
const struct ovs_conntrack_info *info,
struct sk_buff *skb)
{
@@ -408,6 +410,8 @@ static int __ovs_ct_lookup(struct net *net, const struct sw_flow_key *key,
}
}
+ ovs_ct_update_key(skb, key, true);
+
return 0;
}
@@ -430,8 +434,6 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
err = __ovs_ct_lookup(net, key, info, skb);
if (err)
return err;
-
- ovs_ct_update_key(skb, key, true);
}
return 0;
@@ -460,8 +462,6 @@ static int ovs_ct_commit(struct net *net, struct sw_flow_key *key,
if (nf_conntrack_confirm(skb) != NF_ACCEPT)
return -EINVAL;
- ovs_ct_update_key(skb, key, true);
-
return 0;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed.
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
2 siblings, 0 replies; 12+ messages in thread
From: Thomas Graf @ 2015-10-20 8:41 UTC (permalink / raw)
To: Joe Stringer; +Cc: netdev, pshelar, jrajahalme
On 10/19/15 at 07:18pm, Joe Stringer wrote:
> New, related connections are marked as such as part of ovs_ct_lookup(),
> but they are not marked as "new" if the commit flag is used. Make this
> consistent by setting the "new" flag whenever !nf_ct_is_confirmed(ct).
>
> Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
> ---
> v2: Acked.
> v3: Took a different approach to fixing the issue.
Acked-by: Thomas Graf <tgraf@suug.ch>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed.
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
2 siblings, 0 replies; 12+ messages in thread
From: Pravin Shelar @ 2015-10-20 22:07 UTC (permalink / raw)
To: Joe Stringer; +Cc: netdev, Thomas Graf, Jarno Rajahalme
On Mon, Oct 19, 2015 at 7:18 PM, Joe Stringer <joestringer@nicira.com> wrote:
> New, related connections are marked as such as part of ovs_ct_lookup(),
> but they are not marked as "new" if the commit flag is used. Make this
> consistent by setting the "new" flag whenever !nf_ct_is_confirmed(ct).
>
> Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed.
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
2 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-10-22 2:34 UTC (permalink / raw)
To: joestringer; +Cc: netdev, pshelar, tgraf, jrajahalme
From: Joe Stringer <joestringer@nicira.com>
Date: Mon, 19 Oct 2015 19:18:59 -0700
> New, related connections are marked as such as part of ovs_ct_lookup(),
> but they are not marked as "new" if the commit flag is used. Make this
> consistent by setting the "new" flag whenever !nf_ct_is_confirmed(ct).
>
> Reported-by: Jarno Rajahalme <jrajahalme@nicira.com>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided
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 2:18 ` [PATCHv3 net 3/4] openvswitch: Mark connections new when not confirmed Joe Stringer
@ 2015-10-20 2:19 ` Joe Stringer
2015-10-22 2:34 ` David Miller
2015-10-22 2:34 ` [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits David Miller
3 siblings, 1 reply; 12+ messages in thread
From: Joe Stringer @ 2015-10-20 2:19 UTC (permalink / raw)
To: netdev, pshelar; +Cc: tgraf, jrajahalme
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
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided
2015-10-20 2:19 ` [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided Joe Stringer
@ 2015-10-22 2:34 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-10-22 2:34 UTC (permalink / raw)
To: joestringer; +Cc: netdev, pshelar, tgraf, jrajahalme
From: Joe Stringer <joestringer@nicira.com>
Date: Mon, 19 Oct 2015 19:19:00 -0700
> 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>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits
2015-10-20 2:18 [PATCHv3 net 1/4] openvswitch: Reject ct_state masks for unknown bits Joe Stringer
` (2 preceding siblings ...)
2015-10-20 2:19 ` [PATCHv3 net 4/4] openvswitch: Serialize nested ct actions if provided Joe Stringer
@ 2015-10-22 2:34 ` David Miller
3 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-10-22 2:34 UTC (permalink / raw)
To: joestringer; +Cc: netdev, pshelar, tgraf, jrajahalme
From: Joe Stringer <joestringer@nicira.com>
Date: Mon, 19 Oct 2015 19:18:57 -0700
> Currently, 0-bits are generated in ct_state where the bit position is
> undefined, and matches are accepted on these bit-positions. If userspace
> requests to match the 0-value for this bit then it may expect only a
> subset of traffic to match this value, whereas currently all packets
> will have this bit set to 0. Fix this by rejecting such masks.
>
> Signed-off-by: Joe Stringer <joestringer@nicira.com>
> Acked-by: Pravin B Shelar <pshelar@nicira.com>
> Acked-by: Thomas Graf <tgraf@suug.ch>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread