Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1214121 > unrolled thread
| Started by | Joe Stringer <joestringer@nicira.com> |
|---|---|
| First post | 2015-08-26 20:40 +0200 |
| Last post | 2015-08-29 04:30 +0200 |
| Articles | 9 — 4 participants |
Back to article view | Back to linux.kernel
[PATCHv6 net-next 00/10] OVS conntrack support Joe Stringer <joestringer@nicira.com> - 2015-08-26 20:40 +0200
[PATCHv6 net-next 08/10] netfilter: connlabels: Export setting connlabel length Joe Stringer <joestringer@nicira.com> - 2015-08-26 20:40 +0200
[PATCHv6 net-next 06/10] openvswitch: Allow matching on conntrack mark Joe Stringer <joestringer@nicira.com> - 2015-08-26 20:40 +0200
[PATCHv6 net-next 01/10] openvswitch: Serialize acts with original netlink len Joe Stringer <joestringer@nicira.com> - 2015-08-26 20:40 +0200
Re: [PATCHv6 net-next 05/10] openvswitch: Add conntrack action Joe Stringer <joestringer@nicira.com> - 2015-08-26 21:00 +0200
Re: [PATCHv6 net-next 05/10] openvswitch: Add conntrack action Pravin Shelar <pshelar@nicira.com> - 2015-08-26 22:50 +0200
Re: [PATCHv6 net-next 00/10] OVS conntrack support David Miller <davem@davemloft.net> - 2015-08-27 20:50 +0200
Re: [PATCHv6 net-next 00/10] OVS conntrack support Simon Horman <simon.horman@netronome.com> - 2015-08-29 02:00 +0200
Re: [PATCHv6 net-next 00/10] OVS conntrack support Joe Stringer <joestringer@nicira.com> - 2015-08-29 04:30 +0200
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-26 20:40 +0200 |
| Subject | [PATCHv6 net-next 00/10] OVS conntrack support |
| Message-ID | <q1NM5-5sE-3@gated-at.bofh.it> |
The goal of this series is to allow OVS to send packets through the Linux kernel connection tracker, and subsequently match on fields populated by conntrack. This functionality is enabled through a new CONFIG_OPENVSWITCH_CONNTRACK option. This version addresses the feedback from v5, primarily checking the behaviour is correct with different configurations such as disabling CONFIG_OPENVSWITCH_CONNTRACK or disabling individual conntrack features like connlabels. The branch below has been updated with the corresponding userspace pieces: https://github.com/joestringer/ovs dev/ct_20150818 Joe Stringer (10): openvswitch: Serialize acts with original netlink len openvswitch: Move MASKED* macros to datapath.h ipv6: Export nf_ct_frag6_gather() dst: Add __skb_dst_copy() variation openvswitch: Add conntrack action openvswitch: Allow matching on conntrack mark netfilter: Always export nf_connlabels_replace() netfilter: connlabels: Export setting connlabel length openvswitch: Allow matching on conntrack label openvswitch: Allow attaching helpers to ct action include/net/dst.h | 9 +- include/net/netfilter/nf_conntrack_labels.h | 4 + include/uapi/linux/openvswitch.h | 58 +++ net/ipv6/netfilter/nf_conntrack_reasm.c | 1 + net/netfilter/nf_conntrack_labels.c | 34 +- net/netfilter/xt_connlabel.c | 16 +- net/openvswitch/Kconfig | 11 + net/openvswitch/Makefile | 2 + net/openvswitch/actions.c | 229 +++++++-- net/openvswitch/conntrack.c | 744 ++++++++++++++++++++++++++++ net/openvswitch/conntrack.h | 86 ++++ net/openvswitch/datapath.c | 86 +++- net/openvswitch/datapath.h | 13 + net/openvswitch/flow.c | 6 +- net/openvswitch/flow.h | 11 +- net/openvswitch/flow_netlink.c | 119 ++++- net/openvswitch/flow_netlink.h | 13 +- net/openvswitch/vport.c | 1 + 18 files changed, 1336 insertions(+), 107 deletions(-) create mode 100644 net/openvswitch/conntrack.c create mode 100644 net/openvswitch/conntrack.h -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-26 20:40 +0200 |
| Subject | [PATCHv6 net-next 08/10] netfilter: connlabels: Export setting connlabel length |
| Message-ID | <q1NM7-5sE-37@gated-at.bofh.it> |
| In reply to | #1214121 |
Add functions to change connlabel length into nf_conntrack_labels.c so
they may be reused by other modules like OVS and nftables without
needing to jump through xt_match_check() hoops.
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Florian Westphal <fw@strlen.de>
Acked-by: Thomas Graf <tgraf@suug.ch>
---
v2: Protect connlabel modification with spinlock.
Fix reference leak in error case.
Style fixups.
v3: No change.
v4-v5: Add acks.
---
include/net/netfilter/nf_conntrack_labels.h | 4 ++++
net/netfilter/nf_conntrack_labels.c | 32 +++++++++++++++++++++++++++++
net/netfilter/xt_connlabel.c | 16 ++++-----------
3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_labels.h b/include/net/netfilter/nf_conntrack_labels.h
index dec6336..7e2b1d0 100644
--- a/include/net/netfilter/nf_conntrack_labels.h
+++ b/include/net/netfilter/nf_conntrack_labels.h
@@ -54,7 +54,11 @@ int nf_connlabels_replace(struct nf_conn *ct,
#ifdef CONFIG_NF_CONNTRACK_LABELS
int nf_conntrack_labels_init(void);
void nf_conntrack_labels_fini(void);
+int nf_connlabels_get(struct net *net, unsigned int n_bits);
+void nf_connlabels_put(struct net *net);
#else
static inline int nf_conntrack_labels_init(void) { return 0; }
static inline void nf_conntrack_labels_fini(void) {}
+static inline int nf_connlabels_get(struct net *net, unsigned int n_bits) { return 0; }
+static inline void nf_connlabels_put(struct net *net) {}
#endif
diff --git a/net/netfilter/nf_conntrack_labels.c b/net/netfilter/nf_conntrack_labels.c
index daa7c13..3ce5c31 100644
--- a/net/netfilter/nf_conntrack_labels.c
+++ b/net/netfilter/nf_conntrack_labels.c
@@ -14,6 +14,8 @@
#include <net/netfilter/nf_conntrack_ecache.h>
#include <net/netfilter/nf_conntrack_labels.h>
+static spinlock_t nf_connlabels_lock;
+
static unsigned int label_bits(const struct nf_conn_labels *l)
{
unsigned int longs = l->words;
@@ -89,6 +91,35 @@ int nf_connlabels_replace(struct nf_conn *ct,
}
EXPORT_SYMBOL_GPL(nf_connlabels_replace);
+int nf_connlabels_get(struct net *net, unsigned int n_bits)
+{
+ size_t words;
+
+ if (n_bits > (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE))
+ return -ERANGE;
+
+ words = BITS_TO_LONGS(n_bits);
+
+ spin_lock(&nf_connlabels_lock);
+ net->ct.labels_used++;
+ if (words > net->ct.label_words)
+ net->ct.label_words = words;
+ spin_unlock(&nf_connlabels_lock);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(nf_connlabels_get);
+
+void nf_connlabels_put(struct net *net)
+{
+ spin_lock(&nf_connlabels_lock);
+ net->ct.labels_used--;
+ if (net->ct.labels_used == 0)
+ net->ct.label_words = 0;
+ spin_unlock(&nf_connlabels_lock);
+}
+EXPORT_SYMBOL_GPL(nf_connlabels_put);
+
static struct nf_ct_ext_type labels_extend __read_mostly = {
.len = sizeof(struct nf_conn_labels),
.align = __alignof__(struct nf_conn_labels),
@@ -97,6 +128,7 @@ static struct nf_ct_ext_type labels_extend __read_mostly = {
int nf_conntrack_labels_init(void)
{
+ spin_lock_init(&nf_connlabels_lock);
return nf_ct_extend_register(&labels_extend);
}
diff --git a/net/netfilter/xt_connlabel.c b/net/netfilter/xt_connlabel.c
index 9f8719d..bb9cbeb 100644
--- a/net/netfilter/xt_connlabel.c
+++ b/net/netfilter/xt_connlabel.c
@@ -42,10 +42,6 @@ static int connlabel_mt_check(const struct xt_mtchk_param *par)
XT_CONNLABEL_OP_SET;
struct xt_connlabel_mtinfo *info = par->matchinfo;
int ret;
- size_t words;
-
- if (info->bit > XT_CONNLABEL_MAXBIT)
- return -ERANGE;
if (info->options & ~options) {
pr_err("Unknown options in mask %x\n", info->options);
@@ -59,19 +55,15 @@ static int connlabel_mt_check(const struct xt_mtchk_param *par)
return ret;
}
- par->net->ct.labels_used++;
- words = BITS_TO_LONGS(info->bit+1);
- if (words > par->net->ct.label_words)
- par->net->ct.label_words = words;
-
+ ret = nf_connlabels_get(par->net, info->bit + 1);
+ if (ret < 0)
+ nf_ct_l3proto_module_put(par->family);
return ret;
}
static void connlabel_mt_destroy(const struct xt_mtdtor_param *par)
{
- par->net->ct.labels_used--;
- if (par->net->ct.labels_used == 0)
- par->net->ct.label_words = 0;
+ nf_connlabels_put(par->net);
nf_ct_l3proto_module_put(par->family);
}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-26 20:40 +0200 |
| Subject | [PATCHv6 net-next 06/10] openvswitch: Allow matching on conntrack mark |
| Message-ID | <q1NM7-5sE-39@gated-at.bofh.it> |
| In reply to | #1214121 |
Allow matching and setting the ct_mark field. As with ct_state and
ct_zone, these fields are populated when the CT action is executed. To
write to this field, a value and mask can be specified as a nested
attribute under the CT action. This data is stored with the conntrack
entry, and is executed after the lookup occurs for the CT action. The
conntrack entry itself must be committed using the COMMIT flag in the CT
action flags for this change to persist.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
---
v1-v3: No change.
v4: Only allow setting conntrack mark via ct action.
Documentation tweaks.
v5: Rebase against conntrack zone changes.
Add ct_mark to ct action serialization
Replace some #ifdefs with IS_ENABLED.
v6: Add acks.
---
include/uapi/linux/openvswitch.h | 5 +++
net/openvswitch/actions.c | 1 +
net/openvswitch/conntrack.c | 67 ++++++++++++++++++++++++++++++++++++++--
net/openvswitch/conntrack.h | 1 +
net/openvswitch/flow.h | 1 +
net/openvswitch/flow_netlink.c | 12 ++++++-
6 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 55f5997..7a185b5 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -325,6 +325,7 @@ enum ovs_key_attr {
* the accepted length of the array. */
OVS_KEY_ATTR_CT_STATE, /* u8 bitmask of OVS_CS_F_* */
OVS_KEY_ATTR_CT_ZONE, /* u16 connection tracking zone. */
+ OVS_KEY_ATTR_CT_MARK, /* u32 connection tracking mark */
#ifdef __KERNEL__
OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info */
@@ -613,11 +614,15 @@ struct ovs_action_hash {
* enum ovs_ct_attr - Attributes for %OVS_ACTION_ATTR_CT action.
* @OVS_CT_ATTR_FLAGS: u32 connection tracking flags.
* @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
+ * tracking mark field in the connection.
*/
enum ovs_ct_attr {
OVS_CT_ATTR_UNSPEC,
OVS_CT_ATTR_FLAGS, /* u8 bitmask of OVS_CT_F_*. */
OVS_CT_ATTR_ZONE, /* u16 zone id. */
+ OVS_CT_ATTR_MARK, /* mark to associate with this connection. */
__OVS_CT_ATTR_MAX
};
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 72ca2c4..9741d2c 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -968,6 +968,7 @@ static int execute_masked_set_action(struct sk_buff *skb,
case OVS_KEY_ATTR_CT_STATE:
case OVS_KEY_ATTR_CT_ZONE:
+ case OVS_KEY_ATTR_CT_MARK:
err = -EINVAL;
break;
}
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 1189fd5..e53dafc 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -28,12 +28,19 @@ struct ovs_ct_len_tbl {
size_t minlen;
};
+/* Metadata mark for masked write to conntrack mark */
+struct md_mark {
+ u32 value;
+ u32 mask;
+};
+
/* Conntrack action context for execution. */
struct ovs_conntrack_info {
struct nf_conntrack_zone zone;
struct nf_conn *ct;
u32 flags;
u16 family;
+ struct md_mark mark;
};
static u16 key_to_nfproto(const struct sw_flow_key *key)
@@ -84,10 +91,12 @@ static u8 ovs_ct_get_state(enum ip_conntrack_info ctinfo)
}
static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state,
- const struct nf_conntrack_zone *zone)
+ const struct nf_conntrack_zone *zone,
+ const struct nf_conn *ct)
{
key->ct.state = state;
key->ct.zone = zone->id;
+ key->ct.mark = ct ? ct->mark : 0;
}
/* Update 'key' based on skb->nfct. If 'post_ct' is true, then OVS has
@@ -110,7 +119,7 @@ static void ovs_ct_update_key(const struct sk_buff *skb,
} else if (post_ct) {
state = OVS_CS_F_TRACKED | OVS_CS_F_INVALID;
}
- __ovs_ct_update_key(key, state, zone);
+ __ovs_ct_update_key(key, state, zone, ct);
}
void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key)
@@ -127,6 +136,35 @@ int ovs_ct_put_key(const struct sw_flow_key *key, struct sk_buff *skb)
nla_put_u16(skb, OVS_KEY_ATTR_CT_ZONE, key->ct.zone))
return -EMSGSIZE;
+ if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
+ nla_put_u32(skb, OVS_KEY_ATTR_CT_MARK, key->ct.mark))
+ return -EMSGSIZE;
+
+ return 0;
+}
+
+static int ovs_ct_set_mark(struct sk_buff *skb, struct sw_flow_key *key,
+ u32 ct_mark, u32 mask)
+{
+ enum ip_conntrack_info ctinfo;
+ struct nf_conn *ct;
+ u32 new_mark;
+
+ if (!IS_ENABLED(CONFIG_NF_CONNTRACK_MARK))
+ return -ENOTSUPP;
+
+ /* The connection could be invalid, in which case set_mark is no-op. */
+ ct = nf_ct_get(skb, &ctinfo);
+ if (!ct)
+ return 0;
+
+ new_mark = ct_mark | (ct->mark & ~(mask));
+ if (ct->mark != new_mark) {
+ ct->mark = new_mark;
+ nf_conntrack_event_cache(IPCT_MARK, ct);
+ key->ct.mark = new_mark;
+ }
+
return 0;
}
@@ -247,7 +285,7 @@ static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key,
u8 state;
state = OVS_CS_F_TRACKED | OVS_CS_F_NEW | OVS_CS_F_RELATED;
- __ovs_ct_update_key(key, state, &info->zone);
+ __ovs_ct_update_key(key, state, &info->zone, exp->master);
} else {
int err;
@@ -310,7 +348,13 @@ int ovs_ct_execute(struct net *net, struct sk_buff *skb,
err = ovs_ct_commit(net, key, info, skb);
else
err = ovs_ct_lookup(net, key, info, skb);
+ if (err)
+ goto err;
+ if (info->mark.mask)
+ err = ovs_ct_set_mark(skb, key, info->mark.value,
+ info->mark.mask);
+err:
skb_push(skb, nh_ofs);
return err;
}
@@ -320,6 +364,8 @@ static const struct ovs_ct_len_tbl ovs_ct_attr_lens[OVS_CT_ATTR_MAX + 1] = {
.maxlen = sizeof(u32) },
[OVS_CT_ATTR_ZONE] = { .minlen = sizeof(u16),
.maxlen = sizeof(u16) },
+ [OVS_CT_ATTR_MARK] = { .minlen = sizeof(struct md_mark),
+ .maxlen = sizeof(struct md_mark) },
};
static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
@@ -355,6 +401,14 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
info->zone.id = nla_get_u16(a);
break;
#endif
+#ifdef CONFIG_NF_CONNTRACK_MARK
+ case OVS_CT_ATTR_MARK: {
+ struct md_mark *mark = nla_data(a);
+
+ info->mark = *mark;
+ break;
+ }
+#endif
default:
OVS_NLERR(log, "Unknown conntrack attr (%d)",
type);
@@ -377,6 +431,9 @@ bool ovs_ct_verify(enum ovs_key_attr attr)
if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
attr == OVS_KEY_ATTR_CT_ZONE)
return true;
+ if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
+ attr == OVS_KEY_ATTR_CT_MARK)
+ return true;
return false;
}
@@ -439,6 +496,10 @@ 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) &&
+ nla_put(skb, OVS_CT_ATTR_MARK, sizeof(ct_info->mark),
+ &ct_info->mark))
+ return -EMSGSIZE;
nla_nest_end(skb, start);
diff --git a/net/openvswitch/conntrack.h b/net/openvswitch/conntrack.h
index e812ee6..87b289c 100644
--- a/net/openvswitch/conntrack.h
+++ b/net/openvswitch/conntrack.h
@@ -65,6 +65,7 @@ static inline void ovs_ct_fill_key(const struct sk_buff *skb,
{
key->ct.state = 0;
key->ct.zone = 0;
+ key->ct.mark = 0;
}
static inline int ovs_ct_put_key(const struct sw_flow_key *key,
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index 312c7d7..e05e697 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -114,6 +114,7 @@ struct sw_flow_key {
struct {
/* Connection tracking fields. */
u16 zone;
+ u32 mark;
u8 state;
} ct;
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 4e795b2..b17a4ec 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -281,7 +281,7 @@ size_t ovs_key_attr_size(void)
/* Whenever adding new OVS_KEY_ FIELDS, we should consider
* updating this function.
*/
- BUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 24);
+ BUILD_BUG_ON(OVS_KEY_ATTR_TUNNEL_INFO != 25);
return nla_total_size(4) /* OVS_KEY_ATTR_PRIORITY */
+ nla_total_size(0) /* OVS_KEY_ATTR_TUNNEL */
@@ -292,6 +292,7 @@ size_t ovs_key_attr_size(void)
+ nla_total_size(4) /* OVS_KEY_ATTR_RECIRC_ID */
+ nla_total_size(1) /* OVS_KEY_ATTR_CT_STATE */
+ nla_total_size(2) /* OVS_KEY_ATTR_CT_ZONE */
+ + nla_total_size(4) /* OVS_KEY_ATTR_CT_MARK */
+ nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */
+ nla_total_size(2) /* OVS_KEY_ATTR_ETHERTYPE */
+ nla_total_size(4) /* OVS_KEY_ATTR_VLAN */
@@ -343,6 +344,7 @@ static const struct ovs_len_tbl ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = {
[OVS_KEY_ATTR_MPLS] = { .len = sizeof(struct ovs_key_mpls) },
[OVS_KEY_ATTR_CT_STATE] = { .len = sizeof(u8) },
[OVS_KEY_ATTR_CT_ZONE] = { .len = sizeof(u16) },
+ [OVS_KEY_ATTR_CT_MARK] = { .len = sizeof(u32) },
};
static bool is_all_zero(const u8 *fp, size_t size)
@@ -787,6 +789,13 @@ static int metadata_from_nlattrs(struct sw_flow_match *match, u64 *attrs,
SW_FLOW_KEY_PUT(match, ct.zone, ct_zone, is_mask);
*attrs &= ~(1ULL << OVS_KEY_ATTR_CT_ZONE);
}
+ if (*attrs & (1 << OVS_KEY_ATTR_CT_MARK) &&
+ ovs_ct_verify(OVS_KEY_ATTR_CT_MARK)) {
+ u32 mark = nla_get_u32(a[OVS_KEY_ATTR_CT_MARK]);
+
+ SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask);
+ *attrs &= ~(1ULL << OVS_KEY_ATTR_CT_MARK);
+ }
return 0;
}
@@ -1919,6 +1928,7 @@ static int validate_set(const struct nlattr *a,
case OVS_KEY_ATTR_PRIORITY:
case OVS_KEY_ATTR_SKB_MARK:
+ case OVS_KEY_ATTR_CT_MARK:
case OVS_KEY_ATTR_ETHERNET:
break;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-26 20:40 +0200 |
| Subject | [PATCHv6 net-next 01/10] openvswitch: Serialize acts with original netlink len |
| Message-ID | <q1NM7-5sE-45@gated-at.bofh.it> |
| In reply to | #1214121 |
Previously, we used the kernel-internal netlink actions length to
calculate the size of messages to serialize back to userspace.
However,the sw_flow_actions may not be formatted exactly the same as the
actions on the wire, so store the original actions length when
de-serializing and re-use the original length when serializing.
Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
---
v2: No change.
v3: Preserve original length across buffer resize.
v4: Add ack.
v5: No change.
v6: Add ack.
---
net/openvswitch/datapath.c | 2 +-
net/openvswitch/flow.h | 1 +
net/openvswitch/flow_netlink.c | 2 ++
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index ffe984f..d5b5473 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -713,7 +713,7 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts,
/* OVS_FLOW_ATTR_ACTIONS */
if (should_fill_actions(ufid_flags))
- len += nla_total_size(acts->actions_len);
+ len += nla_total_size(acts->orig_len);
return len
+ nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index b62cdb3..082a87b 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -144,6 +144,7 @@ struct sw_flow_id {
struct sw_flow_actions {
struct rcu_head rcu;
+ size_t orig_len; /* From flow_cmd_new netlink actions size */
u32 actions_len;
struct nlattr actions[];
};
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 4e7a3f7..c182b28 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -1619,6 +1619,7 @@ static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa,
memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len);
acts->actions_len = (*sfa)->actions_len;
+ acts->orig_len = (*sfa)->orig_len;
kfree(*sfa);
*sfa = acts;
@@ -2223,6 +2224,7 @@ int ovs_nla_copy_actions(const struct nlattr *attr,
if (IS_ERR(*sfa))
return PTR_ERR(*sfa);
+ (*sfa)->orig_len = nla_len(attr);
err = __ovs_nla_copy_actions(attr, key, 0, sfa, key->eth.type,
key->eth.tci, log);
if (err)
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-26 21:00 +0200 |
| Subject | Re: [PATCHv6 net-next 05/10] openvswitch: Add conntrack action |
| Message-ID | <q1O5s-5Pg-33@gated-at.bofh.it> |
| In reply to | #1214121 |
On 26 August 2015 at 11:31, Joe Stringer <joestringer@nicira.com> wrote: > Expose the kernel connection tracker via OVS. Userspace components can > make use of the CT action to populate the connection state (ct_state) > field for a flow. This state can be subsequently matched. > > Exposed connection states are OVS_CS_F_*: > - NEW (0x01) - Beginning of a new connection. > - ESTABLISHED (0x02) - Part of an existing connection. > - RELATED (0x04) - Related to an established connection. > - INVALID (0x20) - Could not track the connection for this packet. > - REPLY_DIR (0x40) - This packet is in the reply direction for the flow. > - TRACKED (0x80) - This packet has been sent through conntrack. > > When the CT action is executed by itself, it will send the packet > through the connection tracker and populate the ct_state field with one > or more of the connection state flags above. The CT action will always > set the TRACKED bit. > > When the COMMIT flag is passed to the conntrack action, this specifies > that information about the connection should be stored. This allows > subsequent packets for the same (or related) connections to be > correlated with this connection. Sending subsequent packets for the > connection through conntrack allows the connection tracker to consider > the packets as ESTABLISHED, RELATED, and/or REPLY_DIR. > > The CT action may optionally take a zone to track the flow within. This > allows connections with the same 5-tuple to be kept logically separate > from connections in other zones. If the zone is specified, then the > "ct_zone" match field will be subsequently populated with the zone id. > > IP fragments are handled by transparently assembling them as part of the > CT action. The maximum received unit (MRU) size is tracked so that > refragmentation can occur during output. > > IP frag handling contributed by Andy Zhou. Based on original design by Justin Pettit. > Signed-off-by: Joe Stringer <joestringer@nicira.com> > Signed-off-by: Justin Pettit <jpettit@nicira.com> > Signed-off-by: Andy Zhou <azhou@nicira.com> > Acked-by: Thomas Graf <tgraf@suug.ch> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Pravin Shelar <pshelar@nicira.com> |
|---|---|
| Date | 2015-08-26 22:50 +0200 |
| Subject | Re: [PATCHv6 net-next 05/10] openvswitch: Add conntrack action |
| Message-ID | <q1PNU-8kE-9@gated-at.bofh.it> |
| In reply to | #1214121 |
On Wed, Aug 26, 2015 at 11:31 AM, Joe Stringer <joestringer@nicira.com> wrote: > Expose the kernel connection tracker via OVS. Userspace components can > make use of the CT action to populate the connection state (ct_state) > field for a flow. This state can be subsequently matched. > > Exposed connection states are OVS_CS_F_*: > - NEW (0x01) - Beginning of a new connection. > - ESTABLISHED (0x02) - Part of an existing connection. > - RELATED (0x04) - Related to an established connection. > - INVALID (0x20) - Could not track the connection for this packet. > - REPLY_DIR (0x40) - This packet is in the reply direction for the flow. > - TRACKED (0x80) - This packet has been sent through conntrack. > > When the CT action is executed by itself, it will send the packet > through the connection tracker and populate the ct_state field with one > or more of the connection state flags above. The CT action will always > set the TRACKED bit. > > When the COMMIT flag is passed to the conntrack action, this specifies > that information about the connection should be stored. This allows > subsequent packets for the same (or related) connections to be > correlated with this connection. Sending subsequent packets for the > connection through conntrack allows the connection tracker to consider > the packets as ESTABLISHED, RELATED, and/or REPLY_DIR. > > The CT action may optionally take a zone to track the flow within. This > allows connections with the same 5-tuple to be kept logically separate > from connections in other zones. If the zone is specified, then the > "ct_zone" match field will be subsequently populated with the zone id. > > IP fragments are handled by transparently assembling them as part of the > CT action. The maximum received unit (MRU) size is tracked so that > refragmentation can occur during output. > > IP frag handling contributed by Andy Zhou. > > Signed-off-by: Joe Stringer <joestringer@nicira.com> > Signed-off-by: Justin Pettit <jpettit@nicira.com> > Signed-off-by: Andy Zhou <azhou@nicira.com> > Acked-by: Thomas Graf <tgraf@suug.ch> Acked-by: Pravin B Shelar <pshelar@nicira.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-08-27 20:50 +0200 |
| Message-ID | <q2apk-4ol-17@gated-at.bofh.it> |
| In reply to | #1214121 |
From: Joe Stringer <joestringer@nicira.com> Date: Wed, 26 Aug 2015 11:31:43 -0700 > The goal of this series is to allow OVS to send packets through the Linux > kernel connection tracker, and subsequently match on fields populated by > conntrack. This functionality is enabled through a new > CONFIG_OPENVSWITCH_CONNTRACK option. > > This version addresses the feedback from v5, primarily checking the behaviour > is correct with different configurations such as disabling > CONFIG_OPENVSWITCH_CONNTRACK or disabling individual conntrack features like > connlabels. > > The branch below has been updated with the corresponding userspace pieces: > https://github.com/joestringer/ovs dev/ct_20150818 Series applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Simon Horman <simon.horman@netronome.com> |
|---|---|
| Date | 2015-08-29 02:00 +0200 |
| Message-ID | <q2BIS-1Ak-7@gated-at.bofh.it> |
| In reply to | #1214121 |
On Wed, Aug 26, 2015 at 11:31:43AM -0700, Joe Stringer wrote:
> The goal of this series is to allow OVS to send packets through the Linux
> kernel connection tracker, and subsequently match on fields populated by
> conntrack. This functionality is enabled through a new
> CONFIG_OPENVSWITCH_CONNTRACK option.
>
> This version addresses the feedback from v5, primarily checking the behaviour
> is correct with different configurations such as disabling
> CONFIG_OPENVSWITCH_CONNTRACK or disabling individual conntrack features like
> connlabels.
>
> The branch below has been updated with the corresponding userspace pieces:
> https://github.com/joestringer/ovs dev/ct_20150818
Hi Joe,
Nice work getting this patchset in order.
I am seeing the following when compiling without NF_CONNTRACK_MARK set.
CC [M] net/openvswitch//conntrack.o
net/openvswitch//conntrack.c: In function ‘__ovs_ct_update_key’:
net/openvswitch//conntrack.c:127:24: error: ‘const struct nf_conn’ has no member named ‘mark’
key->ct.mark = ct ? ct->mark : 0;
^
net/openvswitch//conntrack.c: In function ‘ovs_ct_set_mark’:
net/openvswitch//conntrack.c:195:26: error: ‘struct nf_conn’ has no member named ‘mark’
new_mark = ct_mark | (ct->mark & ~(mask));
^
net/openvswitch//conntrack.c:196:8: error: ‘struct nf_conn’ has no member named ‘mark’
if (ct->mark != new_mark) {
^
net/openvswitch//conntrack.c:197:5: error: ‘struct nf_conn’ has no member named ‘mark’
ct->mark = new_mark;
^
scripts/Makefile.build:258: recipe for target 'net/openvswitch//conntrack.o' failed
make[1]: *** [net/openvswitch//conntrack.o] Error 1
Makefile:1386: recipe for target '_module_net/openvswitch/' failed
make: *** [_module_net/openvswitch/] Error 2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Stringer <joestringer@nicira.com> |
|---|---|
| Date | 2015-08-29 04:30 +0200 |
| Message-ID | <q2E42-592-9@gated-at.bofh.it> |
| In reply to | #1215613 |
On 28 August 2015 at 16:57, Simon Horman <simon.horman@netronome.com> wrote:
> On Wed, Aug 26, 2015 at 11:31:43AM -0700, Joe Stringer wrote:
>> The goal of this series is to allow OVS to send packets through the Linux
>> kernel connection tracker, and subsequently match on fields populated by
>> conntrack. This functionality is enabled through a new
>> CONFIG_OPENVSWITCH_CONNTRACK option.
>>
>> This version addresses the feedback from v5, primarily checking the behaviour
>> is correct with different configurations such as disabling
>> CONFIG_OPENVSWITCH_CONNTRACK or disabling individual conntrack features like
>> connlabels.
>>
>> The branch below has been updated with the corresponding userspace pieces:
>> https://github.com/joestringer/ovs dev/ct_20150818
>
> Hi Joe,
>
> Nice work getting this patchset in order.
>
> I am seeing the following when compiling without NF_CONNTRACK_MARK set.
>
> CC [M] net/openvswitch//conntrack.o
> net/openvswitch//conntrack.c: In function ‘__ovs_ct_update_key’:
> net/openvswitch//conntrack.c:127:24: error: ‘const struct nf_conn’ has no member named ‘mark’
> key->ct.mark = ct ? ct->mark : 0;
> ^
> net/openvswitch//conntrack.c: In function ‘ovs_ct_set_mark’:
> net/openvswitch//conntrack.c:195:26: error: ‘struct nf_conn’ has no member named ‘mark’
> new_mark = ct_mark | (ct->mark & ~(mask));
> ^
> net/openvswitch//conntrack.c:196:8: error: ‘struct nf_conn’ has no member named ‘mark’
> if (ct->mark != new_mark) {
> ^
> net/openvswitch//conntrack.c:197:5: error: ‘struct nf_conn’ has no member named ‘mark’
> ct->mark = new_mark;
> ^
> scripts/Makefile.build:258: recipe for target 'net/openvswitch//conntrack.o' failed
> make[1]: *** [net/openvswitch//conntrack.o] Error 1
> Makefile:1386: recipe for target '_module_net/openvswitch/' failed
> make: *** [_module_net/openvswitch/] Error 2
Thanks for reporting this, I sent a patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web