* Re: [Patch net-next v2] act_mirred: get rid of tcfm_ifindex from struct tcf_mirred
From: Jiri Pirko @ 2017-12-06 8:33 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Jiri Pirko, Jamal Hadi Salim
In-Reply-To: <20171206001727.25731-1-xiyou.wangcong@gmail.com>
Wed, Dec 06, 2017 at 01:17:26AM CET, xiyou.wangcong@gmail.com wrote:
>tcfm_dev always points to the correct netdev and we already
>hold a refcnt, so no need to use tcfm_ifindex to lookup again.
>
>If we would support moving target netdev across netns, using
>pointer would be better than ifindex.
>
>This also fixes dumping obsolete ifindex, now after the
>target device is gone we just dump 0 as ifindex.
>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Thanks!
^ permalink raw reply
* Re: [PATCH V11 4/5] vsprintf: add printk specifier %px
From: Geert Uytterhoeven @ 2017-12-06 8:32 UTC (permalink / raw)
To: Linus Torvalds
Cc: Sergey Senozhatsky, Randy Dunlap, David Laight, Kees Cook,
Tobin C. Harding, kernel-hardening@lists.openwall.com,
Jason A. Donenfeld, Theodore Ts'o, Paolo Bonzini,
Tycho Andersen, Roberts, William C, Tejun Heo, Jordan Glover,
Greg KH, Petr Mladek, Joe Perches, Ian Campbell,
Sergey Senozhatsky, Catalin Marinas, Will Deacon, Steven Rostedt,
Chris Fries
In-Reply-To: <CA+55aFzMydq1TizkPOjZmRb_eKtHCk3w-xdO-Ce2jw9tu3bsGg@mail.gmail.com>
Hi Linus,
On Wed, Dec 6, 2017 at 2:59 AM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Tue, Dec 5, 2017 at 5:36 PM, Sergey Senozhatsky
> <sergey.senozhatsky.work@gmail.com> wrote:
>> I see some %p-s being used in _supposedly_ important output,
>> like arch/x86/mm/fault.c
>>
>> show_fault_oops(struct pt_regs *regs, unsigned long error_code,
>> unsigned long address)
>> ...
>> printk(KERN_CONT " at %p\n", (void *) address);
>> printk(KERN_ALERT "IP: %pS\n", (void *)regs->ip);
>
> So %pS isn't %p, and shows the symbolic name.
If the symbolic name is available.
Else it prints the non-hashed pointer value (FTR).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
* Re: [PATCH net-next v3 4/4] net: fec: add phy_reset_after_clk_enable() support
From: Richard Leitner @ 2017-12-06 8:12 UTC (permalink / raw)
To: Andy Duan, Richard Leitner,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
andrew-g2DYL2Zd6BY@public.gmane.org,
f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org,
sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org,
baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org,
david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
lukma-ynQEQJNshbs@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <DB6PR0401MB2264B5060F745CEB5405FFBCFF320-2mNvjAGDOPl4towakvZX7o3W/0Ik+aLCnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
Hi Andy,
On 12/06/2017 02:50 AM, Andy Duan wrote:
> From: Richard Leitner <dev-M/VWbR8SM2SsTnJN9+BGXg@public.gmane.org> Sent: Tuesday, December 05, 2017 9:26 PM
>> Some PHYs (for example the SMSC LAN8710/LAN8720) doesn't allow turning
>> the refclk on and off again during operation (according to their datasheet).
>> Nonetheless exactly this behaviour was introduced for power saving reasons
>> by commit e8fcfcd5684a ("net: fec: optimize the clock management to save
>> power").
>> Therefore add support for the phy_reset_after_clk_enable function from
>> phylib to mitigate this issue.
...
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>> b/drivers/net/ethernet/freescale/fec_main.c
>> index 610573855213..8c3d0fb7db20 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -1862,6 +1862,8 @@ static int fec_enet_clk_enable(struct net_device
>> *ndev, bool enable)
>> ret = clk_prepare_enable(fep->clk_ref);
>> if (ret)
>> goto failed_clk_ref;
>> +
>> + phy_reset_after_clk_enable(ndev->phydev);
>> } else {
>> clk_disable_unprepare(fep->clk_ahb);
>> clk_disable_unprepare(fep->clk_enet_out);
>> @@ -2860,6 +2862,11 @@ fec_enet_open(struct net_device *ndev)
>> if (ret)
>> goto err_enet_mii_probe;
>>
>> + /* reset phy if needed here, due to the fact this is the first time we
>> + * have the net_device to phy_driver link
>> + */
>> + phy_reset_after_clk_enable(ndev->phydev);
>> +
>
> The patch series look better.
> But why does it need to reset phy here since phy already is hard reset after clock enable.
The problem here is that in fec_enet_open() the fec_enet_clk_enable()
call is done before the phy is probed. Therefore (as mentioned in the
comment) there's no link from the net_device (ndev) to the phy_driver
(which holds the flags).
Any suggestions for a better solution are highly appreciated here! Thanks!
regards;Richard.L
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [net] netlink: Relax attr validation for fixed length types
From: Johannes Berg @ 2017-12-06 8:06 UTC (permalink / raw)
To: David Ahern, netdev
In-Reply-To: <20171205195540.41822-1-dsahern@gmail.com>
On Tue, 2017-12-05 at 12:55 -0700, David Ahern wrote:
> @@ -70,10 +78,9 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
> BUG_ON(pt->type > NLA_TYPE_MAX);
>
> /* for data types NLA_U* and NLA_S* require exact length */
You should update the comment now :-)
And the comment on nla_attr_len as well.
With the comments fixed, this looks fine to me.
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Since we already have two tables now and may want to add attribute
types with exact enforcement in the future (like the BITFIELD32 one),
I'd actually do things a bit more data driven, but I haven't tested it
right now, and it's better done in net-next after this fix.
diff --git a/lib/nlattr.c b/lib/nlattr.c
index 8bf78b4b78f0..e65eb5400a1a 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -15,21 +15,67 @@
#include <linux/types.h>
#include <net/netlink.h>
-/* for these data types attribute length must be exactly given size */
-static const u8 nla_attr_len[NLA_TYPE_MAX+1] = {
- [NLA_U8] = sizeof(u8),
- [NLA_U16] = sizeof(u16),
- [NLA_U32] = sizeof(u32),
- [NLA_U64] = sizeof(u64),
- [NLA_S8] = sizeof(s8),
- [NLA_S16] = sizeof(s16),
- [NLA_S32] = sizeof(s32),
- [NLA_S64] = sizeof(s64),
-};
-
-static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
- [NLA_MSECS] = sizeof(u64),
- [NLA_NESTED] = NLA_HDRLEN,
+/* netlink validation flags */
+#define NLVF_WARN_WRONG_LEN BIT(0)
+#define NLVF_REJECT_WRONG_LEN BIT(1)
+
+static const struct {
+ u8 len, flags;
+} nla_attr_val[NLA_TYPE_MAX + 1] = {
+ [NLA_FLAG] = {
+ .len = 0,
+ .flags = NLVF_REJECT_WRONG_LEN,
+ },
+ [NLA_BITFIELD32] = {
+ /* further checks below */
+ .len = sizeof(struct nla_bitfield32),
+ .flags = NLVF_REJECT_WRONG_LEN,
+ },
+ [NLA_U8] = {
+ .len = sizeof(u8),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_U16] = {
+ .len = sizeof(u16),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_U32] = {
+ .len = sizeof(u32),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_U64] = {
+ .len = sizeof(u64),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_S8] = {
+ .len = sizeof(s8),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_S16] = {
+ .len = sizeof(s16),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_S32] = {
+ .len = sizeof(s32),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_S64] = {
+ .len = sizeof(s64),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_MSECS] = {
+ .len = sizeof(s64),
+ .flags = NLVF_WARN_WRONG_LEN,
+ },
+ [NLA_NESTED] = {
+ /* minimum length */
+ .len = NLA_HDRLEN,
+ },
+ [NLA_STRING] = {
+ /* minimum length, further checks below */
+ .len = 1,
+ },
+ /* others have .len = 0 and no flags */
};
static int validate_nla_bitfield32(const struct nlattr *nla,
@@ -60,7 +106,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
const struct nla_policy *policy)
{
const struct nla_policy *pt;
- int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
+ int minlen, attrlen = nla_len(nla), type = nla_type(nla);
if (type <= 0 || type > maxtype)
return 0;
@@ -69,23 +115,51 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
BUG_ON(pt->type > NLA_TYPE_MAX);
- /* for data types NLA_U* and NLA_S* require exact length */
- if (nla_attr_len[pt->type]) {
- if (attrlen != nla_attr_len[pt->type])
+ switch (pt->type) {
+ case NLA_BINARY:
+ if (pt->len && attrlen > pt->len)
return -ERANGE;
- return 0;
- }
+ break;
- switch (pt->type) {
- case NLA_FLAG:
- if (attrlen > 0)
+ case NLA_NESTED_COMPAT:
+ if (attrlen < pt->len)
+ return -ERANGE;
+ if (attrlen < NLA_ALIGN(pt->len))
+ break;
+ if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN)
+ return -ERANGE;
+ nla = nla_data(nla) + NLA_ALIGN(pt->len);
+ if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
return -ERANGE;
break;
- case NLA_BITFIELD32:
- if (attrlen != sizeof(struct nla_bitfield32))
+ case NLA_NESTED:
+ /* a nested attributes is allowed to be empty; if its not,
+ * it must have a size of at least NLA_HDRLEN.
+ */
+ if (attrlen == 0)
+ break;
+ /* fall through */
+ default:
+ minlen = nla_attr_val[pt->type].len;
+
+ if (nla_attr_val[pt->type].flags & NLVF_REJECT_WRONG_LEN &&
+ minlen != attrlen)
+ return -ERANGE;
+ if (nla_attr_val[pt->type].flags & NLVF_WARN_WRONG_LEN &&
+ minlen != attrlen)
+ pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
+ current->comm, type);
+
+ if (pt->len)
+ minlen = pt->len;
+
+ if (attrlen < minlen)
return -ERANGE;
+ }
+ switch (pt->type) {
+ case NLA_BITFIELD32:
return validate_nla_bitfield32(nla, pt->validation_data);
case NLA_NUL_STRING:
@@ -99,9 +173,6 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
/* fall through */
case NLA_STRING:
- if (attrlen < 1)
- return -ERANGE;
-
if (pt->len) {
char *buf = nla_data(nla);
@@ -112,37 +183,6 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
return -ERANGE;
}
break;
-
- case NLA_BINARY:
- if (pt->len && attrlen > pt->len)
- return -ERANGE;
- break;
-
- case NLA_NESTED_COMPAT:
- if (attrlen < pt->len)
- return -ERANGE;
- if (attrlen < NLA_ALIGN(pt->len))
- break;
- if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN)
- return -ERANGE;
- nla = nla_data(nla) + NLA_ALIGN(pt->len);
- if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
- return -ERANGE;
- break;
- case NLA_NESTED:
- /* a nested attributes is allowed to be empty; if its not,
- * it must have a size of at least NLA_HDRLEN.
- */
- if (attrlen == 0)
- break;
- default:
- if (pt->len)
- minlen = pt->len;
- else if (pt->type != NLA_UNSPEC)
- minlen = nla_attr_minlen[pt->type];
-
- if (attrlen < minlen)
- return -ERANGE;
}
return 0;
johannes
^ permalink raw reply related
* [PATCH] xen-netback: Fix logging message with spurious period after newline
From: Joe Perches @ 2017-12-06 6:40 UTC (permalink / raw)
To: Wei Liu, Paul Durrant; +Cc: xen-devel, netdev, linux-kernel
Using a period after a newline causes bad output.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/xen-netback/interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index d6dff347f896..78ebe494fef0 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -186,7 +186,7 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Obtain the queue to be used to transmit this packet */
index = skb_get_queue_mapping(skb);
if (index >= num_queues) {
- pr_warn_ratelimited("Invalid queue %hu for packet on interface %s\n.",
+ pr_warn_ratelimited("Invalid queue %hu for packet on interface %s\n",
index, vif->dev->name);
index %= num_queues;
}
--
2.15.0
^ permalink raw reply related
* [PATCH net-next v2 0/2] bpf/tracing: allow user space to query prog array on the same tp
From: Yonghong Song @ 2017-12-06 6:31 UTC (permalink / raw)
To: peterz, rostedt, ast, daniel, kafai, netdev; +Cc: kernel-team
Commit e87c6bc3852b ("bpf: permit multiple bpf attachments
for a single perf event") added support to attach multiple
bpf programs to a single perf event. Given a perf event
(kprobe, uprobe, or kernel tracepoint), the perf ioctl interface
is used to query bpf programs attached to the same trace event.
There already exists a BPF_PROG_QUERY command for introspection
currently used by cgroup+bpf. We did have an implementation for
querying tracepoint+bpf through the same interface. However, it
looks cleaner to use ioctl() style of api here, since attaching
bpf prog to tracepoint/kuprobe is also done via ioctl.
Patch #1 had the core implementation and patch #2 added
a test case in tools bpf selftests suite.
Changelogs:
v1-> v2:
- Rebase on top of net-next.
- Use existing bpf_prog_array_length function instead of
implementing the same functionality in function
bpf_prog_array_copy_info.
Yonghong Song (2):
bpf/tracing: allow user space to query prog array on the same tp
bpf/tracing: add a bpf test for new ioctl query interface
include/linux/bpf.h | 4 +
include/uapi/linux/perf_event.h | 6 +
kernel/bpf/core.c | 21 ++++
kernel/events/core.c | 3 +
kernel/trace/bpf_trace.c | 23 ++++
tools/include/uapi/linux/perf_event.h | 6 +
tools/testing/selftests/bpf/Makefile | 2 +-
tools/testing/selftests/bpf/test_progs.c | 155 ++++++++++++++++++++++++++
tools/testing/selftests/bpf/test_tracepoint.c | 26 +++++
9 files changed, 245 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/bpf/test_tracepoint.c
--
2.9.5
^ permalink raw reply
* [PATCH net-next v2 1/2] bpf/tracing: allow user space to query prog array on the same tp
From: Yonghong Song @ 2017-12-06 6:31 UTC (permalink / raw)
To: peterz, rostedt, ast, daniel, kafai, netdev; +Cc: kernel-team
In-Reply-To: <20171206063129.3730876-1-yhs@fb.com>
Commit e87c6bc3852b ("bpf: permit multiple bpf attachments
for a single perf event") added support to attach multiple
bpf programs to a single perf event.
Commit 2541517c32be ("tracing, perf: Implement BPF programs
attached to kprobes") utilized the existing perf ioctl
interface and added the command PERF_EVENT_IOC_SET_BPF
to attach a bpf program to a tracepoint.
This patch adds a new ioctl
command, given a perf event fd, to query the bpf program array
attached to the same perf tracepoint event.
The new uapi ioctl command:
PERF_EVENT_IOC_QUERY_BPF
The new uapi/linux/perf_event.h structure:
struct perf_event_query_bpf {
__u64 prog_ids;
__u32 prog_cnt;
};
The usage:
struct perf_event_query_bpf query;
query.prog_ids = (__u64)usr_prog_ids_buf;
query.prog_cnt = usr_prog_ids_buf_len;
err = ioctl(pmu_efd, PERF_EVENT_IOC_QUERY_BPF, &query);
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
include/linux/bpf.h | 4 ++++
include/uapi/linux/perf_event.h | 6 ++++++
kernel/bpf/core.c | 21 +++++++++++++++++++++
kernel/events/core.c | 3 +++
kernel/trace/bpf_trace.c | 23 +++++++++++++++++++++++
5 files changed, 57 insertions(+)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index e55e425..f812ac5 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -254,6 +254,7 @@ typedef unsigned long (*bpf_ctx_copy_t)(void *dst, const void *src,
u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy);
+int bpf_event_query_prog_array(struct perf_event *event, void __user *info);
int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
union bpf_attr __user *uattr);
@@ -285,6 +286,9 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs,
void bpf_prog_array_delete_safe(struct bpf_prog_array __rcu *progs,
struct bpf_prog *old_prog);
+int bpf_prog_array_copy_info(struct bpf_prog_array __rcu *array,
+ __u32 __user *prog_ids, u32 request_cnt,
+ __u32 __user *prog_cnt);
int bpf_prog_array_copy(struct bpf_prog_array __rcu *old_array,
struct bpf_prog *exclude_prog,
struct bpf_prog *include_prog,
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index b9a4953..fee0b43 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -418,6 +418,11 @@ struct perf_event_attr {
__u16 __reserved_2; /* align to __u64 */
};
+struct perf_event_query_bpf {
+ __u64 prog_ids;
+ __u32 prog_cnt;
+};
+
#define perf_flags(attr) (*(&(attr)->read_format + 1))
/*
@@ -433,6 +438,7 @@ struct perf_event_attr {
#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *)
enum perf_event_ioc_flags {
PERF_IOC_FLAG_GROUP = 1U << 0,
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 86b50aa..35b427aa 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1462,6 +1462,8 @@ int bpf_prog_array_copy_to_user(struct bpf_prog_array __rcu *progs,
rcu_read_lock();
prog = rcu_dereference(progs)->progs;
for (; *prog; prog++) {
+ if (*prog == &dummy_bpf_prog.prog)
+ continue;
id = (*prog)->aux->id;
if (copy_to_user(prog_ids + i, &id, sizeof(id))) {
rcu_read_unlock();
@@ -1545,6 +1547,25 @@ int bpf_prog_array_copy(struct bpf_prog_array __rcu *old_array,
return 0;
}
+int bpf_prog_array_copy_info(struct bpf_prog_array __rcu *array,
+ __u32 __user *prog_ids, u32 request_cnt,
+ __u32 __user *prog_cnt)
+{
+ u32 cnt = 0;
+
+ if (array)
+ cnt = bpf_prog_array_length(array);
+
+ if (copy_to_user(prog_cnt, &cnt, sizeof(cnt)))
+ return -EFAULT;
+
+ /* return early if user requested only program count or nothing to copy */
+ if (!request_cnt || !prog_ids || !cnt)
+ return 0;
+
+ return bpf_prog_array_copy_to_user(array, prog_ids, request_cnt);
+}
+
static void bpf_prog_free_deferred(struct work_struct *work)
{
struct bpf_prog_aux *aux;
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 16beab4..f10609e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4723,6 +4723,9 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon
rcu_read_unlock();
return 0;
}
+
+ case PERF_EVENT_IOC_QUERY_BPF:
+ return bpf_event_query_prog_array(event, (void __user *)arg);
default:
return -ENOTTY;
}
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 0ce99c3..81eedb2 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -820,3 +820,26 @@ void perf_event_detach_bpf_prog(struct perf_event *event)
unlock:
mutex_unlock(&bpf_event_mutex);
}
+
+int bpf_event_query_prog_array(struct perf_event *event, void __user *info)
+{
+ struct perf_event_query_bpf __user *uquery = info;
+ struct perf_event_query_bpf query = {};
+ int ret;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ if (event->attr.type != PERF_TYPE_TRACEPOINT)
+ return -EINVAL;
+ if (copy_from_user(&query, uquery, sizeof(query)))
+ return -EFAULT;
+
+ mutex_lock(&bpf_event_mutex);
+ ret = bpf_prog_array_copy_info(event->tp_event->prog_array,
+ u64_to_user_ptr(query.prog_ids),
+ query.prog_cnt,
+ &uquery->prog_cnt);
+ mutex_unlock(&bpf_event_mutex);
+
+ return ret;
+}
--
2.9.5
^ permalink raw reply related
* [PATCH net-next v2 2/2] bpf/tracing: add a bpf test for new ioctl query interface
From: Yonghong Song @ 2017-12-06 6:31 UTC (permalink / raw)
To: peterz, rostedt, ast, daniel, kafai, netdev; +Cc: kernel-team
In-Reply-To: <20171206063129.3730876-1-yhs@fb.com>
Added a subtest in test_progs. The tracepoint is
sched/sched_switch. Multiple bpf programs are attached to
this tracepoint and the query interface is exercised.
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
tools/include/uapi/linux/perf_event.h | 6 +
tools/testing/selftests/bpf/Makefile | 2 +-
tools/testing/selftests/bpf/test_progs.c | 155 ++++++++++++++++++++++++++
tools/testing/selftests/bpf/test_tracepoint.c | 26 +++++
4 files changed, 188 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/bpf/test_tracepoint.c
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 362493a..8523db0 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -418,6 +418,11 @@ struct perf_event_attr {
__u16 __reserved_2; /* align to __u64 */
};
+struct perf_event_query_bpf {
+ __u64 prog_ids;
+ __u32 prog_cnt;
+};
+
#define perf_flags(attr) (*(&(attr)->read_format + 1))
/*
@@ -433,6 +438,7 @@ struct perf_event_attr {
#define PERF_EVENT_IOC_ID _IOR('$', 7, __u64 *)
#define PERF_EVENT_IOC_SET_BPF _IOW('$', 8, __u32)
#define PERF_EVENT_IOC_PAUSE_OUTPUT _IOW('$', 9, __u32)
+#define PERF_EVENT_IOC_QUERY_BPF _IOWR('$', 10, struct perf_event_query_bpf *)
enum perf_event_ioc_flags {
PERF_IOC_FLAG_GROUP = 1U << 0,
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 2c9d8c6..255fb1f 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -17,7 +17,7 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \
test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \
- sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o
+ sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o test_tracepoint.o
TEST_PROGS := test_kmod.sh test_xdp_redirect.sh test_xdp_meta.sh \
test_offload.py
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 6942753..dde23ed 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -21,8 +21,10 @@ typedef __u16 __sum16;
#include <linux/ipv6.h>
#include <linux/tcp.h>
#include <linux/filter.h>
+#include <linux/perf_event.h>
#include <linux/unistd.h>
+#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/types.h>
@@ -617,6 +619,158 @@ static void test_obj_name(void)
}
}
+static void test_tp_attach_query(void)
+{
+ const int num_progs = 3;
+ __u32 duration = 0, info_len, prog_ids[num_progs], saved_prog_ids[num_progs];
+ int i, j, bytes, efd, err, prog_fd[num_progs], pmu_fd[num_progs];
+ const char *file = "./test_tracepoint.o";
+ struct perf_event_query_bpf query = {};
+ struct perf_event_attr attr = {};
+ struct bpf_object *obj[num_progs];
+ struct bpf_prog_info prog_info;
+ char buf[256];
+
+ snprintf(buf, sizeof(buf),
+ "/sys/kernel/debug/tracing/events/sched/sched_switch/id");
+ efd = open(buf, O_RDONLY, 0);
+ if (CHECK(efd < 0, "open", "err %d errno %d\n", efd, errno))
+ return;
+ bytes = read(efd, buf, sizeof(buf));
+ close(efd);
+ if (CHECK(bytes <= 0 || bytes >= sizeof(buf),
+ "read", "bytes %d errno %d\n", bytes, errno))
+ return;
+
+ attr.config = strtol(buf, NULL, 0);
+ attr.type = PERF_TYPE_TRACEPOINT;
+ attr.sample_type = PERF_SAMPLE_RAW | PERF_SAMPLE_CALLCHAIN;
+ attr.sample_period = 1;
+ attr.wakeup_events = 1;
+
+ for (i = 0; i < num_progs; i++) {
+ err = bpf_prog_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj[i],
+ &prog_fd[i]);
+ if (CHECK(err, "prog_load", "err %d errno %d\n", err, errno))
+ goto cleanup1;
+
+ bzero(&prog_info, sizeof(prog_info));
+ prog_info.jited_prog_len = 0;
+ prog_info.xlated_prog_len = 0;
+ prog_info.nr_map_ids = 0;
+ info_len = sizeof(prog_info);
+ err = bpf_obj_get_info_by_fd(prog_fd[i], &prog_info, &info_len);
+ if (CHECK(err, "bpf_obj_get_info_by_fd", "err %d errno %d\n",
+ err, errno))
+ goto cleanup1;
+ saved_prog_ids[i] = prog_info.id;
+
+ pmu_fd[i] = syscall(__NR_perf_event_open, &attr, -1 /* pid */,
+ 0 /* cpu 0 */, -1 /* group id */,
+ 0 /* flags */);
+ if (CHECK(pmu_fd[i] < 0, "perf_event_open", "err %d errno %d\n",
+ pmu_fd[i], errno))
+ goto cleanup2;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_ENABLE, 0);
+ if (CHECK(err, "perf_event_ioc_enable", "err %d errno %d\n",
+ err, errno))
+ goto cleanup3;
+
+ if (i == 0) {
+ /* check NULL prog array query */
+ query.prog_ids = (__u64)prog_ids;
+ query.prog_cnt = num_progs;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(err || query.prog_cnt != 0,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+ }
+
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_SET_BPF, prog_fd[i]);
+ if (CHECK(err, "perf_event_ioc_set_bpf", "err %d errno %d\n",
+ err, errno))
+ goto cleanup3;
+
+ if (i == 1) {
+ /* try to get # of programs only: prog_cnt == 0 */
+ query.prog_cnt = 0;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(err || query.prog_cnt != 2,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+
+ /* try to get # of programs only: prog_ids == 0 */
+ query.prog_ids = 0;
+ query.prog_cnt = num_progs;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(err || query.prog_cnt != 2,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+
+ /* try a few negative tests */
+ /* invalid query pointer */
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF,
+ (struct perf_event_query_bpf *)0x1);
+ if (CHECK(!err || errno != EFAULT,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+
+ /* invalid prog_ids pointer */
+ query.prog_ids = 0x1;
+ query.prog_cnt = 1;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(!err || errno != EFAULT,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+
+ /* no enough space */
+ query.prog_ids = (__u64)prog_ids;
+ query.prog_cnt = 1;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(!err || errno != ENOSPC,
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+ }
+
+ query.prog_ids = (__u64)prog_ids;
+ query.prog_cnt = num_progs;
+ err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, &query);
+ if (CHECK(err || query.prog_cnt != (i + 1),
+ "perf_event_ioc_query_bpf",
+ "err %d errno %d query.prog_cnt %u\n",
+ err, errno, query.prog_cnt))
+ goto cleanup3;
+ for (j = 0; j < i + 1; j++)
+ if (CHECK(saved_prog_ids[j] != prog_ids[j],
+ "perf_event_ioc_query_bpf",
+ "#%d saved_prog_id %x query prog_id %x\n",
+ j, saved_prog_ids[j], prog_ids[j]))
+ goto cleanup3;
+ }
+
+ i = num_progs - 1;
+ for (; i >= 0; i--) {
+ cleanup3:
+ ioctl(pmu_fd[i], PERF_EVENT_IOC_DISABLE);
+ cleanup2:
+ close(pmu_fd[i]);
+ cleanup1:
+ bpf_object__close(obj[i]);
+ }
+}
+
int main(void)
{
struct rlimit rinf = { RLIM_INFINITY, RLIM_INFINITY };
@@ -630,6 +784,7 @@ int main(void)
test_bpf_obj_id();
test_pkt_md_access();
test_obj_name();
+ test_tp_attach_query();
printf("Summary: %d PASSED, %d FAILED\n", pass_cnt, error_cnt);
return error_cnt ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/tools/testing/selftests/bpf/test_tracepoint.c b/tools/testing/selftests/bpf/test_tracepoint.c
new file mode 100644
index 0000000..04bf084
--- /dev/null
+++ b/tools/testing/selftests/bpf/test_tracepoint.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2017 Facebook
+
+#include <linux/bpf.h>
+#include "bpf_helpers.h"
+
+/* taken from /sys/kernel/debug/tracing/events/sched/sched_switch/format */
+struct sched_switch_args {
+ unsigned long long pad;
+ char prev_comm[16];
+ int prev_pid;
+ int prev_prio;
+ long long prev_state;
+ char next_comm[16];
+ int next_pid;
+ int next_prio;
+};
+
+SEC("tracepoint/sched/sched_switch")
+int oncpu(struct sched_switch_args *ctx)
+{
+ return 0;
+}
+
+char _license[] SEC("license") = "GPL";
+__u32 _version SEC("version") = 1; /* ignored by tracepoints, required by libbpf.a */
--
2.9.5
^ permalink raw reply related
* Re: [PATCH v2 3/3] net: macb: change GFP_ATOMIC to GFP_KERNEL
From: Julia Lawall @ 2017-12-06 5:49 UTC (permalink / raw)
To: Julia Cartwright
Cc: David Miller, Julia Lawall, rafalo, nicolas.ferre, netdev,
linux-kernel, kbuild-all
In-Reply-To: <da389d51c2f4d8a600418143e00be40423255576.1512518311.git.julia@ni.com>
On Tue, 5 Dec 2017, Julia Cartwright wrote:
> Now that the rx_fs_lock is no longer held across allocation, it's safe
> to use GFP_KERNEL for allocating new entries.
>
> This reverts commit 81da3bf6e3f88 ("net: macb: change GFP_KERNEL to
> GFP_ATOMIC").
>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Julia Cartwright <julia@ni.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 758e8b3042b2..234667eaaa92 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -2800,7 +2800,7 @@ static int gem_add_flow_filter(struct net_device *netdev,
> int ret = -EINVAL;
> bool added = false;
>
> - newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
> + newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
> if (newfs == NULL)
> return -ENOMEM;
> memcpy(&newfs->fs, fs, sizeof(newfs->fs));
> --
> 2.14.2
>
>
^ permalink raw reply
* Re: [PATCH iproute2] iproute2: Fix undeclared __kernel_long_t type build error in RHEL 6.8
From: Leon Romanovsky @ 2017-12-06 5:01 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Riad Abo Raed, Guy Ergas
In-Reply-To: <20171205173325.7245f907@xeon-e3>
On Tue, Dec 05, 2017 at 05:33:25PM -0800, Stephen Hemminger wrote:
> On Fri, 1 Dec 2017 13:04:51 +0200
> Leon Romanovsky <leon@kernel.org> wrote:
>
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > Add asm/posix_types.h header file to the list of needed includes,
> > because the headers files in RHEL 6.8 are too old and doesn't
> > have declaration of __kernel_long_t.
> >
> > In file included from ../include/uapi/linux/kernel.h:5,
> > from ../include/uapi/linux/netfilter/x_tables.h:4,
> > from ../include/xtables.h:20,
> > from em_ipset.c:26:
> > ../include/uapi/linux/sysinfo.h:9: error: expected specifier-qualifier-list before ‘__kernel_long_t’
> >
> > Cc: Riad Abo Raed <riada@mellanox.com>
> > Cc: Guy Ergas <guye@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
> > Stephen,
> > I don't know how to properly solve this type of errors and would like to
> > hear your guidance on it.
> >
> > Should I simply add kernel file? Or maybe I need to add HAVE_xxx checks
> > to configure script to check __kernel_long_t existence and declare only
> > this type?
> >
> > I also have another build error on RHEL 6.8 system and looking for a
> > solution.
> >
> > In file included from em_ipset.c:26:
> > ../include/xtables.h:35:29: error: xtables-version.h: No such file or directory
> > make[1]: *** [em_ipset.o] Error 1
> >
> > The iptables-devel is iptables-devel-1.4.7-16.el6.x86_64 so check_xt()
> > success, but RH headers don't have xtable-version.h and the relevant defines
> > are embedded in the main xtables.h header file.
> >
> > Thanks
> > ---
> > include/uapi/asm/posix_types.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 97 insertions(+)
> > create mode 100644 include/uapi/asm/posix_types.h
> >
> > diff --git a/include/uapi/asm/posix_types.h b/include/uapi/asm/posix_types.h
> > new file mode 100644
> > index 00000000..5e6ea22b
> > --- /dev/null
> > +++ b/include/uapi/asm/posix_types.h
> > @@ -0,0 +1,97 @@
> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> > +#ifndef __ASM_GENERIC_POSIX_TYPES_H
> > +#define __ASM_GENERIC_POSIX_TYPES_H
> > +
> > +#include <asm/bitsperlong.h>
> > +/*
> > + * This file is generally used by user-level software, so you need to
> > + * be a little careful about namespace pollution etc.
> > + *
> > + * First the types that are often defined in different ways across
> > + * architectures, so that you can override them.
> > + */
> > +
> > +#ifndef __kernel_long_t
> > +typedef long __kernel_long_t;
> > +typedef unsigned long __kernel_ulong_t;
> > +#endif
> > +
> > +#ifndef __kernel_ino_t
> > +typedef __kernel_ulong_t __kernel_ino_t;
> > +#endif
> > +
> > +#ifndef __kernel_mode_t
> > +typedef unsigned int __kernel_mode_t;
> > +#endif
> > +
> > +#ifndef __kernel_pid_t
> > +typedef int __kernel_pid_t;
> > +#endif
> > +
> > +#ifndef __kernel_ipc_pid_t
> > +typedef int __kernel_ipc_pid_t;
> > +#endif
> > +
> > +#ifndef __kernel_uid_t
> > +typedef unsigned int __kernel_uid_t;
> > +typedef unsigned int __kernel_gid_t;
> > +#endif
> > +
> > +#ifndef __kernel_suseconds_t
> > +typedef __kernel_long_t __kernel_suseconds_t;
> > +#endif
> > +
> > +#ifndef __kernel_daddr_t
> > +typedef int __kernel_daddr_t;
> > +#endif
> > +
> > +#ifndef __kernel_uid32_t
> > +typedef unsigned int __kernel_uid32_t;
> > +typedef unsigned int __kernel_gid32_t;
> > +#endif
> > +
> > +#ifndef __kernel_old_uid_t
> > +typedef __kernel_uid_t __kernel_old_uid_t;
> > +typedef __kernel_gid_t __kernel_old_gid_t;
> > +#endif
> > +
> > +#ifndef __kernel_old_dev_t
> > +typedef unsigned int __kernel_old_dev_t;
> > +#endif
> > +
> > +/*
> > + * Most 32 bit architectures use "unsigned int" size_t,
> > + * and all 64 bit architectures use "unsigned long" size_t.
> > + */
> > +#ifndef __kernel_size_t
> > +#if __BITS_PER_LONG != 64
> > +typedef unsigned int __kernel_size_t;
> > +typedef int __kernel_ssize_t;
> > +typedef int __kernel_ptrdiff_t;
> > +#else
> > +typedef __kernel_ulong_t __kernel_size_t;
> > +typedef __kernel_long_t __kernel_ssize_t;
> > +typedef __kernel_long_t __kernel_ptrdiff_t;
> > +#endif
> > +#endif
> > +
> > +#ifndef __kernel_fsid_t
> > +typedef struct {
> > + int val[2];
> > +} __kernel_fsid_t;
> > +#endif
> > +
> > +/*
> > + * anything below here should be completely generic
> > + */
> > +typedef __kernel_long_t __kernel_off_t;
> > +typedef long long __kernel_loff_t;
> > +typedef __kernel_long_t __kernel_time_t;
> > +typedef __kernel_long_t __kernel_clock_t;
> > +typedef int __kernel_timer_t;
> > +typedef int __kernel_clockid_t;
> > +typedef char * __kernel_caddr_t;
> > +typedef unsigned short __kernel_uid16_t;
> > +typedef unsigned short __kernel_gid16_t;
> > +
> > +#endif /* __ASM_GENERIC_POSIX_TYPES_H */
> > --
> > 2.15.1
> >
>
> This isn't going to be supportable. The headers in uapi are updated by
> a script from kernel, and this version posix_types.h conflicts with what
> the kernel creates by make headers_install.
At the end, I gave up to fix compilation properly for RHEL 6.8.
After I fixed posix_type and xt-tables, I discovered that glibc headers
are not updated too (missing AF_VSOCK).
My dirty hack was to copy various headers to iproute2 so verification
team can proceed with latest iproute2 on such platform was enough for
them.
Thanks
>
^ permalink raw reply
* Re: Sending 802.1Q packets using AF_PACKET socket on filtered bridge forwards with wrong MAC addresses
From: Toshiaki Makita @ 2017-12-06 4:44 UTC (permalink / raw)
To: Brandon Carpenter
Cc: Stephen Hemminger, David S. Miller, bridge, netdev, linux-kernel,
Vlad Yasevich
In-Reply-To: <CAPpVWGtgf1cLBq0fyXKbZnzAgzvoX2mm3sLYm5QS7us5H-0XKQ@mail.gmail.com>
Hi,
(CC: Vlad)
On 2017/11/30 7:01, Brandon Carpenter wrote:
> I narrowed the search to a memmove() called from
> skb_reorder_vlan_header() in net/core/skbuff.c.
>
>> memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len - VLAN_HLEN,
>> 2 * ETH_ALEN);
>
> Calling skb_reset_mac_len() after skb_reset_mac_header() before
> calling br_allowed_ingress() in net/bridge/br_device.c fixes the
> problem.
>
> diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
> index af5b8c87f590..e10131e2f68f 100644
> --- a/net/bridge/br_device.c
> +++ b/net/bridge/br_device.c
> @@ -58,6 +58,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct
> net_device *dev)
> BR_INPUT_SKB_CB(skb)->brdev = dev;
>
> skb_reset_mac_header(skb);
> + skb_reset_mac_len(skb);
> eth = eth_hdr(skb);
> skb_pull(skb, ETH_HLEN);
Thanks for debugging this problem.
It seems this has been broken since a6e18ff11170 ("vlan: Fix untag
operations of stacked vlans with REORDER_HEADER off").
Unfortunately this does not always work correctly, since in tx path
drivers assume network header to be set to L3 protocol header offset.
Packet socket (packet_snd()) determines network header by
dev_hard_header which is ETH_HLEN in bridge devices, so this works for
packet socket, but with vlan devices on top of bridge device with
tx-vlan hwaccel disabled we get ETH_HLEN + VLAN_HLEN or longer by mac_len.
Since mac_len can be arbitrarily long if we stack vlan devices on bridge
devices, and since we want to untag the outermost tag, using mac_len to
untag in tx path is probably no longer correct.
I'll think deeper about how to fix it.
> I'll put together an official patch and submit it. Should I use
> another email account? Are my emails being ignored because of that
> stupid disclaimer my employer attaches to my messages (outside my
> control)?
>
> Brandon
>
--
Toshiaki Makita
^ permalink raw reply
* Re: Transport mode xfrm_gro
From: Herbert Xu @ 2017-12-06 4:06 UTC (permalink / raw)
To: Steffen Klassert; +Cc: netdev
In-Reply-To: <20171206033717.GA20920@gondor.apana.org.au>
On Wed, Dec 06, 2017 at 02:37:17PM +1100, Herbert Xu wrote:
>
> So why is xfrm_input in the xfrm_gro case trying to reinject the
> skb into the network stack?
Nevermind, I see now that transport_finish has code to skip xfrm_gro
packets.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH net-next] tun: avoid unnecessary READ_ONCE in tun_net_xmit
From: Jason Wang @ 2017-12-06 3:39 UTC (permalink / raw)
To: Willem de Bruijn, netdev; +Cc: davem, Willem de Bruijn
In-Reply-To: <20171206031117.86588-1-willemdebruijn.kernel@gmail.com>
On 2017年12月06日 11:11, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
>
> The statement no longer serves a purpose.
>
> Commit fa35864e0bb7 ("tuntap: Fix for a race in accessing numqueues")
> added the ACCESS_ONCE to avoid a race condition with skb_queue_len.
>
> Commit 436accebb530 ("tuntap: remove unnecessary sk_receive_queue
> length check during xmit") removed the affected skb_queue_len check.
>
> Commit 96f84061620c ("tun: add eBPF based queue selection method")
> split the function, reading the field a second time in the callee.
> The temp variable is now only read once, so just remove it.
>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> ---
> drivers/net/tun.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 787cc35ef89b..c2ad8f3858d1 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -990,14 +990,12 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
> struct tun_struct *tun = netdev_priv(dev);
> int txq = skb->queue_mapping;
> struct tun_file *tfile;
> - u32 numqueues = 0;
>
> rcu_read_lock();
> tfile = rcu_dereference(tun->tfiles[txq]);
> - numqueues = READ_ONCE(tun->numqueues);
>
> /* Drop packet if interface is not attached */
> - if (txq >= numqueues)
> + if (txq >= tun->numqueues)
> goto drop;
>
> if (!rcu_dereference(tun->steering_prog))
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply
* Transport mode xfrm_gro
From: Herbert Xu @ 2017-12-06 3:37 UTC (permalink / raw)
To: Steffen Klassert; +Cc: netdev
Hi Steffen:
I'm looking at the function xfrm_input near the end where it deals
with transport mode packets:
err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async);
if (xfrm_gro) {
if (skb->sp)
skb->sp->olen = 0;
skb_dst_drop(skb);
gro_cells_receive(&gro_cells, skb);
return err;
}
This looks wrong because in transport mode, transport_finish is
well within its rights to consume and free the skb. For example,
IPv4 transport_finish eventually calls xfrm4_rcv_encap_finish which
does:
if (!skb_dst(skb)) {
const struct iphdr *iph = ip_hdr(skb);
if (ip_route_input_noref(skb, iph->daddr, iph->saddr,
iph->tos, skb->dev))
goto drop;
}
return dst_input(skb);
drop:
kfree_skb(skb);
return NET_RX_DROP;
Whichever path it takes the skb is either gone or belongs to someone
else.
So why is xfrm_input in the xfrm_gro case trying to reinject the
skb into the network stack?
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH] ptr_ring: add barriers
From: Jason Wang @ 2017-12-06 3:21 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-kernel, George Cherian, davem, edumazet, netdev,
virtualization
In-Reply-To: <20171206045247-mutt-send-email-mst@kernel.org>
On 2017年12月06日 10:53, Michael S. Tsirkin wrote:
> On Wed, Dec 06, 2017 at 10:31:39AM +0800, Jason Wang wrote:
>>
>> On 2017年12月06日 03:29, Michael S. Tsirkin wrote:
>>> Users of ptr_ring expect that it's safe to give the
>>> data structure a pointer and have it be available
>>> to consumers, but that actually requires an smb_wmb
>>> or a stronger barrier.
>>>
>>> In absence of such barriers and on architectures that reorder writes,
>>> consumer might read an un=initialized value from an skb pointer stored
>>> in the skb array. This was observed causing crashes.
>>>
>>> To fix, add memory barriers. The barrier we use is a wmb, the
>>> assumption being that producers do not need to read the value so we do
>>> not need to order these reads.
>>>
>>> Reported-by: George Cherian <george.cherian@cavium.com>
>>> Suggested-by: Jason Wang <jasowang@redhat.com>
>>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>>> ---
>>>
>>> George, could you pls report whether this patch fixes
>>> the issue for you?
>>>
>>> This seems to be needed in stable as well.
>>>
>>>
>>>
>>>
>>> include/linux/ptr_ring.h | 9 +++++++++
>>> 1 file changed, 9 insertions(+)
>>>
>>> diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
>>> index 37b4bb2..6866df4 100644
>>> --- a/include/linux/ptr_ring.h
>>> +++ b/include/linux/ptr_ring.h
>>> @@ -101,12 +101,18 @@ static inline bool ptr_ring_full_bh(struct ptr_ring *r)
>>> /* Note: callers invoking this in a loop must use a compiler barrier,
>>> * for example cpu_relax(). Callers must hold producer_lock.
>>> + * Callers are responsible for making sure pointer that is being queued
>>> + * points to a valid data.
>>> */
>>> static inline int __ptr_ring_produce(struct ptr_ring *r, void *ptr)
>>> {
>>> if (unlikely(!r->size) || r->queue[r->producer])
>>> return -ENOSPC;
>>> + /* Make sure the pointer we are storing points to a valid data. */
>>> + /* Pairs with smp_read_barrier_depends in __ptr_ring_consume. */
>>> + smp_wmb();
>>> +
>>> r->queue[r->producer++] = ptr;
>>> if (unlikely(r->producer >= r->size))
>>> r->producer = 0;
>>> @@ -275,6 +281,9 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r)
>>> if (ptr)
>>> __ptr_ring_discard_one(r);
>>> + /* Make sure anyone accessing data through the pointer is up to date. */
>>> + /* Pairs with smp_wmb in __ptr_ring_produce. */
>>> + smp_read_barrier_depends();
>>> return ptr;
>>> }
>> I was thinking whether or not it's better to move those to the callers. Then
>> we can save lots of barriers in e.g batch consuming.
>>
>> Thanks
> Batch consumers only do smp_read_barrier_depends which is free on
> non-alpha. I suggest we do the simple thing for stable and reserve
> optimizations for later.
>
Right.
Acked-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply
* Re: [PATCH net-next 00/12] sctp: Implement Stream Interleave: The I-DATA Chunk Supporting User Message Interleaving
From: Xin Long @ 2017-12-06 3:21 UTC (permalink / raw)
To: Marcelo Ricardo Leitner; +Cc: network dev, linux-sctp, Neil Horman, davem
In-Reply-To: <20171205173005.GB3328@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]
On Wed, Dec 6, 2017 at 1:30 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Tue, Dec 05, 2017 at 11:15:57PM +0800, Xin Long wrote:
>> Stream Interleave would be Implemented in two Parts:
>> 1. The I-DATA Chunk Supporting User Message Interleaving
>> 2. Interaction with Other SCTP Extensions
>>
>
> I have reviewed this patchset a couple of times already before the
> posting and other than the missing blank line (heh), it looks good to
> me. Would ack it now but we'll need a respin for the newline.
OK, thanks !
>
> Xin, please wait a bit before respining it. Maybe Neil and others have
> more comments on it.
Sure,
I added the part 2 (Interaction with Other SCTP Extensions) only
as an attachment here, so that it would be more clear to know the
big picture by checking it. (patchset_2.tar.gz)
I also added the test cases here I've done, based on sctp-tests
(conformance.tar.gz). It includes:
idata with ulp layer process
idata with stream reconfig
idata with stream scheduler
idata with sctp prsctp
idata with auth
(idata with sctp-tests others old tests)
and note that another file (debug.tar.gz) is some patches for sctp
to make these tests easier to be done.
[-- Attachment #2: conformance.tar.gz --]
[-- Type: application/x-gzip, Size: 14775 bytes --]
[-- Attachment #3: debug.tar.gz --]
[-- Type: application/x-gzip, Size: 4457 bytes --]
[-- Attachment #4: patchset_2.tar.gz --]
[-- Type: application/x-gzip, Size: 9138 bytes --]
^ permalink raw reply
* Re: [PATCH] netlink: Add netns check on taps
From: Kevin Cernekee @ 2017-12-06 3:14 UTC (permalink / raw)
To: David Ahern; +Cc: davem, Berg, Johannes, netdev, linux-kernel
In-Reply-To: <ca498c45-a37a-ec2e-1faa-5a6ff81384f5@gmail.com>
On Tue, Dec 5, 2017 at 6:19 PM, David Ahern <dsahern@gmail.com> wrote:
>> + if (!net_eq(dev_net(dev), sock_net(sk)) &&
>> + !net_eq(dev_net(dev), &init_net)) {
>
> Why is init_net special? Seems like snooping should be limited to the
> namespace you are in.
Depends how important it is to preserve the current "typical use case"
behavior, where the root user in the init netns can see all netlink
traffic on the system.
^ permalink raw reply
* [PATCH net-next] tun: avoid unnecessary READ_ONCE in tun_net_xmit
From: Willem de Bruijn @ 2017-12-06 3:11 UTC (permalink / raw)
To: netdev; +Cc: jasowang, davem, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
The statement no longer serves a purpose.
Commit fa35864e0bb7 ("tuntap: Fix for a race in accessing numqueues")
added the ACCESS_ONCE to avoid a race condition with skb_queue_len.
Commit 436accebb530 ("tuntap: remove unnecessary sk_receive_queue
length check during xmit") removed the affected skb_queue_len check.
Commit 96f84061620c ("tun: add eBPF based queue selection method")
split the function, reading the field a second time in the callee.
The temp variable is now only read once, so just remove it.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
drivers/net/tun.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 787cc35ef89b..c2ad8f3858d1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -990,14 +990,12 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
struct tun_struct *tun = netdev_priv(dev);
int txq = skb->queue_mapping;
struct tun_file *tfile;
- u32 numqueues = 0;
rcu_read_lock();
tfile = rcu_dereference(tun->tfiles[txq]);
- numqueues = READ_ONCE(tun->numqueues);
/* Drop packet if interface is not attached */
- if (txq >= numqueues)
+ if (txq >= tun->numqueues)
goto drop;
if (!rcu_dereference(tun->steering_prog))
--
2.15.1.424.g9478a66081-goog
^ permalink raw reply related
* Re: Linux 4.14 - regression: broken tun/tap / bridge network with virtio - bisected
From: Jason Wang @ 2017-12-06 3:08 UTC (permalink / raw)
To: Andreas Hartmann; +Cc: netdev, john.fastabend, Michal Kubecek
In-Reply-To: <401a0715-fd28-63a3-8dfd-e89835d70db0@01019freenet.de>
On 2017年12月06日 00:23, Andreas Hartmann wrote:
> On 12/05/2017 at 04:50 AM Jason Wang wrote:
>>
>> On 2017年12月05日 00:28, Andreas Hartmann wrote:
>>> On 12/03/2017 at 12:35 PM Andreas Hartmann wrote:
>>>> On 12/01/2017 at 11:11 AM Andreas Hartmann wrote:
>>>>> Hello!
>>>>>
>>>>> I hopefully could get rid of both of my problems (hanging network w/
>>>>> virtio) and endless hanging qemu-process on VM shutdown by upgrading
>>>>> qemu from 2.6.2 to 2.10.1. I hope it will persist.
>>>> It didn't persist. 10h later - same problems happened again. It's just
>>>> much harder to trigger the problems.
>>>>
>>>> I'm now trying it with
>>>>
>>>> CONFIG_RCU_NOCB_CPU=y and
>>>> rcu_nocbs=0-15
>>>>
>>>> Since then, I didn't see any problem any more. But this doesn't mean
>>>> anything until now ... .
>>> Didn't work ether. Disabling vhost_net's zcopy hadn't any effect, too.
>>>
>>> => It's just finally broken since
>>>
>>> 2ddf71e23cc246e95af72a6deed67b4a50a7b81c
>>> net: add notifier hooks for devmap bpf map
>> Hi:
>>
>> Did you use XDP devmap in host? If not, please double check it was the
>> first bad commit since the patch should only work when XDP/devmap is
>> used on host.
> How do I know if XDP/devmap is enabled / used? Could you please give
> some hint?
>
>
> Thanks,
> Andreas
Something like:
./ip link | grep xdp
10: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdp qdisc mq master
kvmbr0 state UNKNOWN mode DEFAULT group default qlen 1000
prog/xdp id 4 tag 0381911915bc8d7f
But you should have some recent version of ip.
Thanks
^ permalink raw reply
* Re: [PATCH] ptr_ring: add barriers
From: Michael S. Tsirkin @ 2017-12-06 2:53 UTC (permalink / raw)
To: Jason Wang
Cc: linux-kernel, George Cherian, davem, edumazet, netdev,
virtualization
In-Reply-To: <96e8cec4-37db-b41d-b02b-767a21d9efba@redhat.com>
On Wed, Dec 06, 2017 at 10:31:39AM +0800, Jason Wang wrote:
>
>
> On 2017年12月06日 03:29, Michael S. Tsirkin wrote:
> > Users of ptr_ring expect that it's safe to give the
> > data structure a pointer and have it be available
> > to consumers, but that actually requires an smb_wmb
> > or a stronger barrier.
> >
> > In absence of such barriers and on architectures that reorder writes,
> > consumer might read an un=initialized value from an skb pointer stored
> > in the skb array. This was observed causing crashes.
> >
> > To fix, add memory barriers. The barrier we use is a wmb, the
> > assumption being that producers do not need to read the value so we do
> > not need to order these reads.
> >
> > Reported-by: George Cherian <george.cherian@cavium.com>
> > Suggested-by: Jason Wang <jasowang@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > George, could you pls report whether this patch fixes
> > the issue for you?
> >
> > This seems to be needed in stable as well.
> >
> >
> >
> >
> > include/linux/ptr_ring.h | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
> > index 37b4bb2..6866df4 100644
> > --- a/include/linux/ptr_ring.h
> > +++ b/include/linux/ptr_ring.h
> > @@ -101,12 +101,18 @@ static inline bool ptr_ring_full_bh(struct ptr_ring *r)
> > /* Note: callers invoking this in a loop must use a compiler barrier,
> > * for example cpu_relax(). Callers must hold producer_lock.
> > + * Callers are responsible for making sure pointer that is being queued
> > + * points to a valid data.
> > */
> > static inline int __ptr_ring_produce(struct ptr_ring *r, void *ptr)
> > {
> > if (unlikely(!r->size) || r->queue[r->producer])
> > return -ENOSPC;
> > + /* Make sure the pointer we are storing points to a valid data. */
> > + /* Pairs with smp_read_barrier_depends in __ptr_ring_consume. */
> > + smp_wmb();
> > +
> > r->queue[r->producer++] = ptr;
> > if (unlikely(r->producer >= r->size))
> > r->producer = 0;
> > @@ -275,6 +281,9 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r)
> > if (ptr)
> > __ptr_ring_discard_one(r);
> > + /* Make sure anyone accessing data through the pointer is up to date. */
> > + /* Pairs with smp_wmb in __ptr_ring_produce. */
> > + smp_read_barrier_depends();
> > return ptr;
> > }
>
> I was thinking whether or not it's better to move those to the callers. Then
> we can save lots of barriers in e.g batch consuming.
>
> Thanks
Batch consumers only do smp_read_barrier_depends which is free on
non-alpha. I suggest we do the simple thing for stable and reserve
optimizations for later.
--
MST
^ permalink raw reply
* dsa: dsa_slave_port_obj_del calls multiple times with SWITCHDEV_OBJ_ID_HOST_MDB obj id
From: Tristram.Ha @ 2017-12-06 2:33 UTC (permalink / raw)
To: andrew, f.fainelli; +Cc: netdev, UNGLinuxDriver
I found the latest net-next kernel calls dsa_slave_port_obj_del() multiple times,
one for each port, with host port as the parameter.
As the base driver cannot find an entry with that host port, it returns an error
and so users will see a lot of failures from the DSA switch.
Is this a new behavior and the driver needs to handle that? In previous versions
I do not think I saw that.
Typical operation is a PC connected to a port in a switch wants to send multicast
packets. It broadcasts an IGMP membership join message. Function
dsa_slave_port_obj_add is called to setup an entry in the lookup table. When
IGMP membership leave message is received dsa_slave_port_obj_del will be
called after a delay. But then it is called for each port with host port as the
parameter.
Another issue is the host port can setup an entry for IPv6 neighbor discovery like
33:33:FF:??:??:??. When it leaves a failure message will be displayed for lan2,
lan3, and so on. It seems the first deletion is coming from lan1.
^ permalink raw reply
* Re: [PATCH] ptr_ring: add barriers
From: Jason Wang @ 2017-12-06 2:31 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel
Cc: George Cherian, davem, edumazet, netdev, virtualization
In-Reply-To: <1512501990-30029-1-git-send-email-mst@redhat.com>
On 2017年12月06日 03:29, Michael S. Tsirkin wrote:
> Users of ptr_ring expect that it's safe to give the
> data structure a pointer and have it be available
> to consumers, but that actually requires an smb_wmb
> or a stronger barrier.
>
> In absence of such barriers and on architectures that reorder writes,
> consumer might read an un=initialized value from an skb pointer stored
> in the skb array. This was observed causing crashes.
>
> To fix, add memory barriers. The barrier we use is a wmb, the
> assumption being that producers do not need to read the value so we do
> not need to order these reads.
>
> Reported-by: George Cherian <george.cherian@cavium.com>
> Suggested-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> George, could you pls report whether this patch fixes
> the issue for you?
>
> This seems to be needed in stable as well.
>
>
>
>
> include/linux/ptr_ring.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
> index 37b4bb2..6866df4 100644
> --- a/include/linux/ptr_ring.h
> +++ b/include/linux/ptr_ring.h
> @@ -101,12 +101,18 @@ static inline bool ptr_ring_full_bh(struct ptr_ring *r)
>
> /* Note: callers invoking this in a loop must use a compiler barrier,
> * for example cpu_relax(). Callers must hold producer_lock.
> + * Callers are responsible for making sure pointer that is being queued
> + * points to a valid data.
> */
> static inline int __ptr_ring_produce(struct ptr_ring *r, void *ptr)
> {
> if (unlikely(!r->size) || r->queue[r->producer])
> return -ENOSPC;
>
> + /* Make sure the pointer we are storing points to a valid data. */
> + /* Pairs with smp_read_barrier_depends in __ptr_ring_consume. */
> + smp_wmb();
> +
> r->queue[r->producer++] = ptr;
> if (unlikely(r->producer >= r->size))
> r->producer = 0;
> @@ -275,6 +281,9 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r)
> if (ptr)
> __ptr_ring_discard_one(r);
>
> + /* Make sure anyone accessing data through the pointer is up to date. */
> + /* Pairs with smp_wmb in __ptr_ring_produce. */
> + smp_read_barrier_depends();
> return ptr;
> }
>
I was thinking whether or not it's better to move those to the callers.
Then we can save lots of barriers in e.g batch consuming.
Thanks
^ permalink raw reply
* Re: [PATCH net-next V3] tun: add eBPF based queue selection method
From: Jason Wang @ 2017-12-06 2:30 UTC (permalink / raw)
To: David Miller
Cc: netdev, linux-kernel, mst, willemdebruijn.kernel, tom, aconole,
wexu
In-Reply-To: <20171205.120218.108578256595160504.davem@davemloft.net>
On 2017年12月06日 01:02, David Miller wrote:
> From: Jason Wang <jasowang@redhat.com>
> Date: Mon, 4 Dec 2017 17:31:23 +0800
>
>> This patch introduces an eBPF based queue selection method. With this,
>> the policy could be offloaded to userspace completely through a new
>> ioctl TUNSETSTEERINGEBPF.
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>> Changes from V2:
>> - call rtnl during netdev free
>> - switch to use call_rcu() to prevent DOS from userspace
>> - drop the policies setting/getting ioctls and allow detach through
>> passing -1 as fd
> Applied, thanks Jason.
>
> I really wish this driver had newlink/changelink support rather than
> us adding all of these ioctls...
Yes, will add this in my todo list.
Thanks
^ permalink raw reply
* Re: [PATCH] netlink: Add netns check on taps
From: David Ahern @ 2017-12-06 2:19 UTC (permalink / raw)
To: Kevin Cernekee, davem; +Cc: johannes.berg, netdev, linux-kernel
In-Reply-To: <1512513982-20407-1-git-send-email-cernekee@chromium.org>
On 12/5/17 3:46 PM, Kevin Cernekee wrote:
> Currently, a nlmon link inside a child namespace can observe systemwide
> netlink activity. Filter the traffic so that in a non-init netns,
> nlmon can only sniff netlink messages from its own netns.
>
> Test case:
>
> vpnns -- bash -c "ip link add nlmon0 type nlmon; \
> ip link set nlmon0 up; \
> tcpdump -i nlmon0 -q -w /tmp/nlmon.pcap -U" &
> sudo ip xfrm state add src 10.1.1.1 dst 10.1.1.2 proto esp \
> spi 0x1 mode transport \
> auth sha1 0x6162633132330000000000000000000000000000 \
> enc aes 0x00000000000000000000000000000000
> grep abc123 /tmp/nlmon.pcap
>
> Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
> ---
> net/netlink/af_netlink.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index b9e0ee4..88381a2 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -253,6 +253,11 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,
> struct sock *sk = skb->sk;
> int ret = -ENOMEM;
>
> + if (!net_eq(dev_net(dev), sock_net(sk)) &&
> + !net_eq(dev_net(dev), &init_net)) {
Why is init_net special? Seems like snooping should be limited to the
namespace you are in.
^ permalink raw reply
* [PATCH net] enic: add wq clean up budget
From: Govindarajulu Varadarajan @ 2017-12-05 19:14 UTC (permalink / raw)
To: davem, netdev; +Cc: govindarajulu90, benve, Govindarajulu Varadarajan
In case of tx clean up, we set '-1' as budget. This means clean up until
wq is empty or till (1 << 32) pkts are cleaned. Under heavy load this
will run for long time and cause
"watchdog: BUG: soft lockup - CPU#25 stuck for 21s!" warning.
This patch sets wq clean up budget to 256.
Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
---
drivers/net/ethernet/cisco/enic/enic.h | 2 ++
drivers/net/ethernet/cisco/enic/enic_main.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic.h b/drivers/net/ethernet/cisco/enic/enic.h
index 6a9527004cb1..9b218f0e5a4c 100644
--- a/drivers/net/ethernet/cisco/enic/enic.h
+++ b/drivers/net/ethernet/cisco/enic/enic.h
@@ -43,6 +43,8 @@
#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX)
#define ENIC_INTR_MAX (ENIC_CQ_MAX + 2)
+#define ENIC_WQ_NAPI_BUDGET 256
+
#define ENIC_AIC_LARGE_PKT_DIFF 3
struct enic_msix_entry {
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index d98676e43e03..f202ba72a811 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1500,7 +1500,7 @@ static int enic_poll(struct napi_struct *napi, int budget)
unsigned int cq_wq = enic_cq_wq(enic, 0);
unsigned int intr = enic_legacy_io_intr();
unsigned int rq_work_to_do = budget;
- unsigned int wq_work_to_do = -1; /* no limit */
+ unsigned int wq_work_to_do = ENIC_WQ_NAPI_BUDGET;
unsigned int work_done, rq_work_done = 0, wq_work_done;
int err;
@@ -1598,7 +1598,7 @@ static int enic_poll_msix_wq(struct napi_struct *napi, int budget)
struct vnic_wq *wq = &enic->wq[wq_index];
unsigned int cq;
unsigned int intr;
- unsigned int wq_work_to_do = -1; /* clean all desc possible */
+ unsigned int wq_work_to_do = ENIC_WQ_NAPI_BUDGET;
unsigned int wq_work_done;
unsigned int wq_irq;
--
2.15.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox