* [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device
@ 2012-03-31 21:01 Jiri Pirko
2012-03-31 21:01 ` [patch net-next 1/4] filter: Allow to create sk-unattached filters Jiri Pirko
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Jiri Pirko @ 2012-03-31 21:01 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
Jiri Pirko (4):
filter: Allow to create sk-unattached filters
filter: add XOR operation
team: add binary option type
team: add loadbalance mode
drivers/net/team/Kconfig | 11 ++
drivers/net/team/Makefile | 1 +
drivers/net/team/team.c | 28 ++++-
drivers/net/team/team_mode_loadbalance.c | 188 ++++++++++++++++++++++++++++++
include/linux/filter.h | 7 +-
include/linux/if_team.h | 8 ++
net/core/filter.c | 70 +++++++++++-
7 files changed, 304 insertions(+), 9 deletions(-)
create mode 100644 drivers/net/team/team_mode_loadbalance.c
--
1.7.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch net-next 1/4] filter: Allow to create sk-unattached filters
2012-03-31 21:01 [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device Jiri Pirko
@ 2012-03-31 21:01 ` Jiri Pirko
2012-04-03 22:36 ` David Miller
2012-03-31 21:01 ` [patch net-next 2/4] filter: add XOR operation Jiri Pirko
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2012-03-31 21:01 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
Today, BPF filters are bind to sockets. Since BPF machine becomes handy
for other purposes, this patch allows to create unattached filter.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
include/linux/filter.h | 3 ++
net/core/filter.c | 66 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 8eeb205..92dd993 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -153,6 +153,9 @@ static inline unsigned int sk_filter_len(const struct sk_filter *fp)
extern int sk_filter(struct sock *sk, struct sk_buff *skb);
extern unsigned int sk_run_filter(const struct sk_buff *skb,
const struct sock_filter *filter);
+extern int sk_unattached_filter_create(struct sk_filter **pfp,
+ struct sock_fprog *fprog);
+extern void sk_unattached_filter_destroy(struct sk_filter *fp);
extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
extern int sk_detach_filter(struct sock *sk);
extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
diff --git a/net/core/filter.c b/net/core/filter.c
index 5dea452..cfbea88 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -587,6 +587,67 @@ void sk_filter_release_rcu(struct rcu_head *rcu)
}
EXPORT_SYMBOL(sk_filter_release_rcu);
+static int __sk_prepare_filter(struct sk_filter *fp)
+{
+ int err;
+
+ fp->bpf_func = sk_run_filter;
+
+ err = sk_chk_filter(fp->insns, fp->len);
+ if (err)
+ return err;
+
+ bpf_jit_compile(fp);
+ return 0;
+}
+
+/**
+ * sk_unattached_filter_create - create an unattached filter
+ * @fprog: the filter program
+ * @sk: the socket to use
+ *
+ * Create a filter independent ofr any socket. We first run some
+ * sanity checks on it to make sure it does not explode on us later.
+ * If an error occurs or there is insufficient memory for the filter
+ * a negative errno code is returned. On success the return is zero.
+ */
+int sk_unattached_filter_create(struct sk_filter **pfp,
+ struct sock_fprog *fprog)
+{
+ struct sk_filter *fp;
+ unsigned int fsize = sizeof(struct sock_filter) * fprog->len;
+ int err;
+
+ /* Make sure new filter is there and in the right amounts. */
+ if (fprog->filter == NULL)
+ return -EINVAL;
+
+ fp = kmalloc(fsize + sizeof(*fp), GFP_KERNEL);
+ if (!fp)
+ return -ENOMEM;
+ memcpy(fp->insns, fprog->filter, fsize);
+
+ atomic_set(&fp->refcnt, 1);
+ fp->len = fprog->len;
+
+ err = __sk_prepare_filter(fp);
+ if (err)
+ goto free_mem;
+
+ *pfp = fp;
+ return 0;
+free_mem:
+ kfree(fp);
+ return err;
+}
+EXPORT_SYMBOL_GPL(sk_unattached_filter_create);
+
+void sk_unattached_filter_destroy(struct sk_filter *fp)
+{
+ sk_filter_release(fp);
+}
+EXPORT_SYMBOL_GPL(sk_unattached_filter_destroy);
+
/**
* sk_attach_filter - attach a socket filter
* @fprog: the filter program
@@ -617,16 +678,13 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
atomic_set(&fp->refcnt, 1);
fp->len = fprog->len;
- fp->bpf_func = sk_run_filter;
- err = sk_chk_filter(fp->insns, fp->len);
+ err = __sk_prepare_filter(fp);
if (err) {
sk_filter_uncharge(sk, fp);
return err;
}
- bpf_jit_compile(fp);
-
old_fp = rcu_dereference_protected(sk->sk_filter,
sock_owned_by_user(sk));
rcu_assign_pointer(sk->sk_filter, fp);
--
1.7.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [patch net-next 2/4] filter: add XOR operation
2012-03-31 21:01 [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device Jiri Pirko
2012-03-31 21:01 ` [patch net-next 1/4] filter: Allow to create sk-unattached filters Jiri Pirko
@ 2012-03-31 21:01 ` Jiri Pirko
2012-04-03 22:36 ` David Miller
2012-03-31 21:01 ` [patch net-next 3/4] team: add binary option type Jiri Pirko
2012-03-31 21:01 ` [patch net-next 4/4] team: add loadbalance mode Jiri Pirko
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2012-03-31 21:01 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
Add XOR instruction fo BPF machine. Needed for computing packet hashes.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
include/linux/filter.h | 4 +++-
net/core/filter.c | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 92dd993..7209099 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -126,7 +126,8 @@ struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
#define SKF_AD_HATYPE 28
#define SKF_AD_RXHASH 32
#define SKF_AD_CPU 36
-#define SKF_AD_MAX 40
+#define SKF_AD_ALU_XOR_X 40
+#define SKF_AD_MAX 44
#define SKF_NET_OFF (-0x100000)
#define SKF_LL_OFF (-0x200000)
@@ -231,6 +232,7 @@ enum {
BPF_S_ANC_HATYPE,
BPF_S_ANC_RXHASH,
BPF_S_ANC_CPU,
+ BPF_S_ANC_ALU_XOR_X,
};
#endif /* __KERNEL__ */
diff --git a/net/core/filter.c b/net/core/filter.c
index cfbea88..5099c4b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -315,6 +315,9 @@ load_b:
case BPF_S_ANC_CPU:
A = raw_smp_processor_id();
continue;
+ case BPF_S_ANC_ALU_XOR_X:
+ A ^= X;
+ continue;
case BPF_S_ANC_NLATTR: {
struct nlattr *nla;
@@ -559,6 +562,7 @@ int sk_chk_filter(struct sock_filter *filter, unsigned int flen)
ANCILLARY(HATYPE);
ANCILLARY(RXHASH);
ANCILLARY(CPU);
+ ANCILLARY(ALU_XOR_X);
}
}
ftest->code = code;
--
1.7.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [patch net-next 3/4] team: add binary option type
2012-03-31 21:01 [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device Jiri Pirko
2012-03-31 21:01 ` [patch net-next 1/4] filter: Allow to create sk-unattached filters Jiri Pirko
2012-03-31 21:01 ` [patch net-next 2/4] filter: add XOR operation Jiri Pirko
@ 2012-03-31 21:01 ` Jiri Pirko
2012-04-03 22:38 ` David Miller
2012-03-31 21:01 ` [patch net-next 4/4] team: add loadbalance mode Jiri Pirko
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2012-03-31 21:01 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
For transfering generic binary data (e.g. BPF code), introduce new
binary option type.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/team/team.c | 28 ++++++++++++++++++++++++----
include/linux/if_team.h | 8 ++++++++
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 8f81805..9ad52b5b 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1145,10 +1145,7 @@ team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
},
[TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG },
[TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8 },
- [TEAM_ATTR_OPTION_DATA] = {
- .type = NLA_BINARY,
- .len = TEAM_STRING_MAX_LEN,
- },
+ [TEAM_ATTR_OPTION_DATA] = { .type = NLA_BINARY },
};
static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
@@ -1256,6 +1253,7 @@ static int team_nl_fill_options_get(struct sk_buff *skb,
list_for_each_entry(option, &team->option_list, list) {
struct nlattr *option_item;
long arg;
+ struct team_option_binary tbinary;
/* Include only changed options if fill all mode is not on */
if (!fillall && !option->changed)
@@ -1282,6 +1280,13 @@ static int team_nl_fill_options_get(struct sk_buff *skb,
NLA_PUT_STRING(skb, TEAM_ATTR_OPTION_DATA,
(char *) arg);
break;
+ case TEAM_OPTION_TYPE_BINARY:
+ NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_BINARY);
+ arg = (long) &tbinary;
+ team_option_get(team, option, &arg);
+ NLA_PUT(skb, TEAM_ATTR_OPTION_DATA,
+ tbinary.data_len, tbinary.data);
+ break;
default:
BUG();
}
@@ -1366,6 +1371,9 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
case NLA_STRING:
opt_type = TEAM_OPTION_TYPE_STRING;
break;
+ case NLA_BINARY:
+ opt_type = TEAM_OPTION_TYPE_BINARY;
+ break;
default:
goto team_put;
}
@@ -1374,19 +1382,31 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
list_for_each_entry(option, &team->option_list, list) {
long arg;
struct nlattr *opt_data_attr;
+ struct team_option_binary tbinary;
+ int data_len;
if (option->type != opt_type ||
strcmp(option->name, opt_name))
continue;
opt_found = true;
opt_data_attr = mode_attrs[TEAM_ATTR_OPTION_DATA];
+ data_len = nla_len(opt_data_attr);
switch (opt_type) {
case TEAM_OPTION_TYPE_U32:
arg = nla_get_u32(opt_data_attr);
break;
case TEAM_OPTION_TYPE_STRING:
+ if (data_len > TEAM_STRING_MAX_LEN) {
+ err = -EINVAL;
+ goto team_put;
+ }
arg = (long) nla_data(opt_data_attr);
break;
+ case TEAM_OPTION_TYPE_BINARY:
+ tbinary.data_len = data_len;
+ tbinary.data = nla_data(opt_data_attr);
+ arg = (long) &tbinary;
+ break;
default:
BUG();
}
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index 58404b0..41163ac 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -68,6 +68,7 @@ struct team_mode_ops {
enum team_option_type {
TEAM_OPTION_TYPE_U32,
TEAM_OPTION_TYPE_STRING,
+ TEAM_OPTION_TYPE_BINARY,
};
struct team_option {
@@ -82,6 +83,13 @@ struct team_option {
bool removed;
};
+struct team_option_binary {
+ u32 data_len;
+ void *data;
+};
+
+#define team_optarg_tbinary(arg) (*((struct team_option_binary **) arg))
+
struct team_mode {
struct list_head list;
const char *kind;
--
1.7.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [patch net-next 4/4] team: add loadbalance mode
2012-03-31 21:01 [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device Jiri Pirko
` (2 preceding siblings ...)
2012-03-31 21:01 ` [patch net-next 3/4] team: add binary option type Jiri Pirko
@ 2012-03-31 21:01 ` Jiri Pirko
2012-04-03 22:38 ` David Miller
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2012-03-31 21:01 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
This patch introduces new team mode. It's TX port is selected by
user-set BPF hash function.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/team/Kconfig | 11 ++
drivers/net/team/Makefile | 1 +
drivers/net/team/team_mode_loadbalance.c | 188 ++++++++++++++++++++++++++++++
3 files changed, 200 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/team/team_mode_loadbalance.c
diff --git a/drivers/net/team/Kconfig b/drivers/net/team/Kconfig
index 248a144..89024d5 100644
--- a/drivers/net/team/Kconfig
+++ b/drivers/net/team/Kconfig
@@ -40,4 +40,15 @@ config NET_TEAM_MODE_ACTIVEBACKUP
To compile this team mode as a module, choose M here: the module
will be called team_mode_activebackup.
+config NET_TEAM_MODE_LOADBALANCE
+ tristate "Load-balance mode support"
+ depends on NET_TEAM
+ ---help---
+ This mode provides load balancing functionality. Tx port selection
+ is done using BPF function set up from userspace (bpf_hash_func
+ option)
+
+ To compile this team mode as a module, choose M here: the module
+ will be called team_mode_loadbalance.
+
endif # NET_TEAM
diff --git a/drivers/net/team/Makefile b/drivers/net/team/Makefile
index 85f2028..fb9f4c1 100644
--- a/drivers/net/team/Makefile
+++ b/drivers/net/team/Makefile
@@ -5,3 +5,4 @@
obj-$(CONFIG_NET_TEAM) += team.o
obj-$(CONFIG_NET_TEAM_MODE_ROUNDROBIN) += team_mode_roundrobin.o
obj-$(CONFIG_NET_TEAM_MODE_ACTIVEBACKUP) += team_mode_activebackup.o
+obj-$(CONFIG_NET_TEAM_MODE_LOADBALANCE) += team_mode_loadbalance.o
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
new file mode 100644
index 0000000..ed20f39
--- /dev/null
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -0,0 +1,188 @@
+/*
+ * drivers/net/team/team_mode_loadbalance.c - Load-balancing mode for team
+ * Copyright (c) 2012 Jiri Pirko <jpirko@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/netdevice.h>
+#include <linux/filter.h>
+#include <linux/if_team.h>
+
+struct lb_priv {
+ struct sk_filter __rcu *fp;
+ struct sock_fprog *orig_fprog;
+};
+
+static struct lb_priv *lb_priv(struct team *team)
+{
+ return (struct lb_priv *) &team->mode_priv;
+}
+
+static bool lb_transmit(struct team *team, struct sk_buff *skb)
+{
+ struct sk_filter *fp;
+ struct team_port *port;
+ unsigned int hash;
+ int port_index;
+
+ fp = rcu_dereference(lb_priv(team)->fp);
+ if (unlikely(!fp))
+ goto drop;
+ hash = SK_RUN_FILTER(fp, skb);
+ port_index = hash % team->port_count;
+ port = team_get_port_by_index_rcu(team, port_index);
+ if (unlikely(!port))
+ goto drop;
+ skb->dev = port->dev;
+ if (dev_queue_xmit(skb))
+ return false;
+ return true;
+
+drop:
+ dev_kfree_skb_any(skb);
+ return false;
+}
+
+static int lb_bpf_func_get(struct team *team, void *arg)
+{
+ struct team_option_binary *tbinary = team_optarg_tbinary(arg);
+
+ memset(tbinary, 0, sizeof(*tbinary));
+ if (!lb_priv(team)->orig_fprog)
+ return 0;
+
+ tbinary->data_len = lb_priv(team)->orig_fprog->len *
+ sizeof(struct sock_filter);
+ tbinary->data = lb_priv(team)->orig_fprog->filter;
+ return 0;
+}
+
+static int __fprog_create(struct sock_fprog **pfprog, u32 data_len,
+ void *data)
+{
+ struct sock_fprog *fprog;
+ struct sock_filter *filter = (struct sock_filter *) data;
+
+ if (data_len % sizeof(struct sock_filter))
+ return -EINVAL;
+ fprog = kmalloc(sizeof(struct sock_fprog), GFP_KERNEL);
+ if (!fprog)
+ return -ENOMEM;
+ fprog->filter = kmemdup(filter, data_len, GFP_KERNEL);
+ if (!fprog->filter) {
+ kfree(fprog);
+ return -ENOMEM;
+ }
+ fprog->len = data_len / sizeof(struct sock_filter);
+ *pfprog = fprog;
+ return 0;
+}
+
+static void __fprog_destroy(struct sock_fprog *fprog)
+{
+ kfree(fprog->filter);
+ kfree(fprog);
+}
+
+static int lb_bpf_func_set(struct team *team, void *arg)
+{
+ struct team_option_binary *tbinary = team_optarg_tbinary(arg);
+ struct sk_filter *fp = NULL;
+ struct sock_fprog *fprog = NULL;
+ int err;
+
+ if (tbinary->data_len) {
+ err = __fprog_create(&fprog, tbinary->data_len,
+ tbinary->data);
+ if (err)
+ return err;
+ err = sk_unattached_filter_create(&fp, fprog);
+ if (err) {
+ __fprog_destroy(fprog);
+ return err;
+ }
+ }
+
+ if (lb_priv(team)->orig_fprog) {
+ /* Clear old filter data */
+ __fprog_destroy(lb_priv(team)->orig_fprog);
+ sk_unattached_filter_destroy(lb_priv(team)->fp);
+ }
+
+ rcu_assign_pointer(lb_priv(team)->fp, fp);
+ lb_priv(team)->orig_fprog = fprog;
+ return 0;
+}
+
+static const struct team_option lb_options[] = {
+ {
+ .name = "bpf_hash_func",
+ .type = TEAM_OPTION_TYPE_BINARY,
+ .getter = lb_bpf_func_get,
+ .setter = lb_bpf_func_set,
+ },
+};
+
+int lb_init(struct team *team)
+{
+ return team_options_register(team, lb_options,
+ ARRAY_SIZE(lb_options));
+}
+
+void lb_exit(struct team *team)
+{
+ team_options_unregister(team, lb_options,
+ ARRAY_SIZE(lb_options));
+}
+
+static int lb_port_enter(struct team *team, struct team_port *port)
+{
+ return team_port_set_team_mac(port);
+}
+
+static void lb_port_change_mac(struct team *team, struct team_port *port)
+{
+ team_port_set_team_mac(port);
+}
+
+static const struct team_mode_ops lb_mode_ops = {
+ .init = lb_init,
+ .exit = lb_exit,
+ .transmit = lb_transmit,
+ .port_enter = lb_port_enter,
+ .port_change_mac = lb_port_change_mac,
+};
+
+static struct team_mode lb_mode = {
+ .kind = "loadbalance",
+ .owner = THIS_MODULE,
+ .priv_size = sizeof(struct lb_priv),
+ .ops = &lb_mode_ops,
+};
+
+static int __init lb_init_module(void)
+{
+ return team_mode_register(&lb_mode);
+}
+
+static void __exit lb_cleanup_module(void)
+{
+ team_mode_unregister(&lb_mode);
+}
+
+module_init(lb_init_module);
+module_exit(lb_cleanup_module);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Jiri Pirko <jpirko@redhat.com>");
+MODULE_DESCRIPTION("Load-balancing mode for team");
+MODULE_ALIAS("team-mode-loadbalance");
--
1.7.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [patch net-next 1/4] filter: Allow to create sk-unattached filters
2012-03-31 21:01 ` [patch net-next 1/4] filter: Allow to create sk-unattached filters Jiri Pirko
@ 2012-04-03 22:36 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2012-04-03 22:36 UTC (permalink / raw)
To: jpirko
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 31 Mar 2012 23:01:19 +0200
> Today, BPF filters are bind to sockets. Since BPF machine becomes handy
> for other purposes, this patch allows to create unattached filter.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 2/4] filter: add XOR operation
2012-03-31 21:01 ` [patch net-next 2/4] filter: add XOR operation Jiri Pirko
@ 2012-04-03 22:36 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2012-04-03 22:36 UTC (permalink / raw)
To: jpirko
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 31 Mar 2012 23:01:20 +0200
> Add XOR instruction fo BPF machine. Needed for computing packet hashes.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Looks good, applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 3/4] team: add binary option type
2012-03-31 21:01 ` [patch net-next 3/4] team: add binary option type Jiri Pirko
@ 2012-04-03 22:38 ` David Miller
2012-04-04 12:29 ` Jiri Pirko
0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2012-04-03 22:38 UTC (permalink / raw)
To: jpirko
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 31 Mar 2012 23:01:21 +0200
> For transfering generic binary data (e.g. BPF code), introduce new
> binary option type.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Several issues:
> + struct team_option_binary tbinary;
You put this into a netlink attribute, it has a non-fixed
type size because it uses pointer. A compat task will do
the wrong thing and you won't interpret it's attribute
correctly.
> + NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_BINARY);
net-next no longer has NLA_PUT*(), so you'll need to adjust
this as well.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 4/4] team: add loadbalance mode
2012-03-31 21:01 ` [patch net-next 4/4] team: add loadbalance mode Jiri Pirko
@ 2012-04-03 22:38 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2012-04-03 22:38 UTC (permalink / raw)
To: jpirko
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
From: Jiri Pirko <jpirko@redhat.com>
Date: Sat, 31 Mar 2012 23:01:22 +0200
> This patch introduces new team mode. It's TX port is selected by
> user-set BPF hash function.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Please resubmit this once you've fixed up patch #3.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 3/4] team: add binary option type
2012-04-03 22:38 ` David Miller
@ 2012-04-04 12:29 ` Jiri Pirko
2012-04-04 21:45 ` David Miller
0 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2012-04-04 12:29 UTC (permalink / raw)
To: David Miller
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
Wed, Apr 04, 2012 at 12:38:16AM CEST, davem@davemloft.net wrote:
>From: Jiri Pirko <jpirko@redhat.com>
>Date: Sat, 31 Mar 2012 23:01:21 +0200
>
>> For transfering generic binary data (e.g. BPF code), introduce new
>> binary option type.
>>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
>Several issues:
>
>> + struct team_option_binary tbinary;
>
>You put this into a netlink attribute, it has a non-fixed
>type size because it uses pointer. A compat task will do
>the wrong thing and you won't interpret it's attribute
>correctly.
I'm not nla_putting struct team_option_binary tbinary. I'm putting only
the data on what the pointer stored into that points (tbinary.data):
nla_put(skb, TEAM_ATTR_OPTION_DATA, tbinary.data_len, tbinary.data));
>
>> + NLA_PUT_U8(skb, TEAM_ATTR_OPTION_TYPE, NLA_BINARY);
>
>net-next no longer has NLA_PUT*(), so you'll need to adjust
>this as well.
Sure I'll change this.
Jirka
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 3/4] team: add binary option type
2012-04-04 12:29 ` Jiri Pirko
@ 2012-04-04 21:45 ` David Miller
2012-04-04 22:14 ` Jiri Pirko
0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2012-04-04 21:45 UTC (permalink / raw)
To: jpirko
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
From: Jiri Pirko <jpirko@redhat.com>
Date: Wed, 4 Apr 2012 14:29:31 +0200
> Wed, Apr 04, 2012 at 12:38:16AM CEST, davem@davemloft.net wrote:
>>From: Jiri Pirko <jpirko@redhat.com>
>>Date: Sat, 31 Mar 2012 23:01:21 +0200
>>
>>> For transfering generic binary data (e.g. BPF code), introduce new
>>> binary option type.
>>>
>>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>>
>>Several issues:
>>
>>> + struct team_option_binary tbinary;
>>
>>You put this into a netlink attribute, it has a non-fixed
>>type size because it uses pointer. A compat task will do
>>the wrong thing and you won't interpret it's attribute
>>correctly.
>
> I'm not nla_putting struct team_option_binary tbinary. I'm putting only
> the data on what the pointer stored into that points (tbinary.data):
>
> nla_put(skb, TEAM_ATTR_OPTION_DATA, tbinary.data_len, tbinary.data));
Aha, I misread, thanks for explaining.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net-next 3/4] team: add binary option type
2012-04-04 21:45 ` David Miller
@ 2012-04-04 22:14 ` Jiri Pirko
0 siblings, 0 replies; 12+ messages in thread
From: Jiri Pirko @ 2012-04-04 22:14 UTC (permalink / raw)
To: David Miller
Cc: netdev, eric.dumazet, bhutchings, shemminger, raise.sail,
nuno.martins, matt
Wed, Apr 04, 2012 at 11:45:47PM CEST, davem@davemloft.net wrote:
>From: Jiri Pirko <jpirko@redhat.com>
>Date: Wed, 4 Apr 2012 14:29:31 +0200
>
>> Wed, Apr 04, 2012 at 12:38:16AM CEST, davem@davemloft.net wrote:
>>>From: Jiri Pirko <jpirko@redhat.com>
>>>Date: Sat, 31 Mar 2012 23:01:21 +0200
>>>
>>>> For transfering generic binary data (e.g. BPF code), introduce new
>>>> binary option type.
>>>>
>>>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>>>
>>>Several issues:
>>>
>>>> + struct team_option_binary tbinary;
>>>
>>>You put this into a netlink attribute, it has a non-fixed
>>>type size because it uses pointer. A compat task will do
>>>the wrong thing and you won't interpret it's attribute
>>>correctly.
>>
>> I'm not nla_putting struct team_option_binary tbinary. I'm putting only
>> the data on what the pointer stored into that points (tbinary.data):
>>
>> nla_put(skb, TEAM_ATTR_OPTION_DATA, tbinary.data_len, tbinary.data));
>
>Aha, I misread, thanks for explaining.
Going to repost 3/4 and 4/4.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-04-04 22:14 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-31 21:01 [patch net-next 0/4] Introduce BPF-based TX port selecting for Team device Jiri Pirko
2012-03-31 21:01 ` [patch net-next 1/4] filter: Allow to create sk-unattached filters Jiri Pirko
2012-04-03 22:36 ` David Miller
2012-03-31 21:01 ` [patch net-next 2/4] filter: add XOR operation Jiri Pirko
2012-04-03 22:36 ` David Miller
2012-03-31 21:01 ` [patch net-next 3/4] team: add binary option type Jiri Pirko
2012-04-03 22:38 ` David Miller
2012-04-04 12:29 ` Jiri Pirko
2012-04-04 21:45 ` David Miller
2012-04-04 22:14 ` Jiri Pirko
2012-03-31 21:01 ` [patch net-next 4/4] team: add loadbalance mode Jiri Pirko
2012-04-03 22:38 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.