* Re: [PATCH net-next] yellowfin: fix remove set but not used variable warning
From: YueHaibing @ 2019-02-19 2:34 UTC (permalink / raw)
To: David Miller; +Cc: yang.wei9, netdev, kernel-janitors
In-Reply-To: <20190218.121337.147896114474592034.davem@davemloft.net>
On 2019/2/19 4:13, David Miller wrote:
> From: YueHaibing <yuehaibing@huawei.com>
> Date: Mon, 18 Feb 2019 08:15:46 +0000
>
>> @@ -1050,8 +1050,11 @@ static int yellowfin_rx(struct net_device *dev)
>> struct sk_buff *rx_skb = yp->rx_skbuff[entry];
>> s16 frame_status;
>> u16 desc_status;
>> - int data_size, yf_size;
>> + int data_size;
>> u8 *buf_addr;
>> +#ifdef YF_PROTOTYPE
>> + int yf_size = sizeof(struct yellowfin_desc);
>> +#endif
>
> This is just silly.
>
> Please move this variable declaration and initialization into the
> YF_PROTOTYPE basic block in the code below it, like this:
>
> #ifdef YF_PROTOTYPE /* Support for prototype hardware errata. */
> } else if ((yp->flags & HasMACAddrBug) &&
> int yf_size = sizeof(struct yellowfin_desc);
There's just in if condition, define the 'yf_size' seems incorrect
maybe we can remove 'yf_size' and use sizeof directly?
>
> !ether_addr_equal(le32_to_cpu(yp->rx_ring_dma +
> entry * yf_size),
> dev->dev_addr) &&
> !ether_addr_equal(le32_to_cpu(yp->rx_ring_dma +
> entry * yf_size),
> "\377\377\377\377\377\377")) {
> if (bogus_rx++ == 0)
> netdev_warn(dev, "Bad frame to %pM\n",
> buf_addr);
> #endif
>
> Thanks.
>
> .
>
^ permalink raw reply
* Re: [PATCH] can: mark expected switch fall-throughs
From: Gustavo A. R. Silva @ 2019-02-19 2:57 UTC (permalink / raw)
To: Nicolas.Ferre, wg, mkl, davem, alexandre.belloni,
Ludovic.Desroches
Cc: linux-can, netdev, linux-arm-kernel, linux-kernel, Kees Cook
In-Reply-To: <daae008e-35fd-7553-fcb2-7932fe53b959@embeddedor.com>
Hi,
Friendly ping:
Dave, I wonder if you can take this.
Thanks
--
Gustavo
On 2/14/19 3:37 PM, Gustavo A. R. Silva wrote:
>
>
> On 1/30/19 2:11 AM, Nicolas.Ferre@microchip.com wrote:
>> On 29/01/2019 at 19:06, Gustavo A. R. Silva wrote:
>>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>>> where we are expecting to fall through.
>>>
>>> This patch fixes the following warnings:
>>>
>>> drivers/net/can/peak_canfd/peak_pciefd_main.c:668:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> drivers/net/can/spi/mcp251x.c:875:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> drivers/net/can/at91_can.c:895:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> drivers/net/can/at91_can.c:953:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> drivers/net/can/usb/peak_usb/pcan_usb.c: In function ‘pcan_usb_decode_error’:
>>> drivers/net/can/usb/peak_usb/pcan_usb.c:422:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>> if (n & PCAN_USB_ERROR_BUS_LIGHT) {
>>> ^
>>> drivers/net/can/usb/peak_usb/pcan_usb.c:428:2: note: here
>>> case CAN_STATE_ERROR_WARNING:
>>> ^~~~
>>>
>>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>>
>>> This patch is part of the ongoing efforts to enabling
>>> -Wimplicit-fallthrough.
>>>
>>> Notice that in some cases spelling mistakes were fixed.
>>> In other cases, the /* fall through */ comment is placed
>>> at the bottom of the case statement, which is what GCC
>>> is expecting to find.
>>>
>>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>>> ---
>>> drivers/net/can/at91_can.c | 6 ++++--
>>
>> For this one:
>> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
>>
>
> Thanks, Nicolas.
>
> Dave:
>
> I wonder if you can take this patch.
>
> Thanks
> --
> Gustavo
>
>>> drivers/net/can/peak_canfd/peak_pciefd_main.c | 2 +-
>>> drivers/net/can/spi/mcp251x.c | 3 ++-
>>> drivers/net/can/usb/peak_usb/pcan_usb.c | 2 +-
>>> 4 files changed, 8 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
>>> index d98c69045b17..1718c20f9c99 100644
>>> --- a/drivers/net/can/at91_can.c
>>> +++ b/drivers/net/can/at91_can.c
>>> @@ -902,7 +902,8 @@ static void at91_irq_err_state(struct net_device *dev,
>>> CAN_ERR_CRTL_TX_WARNING :
>>> CAN_ERR_CRTL_RX_WARNING;
>>> }
>>> - case CAN_STATE_ERROR_WARNING: /* fallthrough */
>>> + /* fall through */
>>> + case CAN_STATE_ERROR_WARNING:
>>> /*
>>> * from: ERROR_ACTIVE, ERROR_WARNING
>>> * to : ERROR_PASSIVE, BUS_OFF
>>> @@ -951,7 +952,8 @@ static void at91_irq_err_state(struct net_device *dev,
>>> netdev_dbg(dev, "Error Active\n");
>>> cf->can_id |= CAN_ERR_PROT;
>>> cf->data[2] = CAN_ERR_PROT_ACTIVE;
>>> - case CAN_STATE_ERROR_WARNING: /* fallthrough */
>>> + /* fall through */
>>> + case CAN_STATE_ERROR_WARNING:
>>> reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
>>> reg_ier = AT91_IRQ_ERRP;
>>> break;
>>> diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c
>>> index c458d5fdc8d3..e4f4d65a76b4 100644
>>> --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c
>>> +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c
>>> @@ -668,7 +668,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
>>> pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
>>> PCIEFD_REG_CAN_CLK_SEL);
>>>
>>> - /* fallthough */
>>> + /* fall through */
>>> case CANFD_CLK_SEL_80MHZ:
>>> priv->ucan.can.clock.freq = 80 * 1000 * 1000;
>>> break;
>>> diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
>>> index e90817608645..17257c73c302 100644
>>> --- a/drivers/net/can/spi/mcp251x.c
>>> +++ b/drivers/net/can/spi/mcp251x.c
>>> @@ -875,7 +875,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
>>> if (new_state >= CAN_STATE_ERROR_WARNING &&
>>> new_state <= CAN_STATE_BUS_OFF)
>>> priv->can.can_stats.error_warning++;
>>> - case CAN_STATE_ERROR_WARNING: /* fallthrough */
>>> + /* fall through */
>>> + case CAN_STATE_ERROR_WARNING:
>>> if (new_state >= CAN_STATE_ERROR_PASSIVE &&
>>> new_state <= CAN_STATE_BUS_OFF)
>>> priv->can.can_stats.error_passive++;
>>> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
>>> index 13238a72a338..eca785532b6b 100644
>>> --- a/drivers/net/can/usb/peak_usb/pcan_usb.c
>>> +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
>>> @@ -423,7 +423,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
>>> new_state = CAN_STATE_ERROR_WARNING;
>>> break;
>>> }
>>> - /* else: fall through */
>>> + /* fall through */
>>>
>>> case CAN_STATE_ERROR_WARNING:
>>> if (n & PCAN_USB_ERROR_BUS_HEAVY) {
>>>
>>
>>
^ permalink raw reply
* Re: WARNING in xfrm_policy_fini
From: syzbot @ 2019-02-19 3:05 UTC (permalink / raw)
To: davem, herbert, linux-kernel, netdev, steffen.klassert,
syzkaller-bugs
In-Reply-To: <000000000000c5745b0573d62311@google.com>
syzbot has found a reproducer for the following crash on:
HEAD commit: a3b22b9f11d9 Linux 5.0-rc7
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17e3d4d0c00000
kernel config: https://syzkaller.appspot.com/x/.config?x=7132344728e7ec3f
dashboard link: https://syzkaller.appspot.com/bug?extid=9bce6db6c82f06b85d8b
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=177317a8c00000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+9bce6db6c82f06b85d8b@syzkaller.appspotmail.com
bond0 (unregistering): Releasing backup interface bond_slave_1
bond0 (unregistering): Releasing backup interface bond_slave_0
bond0 (unregistering): Released all slaves
cgroup: fork rejected by pids controller in /syz3
cgroup: fork rejected by pids controller in /syz2
WARNING: CPU: 1 PID: 31 at net/xfrm/xfrm_policy.c:3871
xfrm_policy_fini+0x30c/0x3a0 net/xfrm/xfrm_policy.c:3871
Kernel panic - not syncing: panic_on_warn set ...
CPU: 1 PID: 31 Comm: kworker/u4:2 Not tainted 5.0.0-rc7 #77
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: netns cleanup_net
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
panic+0x2cb/0x65c kernel/panic.c:214
__warn.cold+0x20/0x45 kernel/panic.c:571
report_bug+0x263/0x2b0 lib/bug.c:186
fixup_bug arch/x86/kernel/traps.c:178 [inline]
fixup_bug arch/x86/kernel/traps.c:173 [inline]
do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271
do_invalid_op+0x37/0x50 arch/x86/kernel/traps.c:290
invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:973
kobject: 'loop1' (00000000fd200829): kobject_uevent_env
RIP: 0010:xfrm_policy_fini+0x30c/0x3a0 net/xfrm/xfrm_policy.c:3871
Code: c3 e8 b8 e9 72 fb 0f 0b e9 49 fe ff ff e8 ac e9 72 fb 0f 0b e9 cd fd
ff ff e8 a0 e9 72 fb 0f 0b e9 00 ff ff ff e8 94 e9 72 fb <0f> 0b e9 62 fd
ff ff e8 98 e8 a9 fb e9 7d fe ff ff 4c 89 ff e8 ab
kobject: 'loop1' (00000000fd200829): fill_kobj_path: path
= '/devices/virtual/block/loop1'
RSP: 0018:ffff8880a9a8fbb0 EFLAGS: 00010293
RAX: ffff8880a9a82100 RBX: ffff88808e30dbf0 RCX: 1ffff1101535053e
RDX: 0000000000000000 RSI: ffffffff85fcf7ec RDI: ffff8880a9a8297c
RBP: ffff8880a9a8fbf0 R08: ffff8880a9a82100 R09: ffff8880a9a829f0
R10: 0000000000000000 R11: 0000000000000000 R12: ffff88808e30c080
R13: ffff8880a9a8fcc8 R14: ffffffff893d5eb8 R15: dffffc0000000000
xfrm_net_exit+0x1d/0x70 net/xfrm/xfrm_policy.c:3931
ops_exit_list.isra.0+0xb0/0x160 net/core/net_namespace.c:153
cleanup_net+0x3fb/0x960 net/core/net_namespace.c:551
kobject: 'loop1' (00000000fd200829): kobject_uevent_env
kobject: 'loop1' (00000000fd200829): fill_kobj_path: path
= '/devices/virtual/block/loop1'
cgroup: fork rejected by pids controller in /syz1
process_one_work+0x98e/0x1790 kernel/workqueue.c:2173
worker_thread+0x98/0xe40 kernel/workqueue.c:2319
kthread+0x357/0x430 kernel/kthread.c:246
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
Kernel Offset: disabled
Rebooting in 86400 seconds..
^ permalink raw reply
* Re: [PATCH 1/2] wireless: mt76: call hweight8() instead of __sw_hweight8()
From: Kalle Valo @ 2019-02-19 4:06 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Ingo Molnar, Thomas Gleixner, Borislav Petkov, H . Peter Anvin,
X86 ML, linux-wireless, Christoph Hellwig, David S. Miller,
Networking, Linux Kernel Mailing List, Lorenzo Bianconi,
moderated list:ARM/Mediatek SoC support, linux-arm-kernel,
Felix Fietkau, Matthias Brugger
In-Reply-To: <CAK7LNAQMgFXw=rtpdPNZ=xpLw-SiwKGAgM__Owvqd1EhTCUntQ@mail.gmail.com>
Masahiro Yamada <yamada.masahiro@socionext.com> writes:
> On Tue, Feb 19, 2019 at 4:38 AM Kalle Valo <kvalo@codeaurora.org> wrote:
>>
>> Kalle Valo <kvalo@codeaurora.org> writes:
>>
>> > Kalle Valo <kvalo@codeaurora.org> writes:
>> >
>> >> Masahiro Yamada <yamada.masahiro@socionext.com> writes:
>> >>
>> >>> __sw_hweight8() is just internal implementation.
>> >>>
>> >>> Drivers should use the common API, hweight8().
>> >>>
>> >>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> >>
>> >> Acked-by: Kalle Valo <kvalo@codeaurora.org>
>> >>
>> >>> This patch should go to x86 tree along with 2/2.
>> >>>
>> >>> Otherwise, all{yes,mod}config of x86 would be broken.
>> >>>
>> >>> This patch is trivial enough.
>> >>> I want ACK from the net/wireless maintainer
>> >>> so that this can go in via x86 tree.
>> >>
>> >> Sounds good to me, feel free to push via the x86 tree.
>> >
>> > Actually, can you wait a bit? Felix just reminded me that we have a
>> > similar patch pending from Ben Hutchings:
>> >
>> > https://patchwork.kernel.org/patch/10808203/
>> >
>> > And it seems there are two instances of __sw_hweight8, at least in my
>> > wireless-drivers-next tree:
>> >
>> > drivers/net/wireless/mediatek/mt76/mac80211.c: int i, nstream =
>> > __sw_hweight8(dev->antenna_mask);
>> > drivers/net/wireless/mediatek/mt76/mac80211.c: int n_chains =
>> > __sw_hweight8(dev->antenna_mask);
>> >
>> > So we need to think what to do.
>>
>> I think the best would be that Felix applies Ben's patch to the wireless
>> tree and I'll push it to Linus during the next merge window (via
>> net-next). Simpler and less conflicts that way.
>>
>> So Masahiro, could you hold your x86 patch for a while until the mt76
>> patch will be in Linus' tree? That should not take more than two weeks,
>> I think.
>
> Sure.
> I will resend 2/2 later.
Great, thanks!
--
Kalle Valo
^ permalink raw reply
* Re: [PATCH v2 1/2] Provide in-kernel headers for making it easy to extend the kernel
From: Masahiro Yamada @ 2019-02-19 4:14 UTC (permalink / raw)
To: Alexei Starovoitov, Joel Fernandes (Google)
Cc: Networking, Linux Kernel Mailing List, Andrew Morton,
Alexei Starovoitov, atish patra, Daniel Colascione, Dan Williams,
Greg Kroah-Hartman, Jonathan Corbet, Karim Yaghmour, Kees Cook,
kernel-team, open list:DOCUMENTATION,
open list:KERNEL SELFTEST FRAMEWORK, Manoj Rao, Paul McKenney,
Peter Zijlstra (Intel), Randy Dunlap, Steven Rostedt, Shuah Khan,
Thomas Gleixner, Yonghong Song
In-Reply-To: <20190215031926.ljzluy2cfxp64u6o@ast-mbp>
On Fri, Feb 15, 2019 at 11:48 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Mon, Feb 11, 2019 at 09:35:59AM -0500, Joel Fernandes (Google) wrote:
> > Introduce in-kernel headers and other artifacts which are made available
> > as an archive through proc (/proc/kheaders.txz file).
The extension '.txz' is not used in kernel code.
'.tar.xz' is used for 'tarxz-pkg', 'perf-tarxz-src-pkg' etc.
$ git grep '\.txz'
$ git grep '\.tar\.xz'
Documentation/admin-guide/README.rst: xz -cd linux-4.X.tar.xz | tar xvf -
arch/x86/crypto/camellia-aesni-avx-asm_64.S: *
http://koti.mbnet.fi/axh/crypto/camellia-BSD-1.2.0-aesni1.tar.xz
crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
scripts/package/Makefile: @echo ' perf-tarxz-src-pkg - Build
$(perf-tar).tar.xz source tarball'
tools/testing/selftests/gen_kselftest_tar.sh:
ext=".tar.xz"
I prefer '.tar.xz' for consistency.
BTW, have you ever looked at scripts/extract-ikconfig?
You added IKHD_ST and IKHD_ED
just to mimic kernel/configs.c
It is currently pointless without the extracting tool,
but you might think it is useful to extract headers
from vmlinux or the module without mounting procfs.
> > This archive makes
> > it possible to build kernel modules, run eBPF programs, and other
> > tracing programs that need to extend the kernel for tracing purposes
> > without any dependency on the file system having headers and build
> > artifacts.
> >
> > On Android and embedded systems, it is common to switch kernels but not
> > have kernel headers available on the file system. Raw kernel headers
> > also cannot be copied into the filesystem like they can be on other
> > distros, due to licensing and other issues. There's no linux-headers
> > package on Android. Further once a different kernel is booted, any
> > headers stored on the file system will no longer be useful. By storing
> > the headers as a compressed archive within the kernel, we can avoid these
> > issues that have been a hindrance for a long time.
>
> The set looks good to me and since the main use case is building bpf progs
> I can route it via bpf-next tree if there are no objections.
> Masahiro, could you please ack it?
Honestly, I was not tracking this thread
since I did not know I was responsible for this.
I just started to take a closer look, then immediately got scared.
This version is not mature enough for the merge.
First of all, this patch cannot be compiled out-of-tree (O= option).
I do not know why 0-day bot did not catch this apparent breakage.
$ make -j8 O=hoge
make[1]: Entering directory '/home/masahiro/workspace/bsp/linux/hoge'
GEN Makefile
Using .. as source for kernel
DESCEND objtool
CALL ../scripts/checksyscalls.sh
CHK include/generated/compile.h
make[2]: *** No rule to make target 'Module.symvers', needed by
'kernel/kheaders_data.txz'. Stop.
make[2]: *** Waiting for unfinished jobs....
/home/masahiro/workspace/bsp/linux/Makefile:1043: recipe for target
'kernel' failed
make[1]: *** [kernel] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/masahiro/workspace/bsp/linux/hoge'
Makefile:152: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
I was able to compile it in-tree
but it makes the incremental build extremely slow.
(Here, the incremental build means
"make" without changing any code after the full build.)
Before this patch, "make -j8" took 11 sec on my machine.
real 0m11.777s
user 0m16.608s
sys 0m5.164s
After this patch, x86_64_defconfig + CONFIG_IKHEADERS_PROC=y
takes 53 sec for me since kernel/kheaders_data.txz is regenerated
every time even when you did not touch any source file.
$ time make -j8
DESCEND objtool
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
GEN kernel/kheaders_data.txz
UPD kernel/kheaders_data.h
CC kernel/kheaders.o
AR kernel/built-in.a
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
AR init/built-in.a
AR built-in.a
LD vmlinux.o
MODPOST vmlinux.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
Building modules, stage 2.
CC arch/x86/boot/version.o
MODPOST 17 modules
VOFFSET arch/x86/boot/compressed/../voffset.h
OBJCOPY arch/x86/boot/compressed/vmlinux.bin
RELOCS arch/x86/boot/compressed/vmlinux.relocs
CC arch/x86/boot/compressed/kaslr.o
GZIP arch/x86/boot/compressed/vmlinux.bin.gz
CC arch/x86/boot/compressed/misc.o
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
OBJCOPY arch/x86/boot/vmlinux.bin
AS arch/x86/boot/header.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
BUILD arch/x86/boot/bzImage
Setup is 15612 bytes (padded to 15872 bytes).
System is 12673 kB
CRC 697aaf88
Kernel: arch/x86/boot/bzImage is ready (#6)
real 0m53.024s
user 0m32.076s
sys 0m9.296s
Also, I notice $(ARCH) must be fixed to $(SRCARCH),
but that is one of minor issues.
We should take time for careful review and test.
Please give me more time for thorough review.
--
Best Regards
Masahiro Yamada
^ permalink raw reply
* [tipc-discussion][net 2/2] tipc: improve function tipc_wait_for_rcvmsg()
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
In-Reply-To: <20190219042048.23243-1-tung.q.nguyen@dektech.com.au>
This commit replaces schedule_timeout() with wait_woken()
in function tipc_wait_for_rcvmsg(). wait_woken() uses
memory barriers in its implementation to avoid potential
race condition when putting a process into sleeping state
and then waking it up.
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
---
net/tipc/socket.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 81b87916a0eb..684f2125fc6b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1677,7 +1677,7 @@ static void tipc_sk_send_ack(struct tipc_sock *tsk)
static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
{
struct sock *sk = sock->sk;
- DEFINE_WAIT(wait);
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
long timeo = *timeop;
int err = sock_error(sk);
@@ -1685,15 +1685,17 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
return err;
for (;;) {
- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
if (timeo && skb_queue_empty(&sk->sk_receive_queue)) {
if (sk->sk_shutdown & RCV_SHUTDOWN) {
err = -ENOTCONN;
break;
}
+ add_wait_queue(sk_sleep(sk), &wait);
release_sock(sk);
- timeo = schedule_timeout(timeo);
+ timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
+ sched_annotate_sleep();
lock_sock(sk);
+ remove_wait_queue(sk_sleep(sk), &wait);
}
err = 0;
if (!skb_queue_empty(&sk->sk_receive_queue))
@@ -1709,7 +1711,6 @@ static int tipc_wait_for_rcvmsg(struct socket *sock, long *timeop)
if (err)
break;
}
- finish_wait(sk_sleep(sk), &wait);
*timeop = timeo;
return err;
}
--
2.17.1
^ permalink raw reply related
* [tipc-discussion][net 1/2] tipc: improve function tipc_wait_for_cond()
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
In-Reply-To: <20190219042048.23243-1-tung.q.nguyen@dektech.com.au>
Commit 844cf763fba6 ("tipc: make macro tipc_wait_for_cond() smp safe")
replaced finish_wait() with remove_wait_queue() but still used
prepare_to_wait(). This causes unnecessary conditional
checking before adding to wait queue in prepare_to_wait().
This commit replaces prepare_to_wait() with add_wait_queue()
as the pair function with remove_wait_queue().
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
---
net/tipc/socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1217c90a363b..81b87916a0eb 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -388,7 +388,7 @@ static int tipc_sk_sock_err(struct socket *sock, long *timeout)
rc_ = tipc_sk_sock_err((sock_), timeo_); \
if (rc_) \
break; \
- prepare_to_wait(sk_sleep(sk_), &wait_, TASK_INTERRUPTIBLE); \
+ add_wait_queue(sk_sleep(sk_), &wait_); \
release_sock(sk_); \
*(timeo_) = wait_woken(&wait_, TASK_INTERRUPTIBLE, *(timeo_)); \
sched_annotate_sleep(); \
--
2.17.1
^ permalink raw reply related
* [tipc-discussion][net 0/2] improvement for wait and wakeup
From: Tung Nguyen @ 2019-02-19 4:20 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion
Some improvements for tipc_wait_for_xzy().
Tung Nguyen (2):
tipc: improve function tipc_wait_for_cond()
tipc: improve function tipc_wait_for_rcvmsg()
net/tipc/socket.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--
2.17.1
^ permalink raw reply
* Re: [PATCH v2 1/2] Provide in-kernel headers for making it easy to extend the kernel
From: Alexei Starovoitov @ 2019-02-19 4:28 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Joel Fernandes (Google), Networking, Linux Kernel Mailing List,
Andrew Morton, Alexei Starovoitov, atish patra, Daniel Colascione,
Dan Williams, Greg Kroah-Hartman, Jonathan Corbet, Karim Yaghmour,
Kees Cook, kernel-team, open list:DOCUMENTATION,
open list:KERNEL SELFTEST FRAMEWORK, Manoj Rao, Paul McKenney,
Peter Zijlstra (Intel), Randy Dunlap, Steven Rostedt, Shuah Khan,
Thomas Gleixner, Yonghong Song
In-Reply-To: <CAK7LNAThSm1n1B_Ss0gRDZ3H-DWj2bvpZ+6Ui2jEo4Pt9YynEA@mail.gmail.com>
On Tue, Feb 19, 2019 at 01:14:11PM +0900, Masahiro Yamada wrote:
>
> I was able to compile it in-tree
> but it makes the incremental build extremely slow.
>
> (Here, the incremental build means
> "make" without changing any code after the full build.)
>
> Before this patch, "make -j8" took 11 sec on my machine.
>
> After this patch, x86_64_defconfig + CONFIG_IKHEADERS_PROC=y
> takes 53 sec for me since kernel/kheaders_data.txz is regenerated
> every time even when you did not touch any source file.
>
> We should take time for careful review and test.
>
> Please give me more time for thorough review.
Thanks for taking a look. All are very valid points.
Incremental build is must have.
^ permalink raw reply
* Re: Three questions about busy poll
From: Cong Wang @ 2019-02-19 4:30 UTC (permalink / raw)
To: Willem de Bruijn
Cc: Alexander Duyck, Eric Dumazet, Samudrala, Sridhar,
Linux Kernel Network Developers
In-Reply-To: <CA+FuTSc-Oq0XWowxDEYeZ+oT6SG8YZSu5nvzeOO5sUq3v51Lvg@mail.gmail.com>
On Fri, Feb 15, 2019 at 2:47 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> > > > 2. Why there is no socket option for sysctl.net.busy_poll? Clearly
> > > > sysctl_net_busy_poll is global and SO_BUSY_POLL only works for
> > > > sysctl.net.busy_read.
> > >
> > > I guess because of how sock_poll works. In that case it is not needed.
> > > The poll duration applies more to the pollset than any of the
> > > individual sockets, too.
> >
> >
> > Good point, it's probably like struct eventpoll vs. struct epitem.
> >
> > The reason why I am looking for a per-socket tuning is to minimize
> > the impact of setting busy_poll. I don't know if it is possible to somehow
> > make this per-socket via epoll interfaces, perhaps fundamentally
> > it is impossible?
>
> I think it may be possible. The way busy_read and busy_poll work
> in sock_poll is that the sum of all (per socket tunable) busy_read
> durations on the sockets in the pollset is ~bound by (global) busy_poll.
Good idea!!
I was actually thinking about checking sk->sk_ll_usec
ep_set_busy_poll_napi_id(). Your idea sounds better than mine.
Maybe we can do both together. :)
>
> The epoll implementation is restricted in the sense that it polls only
> on one napi_id at a time. Alongside setting ep->napi_id in
> ep_set_busy_poll_napi_id, we could also set a new ep field takes
> the min of the global busy_poll and sk->sk_ll_usec.
>
> Though I guess you want to be able to poll on a given pollset
> without setting the global sysctl_net_busy_poll at all? That
> would be a useful feature both for epoll and poll/select. But
> definitely requires refining net_busy_loop_on() to optionally
> take some state derived from the sockets in the (e)pollset.
Yes, or at least give some control to each application.
I was thinking about this:
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index a5d219d920e7..1b104c8bda5e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -432,7 +432,7 @@ static inline void ep_set_busy_poll_napi_id(struct
epitem *epi)
return;
sk = sock->sk;
- if (!sk)
+ if (!sk || !sk->sk_ll_usec)
return;
napi_id = READ_ONCE(sk->sk_napi_id);
With this change, busy_poll would rely on either busy_read or
SO_BUSY_POLL.
Does this make any sense?
Thanks.
^ permalink raw reply related
* Re: [PATCH v2 1/2] Provide in-kernel headers for making it easy to extend the kernel
From: Joel Fernandes @ 2019-02-19 4:34 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Alexei Starovoitov, Networking, Linux Kernel Mailing List,
Andrew Morton, Alexei Starovoitov, atish patra, Daniel Colascione,
Dan Williams, Greg Kroah-Hartman, Jonathan Corbet, Karim Yaghmour,
Kees Cook, kernel-team, open list:DOCUMENTATION,
open list:KERNEL SELFTEST FRAMEWORK, Manoj Rao, Paul McKenney,
Peter Zijlstra (Intel), Randy Dunlap, Steven Rostedt, Shuah Khan,
Thomas Gleixner, Yonghong Song
In-Reply-To: <CAK7LNAThSm1n1B_Ss0gRDZ3H-DWj2bvpZ+6Ui2jEo4Pt9YynEA@mail.gmail.com>
On Tue, Feb 19, 2019 at 01:14:11PM +0900, Masahiro Yamada wrote:
> On Fri, Feb 15, 2019 at 11:48 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Mon, Feb 11, 2019 at 09:35:59AM -0500, Joel Fernandes (Google) wrote:
> > > Introduce in-kernel headers and other artifacts which are made available
> > > as an archive through proc (/proc/kheaders.txz file).
>
>
> The extension '.txz' is not used in kernel code.
>
>
> '.tar.xz' is used for 'tarxz-pkg', 'perf-tarxz-src-pkg' etc.
>
>
> $ git grep '\.txz'
> $ git grep '\.tar\.xz'
> Documentation/admin-guide/README.rst: xz -cd linux-4.X.tar.xz | tar xvf -
> arch/x86/crypto/camellia-aesni-avx-asm_64.S: *
> http://koti.mbnet.fi/axh/crypto/camellia-BSD-1.2.0-aesni1.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> scripts/package/Makefile: @echo ' perf-tarxz-src-pkg - Build
> $(perf-tar).tar.xz source tarball'
> tools/testing/selftests/gen_kselftest_tar.sh:
> ext=".tar.xz"
>
>
>
> I prefer '.tar.xz' for consistency.
Ok, I will change it to that.
> BTW, have you ever looked at scripts/extract-ikconfig?
>
> You added IKHD_ST and IKHD_ED
> just to mimic kernel/configs.c
>
> It is currently pointless without the extracting tool,
> but you might think it is useful to extract headers
> from vmlinux or the module without mounting procfs.
I am planing add to extraction support in the future, so I prefer to leave the
markers as it is for now. Hope that's Ok with you.
> > > This archive makes
> > > it possible to build kernel modules, run eBPF programs, and other
> > > tracing programs that need to extend the kernel for tracing purposes
> > > without any dependency on the file system having headers and build
> > > artifacts.
> > >
> > > On Android and embedded systems, it is common to switch kernels but not
> > > have kernel headers available on the file system. Raw kernel headers
> > > also cannot be copied into the filesystem like they can be on other
> > > distros, due to licensing and other issues. There's no linux-headers
> > > package on Android. Further once a different kernel is booted, any
> > > headers stored on the file system will no longer be useful. By storing
> > > the headers as a compressed archive within the kernel, we can avoid these
> > > issues that have been a hindrance for a long time.
> >
> > The set looks good to me and since the main use case is building bpf progs
> > I can route it via bpf-next tree if there are no objections.
> > Masahiro, could you please ack it?
>
>
> Honestly, I was not tracking this thread
> since I did not know I was responsible for this.
>
>
> I just started to take a closer look, then immediately got scared.
>
> This version is not mature enough for the merge.
> First of all, this patch cannot be compiled out-of-tree (O= option).
Oh, ok. This is not how I build the kernel. So I am sorry for missing that. I
will try this out-of-tree build option and fix it.
> I do not know why 0-day bot did not catch this apparent breakage.
>
>
> $ make -j8 O=hoge
> make[1]: Entering directory '/home/masahiro/workspace/bsp/linux/hoge'
> GEN Makefile
> Using .. as source for kernel
> DESCEND objtool
> CALL ../scripts/checksyscalls.sh
> CHK include/generated/compile.h
> make[2]: *** No rule to make target 'Module.symvers', needed by
> 'kernel/kheaders_data.txz'. Stop.
> make[2]: *** Waiting for unfinished jobs....
> /home/masahiro/workspace/bsp/linux/Makefile:1043: recipe for target
> 'kernel' failed
> make[1]: *** [kernel] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make[1]: Leaving directory '/home/masahiro/workspace/bsp/linux/hoge'
> Makefile:152: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
>
>
>
>
>
> I was able to compile it in-tree
> but it makes the incremental build extremely slow.
>
> (Here, the incremental build means
> "make" without changing any code after the full build.)
>
>
>
>
> Before this patch, "make -j8" took 11 sec on my machine.
>
> real 0m11.777s
> user 0m16.608s
> sys 0m5.164s
>
>
>
> After this patch, x86_64_defconfig + CONFIG_IKHEADERS_PROC=y
> takes 53 sec for me since kernel/kheaders_data.txz is regenerated
> every time even when you did not touch any source file.
Hmm, true. Let me know look into that as well..
> $ time make -j8
> DESCEND objtool
> CALL scripts/checksyscalls.sh
> CHK include/generated/compile.h
> GEN kernel/kheaders_data.txz
> UPD kernel/kheaders_data.h
> CC kernel/kheaders.o
> AR kernel/built-in.a
> GEN .version
> CHK include/generated/compile.h
> UPD include/generated/compile.h
> CC init/version.o
> AR init/built-in.a
> AR built-in.a
> LD vmlinux.o
> MODPOST vmlinux.o
> KSYM .tmp_kallsyms1.o
> KSYM .tmp_kallsyms2.o
> LD vmlinux
> SORTEX vmlinux
> SYSMAP System.map
> Building modules, stage 2.
> CC arch/x86/boot/version.o
> MODPOST 17 modules
> VOFFSET arch/x86/boot/compressed/../voffset.h
> OBJCOPY arch/x86/boot/compressed/vmlinux.bin
> RELOCS arch/x86/boot/compressed/vmlinux.relocs
> CC arch/x86/boot/compressed/kaslr.o
> GZIP arch/x86/boot/compressed/vmlinux.bin.gz
> CC arch/x86/boot/compressed/misc.o
> MKPIGGY arch/x86/boot/compressed/piggy.S
> AS arch/x86/boot/compressed/piggy.o
> LD arch/x86/boot/compressed/vmlinux
> ZOFFSET arch/x86/boot/zoffset.h
> OBJCOPY arch/x86/boot/vmlinux.bin
> AS arch/x86/boot/header.o
> LD arch/x86/boot/setup.elf
> OBJCOPY arch/x86/boot/setup.bin
> BUILD arch/x86/boot/bzImage
> Setup is 15612 bytes (padded to 15872 bytes).
> System is 12673 kB
> CRC 697aaf88
> Kernel: arch/x86/boot/bzImage is ready (#6)
>
> real 0m53.024s
> user 0m32.076s
> sys 0m9.296s
>
>
>
>
> Also, I notice $(ARCH) must be fixed to $(SRCARCH),
> but that is one of minor issues.
Ok.
> We should take time for careful review and test.
Yes, I agree.
> Please give me more time for thorough review.
Sure. Thanks a lot for the feedback provided so far. I will send another
revision soon with all the suggestions addressed.
thanks,
- Joel
^ permalink raw reply
* [PATCH net] net: avoid false positives in untrusted gso validation
From: Willem de Bruijn @ 2019-02-19 4:37 UTC (permalink / raw)
To: netdev; +Cc: davem, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
GSO packets with vnet_hdr must conform to a small set of gso_types.
The below commit uses flow dissection to drop packets that do not.
But it has false positives when the skb is not fully initialized.
Dissection needs skb->protocol and skb->network_header.
Infer skb->protocol from gso_type as the two must agree.
SKB_GSO_UDP can use both ipv4 and ipv6, so try both.
Exclude callers for which network header offset is not known.
Fixes: d5be7f632bad ("net: validate untrusted gso packets without csum offload")
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
include/linux/virtio_net.h | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 71f2394abbf7..e0348cb0a1dd 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -61,10 +61,20 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
/* gso packets without NEEDS_CSUM do not set transport_offset.
* probe and drop if does not match one of the above types.
*/
- if (gso_type) {
+ if (gso_type && skb->network_header) {
+ if (!skb->protocol)
+ virtio_net_hdr_set_proto(skb, hdr);
+retry:
skb_probe_transport_header(skb, -1);
- if (!skb_transport_header_was_set(skb))
+ if (!skb_transport_header_was_set(skb)) {
+ /* UFO does not specify ipv4 or 6: try both */
+ if (gso_type & SKB_GSO_UDP &&
+ skb->protocol == htons(ETH_P_IP)) {
+ skb->protocol = htons(ETH_P_IPV6);
+ goto retry;
+ }
return -EINVAL;
+ }
}
}
--
2.21.0.rc0.258.g878e2cd30e-goog
^ permalink raw reply related
* Re: [PATCH net] net: validate untrusted gso packets without csum offload
From: Willem de Bruijn @ 2019-02-19 4:40 UTC (permalink / raw)
To: Network Development
Cc: David Miller, Eric Dumazet, Jason Wang, Maxim Mikityanskiy,
Willem de Bruijn, syzbot
In-Reply-To: <CAF=yD-JMwss15tDEpXq0_399H_BTHmmCX30sgUj0Zu94A4ABYw@mail.gmail.com>
On Mon, Feb 18, 2019 at 2:12 PM Willem de Bruijn
<willemdebruijn.kernel@gmail.com> wrote:
>
> On Fri, Feb 15, 2019 at 12:15 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> >
> > From: Willem de Bruijn <willemb@google.com>
> >
> > Syzkaller again found a path to a kernel crash through bad gso input.
> > By building an excessively large packet to cause an skb field to wrap.
> >
> > If VIRTIO_NET_HDR_F_NEEDS_CSUM was set this would have been dropped in
> > skb_partial_csum_set.
> >
> > GSO packets that do not set checksum offload are suspicious and rare.
> > Most callers of virtio_net_hdr_to_skb already pass them to
> > skb_probe_transport_header.
> >
> > Move that test forward, change it to detect parse failure and drop
> > packets on failure as those cleary are not one of the legitimate
> > VIRTIO_NET_HDR_GSO types.
> >
> > Fixes: bfd5f4a3d605 ("packet: Add GSO/csum offload support.")
> > Fixes: f43798c27684 ("tun: Allow GSO using virtio_net_hdr")
> > Reported-by: syzbot <syzkaller@googlegroups.com>
> > Signed-off-by: Willem de Bruijn <willemb@google.com>
>
> This causes false positive drops on virtio-net and tun for these
> packets with gso without csum_off. And on pf_packet with proto 0.
>
> This happens because skb->protocol is set in these callers after
> the call to virtio_net_hdr_to_skb. And the flow dissector relies on
> this to start dissection, not the link layer header (if present).
> Moving this logic forward is too much churn for net, especially since
> eth_type_header pulls the header, requiring additional changes to
> adjust csum_start.
>
> virtio_net_hdr_set_proto() aims to fix this by deriving skb->protocol
> from the gso_type. But unfortunately for UDP it unconditionally
> selects ipv4, which will cause drops for UDP over ipv6.
Suggested fix at http://patchwork.ozlabs.org/patch/1044429/
^ permalink raw reply
* Re: [PATCH v2 1/2] Provide in-kernel headers for making it easy to extend the kernel
From: Masahiro Yamada @ 2019-02-19 4:42 UTC (permalink / raw)
To: Alexei Starovoitov, Joel Fernandes (Google)
Cc: Networking, Linux Kernel Mailing List, Andrew Morton,
Alexei Starovoitov, atish patra, Daniel Colascione, Dan Williams,
Greg Kroah-Hartman, Jonathan Corbet, Karim Yaghmour, Kees Cook,
kernel-team, open list:DOCUMENTATION,
open list:KERNEL SELFTEST FRAMEWORK, Manoj Rao, Paul McKenney,
Peter Zijlstra (Intel), Randy Dunlap, Steven Rostedt, Shuah Khan,
Thomas Gleixner, Yonghong Song
In-Reply-To: <CAK7LNAThSm1n1B_Ss0gRDZ3H-DWj2bvpZ+6Ui2jEo4Pt9YynEA@mail.gmail.com>
On Tue, Feb 19, 2019 at 1:14 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> On Fri, Feb 15, 2019 at 11:48 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Mon, Feb 11, 2019 at 09:35:59AM -0500, Joel Fernandes (Google) wrote:
> > > Introduce in-kernel headers and other artifacts which are made available
> > > as an archive through proc (/proc/kheaders.txz file).
>
>
> The extension '.txz' is not used in kernel code.
>
>
> '.tar.xz' is used for 'tarxz-pkg', 'perf-tarxz-src-pkg' etc.
>
>
> $ git grep '\.txz'
> $ git grep '\.tar\.xz'
> Documentation/admin-guide/README.rst: xz -cd linux-4.X.tar.xz | tar xvf -
> arch/x86/crypto/camellia-aesni-avx-asm_64.S: *
> http://koti.mbnet.fi/axh/crypto/camellia-BSD-1.2.0-aesni1.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> crypto/testmgr.h: * https://bench.cr.yp.to/supercop/supercop-20170228.tar.xz
> scripts/package/Makefile: @echo ' perf-tarxz-src-pkg - Build
> $(perf-tar).tar.xz source tarball'
> tools/testing/selftests/gen_kselftest_tar.sh:
> ext=".tar.xz"
>
>
>
> I prefer '.tar.xz' for consistency.
>
>
>
>
>
>
> BTW, have you ever looked at scripts/extract-ikconfig?
>
> You added IKHD_ST and IKHD_ED
> just to mimic kernel/configs.c
>
> It is currently pointless without the extracting tool,
> but you might think it is useful to extract headers
> from vmlinux or the module without mounting procfs.
>
>
>
>
> > > This archive makes
> > > it possible to build kernel modules, run eBPF programs, and other
> > > tracing programs that need to extend the kernel for tracing purposes
> > > without any dependency on the file system having headers and build
> > > artifacts.
> > >
> > > On Android and embedded systems, it is common to switch kernels but not
> > > have kernel headers available on the file system. Raw kernel headers
> > > also cannot be copied into the filesystem like they can be on other
> > > distros, due to licensing and other issues. There's no linux-headers
> > > package on Android. Further once a different kernel is booted, any
> > > headers stored on the file system will no longer be useful. By storing
> > > the headers as a compressed archive within the kernel, we can avoid these
> > > issues that have been a hindrance for a long time.
> >
> > The set looks good to me and since the main use case is building bpf progs
> > I can route it via bpf-next tree if there are no objections.
> > Masahiro, could you please ack it?
>
>
> Honestly, I was not tracking this thread
> since I did not know I was responsible for this.
>
>
> I just started to take a closer look, then immediately got scared.
>
> This version is not mature enough for the merge.
>
>
>
> First of all, this patch cannot be compiled out-of-tree (O= option).
>
>
> I do not know why 0-day bot did not catch this apparent breakage.
>
>
> $ make -j8 O=hoge
> make[1]: Entering directory '/home/masahiro/workspace/bsp/linux/hoge'
> GEN Makefile
> Using .. as source for kernel
> DESCEND objtool
> CALL ../scripts/checksyscalls.sh
> CHK include/generated/compile.h
> make[2]: *** No rule to make target 'Module.symvers', needed by
> 'kernel/kheaders_data.txz'. Stop.
> make[2]: *** Waiting for unfinished jobs....
> /home/masahiro/workspace/bsp/linux/Makefile:1043: recipe for target
> 'kernel' failed
> make[1]: *** [kernel] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make[1]: Leaving directory '/home/masahiro/workspace/bsp/linux/hoge'
> Makefile:152: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
I saw this build error for in-tree building as well.
We cannot build this from a pristine source tree.
For example, I observed the build error in the following procedure.
$ make mrproper
$ make defconfig
Set CONFIG_IKHEADERS_PROC=y
$ make
Module.symvers is generated in the modpost stage
(the very last stage of build).
But, vmlinux depends on kernel/kheaders_data.txz,
which includes Module.symvers.
So, this is not so simple since it is a circular dependency...
--
Best Regards
Masahiro Yamada
^ permalink raw reply
* Re: [PATCH] net: dsa: qca8k: Enable delay for RGMII_ID mode
From: Vinod Koul @ 2019-02-19 4:59 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S Miller, linux-arm-msm, Bjorn Andersson, netdev,
Niklas Cassel, Florian Fainelli, Michal Vokáč
In-Reply-To: <20190218133309.GB14879@lunn.ch>
Hi Andrew,
On 18-02-19, 14:33, Andrew Lunn wrote:
> On Mon, Feb 18, 2019 at 06:33:51PM +0530, Vinod Koul wrote:
> > RGMII_ID specifies that we should have internal delay, so resurrect the
> > delay addition routine but under the RGMII_ID mode.
> >
> > Fixes: 40269aa9f40a ("net: dsa: qca8k: disable delay for RGMII mode")
> > Signed-off-by: Vinod Koul <vkoul@kernel.org>
> > ---
> > drivers/net/dsa/qca8k.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> > index a4b6cda38016..aa1f7f1b20d3 100644
> > --- a/drivers/net/dsa/qca8k.c
> > +++ b/drivers/net/dsa/qca8k.c
> > @@ -443,6 +443,18 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode)
> > val = QCA8K_PORT_PAD_RGMII_EN;
> > qca8k_write(priv, reg, val);
> > break;
> > + case PHY_INTERFACE_MODE_RGMII_ID:
> > + /* RGMII_ID needs internal delay. This is enabled through
> > + * PORT5_PAD_CTRL for all ports, rather than individual port
> > + * registers
> > + */
> > + qca8k_write(priv, reg,
> > + QCA8K_PORT_PAD_RGMII_EN |
> > + QCA8K_PORT_PAD_RGMII_TX_DELAY(3) |
> > + QCA8K_PORT_PAD_RGMII_RX_DELAY(3));
> > + qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL,
> > + QCA8K_PORT_PAD_RGMII_RX_DELAY_EN);
> > + break;
>
> Hi Vinod
>
> So i'm still confused if this is global, or per-port. The first
> register written looks to be per-port, although only for ports 0 and
> 6. The second write seems to be global.
This is still a global write which enables the delay in all the ports
(as was the case previously)
> Is there a danger that port 0 has PHY_INTERFACE_MODE_RGMII_ID and port
> 6 has PHY_INTERFACE_MODE_RGMII, and we end up with delays disabled?
> Maybe we should try to detect this, and return an error?
If that was the case, I would presume people would have reported an
issue that it doesn't work for them..?
> > case PHY_INTERFACE_MODE_SGMII:
> > qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
> > break;
>
> I think it would be good to add the other two PHY_INTERFACE_MODE_RGMII
> modes to the default clause so we get an error reported that they are
> not implemented.
That is still the case:
default:
pr_err("xMII mode %d not supported\n", mode);
return -EINVAL;
--
~Vinod
^ permalink raw reply
* Re: [PATCH] net: dsa: qca8k: Enable delay for RGMII_ID mode
From: Vinod Koul @ 2019-02-19 5:00 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S Miller, linux-arm-msm, Bjorn Andersson, netdev,
Niklas Cassel, Florian Fainelli, Michal Vokáč
In-Reply-To: <20190218133621.GC14879@lunn.ch>
On 18-02-19, 14:36, Andrew Lunn wrote:
> On Mon, Feb 18, 2019 at 06:33:51PM +0530, Vinod Koul wrote:
> > + case PHY_INTERFACE_MODE_RGMII_ID:
> > + /* RGMII_ID needs internal delay. This is enabled through
> > + * PORT5_PAD_CTRL for all ports, rather than individual port
> > + * registers
> > + */
> > + qca8k_write(priv, reg,
> > + QCA8K_PORT_PAD_RGMII_EN |
> > + QCA8K_PORT_PAD_RGMII_TX_DELAY(3) |
> > + QCA8K_PORT_PAD_RGMII_RX_DELAY(3));
>
> Hi Vinod
>
> Could you add some #defines for the delay values?
Sure will update the patch
--
~Vinod
^ permalink raw reply
* Re: [PATCH v2 1/2] net: phy: at803x: dont inline helpers
From: Vinod Koul @ 2019-02-19 5:02 UTC (permalink / raw)
To: David Miller
Cc: linux-arm-msm, bjorn.andersson, netdev, niklas.cassel, andrew,
f.fainelli, nsekhar, peter.ujfalusi, marc.w.gonzalez
In-Reply-To: <20190218.162850.1254388175691397706.davem@davemloft.net>
Hello Dave,
On 18-02-19, 16:28, David Miller wrote:
> From: Vinod Koul <vkoul@kernel.org>
> Date: Mon, 18 Feb 2019 15:48:52 +0530
>
> > Some helpers were inlined, but makes more sense to allow compiler
> > to do the right optiomazations instead, so remove inline for
> > at803x_disable_rx_delay() and at803x_disable_tx_delay()
> >
> > Signed-off-by: Vinod Koul <vkoul@kernel.org>
>
> Two problem with this patch series.
>
> 1) It fixes a bug in 'net' but the patches only apply cleanly to
> 'net-next'. Please respin this against 'net'.
I assume the 'net' is fixes going into current -rcX. This fixes issues
reported on linux-next due to patches in net-next, so these fixes should
go to net-next as well.
> 2) This series lacks a header posting "[PATCH vX 0/N] " which
> explains at a high level what the series is doing, how it is
> doing it, and why it is doing it that way.
Sure I will add this and repost
Thanks
--
~Vinod
^ permalink raw reply
* Re: [PATCH net-next v4 07/17] net: sched: protect filter_chain list with filter_chain_lock mutex
From: Cong Wang @ 2019-02-19 5:08 UTC (permalink / raw)
To: Vlad Buslov
Cc: Ido Schimmel, netdev@vger.kernel.org, jhs@mojatatu.com,
jiri@resnulli.us, davem@davemloft.net, ast@kernel.org,
daniel@iogearbox.net
In-Reply-To: <vbfh8d5jroi.fsf@mellanox.com>
On Fri, Feb 15, 2019 at 2:02 AM Vlad Buslov <vladbu@mellanox.com> wrote:
>
> I looked at the code and problem seems to be matchall classifier
> specific. My implementation of unlocked cls API assumes that concurrent
> insertions are possible and checks for it when deleting "empty" tp.
> Since classifiers don't expose number of elements, the only way to test
> this is to do tp->walk() on them and assume that walk callback is called
> once per filter on every classifier. In your example new tp is created
> for second filter, filter insertion fails, number of elements on newly
> created tp is checked with tp->walk() before deleting it. However,
> matchall classifier always calls the tp->walk() callback once, even when
> it doesn't have a valid filter (in this case with NULL filter pointer).
Again, this can be eliminated by just switching to normal
non-retry logic. This is yet another headache to review this
kind of unlock-and-retry logic, I have no idea why you are such
a big fan of it.
^ permalink raw reply
* Re: [PATCH v2 1/2] Provide in-kernel headers for making it easy to extend the kernel
From: Joel Fernandes @ 2019-02-19 5:12 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Alexei Starovoitov, Networking, Linux Kernel Mailing List,
Andrew Morton, Alexei Starovoitov, atish patra, Daniel Colascione,
Dan Williams, Greg Kroah-Hartman, Jonathan Corbet, Karim Yaghmour,
Kees Cook, kernel-team, open list:DOCUMENTATION,
open list:KERNEL SELFTEST FRAMEWORK, Manoj Rao, Paul McKenney,
Peter Zijlstra (Intel), Randy Dunlap, Steven Rostedt, Shuah Khan,
Thomas Gleixner, Yonghong Song
In-Reply-To: <CAK7LNATf4adEEqWko2YO46wHHi-Vvc+_LBjQGNnM7rt8GSOgZQ@mail.gmail.com>
On Tue, Feb 19, 2019 at 01:42:13PM +0900, Masahiro Yamada wrote:
[..]
> > > > This archive makes
> > > > it possible to build kernel modules, run eBPF programs, and other
> > > > tracing programs that need to extend the kernel for tracing purposes
> > > > without any dependency on the file system having headers and build
> > > > artifacts.
> > > >
> > > > On Android and embedded systems, it is common to switch kernels but not
> > > > have kernel headers available on the file system. Raw kernel headers
> > > > also cannot be copied into the filesystem like they can be on other
> > > > distros, due to licensing and other issues. There's no linux-headers
> > > > package on Android. Further once a different kernel is booted, any
> > > > headers stored on the file system will no longer be useful. By storing
> > > > the headers as a compressed archive within the kernel, we can avoid these
> > > > issues that have been a hindrance for a long time.
> > >
> > > The set looks good to me and since the main use case is building bpf progs
> > > I can route it via bpf-next tree if there are no objections.
> > > Masahiro, could you please ack it?
> >
> >
> > Honestly, I was not tracking this thread
> > since I did not know I was responsible for this.
> >
> >
> > I just started to take a closer look, then immediately got scared.
> >
> > This version is not mature enough for the merge.
> >
> >
> >
> > First of all, this patch cannot be compiled out-of-tree (O= option).
> >
> >
> > I do not know why 0-day bot did not catch this apparent breakage.
> >
> >
> > $ make -j8 O=hoge
> > make[1]: Entering directory '/home/masahiro/workspace/bsp/linux/hoge'
> > GEN Makefile
> > Using .. as source for kernel
> > DESCEND objtool
> > CALL ../scripts/checksyscalls.sh
> > CHK include/generated/compile.h
> > make[2]: *** No rule to make target 'Module.symvers', needed by
> > 'kernel/kheaders_data.txz'. Stop.
> > make[2]: *** Waiting for unfinished jobs....
> > /home/masahiro/workspace/bsp/linux/Makefile:1043: recipe for target
> > 'kernel' failed
> > make[1]: *** [kernel] Error 2
> > make[1]: *** Waiting for unfinished jobs....
> > make[1]: Leaving directory '/home/masahiro/workspace/bsp/linux/hoge'
> > Makefile:152: recipe for target 'sub-make' failed
> > make: *** [sub-make] Error 2
>
>
>
>
> I saw this build error for in-tree building as well.
>
> We cannot build this from a pristine source tree.
>
> For example, I observed the build error in the following procedure.
>
> $ make mrproper
> $ make defconfig
> Set CONFIG_IKHEADERS_PROC=y
> $ make
>
>
>
>
> Module.symvers is generated in the modpost stage
> (the very last stage of build).
>
> But, vmlinux depends on kernel/kheaders_data.txz,
> which includes Module.symvers.
>
> So, this is not so simple since it is a circular dependency...
I guess I was not building a pristine tree either and missed this circular
dependency :-/ . Any ideas on how we can fix the Module.symvers issue? One
idea is to reserve the space in the binaries, but only populate the space
reserved in the binary *after* the modpost stage, once the archive is ready..
thanks,
- Joel
^ permalink raw reply
* Re: [PATCH net-next v4 07/17] net: sched: protect filter_chain list with filter_chain_lock mutex
From: Cong Wang @ 2019-02-19 5:26 UTC (permalink / raw)
To: Vlad Buslov
Cc: Ido Schimmel, netdev@vger.kernel.org, jhs@mojatatu.com,
jiri@resnulli.us, davem@davemloft.net, ast@kernel.org,
daniel@iogearbox.net
In-Reply-To: <vbfbm3djcd4.fsf@mellanox.com>
On Fri, Feb 15, 2019 at 7:35 AM Vlad Buslov <vladbu@mellanox.com> wrote:
>
> Another problem that I found in cls_fw and cls_route is that they set
> arg->stop when empty. Both of them have code unchanged since it was
> committed initially in 2005 so I assume this convention is no longer
> relevant because all other classifiers don't do that (they only set
> arg->stop when arg->fn returns negative value).
>
The question is why do you want to use arg->stop==0 as
an indication for emptiness? Isn't what arg->count==0
supposed to be?
^ permalink raw reply
* Re: [PATCH v2 1/2] net: phy: at803x: dont inline helpers
From: Sekhar Nori @ 2019-02-19 5:35 UTC (permalink / raw)
To: Vinod Koul, David Miller
Cc: linux-arm-msm, bjorn.andersson, netdev, niklas.cassel, andrew,
f.fainelli, peter.ujfalusi, marc.w.gonzalez
In-Reply-To: <20190219050227.GT21884@vkoul-mobl>
Hi Vinod,
On 19/02/19 10:32 AM, Vinod Koul wrote:
> Hello Dave,
>
> On 18-02-19, 16:28, David Miller wrote:
>> From: Vinod Koul <vkoul@kernel.org>
>> Date: Mon, 18 Feb 2019 15:48:52 +0530
>>
>>> Some helpers were inlined, but makes more sense to allow compiler
>>> to do the right optiomazations instead, so remove inline for
>>> at803x_disable_rx_delay() and at803x_disable_tx_delay()
>>>
>>> Signed-off-by: Vinod Koul <vkoul@kernel.org>
>>
>> Two problem with this patch series.
>>
>> 1) It fixes a bug in 'net' but the patches only apply cleanly to
>> 'net-next'. Please respin this against 'net'.
>
> I assume the 'net' is fixes going into current -rcX. This fixes issues
> reported on linux-next due to patches in net-next, so these fixes should
> go to net-next as well.
net-next should be part of subject prefix in this case. See
Documentation/networking/netdev-FAQ.rst
Thanks,
Sekhar
^ permalink raw reply
* [PATCH bpf-next 4/9] bpf: Add bpf helper bpf_tcp_check_probe_timer
From: brakmo @ 2019-02-19 5:38 UTC (permalink / raw)
To: netdev; +Cc: Martin Lau, Alexei Starovoitov, Daniel Borkmann --cc=Kernel Team
This patch adds a new bpf helper BPF_FUNC_tcp_check_probe_timer
"int bpf_check_tcp_probe_timer(struct tcp_bpf_sock *tp, u32 when_us)".
It is added to BPF_PROG_TYPE_CGROUP_SKB typed bpf_prog which currently
can be attached to the ingress and egress path.
The function forces when_us to be at least TCP_TIMEOUT_MIN (currently
2 jiffies) and no more than TCP_RTO_MIN (currently 200ms).
When using a bpf_prog to limit the egress bandwidth of a cgroup,
it can happen that we drop a packet of a connection that has no
packets out. In this case, the connection may not retry sending
the packet until the probe timer fires. Since the default value
of the probe timer is at least 200ms, this can introduce link
underutiliation (i.e. the cgroup egress bandwidth being smaller
than the specified rate) thus increased tail latency.
This helper function allows for setting a smaller probe timer.
Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
---
include/uapi/linux/bpf.h | 12 +++++++++++-
net/core/filter.c | 27 +++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index 5daf404511f7..a78936acccae 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -2372,6 +2372,15 @@ union bpf_attr {
* val should be one of 0, 1, 2, 3.
* Return
* -EINVAL on error (e.g. val > 3), 0 otherwise.
+ *
+ * int bpf_tcp_check_probe_timer(struct bpf_tcp_sock *tp, int when_us)
+ * Description
+ * Checks that there are no packets out and there is no pending
+ * timer. If both of these are true, it bounds when_us by
+ * TCP_TIMEOUT_MIN (2 jiffies) or TCP_RTO_MIN (200ms) and
+ * sets the probe timer.
+ * Return
+ * 0
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -2472,7 +2481,8 @@ union bpf_attr {
FN(sk_fullsock), \
FN(tcp_sock), \
FN(tcp_enter_cwr), \
- FN(skb_set_ecn),
+ FN(skb_set_ecn), \
+ FN(tcp_check_probe_timer),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
diff --git a/net/core/filter.c b/net/core/filter.c
index 275acfb2117d..2b975e651a04 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5465,6 +5465,31 @@ static const struct bpf_func_proto bpf_skb_set_ecn_proto = {
.arg1_type = ARG_PTR_TO_CTX,
.arg2_type = ARG_ANYTHING,
};
+
+BPF_CALL_2(bpf_tcp_check_probe_timer, struct tcp_sock *, tp, u32, when_us)
+{
+ struct sock *sk = (struct sock *) tp;
+ unsigned long when = usecs_to_jiffies(when_us);
+
+ if (!tp->packets_out && !inet_csk(sk)->icsk_pending) {
+ if (when < TCP_TIMEOUT_MIN)
+ when = TCP_TIMEOUT_MIN;
+ else if (when > TCP_RTO_MIN)
+ when = TCP_RTO_MIN;
+
+ inet_csk_reset_xmit_timer(sk, ICSK_TIME_PROBE0,
+ when, TCP_RTO_MAX);
+ }
+ return 0;
+}
+
+static const struct bpf_func_proto bpf_tcp_check_probe_timer_proto = {
+ .func = bpf_tcp_check_probe_timer,
+ .gpl_only = false,
+ .ret_type = RET_INTEGER,
+ .arg1_type = ARG_PTR_TO_TCP_SOCK,
+ .arg2_type = ARG_ANYTHING,
+};
#endif /* CONFIG_INET */
bool bpf_helper_changes_pkt_data(void *func)
@@ -5628,6 +5653,8 @@ cg_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_tcp_enter_cwr_proto;
case BPF_FUNC_skb_set_ecn:
return &bpf_skb_set_ecn_proto;
+ case BPF_FUNC_tcp_check_probe_timer:
+ return &bpf_tcp_check_probe_timer_proto;
#endif
default:
return sk_filter_func_proto(func_id, prog);
--
2.17.1
^ permalink raw reply related
* [PATCH bpf-next 5/9] bpf: sync bpf.h to tools and update bpf_helpers.h
From: brakmo @ 2019-02-19 5:38 UTC (permalink / raw)
To: netdev; +Cc: Martin Lau, Alexei Starovoitov, Daniel Borkmann --cc=Kernel Team
This patch syncs the uapi bpf.h to tools/ and also updates
bpf_herlpers.h in tools/
Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
---
tools/include/uapi/linux/bpf.h | 27 ++++++++++++++++++++++-
tools/testing/selftests/bpf/bpf_helpers.h | 6 +++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index bcdd2474eee7..a78936acccae 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -2359,6 +2359,28 @@ union bpf_attr {
* Return
* A **struct bpf_tcp_sock** pointer on success, or NULL in
* case of failure.
+ *
+ * int bpf_tcp_enter_cwr(struct bpf_tcp_sock *tp)
+ * Description
+ * Make a tcp_sock enter CWR state.
+ * Return
+ * 0
+ *
+ * int bpf_skb_set_ecn(struct sk_buf *skb, int val)
+ * Description
+ * Sets ECN bits (2) of IP header. Works with IPv6 and IPv4.
+ * val should be one of 0, 1, 2, 3.
+ * Return
+ * -EINVAL on error (e.g. val > 3), 0 otherwise.
+ *
+ * int bpf_tcp_check_probe_timer(struct bpf_tcp_sock *tp, int when_us)
+ * Description
+ * Checks that there are no packets out and there is no pending
+ * timer. If both of these are true, it bounds when_us by
+ * TCP_TIMEOUT_MIN (2 jiffies) or TCP_RTO_MIN (200ms) and
+ * sets the probe timer.
+ * Return
+ * 0
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -2457,7 +2479,10 @@ union bpf_attr {
FN(spin_lock), \
FN(spin_unlock), \
FN(sk_fullsock), \
- FN(tcp_sock),
+ FN(tcp_sock), \
+ FN(tcp_enter_cwr), \
+ FN(skb_set_ecn), \
+ FN(tcp_check_probe_timer),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
index d9999f1ed1d2..8cf5f30034b7 100644
--- a/tools/testing/selftests/bpf/bpf_helpers.h
+++ b/tools/testing/selftests/bpf/bpf_helpers.h
@@ -180,6 +180,12 @@ static struct bpf_sock *(*bpf_sk_fullsock)(struct bpf_sock *sk) =
(void *) BPF_FUNC_sk_fullsock;
static struct bpf_tcp_sock *(*bpf_tcp_sock)(struct bpf_sock *sk) =
(void *) BPF_FUNC_tcp_sock;
+static int (*bpf_tcp_enter_cwr)(struct bpf_tcp_sock *tp) =
+ (void *) BPF_FUNC_tcp_enter_cwr;
+static int (*bpf_skb_set_ecn)(void *ctx, int val) =
+ (void *) BPF_FUNC_skb_set_ecn;
+static int (*bpf_tcp_check_probe_timer)(struct bpf_tcp_sock *tp, int when_us) =
+ (void *) BPF_FUNC_tcp_check_probe_timer;
/* llvm builtin functions that eBPF C program may use to
* emit BPF_LD_ABS and BPF_LD_IND instructions
--
2.17.1
^ permalink raw reply related
* [PATCH bpf-next 6/9] bpf: Sample program to load cg skb BPF programs
From: brakmo @ 2019-02-19 5:38 UTC (permalink / raw)
To: netdev; +Cc: Martin Lau, Alexei Starovoitov, Daniel Borkmann --cc=Kernel Team
The program load_cg_skb can be used to load BPF_PROG_TYPE_CGROUP_SKB
type bpf_prog which currently can be attached to the ingress and egress
patch. It can also be used to detach the bpf_prog.
Examples:
load_cg_skb [-i] <cg-path> <prog filename>
Load and attaches a cg skb program to the specified cgroup.
If "-i" is used, the program is attached as ingress (default is
egress).
load_cg_skb -r[i] <cg-path>
Detaches the currnetly attached egress (or ingress if -ri is used)
cg skb program from the specified cgroup.
Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
---
samples/bpf/Makefile | 2 +
samples/bpf/load_cg_skb.c | 109 ++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 samples/bpf/load_cg_skb.c
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index a0ef7eddd0b3..0cf3347c7443 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -53,6 +53,7 @@ hostprogs-y += xdpsock
hostprogs-y += xdp_fwd
hostprogs-y += task_fd_query
hostprogs-y += xdp_sample_pkts
+hostprogs-y += load_cg_skb
# Libbpf dependencies
LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
@@ -109,6 +110,7 @@ xdpsock-objs := xdpsock_user.o
xdp_fwd-objs := xdp_fwd_user.o
task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS)
xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS)
+load_cg_skb-objs := bpf_load.o load_cg_skb.o
# Tell kbuild to always build the programs
always := $(hostprogs-y)
diff --git a/samples/bpf/load_cg_skb.c b/samples/bpf/load_cg_skb.c
new file mode 100644
index 000000000000..619ff834fc8c
--- /dev/null
+++ b/samples/bpf/load_cg_skb.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2019 Facebook
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/bpf.h>
+#include <bpf/bpf.h>
+#include "bpf_load.h"
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/unistd.h>
+
+static void usage(char *pname)
+{
+ printf("USAGE:\n %s [-i] [-l] <cg-path> <prog filename>\n", pname);
+ printf("\tLoad and attach a cgroup/skb egress/ingress program to"
+ " the specified\n"
+ "\tcgroup\n"
+ "\tIf \"-i\" is used, an ingress program is loaded (default is"
+ " egress)\n"
+ "\tIf \"-l\" is used, the program will continue to run"
+ " printing the BPF log\n"
+ "\tbuffer\n"
+ "\tIf the specified filename does not end in \".o\", it"
+ " appends \"_kern.o\"\n"
+ "\tto the name\n\n");
+ printf(" %s -r <cg-path>\n", pname);
+ printf("\tDetaches the currently attached cgroup/skb egress program\n"
+ "\tfrom the specified cgroup\n");
+ printf(" %s -ri <cg-path>\n", pname);
+ printf("\tDetaches the currently attached cgroup/skb ingress program\n"
+ "\tfrom the specified cgroup\n\n");
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ int logFlag = 0;
+ int error = 0;
+ char *cg_path;
+ char fn[500];
+ char *prog;
+ int cg_fd;
+ int mode = BPF_CGROUP_INET_EGRESS;
+
+ if (argc < 3)
+ usage(argv[0]);
+
+ if (!strcmp(argv[1], "-i")) {
+ mode = BPF_CGROUP_INET_INGRESS;
+ } else if (!strncmp(argv[1], "-r", 2)) {
+ if (argv[1][2] == 'i')
+ mode = BPF_CGROUP_INET_INGRESS;
+ cg_path = argv[2];
+ cg_fd = open(cg_path, O_DIRECTORY, O_RDONLY);
+ error = bpf_prog_detach(cg_fd, mode);
+ if (error) {
+ printf("ERROR: bpf_prog_detach: %d (%s)\n",
+ error, strerror(errno));
+ return 2;
+ }
+ return 0;
+ } else if (!strcmp(argv[1], "-h")) {
+ usage(argv[0]);
+ } else if (!strcmp(argv[1], "-l")) {
+ logFlag = 1;
+ if (argc < 4)
+ usage(argv[0]);
+ }
+
+ prog = argv[argc - 1];
+ cg_path = argv[argc - 2];
+ if (strlen(prog) > 480) {
+ fprintf(stderr, "ERROR: program name too long (> 480 chars)\n");
+ return 3;
+ }
+ cg_fd = open(cg_path, O_DIRECTORY, O_RDONLY);
+
+ if (!strcmp(prog + strlen(prog)-2, ".o"))
+ strcpy(fn, prog);
+ else
+ sprintf(fn, "%s_kern.o", prog);
+ if (logFlag)
+ printf("loading bpf file:%s\n", fn);
+ if (load_bpf_file(fn)) {
+ printf("ERROR: load_bpf_file failed for: %s\n", fn);
+ printf("%s", bpf_log_buf);
+ return 4;
+ }
+ if (logFlag)
+ printf("TCP BPF Loaded %s\n", fn);
+
+ error = bpf_prog_attach(prog_fd[0], cg_fd, BPF_CGROUP_INET_EGRESS, 0);
+ if (error) {
+ printf("ERROR: bpf_prog_attach: %d (%s)\n",
+ error, strerror(errno));
+ return 5;
+ } else if (logFlag) {
+ read_trace_pipe();
+ }
+
+ return error;
+}
--
2.17.1
^ permalink raw reply related
* [PATCH bpf-next 9/9] bpf: NRM test script
From: brakmo @ 2019-02-19 5:38 UTC (permalink / raw)
To: netdev; +Cc: Martin Lau, Alexei Starovoitov, Daniel Borkmann --cc=Kernel Team
Script for testing NRM (Network Resource Manager) framework.
It creates a cgroup to use for testing and load a BPF program to limit
egress bandwidht. It then uses iperf3 or netperf to create
loads. The output is the goodput in Mbps (unless -D is used).
It can work on a single host using loopback or among two hosts (with netperf).
When using loopback, it is recommended to also introduce a delay of at least
1ms (-d=1), otherwise the assigned bandwidth is likely to be underutilized.
USAGE: $name [out] [-b=<prog>|--bpf=<prog>] [-c=<cc>|--cc=<cc>] [-D]
[-d=<delay>|--delay=<delay>] [--debug] [-E]
[-f=<#flows>|--flows=<#flows>] [-h] [-i=<id>|--id=<id >] [-l]
[-N] [-p=<port>|--port=<port>] [-P] [-q=<qdisc>]
[-R] [-s=<server>|--server=<server] [--stats]
[-t=<time>|--time=<time>] [-w] [cubic|dctcp]
Where:
out Egress (default egress)
-b or --bpf BPF program filename to load and attach.
Default is nrm_out_kern.o for egress,
nrm_in_kern.o for ingress
-c or -cc TCP congestion control (cubic or dctcp)
-d or --delay Add a delay in ms using netem
-D In addition to the goodput in Mbps, it also outputs
other detailed information. This information is
test dependent (i.e. iperf3 or netperf).
--debug Print BPF trace buffer
-E Enable ECN (not required for dctcp)
-f or --flows Number of concurrent flows (default=1)
-i or --id cgroup id (an integer, default is 1)
-l Do not limit flows using loopback
-N Use netperf instead of iperf3
-h Help
-p or --port iperf3 port (default is 5201)
-P Use an iperf3 instance for each flow
-q Use the specified qdisc.
-r or --rate Rate in Mbps (default 1s 1Gbps)
-R Use TCP_RR for netperf. 1st flow has req
size of 10KB, rest of 1MB. Reply in all
cases is 1 byte.
More detailed output for each flow can be found
in the files netperf.<cg>.<flow>, where <cg> is the
cgroup id as specified with the -i flag, and <flow>
is the flow id starting at 1 and increasing by 1 for
flow (as specified by -f).
-s or --server hostname of netperf server. Used to create netperf
test traffic between to hosts (default is within host)
netserver must be running on the host.
--stats Get NRM stats (marked, dropped, etc.)
-t or --time duration of iperf3 in seconds (default=5)
-w Work conserving flag. cgroup can increase its
bandwidth beyond the rate limit specified
while there is available bandwidth. Current
implementation assumes there is only one NIC
(eth0), but can be extended to support multiple
NICs. This is just a proof of concept.
cubic or dctcp specify TCP CC to use
Examples:
./do_nrm_test.sh -l -d=1 -D --stats
Runs a 5 second test, using a single iperf3 flow and with the default
rate limit of 1Gbps and a delay of 1ms (using netem) using the default
TCP congestion control on the loopback device (hence we use "-l" to
enforce bandwidth limit on loopback device). Since no direction is
specified, it defaults to egress. Since no TCP CC algorithm is
specified it uses the system default.
With no -D flag, only the value of the AGGREGATE OUTPUT would show.
id refers to the cgroup id and is useful when running multi cgroup
tests (see do_nrm_test_multi.sh script).
Output:
Details for NRM in cgroup 1
id:1
rate_mbps:713
duration:4.9 secs
packets:10072
bytes_MB:468
pkts_dropped:491
bytes_dropped_MB:32
pkts_marked_percent: 28.64
bytes_marked_percent: 29.15
pkts_dropped_percent: 4.87
bytes_dropped_percent: 6.86
PING AVG DELAY:2.072
AGGREGATE_GOODPUT:729
./do_nrm_test.sh -l -d=1 -D --stats dctcp
Same as above but using dctcp. Note that fewer bytes are dropped
(0.13 vs. 6.86%).
Output:
Details for NRM in cgroup 1
id:1
rate_mbps:932
duration:4.9 secs
packets:15514
bytes_MB:570
pkts_dropped:11
bytes_dropped_MB:0
pkts_marked_percent: 40.38
bytes_marked_percent: 46.82
pkts_dropped_percent: 0.07
bytes_dropped_percent: 0.13
PING AVG DELAY:2.069
AGGREGATE_GOODPUT:953
./do_nrm_test.sh -d=1 -D --stats
As first example, but without limiting loopback device (i.e. no
"-l" flag). Since there is no bandwidth limiting, no details for
NRM are printed out.
Output:
Details for NRM in cgroup 1
PING AVG DELAY:2.021
AGGREGATE_GOODPUT:40226
./do_nrm_test.sh -l -d=1 -D --stats -f=2
Uses iper3 and does 2 flows
./do_nrm_test.sh -l -d=1 -D --stats -f=4 -P
Uses iperf3 and does 4 flows, each flow as a separate process.
./do_nrm_test.sh -l -d=1 -D --stats -f=4 -N
Uses netperf, 4 flows
./do_nrm_test.sh -f=1 -r=2000 -t=5 -N -D --stats dctcp -s=<server-name>
Uses netperf between two hosts. The remote host name is specified
with -s= and you need to start the program netserver manually on
the remote host. It will use 1 flow, a rate limit of 2Gbps and dctcp.
./do_nrm_test.sh -f=1 -r=2000 -t=5 -N -D --stats -w dctcp \
-s=<server-name>
As previous, but allows use of extra bandwidth. For this test the
rate is 8Gbps vs. 1Gbps of the previous test.
Signed-off-by: Lawrence Brakmo <brakmo@fb.com>
---
samples/bpf/do_nrm_test.sh | 429 +++++++++++++++++++++++++++++++++++++
1 file changed, 429 insertions(+)
create mode 100755 samples/bpf/do_nrm_test.sh
diff --git a/samples/bpf/do_nrm_test.sh b/samples/bpf/do_nrm_test.sh
new file mode 100755
index 000000000000..c068c6e889d9
--- /dev/null
+++ b/samples/bpf/do_nrm_test.sh
@@ -0,0 +1,429 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019 Facebook
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+
+Usage() {
+ echo "Script for testing NRM (Network Resource Manager) framework."
+ echo "It creates a cgroup to use for testing and load a BPF program to limit"
+ echo "egress or ingress bandwidht. It then uses iperf3 or netperf to create"
+ echo "loads. The output is the goodput in Mbps (unless -D was used)."
+ echo ""
+ echo "USAGE: $name [out] [-b=<prog>|--bpf=<prog>] [-c=<cc>|--cc=<cc>] [-D]"
+ echo " [-d=<delay>|--delay=<delay>] [--debug] [-E]"
+ echo " [-f=<#flows>|--flows=<#flows>] [-h] [-i=<id>|--id=<id >]"
+ echo " [-l] [-N] [-p=<port>|--port=<port>] [-P]"
+ echo " [-q=<qdisc>] [-R] [-s=<server>|--server=<server]"
+ echo " [-S|--stats] -t=<time>|--time=<time>] [-w] [cubic|dctcp]"
+ echo " Where:"
+ echo " out egress (default)"
+ echo " -b or --bpf BPF program filename to load and attach."
+ echo " Default is nrm_out_kern.o for egress,"
+ echo " nrm_in_kern.o for ingress"
+ echo " -c or -cc TCP congestion control (cubic or dctcp)"
+ echo " --debug print BPF trace buffer"
+ echo " -d or --delay add a delay in ms using netem"
+ echo " -D In addition to the goodput in Mbps, it also outputs"
+ echo " other detailed information. This information is"
+ echo " test dependent (i.e. iperf3 or netperf)."
+ echo " -E enable ECN (not required for dctcp)"
+ echo " -f or --flows number of concurrent flows (default=1)"
+ echo " -i or --id cgroup id (an integer, default is 1)"
+ echo " -N use netperf instead of iperf3"
+ echo " -l do not limit flows using loopback"
+ echo " -h Help"
+ echo " -p or --port iperf3 port (default is 5201)"
+ echo " -P use an iperf3 instance for each flow"
+ echo " -q use the specified qdisc"
+ echo " -r or --rate rate in Mbps (default 1s 1Gbps)"
+ echo " -R Use TCP_RR for netperf. 1st flow has req"
+ echo " size of 10KB, rest of 1MB. Reply in all"
+ echo " cases is 1 byte."
+ echo " More detailed output for each flow can be found"
+ echo " in the files netperf.<cg>.<flow>, where <cg> is the"
+ echo " cgroup id as specified with the -i flag, and <flow>"
+ echo " is the flow id starting at 1 and increasing by 1 for"
+ echo " flow (as specified by -f)."
+ echo " -s or --server hostname of netperf server. Used to create netperf"
+ echo " test traffic between to hosts (default is within host)"
+ echo " netserver must be running on the host."
+ echo " -S or --stats whether to update nrm stats (default is yes)."
+ echo " -t or --time duration of iperf3 in seconds (default=5)"
+ echo " -w Work conserving flag. cgroup can increase its"
+ echo " bandwidth beyond the rate limit specified"
+ echo " while there is available bandwidth. Current"
+ echo " implementation assumes there is only one NIC"
+ echo " (eth0), but can be extended to support multiple"
+ echo " NICs."
+ echo " cubic or dctcp specify which TCP CC to use"
+ echo " "
+ exit
+}
+
+#set -x
+
+debug_flag=0
+args="$@"
+name="$0"
+netem=0
+cc=x
+dir="-o"
+dir_name="out"
+dur=5
+flows=1
+id=1
+prog=""
+port=5201
+rate=1000
+multi_iperf=0
+flow_cnt=1
+use_netperf=0
+rr=0
+ecn=0
+details=0
+server=""
+qdisc=""
+flags=""
+do_stats=0
+
+function start_nrm () {
+ rm -f nrm.out
+ echo "./nrm $dir -n $id -r $rate -t $dur $flags $dbg $prog" > nrm.out
+ echo " " >> nrm.out
+ ./nrm $dir -n $id -r $rate -t $dur $flags $dbg $prog >> nrm.out 2>&1 &
+ echo $!
+}
+
+processArgs () {
+ for i in $args ; do
+ case $i in
+ # Support for upcomming ingress rate limiting
+ #in) # support for upcoming ingress rate limiting
+ # dir="-i"
+ # dir_name="in"
+ # ;;
+ out)
+ dir="-o"
+ dir_name="out"
+ ;;
+ -b=*|--bpf=*)
+ prog="${i#*=}"
+ ;;
+ -c=*|--cc=*)
+ cc="${i#*=}"
+ ;;
+ --debug)
+ flags="$flags -d"
+ debug_flag=1
+ ;;
+ -d=*|--delay=*)
+ netem="${i#*=}"
+ ;;
+ -D)
+ details=1
+ ;;
+ -E)
+ ecn=1
+ ;;
+ # Support for upcomming fq Early Departure Time egress rate limiting
+ #--edt)
+ # prog="nrm_out_edt_kern.o"
+ # qdisc="fq"
+ # ;;
+ -f=*|--flows=*)
+ flows="${i#*=}"
+ ;;
+ -i=*|--id=*)
+ id="${i#*=}"
+ ;;
+ -l)
+ flags="$flags -l"
+ ;;
+ -N)
+ use_netperf=1
+ ;;
+ -p=*|--port=*)
+ port="${i#*=}"
+ ;;
+ -P)
+ multi_iperf=1
+ ;;
+ -q=*)
+ qdisc="${i#*=}"
+ ;;
+ -r=*|--rate=*)
+ rate="${i#*=}"
+ ;;
+ -R)
+ rr=1
+ ;;
+ -s=*|--server=*)
+ server="${i#*=}"
+ ;;
+ -S|--stats)
+ flags="$flags -s"
+ do_stats=1
+ ;;
+ -t=*|--time=*)
+ dur="${i#*=}"
+ ;;
+ -w)
+ flags="$flags -w"
+ ;;
+ cubic)
+ cc=cubic
+ ;;
+ dctcp)
+ cc=dctcp
+ ;;
+ *)
+ echo "Unknown arg:$i"
+ Usage
+ ;;
+ esac
+ done
+}
+
+processArgs
+
+if [ $debug_flag -eq 1 ] ; then
+ rm -f nrm_out.log
+fi
+
+nrm_pid=$(start_nrm)
+usleep 100000
+
+host=`hostname`
+cg_base_dir=/sys/fs/cgroup
+cg_dir="$cg_base_dir/cgroup-test-work-dir/nrm$id"
+
+echo $$ >> $cg_dir/cgroup.procs
+
+ulimit -l unlimited
+
+rm -f ss.out
+rm -f nrm.$id.$dir_name
+if [ $ecn -ne 0 ] ; then
+ sysctl -w -q -n net.ipv4.tcp_ecn=1
+fi
+
+if [ $use_netperf -eq 0 ] ; then
+ cur_cc=`sysctl -n net.ipv4.tcp_congestion_control`
+ if [ "$cc" != "x" ] ; then
+ sysctl -w -q -n net.ipv4.tcp_congestion_control=$cc
+ fi
+fi
+
+if [ "$netem" -ne "0" ] ; then
+ if [ "$qdisc" != "" ] ; then
+ echo "WARNING: Ignoring -q options because -d option used"
+ fi
+ tc qdisc del dev lo root > /dev/null 2>&1
+ tc qdisc add dev lo root netem delay $netem\ms > /dev/null 2>&1
+elif [ "$qdisc" != "" ] ; then
+ tc qdisc del dev lo root > /dev/null 2>&1
+ tc qdisc add dev lo root $qdisc > /dev/null 2>&1
+fi
+
+n=0
+m=$[$dur * 5]
+hn="::1"
+if [ $use_netperf -ne 0 ] ; then
+ if [ "$server" != "" ] ; then
+ hn=$server
+ fi
+fi
+(while [ $n -lt $m ] ; \
+ do ss -6 -i -t -m -o state established "( dport = :$port )" >> ss.out ; \
+ n=$[n+1] ; usleep 200000 ; done \
+ ) &
+
+( ping6 -i 0.2 -c $m $hn > ping.out 2>&1 ) &
+
+if [ $use_netperf -ne 0 ] ; then
+ begNetserverPid=`ps ax | grep netserver | grep --invert-match "grep" | \
+ awk '{ print $1 }'`
+ if [ "$begNetserverPid" == "" ] ; then
+ if [ "$server" == "" ] ; then
+ ( ./netserver > /dev/null 2>&1) &
+ usleep 100000
+ fi
+ fi
+ flow_cnt=1
+ if [ "$server" == "" ] ; then
+ np_server=$host
+ else
+ np_server=$server
+ fi
+ if [ "$cc" == "x" ] ; then
+ np_cc=""
+ else
+ np_cc="-K $cc,$cc"
+ fi
+ replySize=1
+ while [ $flow_cnt -le $flows ] ; do
+ if [ $rr -ne 0 ] ; then
+ reqSize=1M
+ if [ $flow_cnt -eq 1 ] ; then
+ reqSize=10K
+ fi
+ if [ "$dir" == "-i" ] ; then
+ replySize=$reqSize
+ reqSize=1
+ fi
+ ( ./netperf -H $np_server -l $dur -f m -j -t TCP_RR -- -r $reqSize,$replySize $np_cc -k P50_lATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,REMOTE_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,LOCAL_RECV_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) &
+ else
+ if [ "$dir" == "-i" ] ; then
+ ( ./netperf -H $np_server -l $dur -f m -j -t TCP_RR -- -r 1,10M $np_cc -k P50_LATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,REMOTE_TRANSPORT_RETRANS,REMOTE_SEND_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) &
+ else
+ ( ./netperf -H $np_server -l $dur -f m -j -t TCP_STREAM -- $np_cc -k P50_lATENCY,P90_LATENCY,LOCAL_TRANSPORT_RETRANS,LOCAL_SEND_THROUGHPUT,REQUEST_SIZE,RESPONSE_SIZE > netperf.$id.$flow_cnt ) &
+ fi
+ fi
+ flow_cnt=$[flow_cnt+1]
+ done
+
+# sleep for duration of test (plus some buffer)
+ n=$[dur+2]
+ sleep $n
+
+# force graceful termination of netperf
+ pids=`pgrep netperf`
+ for p in $pids ; do
+ kill -SIGALRM $p
+ done
+
+ flow_cnt=1
+ rate=0
+ if [ $details -ne 0 ] ; then
+ echo ""
+ echo "Details for NRM in cgroup $id"
+ if [ $do_stats -eq 1 ] ; then
+ if [ -e nrm.$id.$dir_name ] ; then
+ cat nrm.$id.$dir_name
+ fi
+ fi
+ fi
+ while [ $flow_cnt -le $flows ] ; do
+ if [ "$dir" == "-i" ] ; then
+ r=`cat netperf.$id.$flow_cnt | grep -o "REMOTE_SEND_THROUGHPUT=[0-9]*" | grep -o "[0-9]*"`
+ else
+ r=`cat netperf.$id.$flow_cnt | grep -o "LOCAL_SEND_THROUGHPUT=[0-9]*" | grep -o "[0-9]*"`
+ fi
+ echo "rate for flow $flow_cnt: $r"
+ rate=$[rate+r]
+ if [ $details -ne 0 ] ; then
+ echo "-----"
+ echo "Details for cgroup $id, flow $flow_cnt"
+ cat netperf.$id.$flow_cnt
+ fi
+ flow_cnt=$[flow_cnt+1]
+ done
+ if [ $details -ne 0 ] ; then
+ echo ""
+ delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"`
+ echo "PING AVG DELAY:$delay"
+ echo "AGGREGATE_GOODPUT:$rate"
+ else
+ echo $rate
+ fi
+elif [ $multi_iperf -eq 0 ] ; then
+ (iperf3 -s -p $port -1 > /dev/null 2>&1) &
+ usleep 100000
+ iperf3 -c $host -p $port -i 0 -P $flows -f m -t $dur > iperf.$id
+ rates=`grep receiver iperf.$id | grep -o "[0-9.]* Mbits" | grep -o "^[0-9]*"`
+ rate=`echo $rates | grep -o "[0-9]*$"`
+
+ if [ $details -ne 0 ] ; then
+ echo ""
+ echo "Details for NRM in cgroup $id"
+ if [ $do_stats -eq 1 ] ; then
+ if [ -e nrm.$id.$dir_name ] ; then
+ cat nrm.$id.$dir_name
+ fi
+ fi
+ delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"`
+ echo "PING AVG DELAY:$delay"
+ echo "AGGREGATE_GOODPUT:$rate"
+ else
+ echo $rate
+ fi
+else
+ flow_cnt=1
+ while [ $flow_cnt -le $flows ] ; do
+ (iperf3 -s -p $port -1 > /dev/null 2>&1) &
+ ( iperf3 -c $host -p $port -i 0 -P 1 -f m -t $dur | grep receiver | grep -o "[0-9.]* Mbits" | grep -o "^[0-9]*" | grep -o "[0-9]*$" > iperf3.$id.$flow_cnt ) &
+ port=$[port+1]
+ flow_cnt=$[flow_cnt+1]
+ done
+ n=$[dur+1]
+ sleep $n
+ flow_cnt=1
+ rate=0
+ if [ $details -ne 0 ] ; then
+ echo ""
+ echo "Details for NRM in cgroup $id"
+ if [ $do_stats -eq 1 ] ; then
+ if [ -e nrm.$id.$dir_name ] ; then
+ cat nrm.$id.$dir_name
+ fi
+ fi
+ fi
+
+ while [ $flow_cnt -le $flows ] ; do
+ r=`cat iperf3.$id.$flow_cnt`
+# echo "rate for flow $flow_cnt: $r"
+ if [ $details -ne 0 ] ; then
+ echo "Rate for cgroup $id, flow $flow_cnt LOCAL_SEND_THROUGHPUT=$r"
+ fi
+ rate=$[rate+r]
+ flow_cnt=$[flow_cnt+1]
+ done
+ if [ $details -ne 0 ] ; then
+ delay=`grep "avg" ping.out | grep -o "= [0-9.]*/[0-9.]*" | grep -o "[0-9.]*$"`
+ echo "PING AVG DELAY:$delay"
+ echo "AGGREGATE_GOODPUT:$rate"
+ else
+ echo $rate
+ fi
+fi
+
+if [ $use_netperf -eq 0 ] ; then
+ sysctl -w -q -n net.ipv4.tcp_congestion_control=$cur_cc
+fi
+if [ $ecn -ne 0 ] ; then
+ sysctl -w -q -n net.ipv4.tcp_ecn=0
+fi
+if [ "$netem" -ne "0" ] ; then
+ tc qdisc del dev lo root > /dev/null 2>&1
+fi
+
+sleep 2
+
+nrmPid=`ps ax | grep "nrm " | grep --invert-match "grep" | awk '{ print $1 }'`
+if [ "$nrmPid" == "$nrm_pid" ] ; then
+ kill $nrm_pid
+fi
+
+sleep 1
+
+if [ "$dir" == "-i" ] ; then
+ ./load_cg_skb -ri $cg_dir > /dev/null 2>&1
+else
+ ./load_cg_skb -r $cg_dir > /dev/null 2>&1
+fi
+
+if [ $use_netperf -ne 0 ] ; then
+ if [ "$server" == "" ] ; then
+ if [ "$begNetserverPid" == "" ] ; then
+ netserverPid=`ps ax | grep netserver | grep --invert-match "grep" | awk '{ print $1 }'`
+ if [ "$netserverPid" != "" ] ; then
+ kill $netserverPid
+ fi
+ fi
+ fi
+fi
+exit
--
2.17.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