* Re: [PATCH net] packet: refine ring v3 block size test to hold one frame
From: David Miller @ 2018-08-06 20:49 UTC (permalink / raw)
To: willemdebruijn.kernel; +Cc: netdev, eric.dumazet, loke.chetan, willemb
In-Reply-To: <20180806143834.121959-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Mon, 6 Aug 2018 10:38:34 -0400
> From: Willem de Bruijn <willemb@google.com>
>
> TPACKET_V3 stores variable length frames in fixed length blocks.
> Blocks must be able to store a block header, optional private space
> and at least one minimum sized frame.
>
> Frames, even for a zero snaplen packet, store metadata headers and
> optional reserved space.
>
> In the block size bounds check, ensure that the frame of the
> chosen configuration fits. This includes sockaddr_ll and optional
> tp_reserve.
>
> Syzbot was able to construct a ring with insuffient room for the
> sockaddr_ll in the header of a zero-length frame, triggering an
> out-of-bounds write in dev_parse_header.
>
> Convert the comparison to less than, as zero is a valid snap len.
> This matches the test for minimum tp_frame_size immediately below.
>
> Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
> Fixes: eb73190f4fbe ("net/packet: refine check for priv area size")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
Good catch, applied and queued up for -stable, thanks.
^ permalink raw reply
* Re: [PATCH] Use Kconfig flag to remove support of deprecated BE2/BE3 adapters
From: David Miller @ 2018-08-06 20:46 UTC (permalink / raw)
To: poros
Cc: netdev, ivecera, sathya.perla, ajit.khaparde,
sriharsha.basavapatna, somnath.kotur, linux-kernel
In-Reply-To: <20180806121230.23690-1-poros@redhat.com>
From: Petr Oros <poros@redhat.com>
Date: Mon, 6 Aug 2018 14:12:28 +0200
> Add flags to remove support of deprecated BE2/BE3 adapters.
> BE2 disable will reduce .ko size by 2kb and BE3 by 3kb.
> Disable both will reduce .ko size by 9kb.
>
> With dissabled support is also removed coresponding PCI IDs
> and codepath with [BE2|BE3|BEx]_chip checks.
>
> New help style in Kconfig
>
> Signed-off-by: Petr Oros <poros@redhat.com>
Sorry, I'm not too hot about this.
Imagine being one of the people who has one of these cards.
Pulling out detection and working'ness of devices from a driver
is a big step backwards, and I'm sorry I will don't want to be
part of something that facilitates this.
The S390 folks tried something similar in the past and I reject
those changes too.
Thanks.
^ permalink raw reply
* Re: [PATCH bpf] bpf: btf: Change tools/lib/bpf/btf to LGPL
From: Jakub Kicinski @ 2018-08-06 20:33 UTC (permalink / raw)
To: Martin KaFai Lau; +Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team
In-Reply-To: <20180806001913.2312815-1-kafai@fb.com>
On Sun, 5 Aug 2018 17:19:13 -0700, Martin KaFai Lau wrote:
> This patch changes the tools/lib/bpf/btf.[ch] to LGPL which
> is inline with libbpf also.
FWIW:
Reported-by: David Beckett <david.beckett@netronome.com>
And in case removing code in 6534770d6f17 ("tools: bpf: fix BTF code
added twice to different trees") counts as a contribution:
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
for the license change :)
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
> tools/lib/bpf/btf.c | 2 +-
> tools/lib/bpf/btf.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 2d270c560df3..c36a3a76986a 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -1,4 +1,4 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> +// SPDX-License-Identifier: LGPL-2.1
> /* Copyright (c) 2018 Facebook */
>
> #include <stdlib.h>
> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> index e2a09a155f84..caac3a404dc5 100644
> --- a/tools/lib/bpf/btf.h
> +++ b/tools/lib/bpf/btf.h
> @@ -1,4 +1,4 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> +/* SPDX-License-Identifier: LGPL-2.1 */
> /* Copyright (c) 2018 Facebook */
>
> #ifndef __BPF_BTF_H
^ permalink raw reply
* Re: pull-request: ieee802154-next 2018-08-06
From: David Miller @ 2018-08-06 20:18 UTC (permalink / raw)
To: stefan; +Cc: linux-wpan, alex.aring, netdev
In-Reply-To: <20180806193850.31949-1-stefan@datenfreihafen.org>
From: Stefan Schmidt <stefan@datenfreihafen.org>
Date: Mon, 6 Aug 2018 21:38:50 +0200
> An update from ieee802154 for *net-next*
>
> Romuald added a socket option to get the LQI value of the received datagram.
> Alexander added a new hardware simulation driver modelled after hwsim of the
> wireless people. It allows runtime configuration for new nodes and edges over a
> netlink interface (a config utlity is making its way into wpan-tools).
> We also have three fixes in here. One from Colin which is more of a cleanup and
> two from Alex fixing tailroom and single frame space problems.
> I would normally put the last two into my fixes tree, but given we are already
> in -rc8 I simply put them here and added a cc: stable to them.
>
> Please pull, or let me know if there are any problems.
Pulled, thank you.
^ permalink raw reply
* Re: [PATCH net-next] ipv4: frags: precedence bug in ip_expire()
From: David Miller @ 2018-08-06 20:15 UTC (permalink / raw)
To: dan.carpenter; +Cc: posk, kuznet, yoshfuji, netdev, kernel-janitors
In-Reply-To: <20180806191735.c5miffnrhl2w2ljh@kili.mountain>
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 6 Aug 2018 22:17:35 +0300
> We accidentally removed the parentheses here, but they are required
> because '!' has higher precedence than '&'.
>
> Fixes: fa0f527358bd ("ip: use rb trees for IP frag queue.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Ugh, good catch, applied, thanks!
^ permalink raw reply
* [PATCH net-next] liquidio: avoided acquiring post_lock for data only queues
From: Felix Manlunas @ 2018-08-06 20:09 UTC (permalink / raw)
To: davem
Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla,
felix.manlunas, intiyaz.basha
From: Intiyaz Basha <intiyaz.basha@cavium.com>
All control commands (soft commands) goes through only Queue 0
(control and data queue). So only queue-0 needs post_lock,
other queues are only data queues and does not need post_lock
Added a flag to indicate the queue can be used for soft commands.
If this flag is set, post_lock must be acquired before posting
a command to the queue.
If this flag is clear, post_lock is invalid for the queue.
Signed-off-by: Intiyaz Basha <intiyaz.basha@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
drivers/net/ethernet/cavium/liquidio/octeon_iq.h | 10 ++++++++++
.../net/ethernet/cavium/liquidio/request_manager.c | 22 +++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_iq.h b/drivers/net/ethernet/cavium/liquidio/octeon_iq.h
index 5fed7b6..2327062 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_iq.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_iq.h
@@ -82,6 +82,16 @@ struct octeon_instr_queue {
/** A spinlock to protect while posting on the ring. */
spinlock_t post_lock;
+ /** This flag indicates if the queue can be used for soft commands.
+ * If this flag is set, post_lock must be acquired before posting
+ * a command to the queue.
+ * If this flag is clear, post_lock is invalid for the queue.
+ * All control commands (soft commands) will go through only Queue 0
+ * (control and data queue). So only queue-0 needs post_lock,
+ * other queues are only data queues and does not need post_lock
+ */
+ bool allow_soft_cmds;
+
u32 pkt_in_done;
/** A spinlock to protect access to the input ring.*/
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index d5d9e47..8f746e1 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -126,7 +126,12 @@ int octeon_init_instr_queue(struct octeon_device *oct,
/* Initialize the spinlock for this instruction queue */
spin_lock_init(&iq->lock);
- spin_lock_init(&iq->post_lock);
+ if (iq_no == 0) {
+ iq->allow_soft_cmds = true;
+ spin_lock_init(&iq->post_lock);
+ } else {
+ iq->allow_soft_cmds = false;
+ }
spin_lock_init(&iq->iq_flush_running_lock);
@@ -566,7 +571,8 @@ octeon_send_command(struct octeon_device *oct, u32 iq_no,
/* Get the lock and prevent other tasks and tx interrupt handler from
* running.
*/
- spin_lock_bh(&iq->post_lock);
+ if (iq->allow_soft_cmds)
+ spin_lock_bh(&iq->post_lock);
st = __post_command2(iq, cmd);
@@ -583,7 +589,8 @@ octeon_send_command(struct octeon_device *oct, u32 iq_no,
INCR_INSTRQUEUE_PKT_COUNT(oct, iq_no, instr_dropped, 1);
}
- spin_unlock_bh(&iq->post_lock);
+ if (iq->allow_soft_cmds)
+ spin_unlock_bh(&iq->post_lock);
/* This is only done here to expedite packets being flushed
* for cases where there are no IQ completion interrupts.
@@ -702,11 +709,20 @@ octeon_prepare_soft_command(struct octeon_device *oct,
int octeon_send_soft_command(struct octeon_device *oct,
struct octeon_soft_command *sc)
{
+ struct octeon_instr_queue *iq;
struct octeon_instr_ih2 *ih2;
struct octeon_instr_ih3 *ih3;
struct octeon_instr_irh *irh;
u32 len;
+ iq = oct->instr_queue[sc->iq_no];
+ if (!iq->allow_soft_cmds) {
+ dev_err(&oct->pci_dev->dev, "Soft commands are not allowed on Queue %d\n",
+ sc->iq_no);
+ INCR_INSTRQUEUE_PKT_COUNT(oct, sc->iq_no, instr_dropped, 1);
+ return IQ_SEND_FAILED;
+ }
+
if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct)) {
ih3 = (struct octeon_instr_ih3 *)&sc->cmd.cmd3.ih3;
if (ih3->dlengsz) {
--
2.9.0
^ permalink raw reply related
* Re: [endianness bug?] cxgb4_next_header .match_val/.match_mask should be net-endian
From: kbuild test robot @ 2018-08-06 19:51 UTC (permalink / raw)
To: Al Viro
Cc: kbuild-all, Rahul Lakkireddy, netdev, Hariprasad Shenai,
David S. Miller
In-Reply-To: <20180805152811.GF15082@ZenIV.linux.org.uk>
Hi Al,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on v4.18-rc8 next-20180806]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Al-Viro/cxgb4_next_header-match_val-match_mask-should-be-net-endian/20180806-183127
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40: got restricted __be32 [usertype] <noident>
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] val @@ got ed int [unsigned] [usertype] val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: expected unsigned int [unsigned] [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: got restricted __be32 [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] mask @@ got ed int [unsigned] [usertype] mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: expected unsigned int [unsigned] [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: got restricted __be32 [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:236:59: sparse: restricted __be16 degrades to integer
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] val @@ got ed int [unsigned] [usertype] val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: expected unsigned int [unsigned] [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: got restricted __be32 [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] mask @@ got ed int [unsigned] [usertype] mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: expected unsigned int [unsigned] [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: got restricted __be32 [usertype] mask
include/linux/mm.h:591:13: sparse: undefined identifier '__builtin_mul_overflow'
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32
vim +262 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h
256
257 /* Accept a rule with a jump to transport layer header based on IHL field in
258 * IPv4 header.
259 */
260 static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
261 { .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
> 262 .match_off = 8, .match_val = htonl(6 << 16),
> 263 .match_mask = htonl(0xff<<16), .jump = cxgb4_tcp_fields },
264 { .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
265 .match_off = 8, .match_val = htonl(17 << 16),
266 .match_mask = htonl(0xff<<16), .jump = cxgb4_udp_fields },
267 { .jump = NULL }
268 };
269
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply
* [PATCH net-next,v3] net/tls: Calculate nsg for zerocopy path without skb_cow_data.
From: Doron Roberts-Kedes @ 2018-08-06 19:47 UTC (permalink / raw)
To: David S . Miller
Cc: Vakul Garg, Dave Watson, Boris Pismenny, Aviad Yehezkel, netdev,
Doron Roberts-Kedes
decrypt_skb fails if the number of sg elements required to map is
greater than MAX_SKB_FRAGS. As noted by Vakul Garg, nsg must always be
calculated, but skb_cow_data adds unnecessary memcpy's for the zerocopy
case.
The new function skb_nsg calculates the number of scatterlist elements
required to map the skb without the extra overhead of skb_cow_data. This
function mimics the structure of skb_to_sgvec.
Fixes: c46234ebb4d1 ("tls: RX path for ktls")
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
---
net/tls/tls_sw.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 93 insertions(+), 3 deletions(-)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index ff3a6904a722..eb87f931a0d6 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -43,6 +43,80 @@
#define MAX_IV_SIZE TLS_CIPHER_AES_GCM_128_IV_SIZE
+static int __skb_nsg(struct sk_buff *skb, int offset, int len,
+ unsigned int recursion_level)
+{
+ int start = skb_headlen(skb);
+ int i, copy = start - offset;
+ struct sk_buff *frag_iter;
+ int elt = 0;
+
+ if (unlikely(recursion_level >= 24))
+ return -EMSGSIZE;
+
+ if (copy > 0) {
+ if (copy > len)
+ copy = len;
+ elt++;
+ len -= copy;
+ if (len == 0)
+ return elt;
+ offset += copy;
+ }
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ int end;
+
+ WARN_ON(start > offset + len);
+
+ end = start + skb_frag_size(&skb_shinfo(skb)->frags[i]);
+ copy = end - offset;
+ if (copy > 0) {
+ if (copy > len)
+ copy = len;
+ elt++;
+ len -= copy;
+ if (len == 0)
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+
+ skb_walk_frags(skb, frag_iter) {
+ int end, ret;
+
+ WARN_ON(start > offset + len);
+
+ end = start + frag_iter->len;
+ copy = end - offset;
+ if (copy > 0) {
+ if (copy > len)
+ copy = len;
+ ret = __skb_nsg(frag_iter, offset - start, copy,
+ recursion_level + 1);
+ if (unlikely(ret < 0))
+ return ret;
+ elt += ret;
+ len -= copy;
+ if (len == 0)
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+ BUG_ON(len);
+ return elt;
+}
+
+/* Return the number of scatterlist elements required to completely map the
+ * skb, or -EMSGSIZE if the recursion depth is exceeded.
+ */
+static int skb_nsg(struct sk_buff *skb, int offset, int len)
+{
+ return __skb_nsg(skb, offset, len, 0);
+}
+
static int tls_do_decryption(struct sock *sk,
struct scatterlist *sgin,
struct scatterlist *sgout,
@@ -693,7 +767,7 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
struct scatterlist sgin_arr[MAX_SKB_FRAGS + 2];
struct scatterlist *sgin = &sgin_arr[0];
struct strp_msg *rxm = strp_msg(skb);
- int ret, nsg = ARRAY_SIZE(sgin_arr);
+ int ret, nsg;
struct sk_buff *unused;
ret = skb_copy_bits(skb, rxm->offset + TLS_HEADER_SIZE,
@@ -704,11 +778,27 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
memcpy(iv, tls_ctx->rx.iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
if (!sgout) {
- nsg = skb_cow_data(skb, 0, &unused) + 1;
+ nsg = skb_cow_data(skb, 0, &unused);
+ } else {
+ nsg = skb_nsg(skb,
+ rxm->offset + tls_ctx->rx.prepend_size,
+ rxm->full_len - tls_ctx->rx.prepend_size);
+ if (nsg <= 0)
+ return nsg;
+ }
+
+ // We need one extra for ctx->rx_aad_ciphertext
+ nsg++;
+
+ if (nsg > ARRAY_SIZE(sgin_arr)) {
sgin = kmalloc_array(nsg, sizeof(*sgin), sk->sk_allocation);
- sgout = sgin;
+ if (!sgin)
+ return -ENOMEM;
}
+ if (!sgout)
+ sgout = sgin;
+
sg_init_table(sgin, nsg);
sg_set_buf(&sgin[0], ctx->rx_aad_ciphertext, TLS_AAD_SPACE_SIZE);
--
2.17.1
^ permalink raw reply related
* pull-request: ieee802154-next 2018-08-06
From: Stefan Schmidt @ 2018-08-06 19:38 UTC (permalink / raw)
To: davem; +Cc: linux-wpan, alex.aring, netdev
Hello Dave.
An update from ieee802154 for *net-next*
Romuald added a socket option to get the LQI value of the received datagram.
Alexander added a new hardware simulation driver modelled after hwsim of the
wireless people. It allows runtime configuration for new nodes and edges over a
netlink interface (a config utlity is making its way into wpan-tools).
We also have three fixes in here. One from Colin which is more of a cleanup and
two from Alex fixing tailroom and single frame space problems.
I would normally put the last two into my fixes tree, but given we are already
in -rc8 I simply put them here and added a cc: stable to them.
Please pull, or let me know if there are any problems.
regards
Stefan Schmidt
The following changes since commit 981467033a37d916649647fa3afe1fe99bba1817:
tc-testing: remove duplicate spaces in skbedit match patterns (2018-08-05 17:39:24 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next.git ieee802154-for-davem-2018-08-06
for you to fetch changes up to be10d5d1c2d15252624e965202508f30a218a46a:
ieee802154: fakelb: add deprecated msg while probe (2018-08-06 11:21:15 +0200)
----------------------------------------------------------------
Alexander Aring (4):
net: 6lowpan: fix reserved space for single frames
net: mac802154: tx: expand tailroom if necessary
ieee802154: hwsim: add replacement for fakelb
ieee802154: fakelb: add deprecated msg while probe
Colin Ian King (1):
net: ieee802154: 6lowpan: remove redundant pointers 'fq' and 'net'
Romuald CARI (1):
ieee802154: add rx LQI from userspace
Stefan Schmidt (1):
Merge remote-tracking branch 'net-next/master'
drivers/net/ieee802154/Kconfig | 11 +
drivers/net/ieee802154/Makefile | 1 +
drivers/net/ieee802154/fakelb.c | 3 +
drivers/net/ieee802154/mac802154_hwsim.c | 919 +++++++++++++++++++++++++++++++
drivers/net/ieee802154/mac802154_hwsim.h | 73 +++
include/net/af_ieee802154.h | 1 +
net/ieee802154/6lowpan/reassembly.c | 5 -
net/ieee802154/6lowpan/tx.c | 21 +-
net/ieee802154/socket.c | 17 +
net/mac802154/tx.c | 15 +-
10 files changed, 1057 insertions(+), 9 deletions(-)
create mode 100644 drivers/net/ieee802154/mac802154_hwsim.c
create mode 100644 drivers/net/ieee802154/mac802154_hwsim.h
^ permalink raw reply
* Re: [PATCH] rtlwifi: btcoex: Fix if == else warnings in halbtc8723b2ant.c
From: valdis.kletnieks-PjAqaU27lzQ @ 2018-08-06 21:42 UTC (permalink / raw)
To: YueHaibing
Cc: pkshih-Rasf1IRRPZFBDgjK7y7TUQ, kvalo-sgV2jX0FEOL9JmXXK+q4OQ,
Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
colin.king-Z7WLFzj8eWMS+FvcfC7Uqw,
linux-wireless-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20180806045440.11920-1-yuehaibing-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]
On Mon, 06 Aug 2018 12:54:40 +0800, YueHaibing said:
> Fix following coccinelle warning:
>
> ./drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c:2952:2-4: WARNING: possible condition with no effect (if == else)
> /* sw mechanism */
> if (BTC_WIFI_BW_HT40 == wifi_bw) {
> - if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
> - (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
> - btc8723b2ant_sw_mechanism(btcoexist, true, true,
> - false, false);
> - } else {
> - btc8723b2ant_sw_mechanism(btcoexist, true, true,
> - false, false);
> - }
> + btc8723b2ant_sw_mechanism(btcoexist, true, true,
> + false, false);
> } else {
Rather than blindly fixing this, perhaps a bit of thought needs to be
applied to why this code looks like this in the first place.
See commit c6821613e653a (which looks like the bletcherous "do too many
things at once" commit indeed), although the actual diff appears to be a
"no harm, no foul" against this commit, where the issue already existed.
commit aa45a673b291fd761275493bc15316d79555ed55
Author: Larry Finger <Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
Date: Fri Feb 28 15:16:43 2014 -0600
rtlwifi: btcoexist: Add new mini driver
Larry? Can you reach back to 2014 and remember why this code
looked like this in the first place?
[-- Attachment #2: Type: application/pgp-signature, Size: 486 bytes --]
^ permalink raw reply
* Re: [PATCH net-next] ipv4: frags: precedence bug in ip_expire()
From: Peter Oskolkov @ 2018-08-06 19:29 UTC (permalink / raw)
To: dan.carpenter; +Cc: davem, kuznet, yoshfuji, netdev, kernel-janitors
In-Reply-To: <20180806191735.c5miffnrhl2w2ljh@kili.mountain>
Ack. Thanks, Dan!
On Mon, Aug 6, 2018 at 12:17 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> We accidentally removed the parentheses here, but they are required
> because '!' has higher precedence than '&'.
>
> Fixes: fa0f527358bd ("ip: use rb trees for IP frag queue.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
> index 0e8f8de77e71..7cb7ed761d8c 100644
> --- a/net/ipv4/ip_fragment.c
> +++ b/net/ipv4/ip_fragment.c
> @@ -154,7 +154,7 @@ static void ip_expire(struct timer_list *t)
> __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
> __IP_INC_STATS(net, IPSTATS_MIB_REASMTIMEOUT);
>
> - if (!qp->q.flags & INET_FRAG_FIRST_IN)
> + if (!(qp->q.flags & INET_FRAG_FIRST_IN))
> goto out;
>
> /* sk_buff::dev and sk_buff::rbnode are unionized. So we
^ permalink raw reply
* Re: [PATCH mlx5-next] RDMA/mlx5: Don't use cached IRQ affinity mask
From: Steve Wise @ 2018-08-06 19:20 UTC (permalink / raw)
To: Max Gurtovoy, Sagi Grimberg, Jason Gunthorpe
Cc: 'Leon Romanovsky', 'Doug Ledford',
'RDMA mailing list', 'Saeed Mahameed',
'linux-netdev'
In-Reply-To: <f1442839-ff32-ab80-9eab-6923456fe272@mellanox.com>
On 8/1/2018 9:27 AM, Max Gurtovoy wrote:
>
>
> On 8/1/2018 8:12 AM, Sagi Grimberg wrote:
>> Hi Max,
>
> Hi,
>
>>
>>> Yes, since nvmf is the only user of this function.
>>> Still waiting for comments on the suggested patch :)
>>>
>>
>> Sorry for the late response (but I'm on vacation so I have
>> an excuse ;))
>
> NP :) currently the code works..
>
>>
>> I'm thinking that we should avoid trying to find an assignment
>> when stuff like irqbalance daemon is running and changing
>> the affinitization.
>
> but this is exactly what Steve complained and Leon try to fix (and
> break the connection establishment).
> If this is the case and we all agree then we're good without Leon's
> patch and without our suggestions.
>
I don't agree. Currently setting certain affinity mappings breaks nvme
connectivity. I don't think that is desirable. And mlx5 is broken in
that it doesn't allow changing the affinity but silently ignores the
change, which misleads the admin or irqbalance...
>>
>> This extension was made to apply optimal affinity assignment
>> when the device irq affinity is lined up in a vector per
>> core.
>>
>> I'm thinking that when we identify this is not the case, we immediately
>> fallback to the default mapping.
>>
>> 1. when we get a mask, if its weight != 1, we fallback.
>> 2. if a queue was left unmapped, we fallback.
>>
>> Maybe something like the following:
>
> did you test it ? I think it will not work since you need to map all
> the queues and all the CPUs.
>
>> --
>> diff --git a/block/blk-mq-rdma.c b/block/blk-mq-rdma.c
>> index 996167f1de18..1ada6211c55e 100644
>> --- a/block/blk-mq-rdma.c
>> +++ b/block/blk-mq-rdma.c
>> @@ -35,17 +35,26 @@ int blk_mq_rdma_map_queues(struct blk_mq_tag_set
>> *set,
>> const struct cpumask *mask;
>> unsigned int queue, cpu;
>>
>> + /* reset all CPUs mapping */
>> + for_each_possible_cpu(cpu)
>> + set->mq_map[cpu] = UINT_MAX;
>> +
>> for (queue = 0; queue < set->nr_hw_queues; queue++) {
>> mask = ib_get_vector_affinity(dev, first_vec + queue);
>> if (!mask)
>> goto fallback;
>>
>> - for_each_cpu(cpu, mask)
>> - set->mq_map[cpu] = queue;
>> + if (cpumask_weight(mask) != 1)
>> + goto fallback;
>> +
>> + cpu = cpumask_first(mask);
>> + if (set->mq_map[cpu] != UINT_MAX)
>> + goto fallback;
>> +
>> + set->mq_map[cpu] = queue;
>> }
>>
>> return 0;
>> -
>> fallback:
>> return blk_mq_map_queues(set);
>> }
>> --
>
> see attached another algorithem that can improve the mapping (although
> it's not a short one)...
>
> it will try to map according to affinity mask, and also in case the
> mask weight > 1 it will try to be better than the naive mapping I
> suggest in the previous email.
>
Let me know if you want me to try this or any particular fix.
Steve.
^ permalink raw reply
* [PATCH net-next] ipv4: frags: precedence bug in ip_expire()
From: Dan Carpenter @ 2018-08-06 19:17 UTC (permalink / raw)
To: David S. Miller, Peter Oskolkov
Cc: Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev, kernel-janitors
We accidentally removed the parentheses here, but they are required
because '!' has higher precedence than '&'.
Fixes: fa0f527358bd ("ip: use rb trees for IP frag queue.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 0e8f8de77e71..7cb7ed761d8c 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -154,7 +154,7 @@ static void ip_expire(struct timer_list *t)
__IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS);
__IP_INC_STATS(net, IPSTATS_MIB_REASMTIMEOUT);
- if (!qp->q.flags & INET_FRAG_FIRST_IN)
+ if (!(qp->q.flags & INET_FRAG_FIRST_IN))
goto out;
/* sk_buff::dev and sk_buff::rbnode are unionized. So we
^ permalink raw reply related
* [PATCH bpf-next] bpf: introduce update_effective_progs()
From: Roman Gushchin @ 2018-08-06 21:27 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel-team, Roman Gushchin, Alexei Starovoitov,
Daniel Borkmann
__cgroup_bpf_attach() and __cgroup_bpf_detach() functions have
a good amount of duplicated code, which is possible to eliminate
by introducing the update_effective_progs() helper function.
The update_effective_progs() calls compute_effective_progs()
and then in case of success it calls activate_effective_progs()
for each descendant cgroup. In case of failure (OOM), it releases
allocated prog arrays and return the error code.
Signed-off-by: Roman Gushchin <guro@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
---
kernel/bpf/cgroup.c | 99 ++++++++++++++++++++++++-----------------------------
1 file changed, 45 insertions(+), 54 deletions(-)
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 0a4fe5a7dc91..6a7d931bbc55 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -177,6 +177,45 @@ int cgroup_bpf_inherit(struct cgroup *cgrp)
return -ENOMEM;
}
+static int update_effective_progs(struct cgroup *cgrp,
+ enum bpf_attach_type type)
+{
+ struct cgroup_subsys_state *css;
+ int err;
+
+ /* allocate and recompute effective prog arrays */
+ css_for_each_descendant_pre(css, &cgrp->self) {
+ struct cgroup *desc = container_of(css, struct cgroup, self);
+
+ err = compute_effective_progs(desc, type, &desc->bpf.inactive);
+ if (err)
+ goto cleanup;
+ }
+
+ /* all allocations were successful. Activate all prog arrays */
+ css_for_each_descendant_pre(css, &cgrp->self) {
+ struct cgroup *desc = container_of(css, struct cgroup, self);
+
+ activate_effective_progs(desc, type, desc->bpf.inactive);
+ desc->bpf.inactive = NULL;
+ }
+
+ return 0;
+
+cleanup:
+ /* oom while computing effective. Free all computed effective arrays
+ * since they were not activated
+ */
+ css_for_each_descendant_pre(css, &cgrp->self) {
+ struct cgroup *desc = container_of(css, struct cgroup, self);
+
+ bpf_prog_array_free(desc->bpf.inactive);
+ desc->bpf.inactive = NULL;
+ }
+
+ return err;
+}
+
#define BPF_CGROUP_MAX_PROGS 64
/**
@@ -194,7 +233,6 @@ int __cgroup_bpf_attach(struct cgroup *cgrp, struct bpf_prog *prog,
struct list_head *progs = &cgrp->bpf.progs[type];
struct bpf_prog *old_prog = NULL;
struct bpf_cgroup_storage *storage, *old_storage = NULL;
- struct cgroup_subsys_state *css;
struct bpf_prog_list *pl;
bool pl_was_allocated;
int err;
@@ -261,22 +299,9 @@ int __cgroup_bpf_attach(struct cgroup *cgrp, struct bpf_prog *prog,
cgrp->bpf.flags[type] = flags;
- /* allocate and recompute effective prog arrays */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- err = compute_effective_progs(desc, type, &desc->bpf.inactive);
- if (err)
- goto cleanup;
- }
-
- /* all allocations were successful. Activate all prog arrays */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- activate_effective_progs(desc, type, desc->bpf.inactive);
- desc->bpf.inactive = NULL;
- }
+ err = update_effective_progs(cgrp, type);
+ if (err)
+ goto cleanup;
static_branch_inc(&cgroup_bpf_enabled_key);
if (old_storage)
@@ -289,16 +314,6 @@ int __cgroup_bpf_attach(struct cgroup *cgrp, struct bpf_prog *prog,
return 0;
cleanup:
- /* oom while computing effective. Free all computed effective arrays
- * since they were not activated
- */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- bpf_prog_array_free(desc->bpf.inactive);
- desc->bpf.inactive = NULL;
- }
-
/* and cleanup the prog list */
pl->prog = old_prog;
bpf_cgroup_storage_free(pl->storage);
@@ -326,7 +341,6 @@ int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,
struct list_head *progs = &cgrp->bpf.progs[type];
u32 flags = cgrp->bpf.flags[type];
struct bpf_prog *old_prog = NULL;
- struct cgroup_subsys_state *css;
struct bpf_prog_list *pl;
int err;
@@ -365,22 +379,9 @@ int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,
pl->prog = NULL;
}
- /* allocate and recompute effective prog arrays */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- err = compute_effective_progs(desc, type, &desc->bpf.inactive);
- if (err)
- goto cleanup;
- }
-
- /* all allocations were successful. Activate all prog arrays */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- activate_effective_progs(desc, type, desc->bpf.inactive);
- desc->bpf.inactive = NULL;
- }
+ err = update_effective_progs(cgrp, type);
+ if (err)
+ goto cleanup;
/* now can actually delete it from this cgroup list */
list_del(&pl->node);
@@ -396,16 +397,6 @@ int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,
return 0;
cleanup:
- /* oom while computing effective. Free all computed effective arrays
- * since they were not activated
- */
- css_for_each_descendant_pre(css, &cgrp->self) {
- struct cgroup *desc = container_of(css, struct cgroup, self);
-
- bpf_prog_array_free(desc->bpf.inactive);
- desc->bpf.inactive = NULL;
- }
-
/* and restore back old_prog */
pl->prog = old_prog;
return err;
--
2.14.4
^ permalink raw reply related
* Re: [PATCH net-next] net/tls: Calculate nsg for zerocopy path without skb_cow_data.
From: Doron Roberts-Kedes @ 2018-08-06 18:32 UTC (permalink / raw)
To: Vakul Garg
Cc: David S . Miller, Dave Watson, Boris Pismenny, Aviad Yehezkel,
netdev@vger.kernel.org
In-Reply-To: <20180803184902.GA27063@doronrk-mbp.dhcp.thefacebook.com>
On Fri, Aug 03, 2018 at 11:49:02AM -0700, Doron Roberts-Kedes wrote:
> On Fri, Aug 03, 2018 at 01:23:33AM +0000, Vakul Garg wrote:
> >
> >
> > > -----Original Message-----
> > > From: Doron Roberts-Kedes [mailto:doronrk@fb.com]
> > > Sent: Friday, August 3, 2018 6:00 AM
> > > To: David S . Miller <davem@davemloft.net>
> > > Cc: Dave Watson <davejwatson@fb.com>; Vakul Garg
> > > <vakul.garg@nxp.com>; Boris Pismenny <borisp@mellanox.com>; Aviad
> > > Yehezkel <aviadye@mellanox.com>; netdev@vger.kernel.org; Doron
> > > Roberts-Kedes <doronrk@fb.com>
> > > Subject: [PATCH net-next] net/tls: Calculate nsg for zerocopy path without
> > > skb_cow_data.
> > >
> > > decrypt_skb fails if the number of sg elements required to map is greater
> > > than MAX_SKB_FRAGS. As noted by Vakul Garg, nsg must always be
> > > calculated, but skb_cow_data adds unnecessary memcpy's for the zerocopy
> > > case.
> > >
> > > The new function skb_nsg calculates the number of scatterlist elements
> > > required to map the skb without the extra overhead of skb_cow_data. This
> > > function mimics the structure of skb_to_sgvec.
> > >
> > > Fixes: c46234ebb4d1 ("tls: RX path for ktls")
> > > Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
> > > ---
> > > net/tls/tls_sw.c | 89
> > > ++++++++++++++++++++++++++++++++++++++++++++++--
> > > 1 file changed, 86 insertions(+), 3 deletions(-)
> > >
> > > memcpy(iv, tls_ctx->rx.iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
> > > if (!sgout) {
> > > - nsg = skb_cow_data(skb, 0, &unused) + 1;
> > > + nsg = skb_cow_data(skb, 0, &unused);
> > > + } else {
> > > + nsg = skb_nsg(skb,
> > > + rxm->offset + tls_ctx->rx.prepend_size,
> > > + rxm->full_len - tls_ctx->rx.prepend_size);
> > > + if (nsg <= 0)
> > > + return nsg;
> > Comparison should be (nsg < 1). TLS forbids '0' sized records.
>
> Yes true, v2 incoming
>
Glancing at this a second time, I actually don't believe this should be
changed. nsg <= 0 is equivalent to nsg < 1. Returning 0 if the record is
0 sized is the proper behavior here, since decrypting a zero-length skb
is a no-op. It is true that zero sized TLS records are forbidden, but it
is confusing to enforce that in this part of the code. I would be
surpised to learn that tls_sw_recvmsg could be invoked with a len equal
to 0, but if I'm wrong, and that case does need to be handled, then it
should be in a different patch.
^ permalink raw reply
* [PATCH net-next,v2] net/tls: Calculate nsg for zerocopy path without skb_cow_data.
From: Doron Roberts-Kedes @ 2018-08-06 18:25 UTC (permalink / raw)
To: David S . Miller
Cc: Vakul Garg, Dave Watson, Boris Pismenny, Aviad Yehezkel, netdev,
Doron Roberts-Kedes
decrypt_skb fails if the number of sg elements required to map is
greater than MAX_SKB_FRAGS. As noted by Vakul Garg, nsg must always be
calculated, but skb_cow_data adds unnecessary memcpy's for the zerocopy
case.
The new function skb_nsg calculates the number of scatterlist elements
required to map the skb without the extra overhead of skb_cow_data. This
function mimics the structure of skb_to_sgvec.
Fixes: c46234ebb4d1 ("tls: RX path for ktls")
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
---
net/tls/tls_sw.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 90 insertions(+), 3 deletions(-)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index ff3a6904a722..e1c465a2ce0b 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -43,6 +43,76 @@
#define MAX_IV_SIZE TLS_CIPHER_AES_GCM_128_IV_SIZE
+static int __skb_nsg(struct sk_buff *skb, int offset, int len,
+ unsigned int recursion_level)
+{
+ int start = skb_headlen(skb);
+ int i, copy = start - offset;
+ struct sk_buff *frag_iter;
+ int elt = 0;
+
+ if (unlikely(recursion_level >= 24))
+ return -EMSGSIZE;
+
+ if (copy > 0) {
+ if (copy > len)
+ copy = len;
+ elt++;
+ if ((len -= copy) == 0)
+ return elt;
+ offset += copy;
+ }
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ int end;
+
+ WARN_ON(start > offset + len);
+
+ end = start + skb_frag_size(&skb_shinfo(skb)->frags[i]);
+ if ((copy = end - offset) > 0) {
+ if (copy > len)
+ copy = len;
+ elt++;
+ if (!(len -= copy))
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+
+ skb_walk_frags(skb, frag_iter) {
+ int end, ret;
+
+ WARN_ON(start > offset + len);
+
+ end = start + frag_iter->len;
+ if ((copy = end - offset) > 0) {
+
+ if (copy > len)
+ copy = len;
+ ret = __skb_nsg(frag_iter, offset - start, copy,
+ recursion_level + 1);
+ if (unlikely(ret < 0))
+ return ret;
+ elt += ret;
+ if ((len -= copy) == 0)
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+ BUG_ON(len);
+ return elt;
+}
+
+/* Return the number of scatterlist elements required to completely map the
+ * skb, or -EMSGSIZE if the recursion depth is exceeded.
+ */
+static int skb_nsg(struct sk_buff *skb, int offset, int len)
+{
+ return __skb_nsg(skb, offset, len, 0);
+}
+
static int tls_do_decryption(struct sock *sk,
struct scatterlist *sgin,
struct scatterlist *sgout,
@@ -693,7 +763,7 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
struct scatterlist sgin_arr[MAX_SKB_FRAGS + 2];
struct scatterlist *sgin = &sgin_arr[0];
struct strp_msg *rxm = strp_msg(skb);
- int ret, nsg = ARRAY_SIZE(sgin_arr);
+ int ret, nsg;
struct sk_buff *unused;
ret = skb_copy_bits(skb, rxm->offset + TLS_HEADER_SIZE,
@@ -704,11 +774,28 @@ int decrypt_skb(struct sock *sk, struct sk_buff *skb,
memcpy(iv, tls_ctx->rx.iv, TLS_CIPHER_AES_GCM_128_SALT_SIZE);
if (!sgout) {
- nsg = skb_cow_data(skb, 0, &unused) + 1;
+ nsg = skb_cow_data(skb, 0, &unused);
+ } else {
+ nsg = skb_nsg(skb,
+ rxm->offset + tls_ctx->rx.prepend_size,
+ rxm->full_len - tls_ctx->rx.prepend_size);
+ if (nsg <= 0)
+ return nsg;
+ }
+
+ // We need one extra for ctx->rx_aad_ciphertext
+ nsg++;
+
+ if (nsg > ARRAY_SIZE(sgin_arr)) {
sgin = kmalloc_array(nsg, sizeof(*sgin), sk->sk_allocation);
- sgout = sgin;
+ if (!sgin)
+ return -ENOMEM;
}
+
+ if (!sgout)
+ sgout = sgin;
+
sg_init_table(sgin, nsg);
sg_set_buf(&sgin[0], ctx->rx_aad_ciphertext, TLS_AAD_SPACE_SIZE);
--
2.17.1
^ permalink raw reply related
* Re: [PATCH net-next] tcp: fix the calculation of sysctl_max_tw_buckets in tcp_sk_init()
From: David Miller @ 2018-08-06 20:41 UTC (permalink / raw)
To: laoar.shao; +Cc: edumazet, yanhaishuang, netdev, linux-kernel
In-Reply-To: <1533556020-20778-1-git-send-email-laoar.shao@gmail.com>
From: Yafang Shao <laoar.shao@gmail.com>
Date: Mon, 6 Aug 2018 19:47:00 +0800
> tcp_hashinfo.ehash_mask is always an odd number, which is set in function
> alloc_large_system_hash(). See bellow,
> if (_hash_mask)
> *_hash_mask = (1 << log2qty) - 1; <<< always odd number
>
> Hence the local variable 'cnt' is a even number, as a result of that it is
> no difference to do the incrementation here.
>
> Maybe the compiler could also optimize it, but this code is a little ugly.
>
> Fix: fee83d09 ("ipv4: Namespaceify tcp_max_syn_backlog knob")
The correct tag is "Fixes: "
> @@ -2543,7 +2543,7 @@ static int __net_init tcp_sk_init(struct net *net)
> net->ipv4.sysctl_tcp_tw_reuse = 2;
>
> cnt = tcp_hashinfo.ehash_mask + 1;
> - net->ipv4.tcp_death_row.sysctl_max_tw_buckets = (cnt + 1) / 2;
> + net->ipv4.tcp_death_row.sysctl_max_tw_buckets = cnt / 2;
> net->ipv4.tcp_death_row.hashinfo = &tcp_hashinfo;
This is completely harmless, and does no harm.
You aren't "fixing" anything.
^ permalink raw reply
* Re: SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation)
From: Jan Kara @ 2018-08-06 20:20 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: Dave Airlie, DRI, linux-mm, Eric Dumazet, Christoph Lameter,
Gerrit Renker, dccp, coreteam, Jozsef Kadlecsik, Andrey Ryabinin,
linux-ext4, Alexey Kuznetsov, Pablo Neira Ayuso, linux-s390,
Andrey Konovalov, intel-gfx, Jan Kara, Ursula Braun, Rodrigo Vivi,
Theodore Ts'o, Hideaki YOSHIFUJI, Network Development,
Florian Westphal, Linux Kernel Mailing List
In-Reply-To: <CACT4Y+aYZumcc-Od5T1AnP4mwn8-FaWfxvfb93MnNwQPqG8TDw@mail.gmail.com>
On Wed 01-08-18 10:46:35, Dmitry Vyukov wrote:
> I guess it would be useful to have such extensive comment for each
> SLAB_TYPESAFE_BY_RCU use explaining why it is needed and how all the
> tricky aspects are handled.
>
> For example, the one in jbd2 is interesting because it memsets the
> whole object before freeing it into SLAB_TYPESAFE_BY_RCU slab:
>
> memset(jh, JBD2_POISON_FREE, sizeof(*jh));
> kmem_cache_free(jbd2_journal_head_cache, jh);
>
> I guess there are also tricky ways how it can all work in the end
> (type-stable state is only a byte, or we check for all possible
> combinations of being overwritten with JBD2_POISON_FREE). But at first
> sight it does look fishy.
The RCU access is used from a single place:
fs/jbd2/transaction.c: jbd2_write_access_granted()
There are also quite some comments explaining why what it does is safe. The
overwrite by JBD2_POISON_FREE is much older than this RCU stuff (honestly I
didn't know about it until this moment) and has nothing to do with the
safety of RCU access.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply
* [Patch net] vsock: split dwork to avoid reinitializations
From: Cong Wang @ 2018-08-06 18:06 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Andy king, Stefan Hajnoczi, Jorgen Hansen
syzbot reported that we reinitialize an active delayed
work in vsock_stream_connect():
ODEBUG: init active (active state 0) object type: timer_list hint:
delayed_work_timer_fn+0x0/0x90 kernel/workqueue.c:1414
WARNING: CPU: 1 PID: 11518 at lib/debugobjects.c:329
debug_print_object+0x16a/0x210 lib/debugobjects.c:326
The pattern is apparently wrong, we should only initialize
the dealyed work once and could repeatly schedule it. So we
have to move out the initializations to allocation side.
And to avoid confusion, we can split the shared dwork
into two, instead of re-using the same one.
Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
Reported-by: <syzbot+8a9b1bd330476a4f3db6@syzkaller.appspotmail.com>
Cc: Andy king <acking@vmware.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Jorgen Hansen <jhansen@vmware.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
include/net/af_vsock.h | 4 ++--
net/vmw_vsock/af_vsock.c | 15 ++++++++-------
net/vmw_vsock/vmci_transport.c | 3 +--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 9324ac2d9ff2..43913ae79f64 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -64,7 +64,8 @@ struct vsock_sock {
struct list_head pending_links;
struct list_head accept_queue;
bool rejected;
- struct delayed_work dwork;
+ struct delayed_work connect_work;
+ struct delayed_work pending_work;
struct delayed_work close_work;
bool close_work_scheduled;
u32 peer_shutdown;
@@ -77,7 +78,6 @@ struct vsock_sock {
s64 vsock_stream_has_data(struct vsock_sock *vsk);
s64 vsock_stream_has_space(struct vsock_sock *vsk);
-void vsock_pending_work(struct work_struct *work);
struct sock *__vsock_create(struct net *net,
struct socket *sock,
struct sock *parent,
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index c1076c19b858..ab27a2872935 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -451,14 +451,14 @@ static int vsock_send_shutdown(struct sock *sk, int mode)
return transport->shutdown(vsock_sk(sk), mode);
}
-void vsock_pending_work(struct work_struct *work)
+static void vsock_pending_work(struct work_struct *work)
{
struct sock *sk;
struct sock *listener;
struct vsock_sock *vsk;
bool cleanup;
- vsk = container_of(work, struct vsock_sock, dwork.work);
+ vsk = container_of(work, struct vsock_sock, pending_work.work);
sk = sk_vsock(vsk);
listener = vsk->listener;
cleanup = true;
@@ -498,7 +498,6 @@ void vsock_pending_work(struct work_struct *work)
sock_put(sk);
sock_put(listener);
}
-EXPORT_SYMBOL_GPL(vsock_pending_work);
/**** SOCKET OPERATIONS ****/
@@ -597,6 +596,8 @@ static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr)
return retval;
}
+static void vsock_connect_timeout(struct work_struct *work);
+
struct sock *__vsock_create(struct net *net,
struct socket *sock,
struct sock *parent,
@@ -638,6 +639,8 @@ struct sock *__vsock_create(struct net *net,
vsk->sent_request = false;
vsk->ignore_connecting_rst = false;
vsk->peer_shutdown = 0;
+ INIT_DELAYED_WORK(&vsk->connect_work, vsock_connect_timeout);
+ INIT_DELAYED_WORK(&vsk->pending_work, vsock_pending_work);
psk = parent ? vsock_sk(parent) : NULL;
if (parent) {
@@ -1117,7 +1120,7 @@ static void vsock_connect_timeout(struct work_struct *work)
struct vsock_sock *vsk;
int cancel = 0;
- vsk = container_of(work, struct vsock_sock, dwork.work);
+ vsk = container_of(work, struct vsock_sock, connect_work.work);
sk = sk_vsock(vsk);
lock_sock(sk);
@@ -1221,9 +1224,7 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
* timeout fires.
*/
sock_hold(sk);
- INIT_DELAYED_WORK(&vsk->dwork,
- vsock_connect_timeout);
- schedule_delayed_work(&vsk->dwork, timeout);
+ schedule_delayed_work(&vsk->connect_work, timeout);
/* Skip ahead to preserve error code set above. */
goto out_wait;
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index a7a73ffe675b..cb332adb84cd 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -1094,8 +1094,7 @@ static int vmci_transport_recv_listen(struct sock *sk,
vpending->listener = sk;
sock_hold(sk);
sock_hold(pending);
- INIT_DELAYED_WORK(&vpending->dwork, vsock_pending_work);
- schedule_delayed_work(&vpending->dwork, HZ);
+ schedule_delayed_work(&vpending->pending_work, HZ);
out:
return err;
--
2.14.4
^ permalink raw reply related
* Re: [PATCH] mellanox: fix the dport endianness in call of __inet6_lookup_established()
From: David Miller @ 2018-08-06 17:32 UTC (permalink / raw)
To: viro; +Cc: borisp, netdev
In-Reply-To: <20180804204127.GC15082@ZenIV.linux.org.uk>
From: Al Viro <viro@ZenIV.linux.org.uk>
Date: Sat, 4 Aug 2018 21:41:27 +0100
> __inet6_lookup_established() expect th->dport passed in host-endian,
> not net-endian. The reason is microoptimization in __inet6_lookup(),
> but if you use the lower-level helpers, you have to play by their
> rules...
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Applied to net-next, thanks Al.
^ permalink raw reply
* [PATCH iproute2-next 3/3] q_netem: slotting with non-uniform distribution
From: Yousuk Seung @ 2018-08-06 17:09 UTC (permalink / raw)
To: netdev
Cc: Stephen Hemminger, David Ahern, Michael McLennan, Priyaranjan Jha,
Yousuk Seung, Neal Cardwell, Dave Taht
In-Reply-To: <20180806170953.164776-1-ysseung@google.com>
Extend slotting with support for non-uniform distributions. This is
similar to netem's non-uniform distribution delay feature.
Syntax:
slot distribution DISTRIBUTION DELAY JITTER [packets MAX_PACKETS] \
[bytes MAX_BYTES]
The syntax and use of the distribution table is the same as in the
non-uniform distribution delay feature. A file DISTRIBUTION must be
present in TC_LIB_DIR (e.g. /usr/lib/tc) containing numbers scaled by
NETEM_DIST_SCALE. A random value x is selected from the table and it
takes DELAY + ( x * JITTER ) as delay. Correlation between values is not
supported.
Examples:
Normal distribution delay with mean = 800us and stdev = 100us.
> tc qdisc add dev eth0 root netem slot distribution normal \
800us 100us
Optionally set the max slot size in bytes and/or packets.
> tc qdisc add dev eth0 root netem slot distribution normal \
800us 100us bytes 64k packets 42
Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
---
man/man8/tc-netem.8 | 20 ++++++++----
tc/q_netem.c | 75 +++++++++++++++++++++++++++++++++++++--------
2 files changed, 76 insertions(+), 19 deletions(-)
diff --git a/man/man8/tc-netem.8 b/man/man8/tc-netem.8
index 8d485b026751..111109cf042f 100644
--- a/man/man8/tc-netem.8
+++ b/man/man8/tc-netem.8
@@ -53,9 +53,13 @@ NetEm \- Network Emulator
.IR RATE " [ " PACKETOVERHEAD " [ " CELLSIZE " [ " CELLOVERHEAD " ]]]]"
.IR SLOT " := "
-.BR slot
-.IR MIN_DELAY " [ " MAX_DELAY " ] ["
-.BR packets
+.BR slot " { "
+.IR MIN_DELAY " [ " MAX_DELAY " ] |"
+.br
+.RB " " distribution " { "uniform " | " normal " | " pareto " | " paretonormal " | "
+.IR FILE " } " DELAY " " JITTER " } "
+.br
+.RB " [ " packets
.IR PACKETS " ] [ "
.BR bytes
.IR BYTES " ]"
@@ -172,9 +176,13 @@ an artificial packet compression (bursts). Another influence factor are network
adapter buffers which can also add artificial delay.
.SS slot
-defer delivering accumulated packets to within a slot, with each available slot
-configured with a minimum delay to acquire, and an optional maximum delay. Slot
-delays can be specified in nanoseconds, microseconds, milliseconds or seconds
+defer delivering accumulated packets to within a slot. Each available slot can be
+configured with a minimum delay to acquire, and an optional maximum delay.
+Alternatively it can be configured with the distribution similar to
+.BR distribution
+for
+.BR delay
+option. Slot delays can be specified in nanoseconds, microseconds, milliseconds or seconds
(e.g. 800us). Values for the optional parameters
.I BYTES
will limit the number of bytes delivered per slot, and/or
diff --git a/tc/q_netem.c b/tc/q_netem.c
index f52a36b6c31c..e655e1a82e12 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -43,7 +43,9 @@ static void explain(void)
" [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n" \
" [ slot MIN_DELAY [MAX_DELAY] [packets MAX_PACKETS]" \
" [bytes MAX_BYTES]]\n" \
- );
+" [ slot distribution" \
+" {uniform|normal|pareto|paretonormal|custom} DELAY JITTER" \
+" [packets MAX_PACKETS] [bytes MAX_BYTES]]\n");
}
static void explain1(const char *arg)
@@ -159,6 +161,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n, const char *dev)
{
int dist_size = 0;
+ int slot_dist_size = 0;
struct rtattr *tail;
struct tc_netem_qopt opt = { .limit = 1000 };
struct tc_netem_corr cor = {};
@@ -169,6 +172,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct tc_netem_rate rate = {};
struct tc_netem_slot slot = {};
__s16 *dist_data = NULL;
+ __s16 *slot_dist_data = NULL;
__u16 loss_type = NETEM_LOSS_UNSPEC;
int present[__TCA_NETEM_MAX] = {};
__u64 rate64 = 0;
@@ -417,21 +421,53 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
}
}
} else if (matches(*argv, "slot") == 0) {
- NEXT_ARG();
- present[TCA_NETEM_SLOT] = 1;
- if (get_time64(&slot.min_delay, *argv)) {
- explain1("slot min_delay");
- return -1;
- }
if (NEXT_IS_NUMBER()) {
NEXT_ARG();
- if (get_time64(&slot.max_delay, *argv)) {
- explain1("slot min_delay max_delay");
+ present[TCA_NETEM_SLOT] = 1;
+ if (get_time64(&slot.min_delay, *argv)) {
+ explain1("slot min_delay");
+ return -1;
+ }
+ if (NEXT_IS_NUMBER()) {
+ NEXT_ARG();
+ if (get_time64(&slot.max_delay, *argv)) {
+ explain1("slot min_delay max_delay");
+ return -1;
+ }
+ }
+ if (slot.max_delay < slot.min_delay)
+ slot.max_delay = slot.min_delay;
+ } else {
+ NEXT_ARG();
+ if (strcmp(*argv, "distribution") == 0) {
+ present[TCA_NETEM_SLOT] = 1;
+ NEXT_ARG();
+ slot_dist_data = calloc(sizeof(slot_dist_data[0]), MAX_DIST);
+ slot_dist_size = get_distribution(*argv, slot_dist_data, MAX_DIST);
+ if (slot_dist_size <= 0) {
+ free(slot_dist_data);
+ return -1;
+ }
+ NEXT_ARG();
+ if (get_time64(&slot.dist_delay, *argv)) {
+ explain1("slot delay");
+ return -1;
+ }
+ NEXT_ARG();
+ if (get_time64(&slot.dist_jitter, *argv)) {
+ explain1("slot jitter");
+ return -1;
+ }
+ if (slot.dist_jitter <= 0) {
+ fprintf(stderr, "Non-positive jitter\n");
+ return -1;
+ }
+ } else {
+ fprintf(stderr, "Unknown slot parameter: %s\n",
+ *argv);
return -1;
}
}
- if (slot.max_delay < slot.min_delay)
- slot.max_delay = slot.min_delay;
if (NEXT_ARG_OK() &&
matches(*(argv+1), "packets") == 0) {
NEXT_ARG();
@@ -558,6 +594,14 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
free(dist_data);
}
+
+ if (slot_dist_data) {
+ if (addattr_l(n, MAX_DIST * sizeof(slot_dist_data[0]),
+ TCA_NETEM_SLOT_DIST,
+ slot_dist_data, slot_dist_size * sizeof(slot_dist_data[0])) < 0)
+ return -1;
+ free(slot_dist_data);
+ }
tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
return 0;
}
@@ -712,8 +756,13 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
}
if (slot) {
- fprintf(f, " slot %s", sprint_time64(slot->min_delay, b1));
- fprintf(f, " %s", sprint_time64(slot->max_delay, b1));
+ if (slot->dist_jitter > 0) {
+ fprintf(f, " slot distribution %s", sprint_time64(slot->dist_delay, b1));
+ fprintf(f, " %s", sprint_time64(slot->dist_jitter, b1));
+ } else {
+ fprintf(f, " slot %s", sprint_time64(slot->min_delay, b1));
+ fprintf(f, " %s", sprint_time64(slot->max_delay, b1));
+ }
if(slot->max_packets)
fprintf(f, " packets %d", slot->max_packets);
if(slot->max_bytes)
--
2.18.0.597.ga71716f1ad-goog
^ permalink raw reply related
* [PATCH iproute2-next 2/3] q_netem: support delivering packets in delayed time slots
From: Yousuk Seung @ 2018-08-06 17:09 UTC (permalink / raw)
To: netdev
Cc: Stephen Hemminger, David Ahern, Michael McLennan, Priyaranjan Jha,
Dave Taht, Yousuk Seung, Neal Cardwell
In-Reply-To: <20180806170953.164776-1-ysseung@google.com>
From: Dave Taht <dave.taht@gmail.com>
Slotting is a crude approximation of the behaviors of shared media such
as cable, wifi, and LTE, which gather up a bunch of packets within a
varying delay window and deliver them, relative to that, nearly all at
once.
It works within the existing loss, duplication, jitter and delay
parameters of netem. Some amount of inherent latency must be specified,
regardless.
The new "slot" parameter specifies a minimum and maximum delay between
transmission attempts.
The "bytes" and "packets" parameters can be used to limit the amount of
information transferred per slot.
Examples of use:
tc qdisc add dev eth0 root netem delay 200us \
slot 800us 10ms bytes 64k packets 42
A more correct example, using stacked netem instances and a packet limit
to emulate a tail drop wifi queue with slots and variable packet
delivery, with a 200Mbit isochronous underlying rate, and 20ms path
delay:
tc qdisc add dev eth0 root handle 1: netem delay 20ms rate 200mbit \
limit 10000
tc qdisc add dev eth0 parent 1:1 handle 10:1 netem delay 200us \
slot 800us 10ms bytes 64k packets 42 limit 512
Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
---
man/man8/tc-netem.8 | 32 ++++++++++++++++++++++-
tc/q_netem.c | 63 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 93 insertions(+), 2 deletions(-)
diff --git a/man/man8/tc-netem.8 b/man/man8/tc-netem.8
index f2cd86b6ed8a..8d485b026751 100644
--- a/man/man8/tc-netem.8
+++ b/man/man8/tc-netem.8
@@ -8,7 +8,8 @@ NetEm \- Network Emulator
.I OPTIONS
.IR OPTIONS " := [ " LIMIT " ] [ " DELAY " ] [ " LOSS \
-" ] [ " CORRUPT " ] [ " DUPLICATION " ] [ " REORDERING " ][ " RATE " ]"
+" ] [ " CORRUPT " ] [ " DUPLICATION " ] [ " REORDERING " ] [ " RATE \
+" ] [ " SLOT " ]"
.IR LIMIT " := "
.B limit
@@ -51,6 +52,14 @@ NetEm \- Network Emulator
.B rate
.IR RATE " [ " PACKETOVERHEAD " [ " CELLSIZE " [ " CELLOVERHEAD " ]]]]"
+.IR SLOT " := "
+.BR slot
+.IR MIN_DELAY " [ " MAX_DELAY " ] ["
+.BR packets
+.IR PACKETS " ] [ "
+.BR bytes
+.IR BYTES " ]"
+
.SH DESCRIPTION
NetEm is an enhancement of the Linux traffic control facilities
@@ -162,6 +171,27 @@ granularity avoid a perfect shaping at a specific level. This will show up in
an artificial packet compression (bursts). Another influence factor are network
adapter buffers which can also add artificial delay.
+.SS slot
+defer delivering accumulated packets to within a slot, with each available slot
+configured with a minimum delay to acquire, and an optional maximum delay. Slot
+delays can be specified in nanoseconds, microseconds, milliseconds or seconds
+(e.g. 800us). Values for the optional parameters
+.I BYTES
+will limit the number of bytes delivered per slot, and/or
+.I PACKETS
+will limit the number of packets delivered per slot.
+
+These slot options can provide a crude approximation of bursty MACs such as
+DOCSIS, WiFi, and LTE.
+
+Note that slotting is limited by several factors: the kernel clock granularity,
+as with a rate, and attempts to deliver many packets within a slot will be
+smeared by the timer resolution, and by the underlying native bandwidth also.
+
+It is possible to combine slotting with a rate, in which case complex behaviors
+where either the rate, or the slot limits on bytes or packets per slot, govern
+the actual delivered rate.
+
.SH LIMITATIONS
The main known limitation of Netem are related to timer granularity, since
Linux is not a real-time operating system.
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 9f9a9b3df255..f52a36b6c31c 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -40,7 +40,10 @@ static void explain(void)
" [ loss gemodel PERCENT [R [1-H [1-K]]]\n" \
" [ ecn ]\n" \
" [ reorder PRECENT [CORRELATION] [ gap DISTANCE ]]\n" \
-" [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n");
+" [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n" \
+" [ slot MIN_DELAY [MAX_DELAY] [packets MAX_PACKETS]" \
+" [bytes MAX_BYTES]]\n" \
+ );
}
static void explain1(const char *arg)
@@ -164,6 +167,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct tc_netem_gimodel gimodel;
struct tc_netem_gemodel gemodel;
struct tc_netem_rate rate = {};
+ struct tc_netem_slot slot = {};
__s16 *dist_data = NULL;
__u16 loss_type = NETEM_LOSS_UNSPEC;
int present[__TCA_NETEM_MAX] = {};
@@ -412,6 +416,44 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
return -1;
}
}
+ } else if (matches(*argv, "slot") == 0) {
+ NEXT_ARG();
+ present[TCA_NETEM_SLOT] = 1;
+ if (get_time64(&slot.min_delay, *argv)) {
+ explain1("slot min_delay");
+ return -1;
+ }
+ if (NEXT_IS_NUMBER()) {
+ NEXT_ARG();
+ if (get_time64(&slot.max_delay, *argv)) {
+ explain1("slot min_delay max_delay");
+ return -1;
+ }
+ }
+ if (slot.max_delay < slot.min_delay)
+ slot.max_delay = slot.min_delay;
+ if (NEXT_ARG_OK() &&
+ matches(*(argv+1), "packets") == 0) {
+ NEXT_ARG();
+ if (!NEXT_ARG_OK() ||
+ get_s32(&slot.max_packets, *(argv+1), 0)) {
+ explain1("slot packets");
+ return -1;
+ }
+ NEXT_ARG();
+ }
+ if (NEXT_ARG_OK() &&
+ matches(*(argv+1), "bytes") == 0) {
+ unsigned int max_bytes;
+ NEXT_ARG();
+ if (!NEXT_ARG_OK() ||
+ get_size(&max_bytes, *(argv+1))) {
+ explain1("slot bytes");
+ return -1;
+ }
+ slot.max_bytes = (int) max_bytes;
+ NEXT_ARG();
+ }
} else if (strcmp(*argv, "help") == 0) {
explain();
return -1;
@@ -472,6 +514,10 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,
addattr_l(n, 1024, TCA_NETEM_CORRUPT, &corrupt, sizeof(corrupt)) < 0)
return -1;
+ if (present[TCA_NETEM_SLOT] &&
+ addattr_l(n, 1024, TCA_NETEM_SLOT, &slot, sizeof(slot)) < 0)
+ return -1;
+
if (loss_type != NETEM_LOSS_UNSPEC) {
struct rtattr *start;
@@ -526,6 +572,7 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
int *ecn = NULL;
struct tc_netem_qopt qopt;
const struct tc_netem_rate *rate = NULL;
+ const struct tc_netem_slot *slot = NULL;
int len;
__u64 rate64 = 0;
@@ -586,6 +633,11 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
return -1;
rate64 = rta_getattr_u64(tb[TCA_NETEM_RATE64]);
}
+ if (tb[TCA_NETEM_SLOT]) {
+ if (RTA_PAYLOAD(tb[TCA_NETEM_SLOT]) < sizeof(*slot))
+ return -1;
+ slot = RTA_DATA(tb[TCA_NETEM_SLOT]);
+ }
}
fprintf(f, "limit %d", qopt.limit);
@@ -659,6 +711,15 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
fprintf(f, " celloverhead %d", rate->cell_overhead);
}
+ if (slot) {
+ fprintf(f, " slot %s", sprint_time64(slot->min_delay, b1));
+ fprintf(f, " %s", sprint_time64(slot->max_delay, b1));
+ if(slot->max_packets)
+ fprintf(f, " packets %d", slot->max_packets);
+ if(slot->max_bytes)
+ fprintf(f, " bytes %d", slot->max_bytes);
+ }
+
if (ecn)
fprintf(f, " ecn ");
--
2.18.0.597.ga71716f1ad-goog
^ permalink raw reply related
* [PATCH iproute2-next 1/3] tc: support conversions to or from 64 bit nanosecond-based time
From: Yousuk Seung @ 2018-08-06 17:09 UTC (permalink / raw)
To: netdev
Cc: Stephen Hemminger, David Ahern, Michael McLennan, Priyaranjan Jha,
Dave Taht, Yousuk Seung, Neal Cardwell
In-Reply-To: <20180806170953.164776-1-ysseung@google.com>
From: Dave Taht <dave.taht@gmail.com>
Using a 32 bit field to represent time in nanoseconds results in a
maximum value of about 4.3 seconds, which is well below many observed
delays in WiFi and LTE, and barely in the ballpark for a trip past the
Earth's moon, Luna.
Using 64 bit time fields in nanoseconds allows us to simulate
network diameters of several hundred light-years. However, only
conversions to and from ns, us, ms, and seconds are provided.
Signed-off-by: Yousuk Seung <ysseung@google.com>
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
---
tc/tc_core.h | 4 ++++
tc/tc_util.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tc/tc_util.h | 3 +++
3 files changed, 62 insertions(+)
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 1dfa9a4f773b..a0fe0923d171 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -7,6 +7,10 @@
#define TIME_UNITS_PER_SEC 1000000
+#define NSEC_PER_USEC 1000
+#define NSEC_PER_MSEC 1000000
+#define NSEC_PER_SEC 1000000000LL
+
enum link_layer {
LINKLAYER_UNSPEC,
LINKLAYER_ETHERNET,
diff --git a/tc/tc_util.c b/tc/tc_util.c
index d7578528a31b..c39c9046dcae 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -385,6 +385,61 @@ char *sprint_ticks(__u32 ticks, char *buf)
return sprint_time(tc_core_tick2time(ticks), buf);
}
+/* 64 bit times are represented internally in nanoseconds */
+int get_time64(__s64 *time, const char *str)
+{
+ double nsec;
+ char *p;
+
+ nsec = strtod(str, &p);
+ if (p == str)
+ return -1;
+
+ if (*p) {
+ if (strcasecmp(p, "s") == 0 ||
+ strcasecmp(p, "sec") == 0 ||
+ strcasecmp(p, "secs") == 0)
+ nsec *= NSEC_PER_SEC;
+ else if (strcasecmp(p, "ms") == 0 ||
+ strcasecmp(p, "msec") == 0 ||
+ strcasecmp(p, "msecs") == 0)
+ nsec *= NSEC_PER_MSEC;
+ else if (strcasecmp(p, "us") == 0 ||
+ strcasecmp(p, "usec") == 0 ||
+ strcasecmp(p, "usecs") == 0)
+ nsec *= NSEC_PER_USEC;
+ else if (strcasecmp(p, "ns") == 0 ||
+ strcasecmp(p, "nsec") == 0 ||
+ strcasecmp(p, "nsecs") == 0)
+ nsec *= 1;
+ else
+ return -1;
+ }
+
+ *time = nsec;
+ return 0;
+}
+
+void print_time64(char *buf, int len, __s64 time)
+{
+ double nsec = time;
+
+ if (time >= NSEC_PER_SEC)
+ snprintf(buf, len, "%.3fs", nsec/NSEC_PER_SEC);
+ else if (time >= NSEC_PER_MSEC)
+ snprintf(buf, len, "%.3fms", nsec/NSEC_PER_MSEC);
+ else if (time >= NSEC_PER_USEC)
+ snprintf(buf, len, "%.3fus", nsec/NSEC_PER_USEC);
+ else
+ snprintf(buf, len, "%lldns", time);
+}
+
+char *sprint_time64(__s64 time, char *buf)
+{
+ print_time64(buf, SPRINT_BSIZE-1, time);
+ return buf;
+}
+
int get_size(unsigned int *size, const char *str)
{
double sz;
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 6632c4f9c528..87be951c622d 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -82,12 +82,14 @@ int get_percent_rate64(__u64 *rate, const char *str, const char *dev);
int get_size(unsigned int *size, const char *str);
int get_size_and_cell(unsigned int *size, int *cell_log, char *str);
int get_time(unsigned int *time, const char *str);
+int get_time64(__s64 *time, const char *str);
int get_linklayer(unsigned int *val, const char *arg);
void print_rate(char *buf, int len, __u64 rate);
void print_size(char *buf, int len, __u32 size);
void print_qdisc_handle(char *buf, int len, __u32 h);
void print_time(char *buf, int len, __u32 time);
+void print_time64(char *buf, int len, __s64 time);
void print_linklayer(char *buf, int len, unsigned int linklayer);
void print_devname(enum output_type type, int ifindex);
@@ -96,6 +98,7 @@ char *sprint_size(__u32 size, char *buf);
char *sprint_qdisc_handle(__u32 h, char *buf);
char *sprint_tc_classid(__u32 h, char *buf);
char *sprint_time(__u32 time, char *buf);
+char *sprint_time64(__s64 time, char *buf);
char *sprint_ticks(__u32 ticks, char *buf);
char *sprint_linklayer(unsigned int linklayer, char *buf);
--
2.18.0.597.ga71716f1ad-goog
^ permalink raw reply related
* [PATCH iproute2-next 0/3] support delivering packets in delayed
From: Yousuk Seung @ 2018-08-06 17:09 UTC (permalink / raw)
To: netdev
Cc: Stephen Hemminger, David Ahern, Michael McLennan, Priyaranjan Jha,
Yousuk Seung
This series adds support for the new "slot" netem parameter for
slotting. Slotting is an approximation of shared media that gather up
packets within a varying delay window before delivering them nearly at
once.
Dave Taht (2):
tc: support conversions to or from 64 bit nanosecond-based time
q_netem: support delivering packets in delayed time slots
Yousuk Seung (1):
q_netem: slotting with non-uniform distribution
man/man8/tc-netem.8 | 40 +++++++++++++++-
tc/q_netem.c | 112 +++++++++++++++++++++++++++++++++++++++++++-
tc/tc_core.h | 4 ++
tc/tc_util.c | 55 ++++++++++++++++++++++
tc/tc_util.h | 3 ++
5 files changed, 212 insertions(+), 2 deletions(-)
--
2.18.0.597.ga71716f1ad-goog
^ permalink raw reply
* Re: [PATCH] ptp_qoriq: use div_u64/div_u64_rem for 64-bit division
From: David Miller @ 2018-08-06 17:43 UTC (permalink / raw)
To: yangbo.lu; +Cc: netdev, richardcochran, linux-kernel
In-Reply-To: <20180806043911.15437-1-yangbo.lu@nxp.com>
From: Yangbo Lu <yangbo.lu@nxp.com>
Date: Mon, 6 Aug 2018 12:39:11 +0800
> This is a fix-up patch for below build issue with multi_v7_defconfig.
>
> drivers/ptp/ptp_qoriq.o: In function `qoriq_ptp_probe':
> ptp_qoriq.c:(.text+0xd0c): undefined reference to `__aeabi_uldivmod'
>
> Fixes: 91305f281262 ("ptp_qoriq: support automatic configuration for ptp timer")
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Applied.
^ 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