aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Stringer <joestringer@nicira.com>2015-10-06 14:00:00 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-07 08:03:06 -0400
commitfbccce5965a58d56aaed9e9acd1bec75d8a66e87 (patch)
treebd9a9d1b2adc68773013bd5cbdae091617bceaae
parent6f225952461b5e9b5520d0dc6e2ff0af57874fbb (diff)
openvswitch: Extend ct_state match field to 32 bits
The ct_state field was initially added as an 8-bit field, however six of the bits are already being used and use cases are already starting to appear that may push the limits of this field. This patch extends the field to 32 bits while retaining the internal representation of 8 bits. This should cover forward compatibility of the ABI for the foreseeable future. This patch also reorders the OVS_CS_F_* bits to be sequential. Suggested-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/openvswitch.h8
-rw-r--r--net/openvswitch/conntrack.c2
-rw-r--r--net/openvswitch/conntrack.h4
-rw-r--r--net/openvswitch/flow_netlink.c8
4 files changed, 11 insertions, 11 deletions
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index a9a4a59912e9..c861a4cf5fec 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -323,7 +323,7 @@ enum ovs_key_attr {
323 OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls. 323 OVS_KEY_ATTR_MPLS, /* array of struct ovs_key_mpls.
324 * The implementation may restrict 324 * The implementation may restrict
325 * the accepted length of the array. */ 325 * the accepted length of the array. */
326 OVS_KEY_ATTR_CT_STATE, /* u8 bitmask of OVS_CS_F_* */ 326 OVS_KEY_ATTR_CT_STATE, /* u32 bitmask of OVS_CS_F_* */
327 OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */ 327 OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */
328 OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */ 328 OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */
329 OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */ 329 OVS_KEY_ATTR_CT_LABELS, /* 16-octet connection tracking label */
@@ -449,9 +449,9 @@ struct ovs_key_ct_labels {
449#define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */ 449#define OVS_CS_F_ESTABLISHED 0x02 /* Part of an existing connection. */
450#define OVS_CS_F_RELATED 0x04 /* Related to an established 450#define OVS_CS_F_RELATED 0x04 /* Related to an established
451 * connection. */ 451 * connection. */
452#define OVS_CS_F_INVALID 0x20 /* Could not track connection. */ 452#define OVS_CS_F_REPLY_DIR 0x08 /* Flow is in the reply direction. */
453#define OVS_CS_F_REPLY_DIR 0x40 /* Flow is in the reply direction. */ 453#define OVS_CS_F_INVALID 0x10 /* Could not track connection. */
454#define OVS_CS_F_TRACKED 0x80 /* Conntrack has occurred. */ 454#define OVS_CS_F_TRACKED 0x20 /* Conntrack has occurred. */
455 455
456/** 456/**
457 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands. 457 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 7d80acfb80d0..466d5576fe3f 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -167,7 +167,7 @@ void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key)
167 167
168int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb) 168int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb)
169{ 169{
170 if (nla_put_u8(skb, OVS_KEY_ATTR_CT_STATE, key->ct.state)) 170 if (nla_put_u32(skb, OVS_KEY_ATTR_CT_STATE, key->ct.state))
171 return -EMSGSIZE; 171 return -EMSGSIZE;
172 172
173 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && 173 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
diff --git a/net/openvswitch/conntrack.h b/net/openvswitch/conntrack.h
index d6eca8394254..da8714942c95 100644
--- a/net/openvswitch/conntrack.h
+++ b/net/openvswitch/conntrack.h
@@ -35,7 +35,7 @@ void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key);
35int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb); 35int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb);
36void ovs_ct_free_action(const struct nlattr *a); 36void ovs_ct_free_action(const struct nlattr *a);
37 37
38static inline bool ovs_ct_state_supported(u8 state) 38static inline bool ovs_ct_state_supported(u32 state)
39{ 39{
40 return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED | 40 return !(state & ~(OVS_CS_F_NEW | OVS_CS_F_ESTABLISHED |
41 OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR | 41 OVS_CS_F_RELATED | OVS_CS_F_REPLY_DIR |
@@ -53,7 +53,7 @@ static inline bool ovs_ct_verify(struct net *net, int attr)
53 return false; 53 return false;
54} 54}
55 55
56static inline bool ovs_ct_state_supported(u8 state) 56static inline bool ovs_ct_state_supported(u32 state)
57{ 57{
58 return false; 58 return false;
59} 59}
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index d47b5c5c640e..171a691f1c32 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -291,7 +291,7 @@ size_t ovs_key_attr_size(void)
291 + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */ 291 + nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */
292 + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */ 292 + nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */
293 + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */ 293 + nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */
294 + nla_total_size(1) /* OVS_KEY_ATTR_CT_STATE */ 294 + nla_total_size(4) /* OVS_KEY_ATTR_CT_STATE */
295 + nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */ 295 + nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */
296 + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */ 296 + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */
297 + nla_total_size(16) /* OVS_KEY_ATTR_CT_LABELS */ 297 + nla_total_size(16) /* OVS_KEY_ATTR_CT_LABELS */
@@ -349,7 +349,7 @@ static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
349 [OVS_KEY_ATTR_TUNNEL] = { .len = OVS_ATTR_NESTED, 349 [OVS_KEY_ATTR_TUNNEL] = { .len = OVS_ATTR_NESTED,
350 .next = ovs_tunnel_key_lens, }, 350 .next = ovs_tunnel_key_lens, },
351 [OVS_KEY_ATTR_MPLS] = { .len = sizeof(struct ovs_key_mpls) }, 351 [OVS_KEY_ATTR_MPLS] = { .len = sizeof(struct ovs_key_mpls) },
352 [OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u8) }, 352 [OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u32) },
353 [OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) }, 353 [OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) },
354 [OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) }, 354 [OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) },
355 [OVS_KEY_ATTR_CT_LABELS] = { .len = sizeof(struct ovs_key_ct_labels) }, 355 [OVS_KEY_ATTR_CT_LABELS] = { .len = sizeof(struct ovs_key_ct_labels) },
@@ -814,10 +814,10 @@ static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match,
814 814
815 if (*attrs & (1 << OVS_KEY_ATTR_CT_STATE) && 815 if (*attrs & (1 << OVS_KEY_ATTR_CT_STATE) &&
816 ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) { 816 ovs_ct_verify(net, OVS_KEY_ATTR_CT_STATE)) {
817 u8 ct_state = nla_get_u8(a[OVS_KEY_ATTR_CT_STATE]); 817 u32 ct_state = nla_get_u32(a[OVS_KEY_ATTR_CT_STATE]);
818 818
819 if (!is_mask && !ovs_ct_state_supported(ct_state)) { 819 if (!is_mask && !ovs_ct_state_supported(ct_state)) {
820 OVS_NLERR(log, "ct_state flags %02x unsupported", 820 OVS_NLERR(log, "ct_state flags %08x unsupported",
821 ct_state); 821 ct_state);
822 return -EINVAL; 822 return -EINVAL;
823 } 823 }