* [PATCH v3 4/4] tools: add selftest for BPF_F_ZERO_SEED
From: Lorenz Bauer @ 2018-11-16 11:41 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-api, songliubraving, Lorenz Bauer
In-Reply-To: <20181116114111.31177-1-lmb@cloudflare.com>
Check that iterating two separate hash maps produces the same
order of keys if BPF_F_ZERO_SEED is used.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
tools/testing/selftests/bpf/test_maps.c | 68 +++++++++++++++++++++----
1 file changed, 57 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 4db2116e52be..9f0a5b16a246 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -258,23 +258,35 @@ static void test_hashmap_percpu(int task, void *data)
close(fd);
}
+static int helper_fill_hashmap(int max_entries)
+{
+ int i, fd, ret;
+ long long key, value;
+
+ fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
+ max_entries, map_flags);
+ CHECK(fd < 0,
+ "failed to create hashmap",
+ "err: %s, flags: 0x%x\n", strerror(errno), map_flags);
+
+ for (i = 0; i < max_entries; i++) {
+ key = i; value = key;
+ ret = bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST);
+ CHECK(ret != 0,
+ "can't update hashmap",
+ "err: %s\n", strerror(ret));
+ }
+
+ return fd;
+}
+
static void test_hashmap_walk(int task, void *data)
{
int fd, i, max_entries = 1000;
long long key, value, next_key;
bool next_key_valid = true;
- fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(key), sizeof(value),
- max_entries, map_flags);
- if (fd < 0) {
- printf("Failed to create hashmap '%s'!\n", strerror(errno));
- exit(1);
- }
-
- for (i = 0; i < max_entries; i++) {
- key = i; value = key;
- assert(bpf_map_update_elem(fd, &key, &value, BPF_NOEXIST) == 0);
- }
+ fd = helper_fill_hashmap(max_entries);
for (i = 0; bpf_map_get_next_key(fd, !i ? NULL : &key,
&next_key) == 0; i++) {
@@ -306,6 +318,39 @@ static void test_hashmap_walk(int task, void *data)
close(fd);
}
+static void test_hashmap_zero_seed(void)
+{
+ int i, first, second, old_flags;
+ long long key, next_first, next_second;
+
+ old_flags = map_flags;
+ map_flags |= BPF_F_ZERO_SEED;
+
+ first = helper_fill_hashmap(3);
+ second = helper_fill_hashmap(3);
+
+ for (i = 0; ; i++) {
+ void *key_ptr = !i ? NULL : &key;
+
+ if (bpf_map_get_next_key(first, key_ptr, &next_first) != 0)
+ break;
+
+ CHECK(bpf_map_get_next_key(second, key_ptr, &next_second) != 0,
+ "next_key for second map must succeed",
+ "key_ptr: %p", key_ptr);
+ CHECK(next_first != next_second,
+ "keys must match",
+ "i: %d first: %lld second: %lld\n", i,
+ next_first, next_second);
+
+ key = next_first;
+ }
+
+ map_flags = old_flags;
+ close(first);
+ close(second);
+}
+
static void test_arraymap(int task, void *data)
{
int key, next_key, fd;
@@ -1534,6 +1579,7 @@ static void run_all_tests(void)
test_hashmap(0, NULL);
test_hashmap_percpu(0, NULL);
test_hashmap_walk(0, NULL);
+ test_hashmap_zero_seed();
test_arraymap(0, NULL);
test_arraymap_percpu(0, NULL);
--
2.17.1
^ permalink raw reply related
* Re: [PATCH bpf-next] bpf: support raw tracepoints in modules
From: kbuild test robot @ 2018-11-16 21:55 UTC (permalink / raw)
To: Matt Mullins
Cc: kbuild-all, ast, daniel, netdev, kernel-team, Matt Mullins,
Jessica Yu, Steven Rostedt, Ingo Molnar, linux-kernel
In-Reply-To: <20181109220632.3944136-1-mmullins@fb.com>
Hi Matt,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Matt-Mullins/bpf-support-raw-tracepoints-in-modules/20181110-144839
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
smatch warnings:
kernel/trace/bpf_trace.c:1284 bpf_event_notify() error: potential null dereference 'btm'. (kzalloc returns null)
vim +/btm +1284 kernel/trace/bpf_trace.c
1269
1270 #ifdef CONFIG_MODULES
1271 int bpf_event_notify(struct notifier_block *nb, unsigned long op, void *module)
1272 {
1273 struct bpf_trace_module *btm, *tmp;
1274 struct module *mod = module;
1275
1276 if (mod->num_bpf_raw_events == 0)
1277 return 0;
1278
1279 mutex_lock(&bpf_module_mutex);
1280
1281 switch (op) {
1282 case MODULE_STATE_COMING:
1283 btm = kzalloc(sizeof(*btm), GFP_KERNEL);
> 1284 btm->module = module;
1285 list_add(&btm->list, &bpf_trace_modules);
1286 break;
1287 case MODULE_STATE_GOING:
1288 list_for_each_entry_safe(btm, tmp, &bpf_trace_modules, list) {
1289 if (btm->module == module) {
1290 list_del(&btm->list);
1291 kfree(btm);
1292 break;
1293 }
1294 }
1295 break;
1296 }
1297
1298 mutex_unlock(&bpf_module_mutex);
1299
1300 return 0;
1301 }
1302
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply
* Re: kernel BUG at mm/slab.c:LINE! (3)
From: Dmitry Vyukov @ 2018-11-16 21:56 UTC (permalink / raw)
To: syzbot, netdev, David Miller; +Cc: LKML, syzkaller-bugs
In-Reply-To: <0000000000005b7456057a9abc57@google.com>
On Tue, Nov 13, 2018 at 11:18 PM, syzbot
<syzbot+2182db487a523d86bf34@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: 3e536cff3424 net: phy: check if advertising is zero using ..
> git tree: net-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=16f95b83400000
> kernel config: https://syzkaller.appspot.com/x/.config?x=4a0a89f12ca9b0f5
> dashboard link: https://syzkaller.appspot.com/bug?extid=2182db487a523d86bf34
> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=148d46d5400000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15c6a225400000
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+2182db487a523d86bf34@syzkaller.appspotmail.com
All reproducers just do something simple with inet6 sockets and all
crashes are on net-next, so +netdev
r0 = socket$inet6(0xa, 0x2, 0x0)
connect$inet6(r0, &(0x7f0000000080)={0xa, 0x4e24, 0x0, @ipv4={[], [],
@loopback}}, 0x1c)
sendmmsg(r0, &(0x7f00000092c0), 0x3ffffffffff0c00, 0x0)
> ------------[ cut here ]------------
> DEBUG_LOCKS_WARN_ON(depth >= MAX_LOCK_DEPTH)
> ------------[ cut here ]------------
> kernel BUG at mm/slab.c:4425!
> invalid opcode: 0000 [#1] PREEMPT SMP KASAN
> CPU: 0 PID: -642842048 Comm: ksoftirqd/0 Not tainted 4.20.0-rc2+ #294
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> RIP: 0010:__check_heap_object+0xa7/0xb5 mm/slab.c:4450
> Code: 48 c7 c7 15 73 12 89 e8 97 e3 0a 00 5d c3 41 8b 91 04 01 00 00 48 29
> c7 48 39 d7 77 be 48 01 d0 48 29 c8 48 39 f0 72 b3 5d c3 <0f> 0b 48 c7 c7 15
> 73 12 89 e8 fd eb 0a 00 44 89 e9 48 c7 c7 d0 73
> RSP: 0018:ffff8881d9af0030 EFLAGS: 00010093
> RAX: 00000000000a57eb RBX: 1ffff1103b35e00d RCX: 000000000000000c
> RDX: ffff8881d9af0240 RSI: 0000000000000002 RDI: ffff8881d9af01d8
> RBP: ffff8881d9af0030 R08: ffff8881d9af0240 R09: ffff8881da970180
> R10: 000000004afd69e7 R11: 0000000000000000 R12: ffff8881d9af01d8
> R13: 0000000000000002 R14: ffffea000766bc00 R15: 0000000000000001
> FS: 0000000000000000(0000) GS:ffff8881dae00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000000000068 CR3: 00000001bb987000 CR4: 00000000001406f0
> Call Trace:
> Modules linked in:
> ---[ end trace 1c9eb38e9e38ee03 ]---
> RIP: 0010:__check_heap_object+0xa7/0xb5 mm/slab.c:4450
> Code: 48 c7 c7 15 73 12 89 e8 97 e3 0a 00 5d c3 41 8b 91 04 01 00 00 48 29
> c7 48 39 d7 77 be 48 01 d0 48 29 c8 48 39 f0 72 b3 5d c3 <0f> 0b 48 c7 c7 15
> 73 12 89 e8 fd eb 0a 00 44 89 e9 48 c7 c7 d0 73
> RSP: 0018:ffff8881d9af0030 EFLAGS: 00010093
> RAX: 00000000000a57eb RBX: 1ffff1103b35e00d RCX: 000000000000000c
> RDX: ffff8881d9af0240 RSI: 0000000000000002 RDI: ffff8881d9af01d8
> RBP: ffff8881d9af0030 R08: ffff8881d9af0240 R09: ffff8881da970180
> R10: 000000004afd69e7 R11: 0000000000000000 R12: ffff8881d9af01d8
> R13: 0000000000000002 R14: ffffea000766bc00 R15: 0000000000000001
> FS: 0000000000000000(0000) GS:ffff8881dae00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000000000068 CR3: 00000001bb987000 CR4: 00000000001406f0
>
>
> ---
> This bug is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
>
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
> syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/syzkaller-bugs/0000000000005b7456057a9abc57%40google.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply
* [PATCH] atm: Convert to using %pOFn instead of device_node.name
From: Rob Herring @ 2018-11-16 22:05 UTC (permalink / raw)
To: Chas Williams; +Cc: devicetree, linux-kernel, linux-atm-general, netdev
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.
Cc: Chas Williams <3chas3@gmail.com>
Cc: linux-atm-general@lists.sourceforge.net
Cc: netdev@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/atm/fore200e.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index f55ffde877b5..14053e01a2cc 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -754,8 +754,8 @@ static int fore200e_sba_proc_read(struct fore200e *fore200e, char *page)
regs = of_get_property(op->dev.of_node, "reg", NULL);
- return sprintf(page, " SBUS slot/device:\t\t%d/'%s'\n",
- (regs ? regs->which_io : 0), op->dev.of_node->name);
+ return sprintf(page, " SBUS slot/device:\t\t%d/'%pOFn'\n",
+ (regs ? regs->which_io : 0), op->dev.of_node);
}
static const struct fore200e_bus fore200e_sbus_ops = {
--
2.19.1
^ permalink raw reply related
* WARNING in cttimeout_default_get
From: syzbot @ 2018-11-16 22:09 UTC (permalink / raw)
To: coreteam, davem, fw, kadlec, linux-kernel, netdev,
netfilter-devel, pablo, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: da5322e65940 Merge tag 'selinux-pr-20181115' of git://git...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15d719eb400000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a0a89f12ca9b0f5
dashboard link: https://syzkaller.appspot.com/bug?extid=2fae8fa157dd92618cae
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=129e0893400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=125f66a3400000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+2fae8fa157dd92618cae@syzkaller.appspotmail.com
audit: type=1800 audit(1542315810.422:30): pid=5877 uid=0 auid=4294967295
ses=4294967295 subj==unconfined op=collect_data cause=failed(directio)
comm="startpar" name="rmnologin" dev="sda1" ino=2423 res=0
netlink: 'syz-executor298': attribute type 3 has an invalid length.
netlink: 'syz-executor298': attribute type 2 has an invalid length.
WARNING: CPU: 0 PID: 6032 at net/netfilter/nfnetlink_cttimeout.c:478
cttimeout_default_get+0x1df/0xb30 net/netfilter/nfnetlink_cttimeout.c:478
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 6032 Comm: syz-executor298 Not tainted 4.20.0-rc2+ #336
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x244/0x39d lib/dump_stack.c:113
panic+0x2ad/0x55c kernel/panic.c:188
__warn.cold.8+0x20/0x45 kernel/panic.c:540
report_bug+0x254/0x2d0 lib/bug.c:186
fixup_bug arch/x86/kernel/traps.c:178 [inline]
do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271
do_invalid_op+0x36/0x40 arch/x86/kernel/traps.c:290
invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:969
RIP: 0010:cttimeout_default_get+0x1df/0xb30
net/netfilter/nfnetlink_cttimeout.c:478
Code: 00 0f 87 8d 00 00 00 41 80 ff 06 0f 84 94 07 00 00 41 80 ff 11 0f 84
6c 07 00 00 41 80 ff 01 0f 84 44 07 00 00 e8 91 f1 20 fb <0f> 0b 41 bd a1
ff ff ff eb 06 41 bd a1 ff ff ff e8 7c f1 20 fb 48
RSP: 0018:ffff8881b64c72b0 EFLAGS: 00010293
RAX: ffff8881c1686380 RBX: ffffffff88bf58e0 RCX: ffffffff865e961c
RDX: 0000000000000000 RSI: ffffffff865e964f RDI: 0000000000000001
RBP: ffff8881b64c73c0 R08: ffff8881c1686380 R09: ffffed103b5c5b67
R10: 0000000000000002 R11: ffff8881dae2db3b R12: 0000000000000088
R13: ffff8881bf42b300 R14: 0000000000000000 R15: 0000000000000088
nfnetlink_rcv_msg+0xdd3/0x10c0 net/netfilter/nfnetlink.c:228
netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2477
nfnetlink_rcv+0x1c0/0x4d0 net/netfilter/nfnetlink.c:560
netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
netlink_unicast+0x5a5/0x760 net/netlink/af_netlink.c:1336
netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1917
sock_sendmsg_nosec net/socket.c:621 [inline]
sock_sendmsg+0xd5/0x120 net/socket.c:631
___sys_sendmsg+0x7fd/0x930 net/socket.c:2116
__sys_sendmsg+0x11d/0x280 net/socket.c:2154
__do_sys_sendmsg net/socket.c:2163 [inline]
__se_sys_sendmsg net/socket.c:2161 [inline]
__x64_sys_sendmsg+0x78/0xb0 net/socket.c:2161
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4400d9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc704c30c8 EFLAGS: 00000213 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004400d9
RDX: 0000000000000000 RSI: 0000000020dddfc8 RDI: 0000000000000003
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000213 R12: 0000000000401960
R13: 00000000004019f0 R14: 0000000000000000 R15: 0000000000000000
Kernel Offset: disabled
Rebooting in 86400 seconds..
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply
* [PATCH] net: fsl: Use device_type helpers to access the node type
From: Rob Herring @ 2018-11-16 22:11 UTC (permalink / raw)
To: David S. Miller; +Cc: devicetree, linux-kernel, netdev
Remove directly accessing device_node.type pointer and use the accessors
instead. This will eventually allow removing the type pointer.
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 82722d05fedb..88a396fd242f 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -473,7 +473,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
if (data->get_tbipa) {
for_each_child_of_node(np, tbi) {
- if (strcmp(tbi->type, "tbi-phy") == 0) {
+ if (of_node_is_type(tbi, "tbi-phy")) {
dev_dbg(&pdev->dev, "found TBI PHY node %pOFP\n",
tbi);
break;
--
2.19.1
^ permalink raw reply related
* [PATCH net V3 0/5] net/smc: fixes 2018-11-12
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
Dave,
here is V3 of some net/smc fixes in different areas for the net tree.
v1->v2:
do not define 8-byte alignment for union smcd_cdc_cursor in
patch 4/5 "net/smc: atomic SMCD cursor handling"
v2->v3:
stay with 8-byte alignment for union smcd_cdc_cursor in
patch 4/5 "net/smc: atomic SMCD cursor handling", but get rid of
__packed for struct smcd_cdc_msg
Thanks, Ursula
Hans Wippel (2):
net/smc: abort CLC connection in smc_release
net/smc: add SMC-D shutdown signal
Karsten Graul (1):
net/smc: use queue pair number when matching link group
Ursula Braun (2):
net/smc: atomic SMCD cursor handling
net/smc: use after free fix in smc_wr_tx_put_slot()
net/smc/af_smc.c | 11 +++++++----
net/smc/smc_cdc.c | 24 ++++++++++++----------
net/smc/smc_cdc.h | 58 +++++++++++++++++++++++++++++++++++++++++-------------
net/smc/smc_core.c | 20 +++++++++++++------
net/smc/smc_core.h | 5 +++--
net/smc/smc_ism.c | 43 +++++++++++++++++++++++++++++-----------
net/smc/smc_ism.h | 1 +
net/smc/smc_wr.c | 4 +++-
8 files changed, 118 insertions(+), 48 deletions(-)
--
2.16.4
^ permalink raw reply
* [PATCH net V3 1/5] net/smc: abort CLC connection in smc_release
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20181116123617.72948-1-ubraun@linux.ibm.com>
From: Hans Wippel <hwippel@linux.ibm.com>
In case of a non-blocking SMC socket, the initial CLC handshake is
performed over a blocking TCP connection in a worker. If the SMC socket
is released, smc_release has to wait for the blocking CLC socket
operations (e.g., kernel_connect) inside the worker.
This patch aborts a CLC connection when the respective non-blocking SMC
socket is released to avoid waiting on socket operations or timeouts.
Signed-off-by: Hans Wippel <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/af_smc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 80e2119f1c70..84f67f601838 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -127,6 +127,8 @@ static int smc_release(struct socket *sock)
smc = smc_sk(sk);
/* cleanup for a dangling non-blocking connect */
+ if (smc->connect_info && sk->sk_state == SMC_INIT)
+ tcp_abort(smc->clcsock->sk, ECONNABORTED);
flush_work(&smc->connect_work);
kfree(smc->connect_info);
smc->connect_info = NULL;
--
2.16.4
^ permalink raw reply related
* [PATCH net V3 2/5] net/smc: use queue pair number when matching link group
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20181116123617.72948-1-ubraun@linux.ibm.com>
From: Karsten Graul <kgraul@linux.ibm.com>
When searching for an existing link group the queue pair number is also
to be taken into consideration. When the SMC server sends a new number
in a CLC packet (keeping all other values equal) then a new link group
is to be created on the SMC client side.
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/af_smc.c | 9 +++++----
net/smc/smc_core.c | 10 ++++++----
net/smc/smc_core.h | 2 +-
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 84f67f601838..5fbaf1901571 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -549,7 +549,8 @@ static int smc_connect_rdma(struct smc_sock *smc,
mutex_lock(&smc_create_lgr_pending);
local_contact = smc_conn_create(smc, false, aclc->hdr.flag, ibdev,
- ibport, &aclc->lcl, NULL, 0);
+ ibport, ntoh24(aclc->qpn), &aclc->lcl,
+ NULL, 0);
if (local_contact < 0) {
if (local_contact == -ENOMEM)
reason_code = SMC_CLC_DECL_MEM;/* insufficient memory*/
@@ -620,7 +621,7 @@ static int smc_connect_ism(struct smc_sock *smc,
int rc = 0;
mutex_lock(&smc_create_lgr_pending);
- local_contact = smc_conn_create(smc, true, aclc->hdr.flag, NULL, 0,
+ local_contact = smc_conn_create(smc, true, aclc->hdr.flag, NULL, 0, 0,
NULL, ismdev, aclc->gid);
if (local_contact < 0)
return smc_connect_abort(smc, SMC_CLC_DECL_MEM, 0);
@@ -1085,7 +1086,7 @@ static int smc_listen_rdma_init(struct smc_sock *new_smc,
int *local_contact)
{
/* allocate connection / link group */
- *local_contact = smc_conn_create(new_smc, false, 0, ibdev, ibport,
+ *local_contact = smc_conn_create(new_smc, false, 0, ibdev, ibport, 0,
&pclc->lcl, NULL, 0);
if (*local_contact < 0) {
if (*local_contact == -ENOMEM)
@@ -1109,7 +1110,7 @@ static int smc_listen_ism_init(struct smc_sock *new_smc,
struct smc_clc_msg_smcd *pclc_smcd;
pclc_smcd = smc_get_clc_msg_smcd(pclc);
- *local_contact = smc_conn_create(new_smc, true, 0, NULL, 0, NULL,
+ *local_contact = smc_conn_create(new_smc, true, 0, NULL, 0, 0, NULL,
ismdev, pclc_smcd->gid);
if (*local_contact < 0) {
if (*local_contact == -ENOMEM)
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 18daebcef181..3c023de58afd 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -559,7 +559,7 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, unsigned short *vlan_id)
static bool smcr_lgr_match(struct smc_link_group *lgr,
struct smc_clc_msg_local *lcl,
- enum smc_lgr_role role)
+ enum smc_lgr_role role, u32 clcqpn)
{
return !memcmp(lgr->peer_systemid, lcl->id_for_peer,
SMC_SYSTEMID_LEN) &&
@@ -567,7 +567,9 @@ static bool smcr_lgr_match(struct smc_link_group *lgr,
SMC_GID_SIZE) &&
!memcmp(lgr->lnk[SMC_SINGLE_LINK].peer_mac, lcl->mac,
sizeof(lcl->mac)) &&
- lgr->role == role;
+ lgr->role == role &&
+ (lgr->role == SMC_SERV ||
+ lgr->lnk[SMC_SINGLE_LINK].peer_qpn == clcqpn);
}
static bool smcd_lgr_match(struct smc_link_group *lgr,
@@ -578,7 +580,7 @@ static bool smcd_lgr_match(struct smc_link_group *lgr,
/* create a new SMC connection (and a new link group if necessary) */
int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
- struct smc_ib_device *smcibdev, u8 ibport,
+ struct smc_ib_device *smcibdev, u8 ibport, u32 clcqpn,
struct smc_clc_msg_local *lcl, struct smcd_dev *smcd,
u64 peer_gid)
{
@@ -603,7 +605,7 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
list_for_each_entry(lgr, &smc_lgr_list.list, list) {
write_lock_bh(&lgr->conns_lock);
if ((is_smcd ? smcd_lgr_match(lgr, smcd, peer_gid) :
- smcr_lgr_match(lgr, lcl, role)) &&
+ smcr_lgr_match(lgr, lcl, role, clcqpn)) &&
!lgr->sync_err &&
lgr->vlan_id == vlan_id &&
(role == SMC_CLNT ||
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
index c156674733c9..5bc6cbaf0ed5 100644
--- a/net/smc/smc_core.h
+++ b/net/smc/smc_core.h
@@ -262,7 +262,7 @@ int smc_vlan_by_tcpsk(struct socket *clcsock, unsigned short *vlan_id);
void smc_conn_free(struct smc_connection *conn);
int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact,
- struct smc_ib_device *smcibdev, u8 ibport,
+ struct smc_ib_device *smcibdev, u8 ibport, u32 clcqpn,
struct smc_clc_msg_local *lcl, struct smcd_dev *smcd,
u64 peer_gid);
void smcd_conn_free(struct smc_connection *conn);
--
2.16.4
^ permalink raw reply related
* [PATCH net V3 3/5] net/smc: add SMC-D shutdown signal
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20181116123617.72948-1-ubraun@linux.ibm.com>
From: Hans Wippel <hwippel@linux.ibm.com>
When a SMC-D link group is freed, a shutdown signal should be sent to
the peer to indicate that the link group is invalid. This patch adds the
shutdown signal to the SMC code.
Signed-off-by: Hans Wippel <hwippel@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/smc_core.c | 10 ++++++++--
net/smc/smc_core.h | 3 ++-
net/smc/smc_ism.c | 43 ++++++++++++++++++++++++++++++++-----------
net/smc/smc_ism.h | 1 +
4 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 3c023de58afd..1c9fa7f0261a 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -184,6 +184,8 @@ static void smc_lgr_free_work(struct work_struct *work)
if (!lgr->is_smcd && lnk->state != SMC_LNK_INACTIVE)
smc_llc_link_inactive(lnk);
+ if (lgr->is_smcd)
+ smc_ism_signal_shutdown(lgr);
smc_lgr_free(lgr);
}
}
@@ -485,7 +487,7 @@ void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport)
}
/* Called when SMC-D device is terminated or peer is lost */
-void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid)
+void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid, unsigned short vlan)
{
struct smc_link_group *lgr, *l;
LIST_HEAD(lgr_free_list);
@@ -495,7 +497,7 @@ void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid)
list_for_each_entry_safe(lgr, l, &smc_lgr_list.list, list) {
if (lgr->is_smcd && lgr->smcd == dev &&
(!peer_gid || lgr->peer_gid == peer_gid) &&
- !list_empty(&lgr->list)) {
+ (vlan == VLAN_VID_MASK || lgr->vlan_id == vlan)) {
__smc_lgr_terminate(lgr);
list_move(&lgr->list, &lgr_free_list);
}
@@ -506,6 +508,8 @@ void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid)
list_for_each_entry_safe(lgr, l, &lgr_free_list, list) {
list_del_init(&lgr->list);
cancel_delayed_work_sync(&lgr->free_work);
+ if (!peer_gid && vlan == VLAN_VID_MASK) /* dev terminated? */
+ smc_ism_signal_shutdown(lgr);
smc_lgr_free(lgr);
}
}
@@ -1026,6 +1030,8 @@ void smc_core_exit(void)
smc_llc_link_inactive(lnk);
}
cancel_delayed_work_sync(&lgr->free_work);
+ if (lgr->is_smcd)
+ smc_ism_signal_shutdown(lgr);
smc_lgr_free(lgr); /* free link group */
}
}
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
index 5bc6cbaf0ed5..cf98f4d6093e 100644
--- a/net/smc/smc_core.h
+++ b/net/smc/smc_core.h
@@ -247,7 +247,8 @@ void smc_lgr_free(struct smc_link_group *lgr);
void smc_lgr_forget(struct smc_link_group *lgr);
void smc_lgr_terminate(struct smc_link_group *lgr);
void smc_port_terminate(struct smc_ib_device *smcibdev, u8 ibport);
-void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid);
+void smc_smcd_terminate(struct smcd_dev *dev, u64 peer_gid,
+ unsigned short vlan);
int smc_buf_create(struct smc_sock *smc, bool is_smcd);
int smc_uncompress_bufsize(u8 compressed);
int smc_rmb_rtoken_handling(struct smc_connection *conn,
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
index e36f21ce7252..2fff79db1a59 100644
--- a/net/smc/smc_ism.c
+++ b/net/smc/smc_ism.c
@@ -187,22 +187,28 @@ struct smc_ism_event_work {
#define ISM_EVENT_REQUEST 0x0001
#define ISM_EVENT_RESPONSE 0x0002
#define ISM_EVENT_REQUEST_IR 0x00000001
+#define ISM_EVENT_CODE_SHUTDOWN 0x80
#define ISM_EVENT_CODE_TESTLINK 0x83
+union smcd_sw_event_info {
+ u64 info;
+ struct {
+ u8 uid[SMC_LGR_ID_SIZE];
+ unsigned short vlan_id;
+ u16 code;
+ };
+};
+
static void smcd_handle_sw_event(struct smc_ism_event_work *wrk)
{
- union {
- u64 info;
- struct {
- u32 uid;
- unsigned short vlanid;
- u16 code;
- };
- } ev_info;
+ union smcd_sw_event_info ev_info;
+ ev_info.info = wrk->event.info;
switch (wrk->event.code) {
+ case ISM_EVENT_CODE_SHUTDOWN: /* Peer shut down DMBs */
+ smc_smcd_terminate(wrk->smcd, wrk->event.tok, ev_info.vlan_id);
+ break;
case ISM_EVENT_CODE_TESTLINK: /* Activity timer */
- ev_info.info = wrk->event.info;
if (ev_info.code == ISM_EVENT_REQUEST) {
ev_info.code = ISM_EVENT_RESPONSE;
wrk->smcd->ops->signal_event(wrk->smcd,
@@ -215,6 +221,21 @@ static void smcd_handle_sw_event(struct smc_ism_event_work *wrk)
}
}
+int smc_ism_signal_shutdown(struct smc_link_group *lgr)
+{
+ int rc;
+ union smcd_sw_event_info ev_info;
+
+ memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE);
+ ev_info.vlan_id = lgr->vlan_id;
+ ev_info.code = ISM_EVENT_REQUEST;
+ rc = lgr->smcd->ops->signal_event(lgr->smcd, lgr->peer_gid,
+ ISM_EVENT_REQUEST_IR,
+ ISM_EVENT_CODE_SHUTDOWN,
+ ev_info.info);
+ return rc;
+}
+
/* worker for SMC-D events */
static void smc_ism_event_work(struct work_struct *work)
{
@@ -223,7 +244,7 @@ static void smc_ism_event_work(struct work_struct *work)
switch (wrk->event.type) {
case ISM_EVENT_GID: /* GID event, token is peer GID */
- smc_smcd_terminate(wrk->smcd, wrk->event.tok);
+ smc_smcd_terminate(wrk->smcd, wrk->event.tok, VLAN_VID_MASK);
break;
case ISM_EVENT_DMB:
break;
@@ -289,7 +310,7 @@ void smcd_unregister_dev(struct smcd_dev *smcd)
spin_unlock(&smcd_dev_list.lock);
flush_workqueue(smcd->event_wq);
destroy_workqueue(smcd->event_wq);
- smc_smcd_terminate(smcd, 0);
+ smc_smcd_terminate(smcd, 0, VLAN_VID_MASK);
device_del(&smcd->dev);
}
diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h
index aee45b860b79..4da946cbfa29 100644
--- a/net/smc/smc_ism.h
+++ b/net/smc/smc_ism.h
@@ -45,4 +45,5 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size,
int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc);
int smc_ism_write(struct smcd_dev *dev, const struct smc_ism_position *pos,
void *data, size_t len);
+int smc_ism_signal_shutdown(struct smc_link_group *lgr);
#endif
--
2.16.4
^ permalink raw reply related
* [PATCH net V3 5/5] net/smc: use after free fix in smc_wr_tx_put_slot()
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20181116123617.72948-1-ubraun@linux.ibm.com>
From: Ursula Braun <ursula.braun@linux.ibm.com>
In smc_wr_tx_put_slot() field pend->idx is used after being
cleared. That means always idx 0 is cleared in the wr_tx_mask.
This results in a broken administration of available WR send
payload buffers.
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/smc_wr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index 3c458d279855..c2694750a6a8 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -215,12 +215,14 @@ int smc_wr_tx_put_slot(struct smc_link *link,
pend = container_of(wr_pend_priv, struct smc_wr_tx_pend, priv);
if (pend->idx < link->wr_tx_cnt) {
+ u32 idx = pend->idx;
+
/* clear the full struct smc_wr_tx_pend including .priv */
memset(&link->wr_tx_pends[pend->idx], 0,
sizeof(link->wr_tx_pends[pend->idx]));
memset(&link->wr_tx_bufs[pend->idx], 0,
sizeof(link->wr_tx_bufs[pend->idx]));
- test_and_clear_bit(pend->idx, link->wr_tx_mask);
+ test_and_clear_bit(idx, link->wr_tx_mask);
return 1;
}
--
2.16.4
^ permalink raw reply related
* [PATCH net V3 4/5] net/smc: atomic SMCD cursor handling
From: Ursula Braun @ 2018-11-16 12:36 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, schwidefsky, heiko.carstens, raspl, ubraun
In-Reply-To: <20181116123617.72948-1-ubraun@linux.ibm.com>
Running uperf tests with SMCD on LPARs results in corrupted cursors.
SMCD cursors should be treated atomically to fix cursor corruption.
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
net/smc/smc_cdc.c | 24 +++++++++++++----------
net/smc/smc_cdc.h | 58 +++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 58 insertions(+), 24 deletions(-)
diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
index ed5dcf03fe0b..18c047c155fd 100644
--- a/net/smc/smc_cdc.c
+++ b/net/smc/smc_cdc.c
@@ -177,23 +177,24 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn)
int smcd_cdc_msg_send(struct smc_connection *conn)
{
struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
+ union smc_host_cursor curs;
struct smcd_cdc_msg cdc;
int rc, diff;
memset(&cdc, 0, sizeof(cdc));
cdc.common.type = SMC_CDC_MSG_TYPE;
- cdc.prod_wrap = conn->local_tx_ctrl.prod.wrap;
- cdc.prod_count = conn->local_tx_ctrl.prod.count;
-
- cdc.cons_wrap = conn->local_tx_ctrl.cons.wrap;
- cdc.cons_count = conn->local_tx_ctrl.cons.count;
- cdc.prod_flags = conn->local_tx_ctrl.prod_flags;
- cdc.conn_state_flags = conn->local_tx_ctrl.conn_state_flags;
+ curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.prod.acurs);
+ cdc.prod.wrap = curs.wrap;
+ cdc.prod.count = curs.count;
+ curs.acurs.counter = atomic64_read(&conn->local_tx_ctrl.cons.acurs);
+ cdc.cons.wrap = curs.wrap;
+ cdc.cons.count = curs.count;
+ cdc.cons.prod_flags = conn->local_tx_ctrl.prod_flags;
+ cdc.cons.conn_state_flags = conn->local_tx_ctrl.conn_state_flags;
rc = smcd_tx_ism_write(conn, &cdc, sizeof(cdc), 0, 1);
if (rc)
return rc;
- smc_curs_copy(&conn->rx_curs_confirmed, &conn->local_tx_ctrl.cons,
- conn);
+ smc_curs_copy(&conn->rx_curs_confirmed, &curs, conn);
/* Calculate transmitted data and increment free send buffer space */
diff = smc_curs_diff(conn->sndbuf_desc->len, &conn->tx_curs_fin,
&conn->tx_curs_sent);
@@ -331,13 +332,16 @@ static void smc_cdc_msg_recv(struct smc_sock *smc, struct smc_cdc_msg *cdc)
static void smcd_cdc_rx_tsklet(unsigned long data)
{
struct smc_connection *conn = (struct smc_connection *)data;
+ struct smcd_cdc_msg *data_cdc;
struct smcd_cdc_msg cdc;
struct smc_sock *smc;
if (!conn)
return;
- memcpy(&cdc, conn->rmb_desc->cpu_addr, sizeof(cdc));
+ data_cdc = (struct smcd_cdc_msg *)conn->rmb_desc->cpu_addr;
+ smcd_curs_copy(&cdc.prod, &data_cdc->prod, conn);
+ smcd_curs_copy(&cdc.cons, &data_cdc->cons, conn);
smc = container_of(conn, struct smc_sock, conn);
smc_cdc_msg_recv(smc, (struct smc_cdc_msg *)&cdc);
}
diff --git a/net/smc/smc_cdc.h b/net/smc/smc_cdc.h
index 934df4473a7c..884218910353 100644
--- a/net/smc/smc_cdc.h
+++ b/net/smc/smc_cdc.h
@@ -50,19 +50,29 @@ struct smc_cdc_msg {
u8 reserved[18];
} __packed; /* format defined in RFC7609 */
+/* SMC-D cursor format */
+union smcd_cdc_cursor {
+ struct {
+ u16 wrap;
+ u32 count;
+ struct smc_cdc_producer_flags prod_flags;
+ struct smc_cdc_conn_state_flags conn_state_flags;
+ } __packed;
+#ifdef KERNEL_HAS_ATOMIC64
+ atomic64_t acurs; /* for atomic processing */
+#else
+ u64 acurs; /* for atomic processing */
+#endif
+} __aligned(8);
+
/* CDC message for SMC-D */
struct smcd_cdc_msg {
struct smc_wr_rx_hdr common; /* Type = 0xFE */
u8 res1[7];
- u16 prod_wrap;
- u32 prod_count;
- u8 res2[2];
- u16 cons_wrap;
- u32 cons_count;
- struct smc_cdc_producer_flags prod_flags;
- struct smc_cdc_conn_state_flags conn_state_flags;
+ union smcd_cdc_cursor prod;
+ union smcd_cdc_cursor cons;
u8 res3[8];
-} __packed;
+} __aligned(8);
static inline bool smc_cdc_rxed_any_close(struct smc_connection *conn)
{
@@ -135,6 +145,21 @@ static inline void smc_curs_copy_net(union smc_cdc_cursor *tgt,
#endif
}
+static inline void smcd_curs_copy(union smcd_cdc_cursor *tgt,
+ union smcd_cdc_cursor *src,
+ struct smc_connection *conn)
+{
+#ifndef KERNEL_HAS_ATOMIC64
+ unsigned long flags;
+
+ spin_lock_irqsave(&conn->acurs_lock, flags);
+ tgt->acurs = src->acurs;
+ spin_unlock_irqrestore(&conn->acurs_lock, flags);
+#else
+ atomic64_set(&tgt->acurs, atomic64_read(&src->acurs));
+#endif
+}
+
/* calculate cursor difference between old and new, where old <= new */
static inline int smc_curs_diff(unsigned int size,
union smc_host_cursor *old,
@@ -222,12 +247,17 @@ static inline void smcr_cdc_msg_to_host(struct smc_host_cdc_msg *local,
static inline void smcd_cdc_msg_to_host(struct smc_host_cdc_msg *local,
struct smcd_cdc_msg *peer)
{
- local->prod.wrap = peer->prod_wrap;
- local->prod.count = peer->prod_count;
- local->cons.wrap = peer->cons_wrap;
- local->cons.count = peer->cons_count;
- local->prod_flags = peer->prod_flags;
- local->conn_state_flags = peer->conn_state_flags;
+ union smc_host_cursor temp;
+
+ temp.wrap = peer->prod.wrap;
+ temp.count = peer->prod.count;
+ atomic64_set(&local->prod.acurs, atomic64_read(&temp.acurs));
+
+ temp.wrap = peer->cons.wrap;
+ temp.count = peer->cons.count;
+ atomic64_set(&local->cons.acurs, atomic64_read(&temp.acurs));
+ local->prod_flags = peer->cons.prod_flags;
+ local->conn_state_flags = peer->cons.conn_state_flags;
}
static inline void smc_cdc_msg_to_host(struct smc_host_cdc_msg *local,
--
2.16.4
^ permalink raw reply related
* [PATCH 0/3] Fix unsafe BPF_PROG_TEST_RUN interface
From: Lorenz Bauer @ 2018-11-16 12:53 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-api, Lorenz Bauer
Right now, there is no safe way to use BPF_PROG_TEST_RUN with data_out.
This is because bpf_test_finish copies the output buffer to user space
without checking its size. This can lead to the kernel overwriting
data in user space after the buffer if xdp_adjust_head and friends are
in play.
Fix this by using bpf_attr.test.data_size_out as a size hint. The old
behaviour is retained if size_hint is zero.
Interestingly, do_test_single() in test_verifier.c already assumes
that this is the intended use of data_size_out, and sets it to the
output buffer size.
Lorenz Bauer (3):
bpf: respect size hint to BPF_PROG_TEST_RUN if present
libbpf: require size hint in bpf_prog_test_run
selftests: add a test for bpf_prog_test_run output size
net/bpf/test_run.c | 9 ++++-
tools/lib/bpf/bpf.c | 4 ++-
tools/testing/selftests/bpf/test_progs.c | 44 ++++++++++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
--
2.17.1
^ permalink raw reply
* [PATCH 1/3] bpf: respect size hint to BPF_PROG_TEST_RUN if present
From: Lorenz Bauer @ 2018-11-16 12:53 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-api, Lorenz Bauer
In-Reply-To: <20181116125329.3974-1-lmb@cloudflare.com>
Use data_size_out as a size hint when copying test output to user space.
A program using BPF_PERF_OUTPUT can compare its own buffer length with
data_size_out after the syscall to detect whether truncation has taken
place. Callers which so far did not set data_size_in are not affected.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
net/bpf/test_run.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index c89c22c49015..30c57b7f4ba4 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -74,8 +74,15 @@ static int bpf_test_finish(const union bpf_attr *kattr,
{
void __user *data_out = u64_to_user_ptr(kattr->test.data_out);
int err = -EFAULT;
+ u32 copy_size = size;
- if (data_out && copy_to_user(data_out, data, size))
+ /* Clamp copy if the user has provided a size hint, but copy the full
+ * buffer if not to retain old behaviour.
+ */
+ if (kattr->test.data_size_out && copy_size > kattr->test.data_size_out)
+ copy_size = kattr->test.data_size_out;
+
+ if (data_out && copy_to_user(data_out, data, copy_size))
goto out;
if (copy_to_user(&uattr->test.data_size_out, &size, sizeof(size)))
goto out;
--
2.17.1
^ permalink raw reply related
* [PATCH 2/3] libbpf: require size hint in bpf_prog_test_run
From: Lorenz Bauer @ 2018-11-16 12:53 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-api, Lorenz Bauer
In-Reply-To: <20181116125329.3974-1-lmb@cloudflare.com>
Require size_out to be non-NULL if data_out is given. This prevents
accidental overwriting of process memory after the output buffer.
Adjust callers of bpf_prog_test_run to this behaviour.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
tools/lib/bpf/bpf.c | 4 +++-
tools/testing/selftests/bpf/test_progs.c | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 03f9bcc4ef50..127a9aa6170e 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -403,10 +403,12 @@ int bpf_prog_test_run(int prog_fd, int repeat, void *data, __u32 size,
attr.test.data_in = ptr_to_u64(data);
attr.test.data_out = ptr_to_u64(data_out);
attr.test.data_size_in = size;
+ if (data_out)
+ attr.test.data_size_out = *size_out;
attr.test.repeat = repeat;
ret = sys_bpf(BPF_PROG_TEST_RUN, &attr, sizeof(attr));
- if (size_out)
+ if (data_out)
*size_out = attr.test.data_size_out;
if (retval)
*retval = attr.test.retval;
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 2d3c04f45530..560d7527b86b 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -150,6 +150,7 @@ static void test_xdp(void)
bpf_map_update_elem(map_fd, &key4, &value4, 0);
bpf_map_update_elem(map_fd, &key6, &value6, 0);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
@@ -158,6 +159,7 @@ static void test_xdp(void)
"err %d errno %d retval %d size %d\n",
err, errno, retval, size);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
buf, &size, &retval, &duration);
CHECK(err || retval != XDP_TX || size != 114 ||
@@ -182,6 +184,7 @@ static void test_xdp_adjust_tail(void)
return;
}
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
@@ -189,6 +192,7 @@ static void test_xdp_adjust_tail(void)
"ipv4", "err %d errno %d retval %d size %d\n",
err, errno, retval, size);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
buf, &size, &retval, &duration);
CHECK(err || retval != XDP_TX || size != 54,
@@ -252,6 +256,7 @@ static void test_l4lb(const char *file)
goto out;
bpf_map_update_elem(map_fd, &real_num, &real_def, 0);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
CHECK(err || retval != 7/*TC_ACT_REDIRECT*/ || size != 54 ||
@@ -259,6 +264,7 @@ static void test_l4lb(const char *file)
"err %d errno %d retval %d size %d magic %x\n",
err, errno, retval, size, *magic);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
buf, &size, &retval, &duration);
CHECK(err || retval != 7/*TC_ACT_REDIRECT*/ || size != 74 ||
@@ -341,6 +347,7 @@ static void test_xdp_noinline(void)
goto out;
bpf_map_update_elem(map_fd, &real_num, &real_def, 0);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
CHECK(err || retval != 1 || size != 54 ||
@@ -348,6 +355,7 @@ static void test_xdp_noinline(void)
"err %d errno %d retval %d size %d magic %x\n",
err, errno, retval, size, *magic);
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
buf, &size, &retval, &duration);
CHECK(err || retval != 1 || size != 74 ||
@@ -1795,6 +1803,7 @@ static void test_queue_stack_map(int type)
pkt_v4.iph.saddr = vals[MAP_SIZE - 1 - i] * 5;
}
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
if (err || retval || size != sizeof(pkt_v4) ||
@@ -1808,6 +1817,7 @@ static void test_queue_stack_map(int type)
err, errno, retval, size, iph->daddr);
/* Queue is empty, program should return TC_ACT_SHOT */
+ size = sizeof(buf);
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
buf, &size, &retval, &duration);
CHECK(err || retval != 2 /* TC_ACT_SHOT */|| size != sizeof(pkt_v4),
--
2.17.1
^ permalink raw reply related
* [PATCH 3/3] selftests: add a test for bpf_prog_test_run output size
From: Lorenz Bauer @ 2018-11-16 12:53 UTC (permalink / raw)
To: ast, daniel; +Cc: netdev, linux-api, Lorenz Bauer
In-Reply-To: <20181116125329.3974-1-lmb@cloudflare.com>
Make sure that bpf_prog_test_run returns the correct length
in the size_out argument and that the kernel respects the
output size hint.
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
---
tools/testing/selftests/bpf/test_progs.c | 34 ++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 560d7527b86b..6ab98e10e86f 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -124,6 +124,39 @@ static void test_pkt_access(void)
bpf_object__close(obj);
}
+static void test_output_size_hint(void)
+{
+ const char *file = "./test_pkt_access.o";
+ struct bpf_object *obj;
+ __u32 retval, size, duration;
+ int err, prog_fd;
+ char buf[10];
+
+ err = bpf_prog_load(file, BPF_PROG_TYPE_SCHED_CLS, &obj, &prog_fd);
+ if (err) {
+ error_cnt++;
+ return;
+ }
+
+ memset(buf, 0, sizeof(buf));
+
+ size = 5;
+ err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
+ buf, &size, &retval, &duration);
+ CHECK(err || retval, "run",
+ "err %d errno %d retval %d\n",
+ err, errno, retval);
+
+ CHECK(size != sizeof(pkt_v4), "out_size",
+ "incorrect output size, want %lu have %u\n",
+ sizeof(pkt_v4), size);
+
+ CHECK(buf[5] != 0, "overflow",
+ "prog_test_run ignored size hint\n");
+
+ bpf_object__close(obj);
+}
+
static void test_xdp(void)
{
struct vip key4 = {.protocol = 6, .family = AF_INET};
@@ -1847,6 +1880,7 @@ int main(void)
jit_enabled = is_jit_enabled();
test_pkt_access();
+ test_output_size_hint();
test_xdp();
test_xdp_adjust_tail();
test_l4lb_all();
--
2.17.1
^ permalink raw reply related
* Re: [PATCH bpf] bpf: allocate local storage buffers using GFP_ATOMIC
From: Y Song @ 2018-11-16 23:30 UTC (permalink / raw)
To: guroan; +Cc: netdev, LKML, kernel-team, guro, Alexei Starovoitov,
Daniel Borkmann
In-Reply-To: <20181114180034.25558-1-guro@fb.com>
On Wed, Nov 14, 2018 at 6:01 PM Roman Gushchin <guroan@gmail.com> wrote:
>
> Naresh reported an issue with the non-atomic memory allocation of
> cgroup local storage buffers:
>
> [ 73.047526] BUG: sleeping function called from invalid context at
> /srv/oe/build/tmp-rpb-glibc/work-shared/intel-corei7-64/kernel-source/mm/slab.h:421
> [ 73.060915] in_atomic(): 1, irqs_disabled(): 0, pid: 3157, name: test_cgroup_sto
> [ 73.068342] INFO: lockdep is turned off.
> [ 73.072293] CPU: 2 PID: 3157 Comm: test_cgroup_sto Not tainted
> 4.20.0-rc2-next-20181113 #1
> [ 73.080548] Hardware name: Supermicro SYS-5019S-ML/X11SSH-F, BIOS
> 2.0b 07/27/2017
> [ 73.088018] Call Trace:
> [ 73.090463] dump_stack+0x70/0xa5
> [ 73.093783] ___might_sleep+0x152/0x240
> [ 73.097619] __might_sleep+0x4a/0x80
> [ 73.101191] __kmalloc_node+0x1cf/0x2f0
> [ 73.105031] ? cgroup_storage_update_elem+0x46/0x90
> [ 73.109909] cgroup_storage_update_elem+0x46/0x90
>
> cgroup_storage_update_elem() (as well as other update map update
> callbacks) is called with disabled preemption, so GFP_ATOMIC
> allocation should be used: e.g. alloc_htab_elem() in hashtab.c.
>
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> kernel/bpf/local_storage.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
^ permalink raw reply
* Re: [PATCH net-next 6/8] net: eth: altera: tse: add support for ptp and timestamping
From: Dalon Westergreen @ 2018-11-16 13:33 UTC (permalink / raw)
To: Richard Cochran; +Cc: netdev, dinguyen, thor.thayer
In-Reply-To: <20181116021418.dhbw5cu4y56cfjls@localhost>
On Thu, 2018-11-15 at 18:14 -0800, Richard Cochran wrote:
> On Thu, Nov 15, 2018 at 06:55:29AM -0800, Dalon Westergreen wrote:
> > Sure, I would like to keep the debugfs entries for disabling freq
> > correction,and
> > reading the current scaled_ppm value. I intend to use these to tune
> > anexternal
> > vcxo. If there is a better way to do this, please let me know.
>
> Yes, there is. The external VCXO should be a proper PHC. Then, with
> a minor change to the linuxptp stack (already in the pipe), you can
> just use that.
>
> You should not disable frequency correction in the driver. Leave that
> decision to the user space PTP stack.
Good to know, thanks.
>
> > I would prefer to keep altera just to be consistent with the altera_tse
> > stuff,
> > and i intend to reusethis code for a 10GbE driver, so perhaps altera_tod to
> > reference the fpga ip name?
>
> So the IP core is called "tod"? Really?
yes, i am afraid so. "Time of Day"
--dalon
>
> Thanks,
> Richard
^ permalink raw reply
* Re: [PATCH net-next 1/4] enetc: Introduce basic PF and VF ENETC ethernet drivers
From: Andrew Lunn @ 2018-11-16 23:48 UTC (permalink / raw)
To: Claudiu Manoil
Cc: David S . Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Alexandru Marginean,
Catalin Horghidan
In-Reply-To: <VI1PR04MB4880BE4EA7B7C0A1EEA0A0D196DD0@VI1PR04MB4880.eurprd04.prod.outlook.com>
> I know phylib has some limitations that are supposed to be addressed by phylink,
> but I didn't figure out yet how phylink does that or whether it works on our designs
> too.
Anything which phylib can do, phylink should also be able to do.
And phylink should make it easier to support SGMII. If you are using
the in-band signalling, you need to get that information out of the
MAC. And when you add support for 2.5G, you need to dynamically
reconfigure your SGMII link, depending on what speed the PHY decides
to do. phylink will help with that.
But you can start with phylib and convert later, if you want.
Andrew
^ permalink raw reply
* Re: [v3, PATCH 2/2] dt-binding: mediatek-dwmac: add binding document for MediaTek MT2712 DWMAC
From: Sean Wang @ 2018-11-17 0:21 UTC (permalink / raw)
To: biao.huang
Cc: davem, robh+dt, mark.rutland, devicetree, nelson.chang, andrew,
netdev, liguo.zhang, linux-kernel, Matthias Brugger, joabreu,
linux-mediatek, honghui.zhang, linux-arm-kernel
In-Reply-To: <1542359926-28800-2-git-send-email-biao.huang@mediatek.com>
On Fri, Nov 16, 2018 at 1:19 AM Biao Huang <biao.huang@mediatek.com> wrote:
>
> The commit adds the device tree binding documentation for the MediaTek DWMAC
> found on MediaTek MT2712.
>
> Change-Id: I3728666bf65927164bd82fa8dddb90df8270bd44
Drop change-id
> Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> ---
> .../devicetree/bindings/net/mediatek-dwmac.txt | 77 ++++++++++++++++++++
> 1 file changed, 77 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
>
> diff --git a/Documentation/devicetree/bindings/net/mediatek-dwmac.txt b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
> new file mode 100644
> index 0000000..7fd56e0
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/mediatek-dwmac.txt
> @@ -0,0 +1,77 @@
> +MediaTek DWMAC glue layer controller
> +
> +This file documents platform glue layer for stmmac.
> +Please see stmmac.txt for the other unchanged properties.
> +
> +The device node has following properties.
> +
> +Required properties:
> +- compatible: Should be "mediatek,mt2712-gmac" for MT2712 SoC
> +- reg: Address and length of the register set for the device
> +- interrupts: Should contain the MAC interrupts
> +- interrupt-names: Should contain a list of interrupt names corresponding to
> + the interrupts in the interrupts property, if available.
> + Should be "macirq" for the main MAC IRQ
> +- clocks: Must contain a phandle for each entry in clock-names.
> +- clock-names: The name of the clock listed in the clocks property. These are
> + "axi", "apb", "mac_ext", "mac_parent", "ptp_ref", "ptp_parent", "ptp_top"
> + for MT2712 SoC
About not including these parent clocks to the controller, you can
refer to assigned-clocks, assigned-clock-parents, assigned-clock-rates
noted in Documentation/devicetree/bindings/clock/clock-bindings.txt to
determine what speed these MUXs should be run at and see [1] as the
example how applied in dts.
[1]
https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/mt7623.dtsi#L660
> +- mac-address: See ethernet.txt in the same directory
> +- phy-mode: See ethernet.txt in the same directory
> +
> +Optional properties:
> +- tx-delay: TX clock delay macro value. Range is 0~31. Default is 0.
> + It should be defined for rgmii/rgmii-rxid/mii interface.
> +- rx-delay: RX clock delay macro value. Range is 0~31. Default is 0.
> + It should be defined for rgmii/rgmii-txid/mii/rmii interface.
> +- fine-tune: This property will select coarse-tune delay or fine delay
> + for rgmii interface.
what is the property's type?
> + If fine-tune delay is enabled, tx-delay/rx-delay is 170+/-50ps
> + per stage.
> + Else coarse-tune delay is enabled, tx-delay/rx-delay is 0.55+/-0.2ns
> + per stage.
> + This property do not apply to non-rgmii PHYs.
> + Only coarse-tune delay is supported for mii/rmii PHYs.
> +- rmii-rxc: Reference clock of rmii is from external PHYs,
what is the property's type?
> + and it can be connected to TXC or RXC pin on MT2712 SoC.
> + If ref_clk <--> TXC, disable it.
> + Else ref_clk <--> RXC, enable it.
> +- txc-inverse: Inverse tx clock for mii/rgmii.
what is the property's type?
> + Inverse tx clock inside MAC relative to reference clock for rmii,
> + and it rarely happen.
> +- rxc-inverse: Inverse rx clock for mii/rgmii interfaces.
what is the property's type?
> + Inverse reference clock for rmii.
If these optional properties look like generic enough, it would be
good that place them to stmmac.txt. Otherwise, they should be added
"mediatek," as the prefix string for these vendor-specific things.
> +
> +Example:
> + eth: ethernet@1101c000 {
> + compatible = "mediatek,mt2712-gmac";
> + reg = <0 0x1101c000 0 0x1300>;
> + interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
> + interrupt-names = "macirq";
> + phy-mode ="rgmii-id";
> + mac-address = [00 55 7b b5 7d f7];
> + clock-names = "axi",
> + "apb",
> + "mac_ext",
> + "mac_parent",
> + "ptp_ref",
> + "ptp_parent",
> + "ptp_top";
> + clocks = <&pericfg CLK_PERI_GMAC>,
> + <&pericfg CLK_PERI_GMAC_PCLK>,
> + <&topckgen CLK_TOP_ETHER_125M_SEL>,
> + <&topckgen CLK_TOP_ETHERPLL_125M>,
> + <&topckgen CLK_TOP_ETHER_50M_SEL>,
> + <&topckgen CLK_TOP_APLL1_D3>,
> + <&topckgen CLK_TOP_APLL1>;
> + snps,txpbl = <32>;
> + snps,rxpbl = <32>;
> + snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
> + snps,reset-active-low;
> + tx-delay = <9>;
> + rx-delay = <9>;
> + fine-tune;
> + rmii-rxc;
> + txc-inverse;
> + rxc-inverse;
> + };
> --
> 1.7.9.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply
* Re: [PATCH net-next 1/4] enetc: Introduce basic PF and VF ENETC ethernet drivers
From: Andrew Lunn @ 2018-11-17 0:30 UTC (permalink / raw)
To: Claudiu Manoil
Cc: David S . Miller, netdev, linux-kernel, alexandru.marginean,
catalin.horghidan
In-Reply-To: <1542298436-23422-2-git-send-email-claudiu.manoil@nxp.com>
> +++ b/drivers/net/ethernet/freescale/enetc/Kconfig
> @@ -0,0 +1,19 @@
> +# SPDX-License-Identifier: GPL-2.0
> +config FSL_ENETC
> + tristate "ENETC PF driver"
> + depends on PCI && PCI_MSI && ARCH_LAYERSCAPE
It would be good to add COMPILE_TEST.
> + help
> + This driver supports NXP ENETC gigabit ethernet controller PCIe
> + physical function (PF) devices, managing ENETC Ports at a privileged
> + level.
> +
> + If compiled as module (M), the module name is fsl-enetc.
> +
> +config FSL_ENETC_VF
> + tristate "ENETC VF driver"
> + depends on PCI && PCI_MSI && ARCH_LAYERSCAPE
and here.
> +// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
> +/* Copyright 2017-2018 NXP */
> +
> +#include "enetc.h"
> +#include <linux/tcp.h>
> +#include <linux/udp.h>
> +#include <linux/of_mdio.h>
> +
> +static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb);
> +static void enetc_unmap_tx_buff(struct enetc_bdr *tx_ring,
> + struct enetc_tx_swbd *tx_swbd);
> +static int enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int budget);
> +
> +static struct sk_buff *enetc_map_rx_buff_to_skb(struct enetc_bdr *rx_ring,
> + int i, u16 size);
> +static void enetc_add_rx_buff_to_skb(struct enetc_bdr *rx_ring, int i,
> + u16 size, struct sk_buff *skb);
> +static void enetc_process_skb(struct enetc_bdr *rx_ring, struct sk_buff *skb);
> +static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
> + struct napi_struct *napi, int work_limit);
> +
Please try to avoid forward declarations. Move the code around so you
don't need them.
> +static bool enetc_tx_csum(struct sk_buff *skb, union enetc_tx_bd *txbd)
> +{
> + int l3_start, l3_hsize;
> + u16 l3_flags, l4_flags;
> +
> + if (skb->ip_summed != CHECKSUM_PARTIAL)
> + return false;
> +
> + switch (skb->csum_offset) {
> + case offsetof(struct tcphdr, check):
> + l4_flags = ENETC_TXBD_L4_TCP;
> + break;
> + case offsetof(struct udphdr, check):
> + l4_flags = ENETC_TXBD_L4_UDP;
> + break;
> + default:
> + skb_checksum_help(skb);
> + return false;
> + }
> +
> + l3_start = skb_network_offset(skb);
> + l3_hsize = skb_network_header_len(skb);
> +
> + l3_flags = 0;
> + if (skb->protocol == htons(ETH_P_IPV6))
> + l3_flags = ENETC_TXBD_L3_IPV6;
Is there no need to do anything with IPv4?
> +
> + /* write BD fields */
> + txbd->l3_csoff = enetc_txbd_l3_csoff(l3_start, l3_hsize, l3_flags);
> + txbd->l4_csoff = l4_flags;
> +
> + return true;
> +}
> +
> +static int enetc_setup_irqs(struct enetc_ndev_priv *priv)
> +{
> + struct pci_dev *pdev = priv->si->pdev;
> + int i, j, err;
> +
> + for (i = 0; i < priv->bdr_int_num; i++) {
> + int irq = pci_irq_vector(pdev, ENETC_BDR_INT_BASE_IDX + i);
> + struct enetc_int_vector *v = priv->int_vector[i];
> + int entry = ENETC_BDR_INT_BASE_IDX + i;
> + struct enetc_hw *hw = &priv->si->hw;
> +
> + sprintf(v->name, "%s-rxtx%d", priv->ndev->name, i);
I would not be too surprised if static analyser people complain that
you can in theory overflow name. You might want to use snprintf() to
prevent this.
> + err = request_irq(irq, enetc_msix, 0, v->name, v);
> + if (err) {
> + dev_err(priv->dev, "request_irq() failed!\n");
> + goto irq_err;
> + }
> +
> + v->tbier_base = hw->reg + ENETC_BDR(TX, 0, ENETC_TBIER);
> + v->rbier = hw->reg + ENETC_BDR(RX, i, ENETC_RBIER);
> +
> + enetc_wr(hw, ENETC_SIMSIRRV(i), entry);
> +
> + for (j = 0; j < v->count_tx_rings; j++) {
> + int idx = v->tx_ring[j].index;
> +
> + enetc_wr(hw, ENETC_SIMSITRV(idx), entry);
> + }
> + }
> +
> + return 0;
> +
> +irq_err:
> + while (i--)
> + free_irq(pci_irq_vector(pdev, ENETC_BDR_INT_BASE_IDX + i),
> + priv->int_vector[i]);
> +
> + return err;
> +}
> +static void adjust_link(struct net_device *ndev)
> +{
> + struct phy_device *phydev = ndev->phydev;
> +
> + phy_print_status(phydev);
You normally need more than that. Maybe later patches add to this?
> +static int enetc_phy_connect(struct net_device *ndev)
> +{
> + struct enetc_ndev_priv *priv = netdev_priv(ndev);
> + struct phy_device *phydev;
> +
> + if (!priv->phy_node)
> + return 0; /* phy-less mode */
What are your user-cases for phy-less? If you don't have a PHY it is
mostly because you are connected to an Ethernet switch. In that case
you use fixed-link, which gives you a phy.
> +
> + phydev = of_phy_connect(ndev, priv->phy_node, &adjust_link,
> + 0, priv->if_mode);
> + if (!phydev) {
> + dev_err(&ndev->dev, "could not attach to PHY\n");
> + return -ENODEV;
> + }
> +
> + phy_attached_info(phydev);
> +
> + return 0;
> +}
> +
> +int enetc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
> +{
> + return -EINVAL;
> +}
> +
I think EOPNOTSUPP is more normal. But it should be O.K, to not have
an ioctl handler at all.
> +int enetc_pci_probe(struct pci_dev *pdev, const char *name, int sizeof_priv)
> +{
> + struct enetc_si *si, *p;
> + struct enetc_hw *hw;
> + size_t alloc_size;
> + int err, len;
> +
> + err = pci_enable_device_mem(pdev);
> + if (err) {
> + dev_err(&pdev->dev, "device enable failed\n");
> + return err;
> + }
> +
> + /* set up for high or low dma */
> + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> + if (err) {
> + err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> + if (err) {
> + dev_err(&pdev->dev,
> + "DMA configuration failed: 0x%x\n", err);
> + goto err_dma;
> + }
> + }
Humm, i thought drivers were not supposed to do this. The architecture
code should be setting masks. But i've not followed all those
conversations...
> +static int enetc_get_reglen(struct net_device *ndev)
> +{
> + struct enetc_ndev_priv *priv = netdev_priv(ndev);
> + struct enetc_hw *hw = &priv->si->hw;
> + int len;
> +
> + len = ARRAY_SIZE(enetc_si_regs);
> + len += ARRAY_SIZE(enetc_txbdr_regs) * priv->num_tx_rings;
> + len += ARRAY_SIZE(enetc_rxbdr_regs) * priv->num_rx_rings;
> +
> + if (hw->port)
> + len += ARRAY_SIZE(enetc_port_regs);
> +
> + len *= sizeof(u32) * 2; /* store 2 etries per reg: addr and value */
entries
> +
> + return len;
> +}
> +
Andrew
^ permalink raw reply
* Re: [PATCH bpf] bpf: fix off-by-one error in adjust_subprog_starts
From: Y Song @ 2018-11-17 0:44 UTC (permalink / raw)
To: Edward Cree
Cc: Alexei Starovoitov, Daniel Borkmann, netdev, LKML, syzkaller-bugs
In-Reply-To: <bce0322a-6392-3fd4-a6fb-562160c26198@solarflare.com>
On Fri, Nov 16, 2018 at 12:00 PM Edward Cree <ecree@solarflare.com> wrote:
>
> When patching in a new sequence for the first insn of a subprog, the start
> of that subprog does not change (it's the first insn of the sequence), so
> adjust_subprog_starts should check start <= off (rather than < off).
> Also added a test to test_verifier.c (it's essentially the syz reproducer).
>
> Fixes: cc8b0b92a169 ("bpf: introduce function calls (function boundaries)")
> Reported-by: syzbot+4fc427c7af994b0948be@syzkaller.appspotmail.com
> Signed-off-by: Edward Cree <ecree@solarflare.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply
* Re: [PATCH net-next 2/2] net/sched: act_police: don't use spinlock in the data path
From: Eric Dumazet @ 2018-11-16 14:34 UTC (permalink / raw)
To: Davide Caratti, Eric Dumazet, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S. Miller
Cc: netdev
In-Reply-To: <e7e539deac5573c913ed05cfd85bf5eb8533be19.camel@redhat.com>
On 11/16/2018 03:28 AM, Davide Caratti wrote:
> On Thu, 2018-11-15 at 05:53 -0800, Eric Dumazet wrote:
>>
>> On 11/15/2018 03:43 AM, Davide Caratti wrote:
>>> On Wed, 2018-11-14 at 22:46 -0800, Eric Dumazet wrote:
>>>> On 09/13/2018 10:29 AM, Davide Caratti wrote:
>>>>> use RCU instead of spinlocks, to protect concurrent read/write on
>>>>> act_police configuration. This reduces the effects of contention in the
>>>>> data path, in case multiple readers are present.
>>>>>
>>>>> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
>>>>> ---
>>>>> net/sched/act_police.c | 156 ++++++++++++++++++++++++-----------------
>>>>> 1 file changed, 92 insertions(+), 64 deletions(-)
>>>>>
>>>>
>>>> I must be missing something obvious with this patch.
>>>
>>> hello Eric,
>>>
>>> On the opposite, I missed something obvious when I wrote that patch: there
>>> is a race condition on tcfp_toks, tcfp_ptoks and tcfp_t_c: thank you for
>>> noticing it.
>>>
>>> These variables still need to be protected with a spinlock. I will do a
>>> patch and evaluate if 'act_police' is still faster than a version where
>>> 2d550dbad83c ("net/sched: .... ") is reverted, and share results in the
>>> next hours.
>>>
>>> Ok?
>>>
>>
>> SGTM, thanks.
>
> hello,
> I just finished the comparison of act_police, in the following cases:
>
> a) revert the RCU-ification (i.e. commit 2d550dbad83c ("net/sched:
> act_police: don't use spinlock in the data path"), and leave per-cpu
> counters used by the rate estimator
>
> b) keep RCU-ified configuration parameters, and protect read/update of
> tcfp_toks, tcfp_ptoks and tcfp_t with a spinlock (code at the bottom of
> this message).
>
> ## Test setup:
>
> $DEV is a 'dummy' with clsact qdisc; the following two commands,
>
> # test police with 'rate'
> $TC filter add dev $DEV egress matchall \
> action police rate 2gbit burst 100k conform-exceed pass/pass index 100
>
> # test police with 'avrate'
> $TC filter add dev prova egress estimator 1s 8s matchall \
> action police avrate 2gbit conform-exceed pass/pass index 100
>
> are tested with the following loop:
>
> for c in 1 2 4 8 16; do
> ./pktgen/pktgen_bench_xmit_mode_queue_xmit.sh -v -s 64 -t $c -n 5000000 -i $DEV
> done
>
>
> ## Test results:
>
> using rate | reverted | patched
> $c | act_police (a) | act_police (b)
> -------------+----------------+---------------
> 1 | 3364442 | 3345580
> 2 | 2703030 | 2721919
> 4 | 1130146 | 1253555
> 8 | 664238 | 658777
> 16 | 154026 | 155259
>
>
> using avrate | reverted | patched
> $c | act_police (a) | act_police (b)
> -------------+----------------+---------------
> 1 | 3621796 | 3658472
> 2 | 3075589 | 3548135
> 4 | 2313314 | 3343717
> 8 | 768458 | 3260480
> 16 | 177776 | 3254128
>
>
> so, 'avrate' still gets a significant improvement because the 'conform/exceed'
> decision doesn't need the spinlock in this case. The estimation is probably
> less accurate, because it use per-CPU variables: if this is not acceptable,
> then we need to revert also 93be42f9173b ("net/sched: act_police: use per-cpu
> counters").
>
>
> ## patch code:
>
> -- >8 --
> diff --git a/net/sched/act_police.c b/net/sched/act_police.c
> index 052855d..42db852 100644
> --- a/net/sched/act_police.c
> +++ b/net/sched/act_police.c
> @@ -27,10 +27,7 @@ struct tcf_police_params {
> u32 tcfp_ewma_rate;
> s64 tcfp_burst;
> u32 tcfp_mtu;
> - s64 tcfp_toks;
> - s64 tcfp_ptoks;
> s64 tcfp_mtu_ptoks;
> - s64 tcfp_t_c;
> struct psched_ratecfg rate;
> bool rate_present;
> struct psched_ratecfg peak;
> @@ -40,6 +37,9 @@ struct tcf_police_params {
>
> struct tcf_police {
> struct tc_action common;
> + s64 tcfp_toks;
> + s64 tcfp_ptoks;
> + s64 tcfp_t_c;
I suggest to use a single cache line with a dedicated spinlock and these three s64
spinlock_t tcfp_lock ____cacheline_aligned_in_smp;
s64 ...
s64 ...
s64 ...
> struct tcf_police_params __rcu *params;
Make sure to use a different cache line for *params
struct tcf_police_params __rcu *params ____cacheline_aligned_in_smp;
> };
>
> @@ -186,12 +186,6 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
> }
>
> new->tcfp_burst = PSCHED_TICKS2NS(parm->burst);
> - new->tcfp_toks = new->tcfp_burst;
> - if (new->peak_present) {
> - new->tcfp_mtu_ptoks = (s64)psched_l2t_ns(&new->peak,
> - new->tcfp_mtu);
> - new->tcfp_ptoks = new->tcfp_mtu_ptoks;
> - }
>
> if (tb[TCA_POLICE_AVRATE])
> new->tcfp_ewma_rate = nla_get_u32(tb[TCA_POLICE_AVRATE]);
> @@ -207,7 +201,14 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
> }
>
> spin_lock_bh(&police->tcf_lock);
> - new->tcfp_t_c = ktime_get_ns();
> + police->tcfp_t_c = ktime_get_ns();
> + police->tcfp_toks = new->tcfp_burst;
> + if (new->peak_present) {
> + new->tcfp_mtu_ptoks = (s64)psched_l2t_ns(&new->peak,
> + new->tcfp_mtu);
> + police->tcfp_ptoks = new->tcfp_mtu_ptoks;
> + }
> +
> police->tcf_action = parm->action;
> rcu_swap_protected(police->params,
> new,
> @@ -255,27 +256,29 @@ static int tcf_police_act(struct sk_buff *skb, const struct tc_action *a,
> ret = p->tcfp_result;
> goto end;
> }
> -
> + spin_lock_bh(&police->tcf_lock);
> now = ktime_get_ns();
The ktime_get_ns() call can be done before acquiring the spinlock
> - toks = min_t(s64, now - p->tcfp_t_c, p->tcfp_burst);
> + toks = min_t(s64, now - police->tcfp_t_c, p->tcfp_burst);
> if (p->peak_present) {
> - ptoks = toks + p->tcfp_ptoks;
> + ptoks = toks + police->tcfp_ptoks;
> if (ptoks > p->tcfp_mtu_ptoks)
> ptoks = p->tcfp_mtu_ptoks;
> ptoks -= (s64)psched_l2t_ns(&p->peak,
> qdisc_pkt_len(skb));
> }
> - toks += p->tcfp_toks;
> + toks += police->tcfp_toks;
> if (toks > p->tcfp_burst)
> toks = p->tcfp_burst;
> toks -= (s64)psched_l2t_ns(&p->rate, qdisc_pkt_len(skb));
> if ((toks|ptoks) >= 0) {
> - p->tcfp_t_c = now;
> - p->tcfp_toks = toks;
> - p->tcfp_ptoks = ptoks;
> + police->tcfp_t_c = now;
> + police->tcfp_toks = toks;
> + police->tcfp_ptoks = ptoks;
> + spin_unlock_bh(&police->tcf_lock);
> ret = p->tcfp_result;
> goto inc_drops;
> }
> + spin_unlock_bh(&police->tcf_lock);
> }
>
> inc_overlimits:
> -- >8 --
>
> any feedback is appreciated.
> thanks!
>
^ permalink raw reply
* Re: [PATCHv2 net] ipvs: call ip_vs_dst_notifier earlier than ipv6_dev_notf
From: Simon Horman @ 2018-11-16 14:37 UTC (permalink / raw)
To: Julian Anastasov, Pablo Neira Ayuso
Cc: Xin Long, network dev, netfilter-devel, David S. Miller,
Hans Schillstrom
In-Reply-To: <alpine.LFD.2.21.1811160907480.2751@ja.home.ssi.bg>
On Fri, Nov 16, 2018 at 09:10:16AM +0200, Julian Anastasov wrote:
>
> Hello,
>
> On Thu, 15 Nov 2018, Xin Long wrote:
>
> > ip_vs_dst_event is supposed to clean up all dst used in ipvs'
> > destinations when a net dev is going down. But it works only
> > when the dst's dev is the same as the dev from the event.
> >
> > Now with the same priority but late registration,
> > ip_vs_dst_notifier is always called later than ipv6_dev_notf
> > where the dst's dev is set to lo for NETDEV_DOWN event.
> >
> > As the dst's dev lo is not the same as the dev from the event
> > in ip_vs_dst_event, ip_vs_dst_notifier doesn't actually work.
> > Also as these dst have to wait for dest_trash_timer to clean
> > them up. It would cause some non-permanent kernel warnings:
> >
> > unregister_netdevice: waiting for br0 to become free. Usage count = 3
> >
> > To fix it, call ip_vs_dst_notifier earlier than ipv6_dev_notf
> > by increasing its priority to ADDRCONF_NOTIFY_PRIORITY + 5.
> >
> > Note that for ipv4 route fib_netdev_notifier doesn't set dst's
> > dev to lo in NETDEV_DOWN event, so this fix is only needed when
> > IP_VS_IPV6 is defined.
> >
> > v1->v2:
> > - apply it only when CONFIG_IP_VS_IPV6 is defined.
> >
> > Fixes: 7a4f0761fce3 ("IPVS: init and cleanup restructuring")
> > Reported-by: Li Shuang <shuali@redhat.com>
> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
>
> Acked-by: Julian Anastasov <ja@ssi.bg>
Thanks,
Pablo, could you consider this for nf?
Acked-by: Simon Horman <horms@verge.net.au>
>
> > ---
> > net/netfilter/ipvs/ip_vs_ctl.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index 83395bf6..432141f 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -3980,6 +3980,9 @@ static void __net_exit ip_vs_control_net_cleanup_sysctl(struct netns_ipvs *ipvs)
> >
> > static struct notifier_block ip_vs_dst_notifier = {
> > .notifier_call = ip_vs_dst_event,
> > +#ifdef CONFIG_IP_VS_IPV6
> > + .priority = ADDRCONF_NOTIFY_PRIORITY + 5,
> > +#endif
> > };
> >
> > int __net_init ip_vs_control_net_init(struct netns_ipvs *ipvs)
> > --
> > 2.1.0
>
> Regards
>
> --
> Julian Anastasov <ja@ssi.bg>
>
^ permalink raw reply
* Re: [PATCH net-next 2/2] net/sched: act_police: don't use spinlock in the data path
From: Eric Dumazet @ 2018-11-16 14:39 UTC (permalink / raw)
To: Davide Caratti, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S. Miller
Cc: netdev
In-Reply-To: <7ba53062-de84-a8f1-14dc-3c49a2480925@gmail.com>
On 11/16/2018 06:34 AM, Eric Dumazet wrote:
>
>> + s64 tcfp_toks;
>> + s64 tcfp_ptoks;
>> + s64 tcfp_t_c;
>
> I suggest to use a single cache line with a dedicated spinlock and these three s64
>
> spinlock_t tcfp_lock ____cacheline_aligned_in_smp;
> s64 ...
> s64 ...
> s64 ...
>
>
>> struct tcf_police_params __rcu *params;
>
> Make sure to use a different cache line for *params
>
> struct tcf_police_params __rcu *params ____cacheline_aligned_in_smp;
Or move it before the cacheline used by the lock and three s64,
since 'common' should be read-mostly. No need for a separate cache line.
^ permalink raw reply
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