diff options
author | Joe Stringer <joestringer@nicira.com> | 2015-10-06 14:00:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-07 08:03:06 -0400 |
commit | ab38a7b5a4493a3658d891a8e91f9ffcb3d2defb (patch) | |
tree | 60bffa8ee121a82fcd16a55387a68cec62657ec9 | |
parent | fbccce5965a58d56aaed9e9acd1bec75d8a66e87 (diff) |
openvswitch: Change CT_ATTR_FLAGS to CT_ATTR_COMMIT
Previously, the CT_ATTR_FLAGS attribute, when nested under the
OVS_ACTION_ATTR_CT, encoded a 32-bit bitmask of flags that modify the
semantics of the ct action. It's more extensible to just represent each
flag as a nested attribute, and this requires no additional error
checking to reject flags that aren't currently supported.
Suggested-by: Ben Pfaff <blp@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.h | 14 | ||||
-rw-r--r-- | net/openvswitch/conntrack.c | 13 |
2 files changed, 10 insertions, 17 deletions
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h index c861a4cf5fec..036f73bc54cd 100644 --- a/include/uapi/linux/openvswitch.h +++ b/include/uapi/linux/openvswitch.h | |||
@@ -618,7 +618,9 @@ struct ovs_action_hash { | |||
618 | 618 | ||
619 | /** | 619 | /** |
620 | * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. | 620 | * enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action. |
621 | * @OVS_CT_ATTR_FLAGS: u32 connection tracking flags. | 621 | * @OVS_CT_ATTR_COMMIT: If present, commits the connection to the conntrack |
622 | * table. This allows future packets for the same connection to be identified | ||
623 | * as 'established' or 'related'. | ||
622 | * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. | 624 | * @OVS_CT_ATTR_ZONE: u16 connection tracking zone. |
623 | * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the | 625 | * @OVS_CT_ATTR_MARK: u32 value followed by u32 mask. For each bit set in the |
624 | * mask, the corresponding bit in the value is copied to the connection | 626 | * mask, the corresponding bit in the value is copied to the connection |
@@ -630,7 +632,7 @@ struct ovs_action_hash { | |||
630 | */ | 632 | */ |
631 | enum ovs_ct_attr { | 633 | enum ovs_ct_attr { |
632 | OVS_CT_ATTR_UNSPEC, | 634 | OVS_CT_ATTR_UNSPEC, |
633 | OVS_CT_ATTR_FLAGS, /* u32 bitmask of OVS_CT_F_*. */ | 635 | OVS_CT_ATTR_COMMIT, /* No argument, commits connection. */ |
634 | OVS_CT_ATTR_ZONE, /* u16 zone id. */ | 636 | OVS_CT_ATTR_ZONE, /* u16 zone id. */ |
635 | OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ | 637 | OVS_CT_ATTR_MARK, /* mark to associate with this connection. */ |
636 | OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */ | 638 | OVS_CT_ATTR_LABELS, /* labels to associate with this connection. */ |
@@ -641,14 +643,6 @@ enum ovs_ct_attr { | |||
641 | 643 | ||
642 | #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) | 644 | #define OVS_CT_ATTR_MAX (__OVS_CT_ATTR_MAX - 1) |
643 | 645 | ||
644 | /* | ||
645 | * OVS_CT_ATTR_FLAGS flags - bitmask of %OVS_CT_F_* | ||
646 | * @OVS_CT_F_COMMIT: Commits the flow to the conntrack table. This allows | ||
647 | * future packets for the same connection to be identified as 'established' | ||
648 | * or 'related'. | ||
649 | */ | ||
650 | #define OVS_CT_F_COMMIT 0x01 | ||
651 | |||
652 | /** | 646 | /** |
653 | * enum ovs_action_attr - Action types. | 647 | * enum ovs_action_attr - Action types. |
654 | * | 648 | * |
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 466d5576fe3f..80bf702715bb 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
@@ -47,7 +47,7 @@ struct ovs_conntrack_info { | |||
47 | struct nf_conntrack_helper *helper; | 47 | struct nf_conntrack_helper *helper; |
48 | struct nf_conntrack_zone zone; | 48 | struct nf_conntrack_zone zone; |
49 | struct nf_conn *ct; | 49 | struct nf_conn *ct; |
50 | u32 flags; | 50 | u8 commit : 1; |
51 | u16 family; | 51 | u16 family; |
52 | struct md_mark mark; | 52 | struct md_mark mark; |
53 | struct md_labels labels; | 53 | struct md_labels labels; |
@@ -493,7 +493,7 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, | |||
493 | return err; | 493 | return err; |
494 | } | 494 | } |
495 | 495 | ||
496 | if (info->flags & OVS_CT_F_COMMIT) | 496 | if (info->commit) |
497 | err = ovs_ct_commit(net, key, info, skb); | 497 | err = ovs_ct_commit(net, key, info, skb); |
498 | else | 498 | else |
499 | err = ovs_ct_lookup(net, key, info, skb); | 499 | err = ovs_ct_lookup(net, key, info, skb); |
@@ -539,8 +539,7 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name, | |||
539 | } | 539 | } |
540 | 540 | ||
541 | static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = { | 541 | static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = { |
542 | [OVS_CT_ATTR_FLAGS] = { .minlen = sizeof(u32), | 542 | [OVS_CT_ATTR_COMMIT] = { .minlen = 0, .maxlen = 0 }, |
543 | .maxlen = sizeof(u32) }, | ||
544 | [OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16), | 543 | [OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16), |
545 | .maxlen = sizeof(u16) }, | 544 | .maxlen = sizeof(u16) }, |
546 | [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark), | 545 | [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark), |
@@ -576,8 +575,8 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, | |||
576 | } | 575 | } |
577 | 576 | ||
578 | switch (type) { | 577 | switch (type) { |
579 | case OVS_CT_ATTR_FLAGS: | 578 | case OVS_CT_ATTR_COMMIT: |
580 | info->flags = nla_get_u32(a); | 579 | info->commit = true; |
581 | break; | 580 | break; |
582 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 581 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
583 | case OVS_CT_ATTR_ZONE: | 582 | case OVS_CT_ATTR_ZONE: |
@@ -701,7 +700,7 @@ int ovs_ct_action_to_attr(const struct ovs_conntrack_info *ct_info, | |||
701 | if (!start) | 700 | if (!start) |
702 | return -EMSGSIZE; | 701 | return -EMSGSIZE; |
703 | 702 | ||
704 | if (nla_put_u32(skb, OVS_CT_ATTR_FLAGS, ct_info->flags)) | 703 | if (ct_info->commit && nla_put_flag(skb, OVS_CT_ATTR_COMMIT)) |
705 | return -EMSGSIZE; | 704 | return -EMSGSIZE; |
706 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && | 705 | if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) && |
707 | nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id)) | 706 | nla_put_u16(skb, OVS_CT_ATTR_ZONE, ct_info->zone.id)) |