diff options
| author | Jarno Rajahalme <jarno@ovn.org> | 2016-06-21 17:59:37 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-06-25 11:55:51 -0400 |
| commit | 1c1779fa54b2a9d4e1de990095d790d64b9e00a1 (patch) | |
| tree | c22f72ba1b163237a9d4d1d01ce68fb66a5b9f3c /net/openvswitch | |
| parent | fad09c73c27020001cd472343efdacf60a93f8ea (diff) | |
openvswitch: Set mark and labels before confirming.
Set conntrack mark and labels right before committing so that
the initial conntrack NEW event has the mark and labels.
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch')
| -rw-r--r-- | net/openvswitch/conntrack.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 3d5feede962d..23fd4fbd11e2 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
| @@ -824,23 +824,6 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key, | |||
| 824 | return 0; | 824 | return 0; |
| 825 | } | 825 | } |
| 826 | 826 | ||
| 827 | /* Lookup connection and confirm if unconfirmed. */ | ||
| 828 | static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, | ||
| 829 | const struct ovs_conntrack_info *info, | ||
| 830 | struct sk_buff *skb) | ||
| 831 | { | ||
| 832 | int err; | ||
| 833 | |||
| 834 | err = __ovs_ct_lookup(net, key, info, skb); | ||
| 835 | if (err) | ||
| 836 | return err; | ||
| 837 | /* This is a no-op if the connection has already been confirmed. */ | ||
| 838 | if (nf_conntrack_confirm(skb) != NF_ACCEPT) | ||
| 839 | return -EINVAL; | ||
| 840 | |||
| 841 | return 0; | ||
| 842 | } | ||
| 843 | |||
| 844 | static bool labels_nonzero(const struct ovs_key_ct_labels *labels) | 827 | static bool labels_nonzero(const struct ovs_key_ct_labels *labels) |
| 845 | { | 828 | { |
| 846 | size_t i; | 829 | size_t i; |
| @@ -873,21 +856,33 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb, | |||
| 873 | } | 856 | } |
| 874 | 857 | ||
| 875 | if (info->commit) | 858 | if (info->commit) |
| 876 | err = ovs_ct_commit(net, key, info, skb); | 859 | err = __ovs_ct_lookup(net, key, info, skb); |
| 877 | else | 860 | else |
| 878 | err = ovs_ct_lookup(net, key, info, skb); | 861 | err = ovs_ct_lookup(net, key, info, skb); |
| 879 | if (err) | 862 | if (err) |
| 880 | goto err; | 863 | goto err; |
| 881 | 864 | ||
| 865 | /* Apply changes before confirming the connection so that the initial | ||
| 866 | * conntrack NEW netlink event carries the values given in the CT | ||
| 867 | * action. | ||
| 868 | */ | ||
| 882 | if (info->mark.mask) { | 869 | if (info->mark.mask) { |
| 883 | err = ovs_ct_set_mark(skb, key, info->mark.value, | 870 | err = ovs_ct_set_mark(skb, key, info->mark.value, |
| 884 | info->mark.mask); | 871 | info->mark.mask); |
| 885 | if (err) | 872 | if (err) |
| 886 | goto err; | 873 | goto err; |
| 887 | } | 874 | } |
| 888 | if (labels_nonzero(&info->labels.mask)) | 875 | if (labels_nonzero(&info->labels.mask)) { |
| 889 | err = ovs_ct_set_labels(skb, key, &info->labels.value, | 876 | err = ovs_ct_set_labels(skb, key, &info->labels.value, |
| 890 | &info->labels.mask); | 877 | &info->labels.mask); |
| 878 | if (err) | ||
| 879 | goto err; | ||
| 880 | } | ||
| 881 | /* This will take care of sending queued events even if the connection | ||
| 882 | * is already confirmed. | ||
| 883 | */ | ||
| 884 | if (info->commit && nf_conntrack_confirm(skb) != NF_ACCEPT) | ||
| 885 | err = -EINVAL; | ||
| 891 | err: | 886 | err: |
| 892 | skb_push(skb, nh_ofs); | 887 | skb_push(skb, nh_ofs); |
| 893 | if (err) | 888 | if (err) |
