* [PATCH 3/5] net: don not detour through struct sock to find the poll waitqueue
From: Christoph Hellwig @ 2018-07-27 14:02 UTC (permalink / raw)
To: netdev
In-Reply-To: <20180727140214.1938-1-hch@lst.de>
For any open socket file descriptor sock->sk->sk_wq->wait will always
point to sock->wq->wait. That means we can do the shorter dereference
and removal a NULL check and don't have to not worry about any RCU
protection.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/net/sock.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 946ee8651714..9b6011912691 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2001,10 +2001,9 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq)
static inline void sock_poll_wait(struct file *filp, poll_table *p)
{
struct socket *sock = filp->private_data;
- wait_queue_head_t *wq = sk_sleep(sock->sk);
- if (!poll_does_not_wait(p) && wq) {
- poll_wait(filp, wq, p);
+ if (!poll_does_not_wait(p)) {
+ poll_wait(filp, &sock->wq->wait, p);
/* We need to be sure we are in sync with the
* socket flags modification.
*
--
2.18.0
^ permalink raw reply related
* [PATCH 2/5] net: simplify sock_poll_wait
From: Christoph Hellwig @ 2018-07-27 14:02 UTC (permalink / raw)
To: netdev
In-Reply-To: <20180727140214.1938-1-hch@lst.de>
The wait_address argument is always directly derived from the filp
argument, so remove it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
crypto/af_alg.c | 2 +-
include/net/sock.h | 11 ++++++-----
net/atm/common.c | 2 +-
net/caif/caif_socket.c | 2 +-
net/core/datagram.c | 2 +-
net/dccp/proto.c | 2 +-
net/ipv4/tcp.c | 2 +-
net/iucv/af_iucv.c | 2 +-
net/nfc/llcp_sock.c | 2 +-
net/rxrpc/af_rxrpc.c | 2 +-
net/smc/af_smc.c | 2 +-
net/tipc/socket.c | 2 +-
net/unix/af_unix.c | 4 ++--
13 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index c166f424871c..b053179e0bc5 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1071,7 +1071,7 @@ __poll_t af_alg_poll(struct file *file, struct socket *sock,
struct af_alg_ctx *ctx = ask->private;
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
if (!ctx->more || ctx->used)
diff --git a/include/net/sock.h b/include/net/sock.h
index ad85d37c83c8..946ee8651714 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1994,16 +1994,17 @@ static inline bool skwq_has_sleeper(struct socket_wq *wq)
/**
* sock_poll_wait - place memory barrier behind the poll_wait call.
* @filp: file
- * @wait_address: socket wait queue
* @p: poll_table
*
* See the comments in the wq_has_sleeper function.
*/
-static inline void sock_poll_wait(struct file *filp,
- wait_queue_head_t *wait_address, poll_table *p)
+static inline void sock_poll_wait(struct file *filp, poll_table *p)
{
- if (!poll_does_not_wait(p) && wait_address) {
- poll_wait(filp, wait_address, p);
+ struct socket *sock = filp->private_data;
+ wait_queue_head_t *wq = sk_sleep(sock->sk);
+
+ if (!poll_does_not_wait(p) && wq) {
+ poll_wait(filp, wq, p);
/* We need to be sure we are in sync with the
* socket flags modification.
*
diff --git a/net/atm/common.c b/net/atm/common.c
index a7a68e509628..9f8cb0d2e71e 100644
--- a/net/atm/common.c
+++ b/net/atm/common.c
@@ -653,7 +653,7 @@ __poll_t vcc_poll(struct file *file, struct socket *sock, poll_table *wait)
struct atm_vcc *vcc;
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
vcc = ATM_SD(sock);
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c
index a6fb1b3bcad9..d18965f3291f 100644
--- a/net/caif/caif_socket.c
+++ b/net/caif/caif_socket.c
@@ -941,7 +941,7 @@ static __poll_t caif_poll(struct file *file,
__poll_t mask;
struct caifsock *cf_sk = container_of(sk, struct caifsock, sk);
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
/* exceptional events? */
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 9938952c5c78..9aac0d63d53e 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -837,7 +837,7 @@ __poll_t datagram_poll(struct file *file, struct socket *sock,
struct sock *sk = sock->sk;
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
/* exceptional events? */
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 0d56e36a6db7..875858c8b059 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -325,7 +325,7 @@ __poll_t dccp_poll(struct file *file, struct socket *sock,
__poll_t mask;
struct sock *sk = sock->sk;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
if (sk->sk_state == DCCP_LISTEN)
return inet_csk_listen_poll(sk);
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4491faf83f4f..0b93290c9255 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -507,7 +507,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
const struct tcp_sock *tp = tcp_sk(sk);
int state;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
state = inet_sk_state_load(sk);
if (state == TCP_LISTEN)
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 893a022f9620..e7b93cd14b52 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1494,7 +1494,7 @@ __poll_t iucv_sock_poll(struct file *file, struct socket *sock,
struct sock *sk = sock->sk;
__poll_t mask = 0;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
if (sk->sk_state == IUCV_LISTEN)
return iucv_accept_poll(sk);
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index ea0c0c6f1874..dd4adf8b1167 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -556,7 +556,7 @@ static __poll_t llcp_sock_poll(struct file *file, struct socket *sock,
pr_debug("%p\n", sk);
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
if (sk->sk_state == LLCP_LISTEN)
return llcp_accept_poll(sk);
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 2b463047dd7b..ac44d8afffb1 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -741,7 +741,7 @@ static __poll_t rxrpc_poll(struct file *file, struct socket *sock,
struct rxrpc_sock *rx = rxrpc_sk(sk);
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
/* the socket is readable if there are any messages waiting on the Rx
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 05e4ffe5aabd..09df79313f60 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1351,7 +1351,7 @@ static __poll_t smc_poll(struct file *file, struct socket *sock,
mask |= EPOLLERR;
} else {
if (sk->sk_state != SMC_CLOSED)
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
if (sk->sk_err)
mask |= EPOLLERR;
if ((sk->sk_shutdown == SHUTDOWN_MASK) ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 930852c54d7a..9a9050131724 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -716,7 +716,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
struct tipc_sock *tsk = tipc_sk(sk);
__poll_t revents = 0;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
if (sk->sk_shutdown & RCV_SHUTDOWN)
revents |= EPOLLRDHUP | EPOLLIN | EPOLLRDNORM;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e5473c03d667..1772a0e32665 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2635,7 +2635,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
struct sock *sk = sock->sk;
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
/* exceptional events? */
@@ -2672,7 +2672,7 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
unsigned int writable;
__poll_t mask;
- sock_poll_wait(file, sk_sleep(sk), wait);
+ sock_poll_wait(file, wait);
mask = 0;
/* exceptional events? */
--
2.18.0
^ permalink raw reply related
* [PATCH 1/5] net: remove bogus RCU annotations on socket.wq
From: Christoph Hellwig @ 2018-07-27 14:02 UTC (permalink / raw)
To: netdev
In-Reply-To: <20180727140214.1938-1-hch@lst.de>
We never use RCU protection for it, just a lot of cargo-cult
rcu_deference_protects calls.
Note that we do keep the kfree_rcu call for it, as the references through
struct sock are RCU protected and thus might require a grace period before
freeing.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/net.h | 2 +-
include/net/sock.h | 2 +-
net/socket.c | 10 ++++------
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 6554d3ba4396..e0930678c8bf 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -114,7 +114,7 @@ struct socket {
unsigned long flags;
- struct socket_wq __rcu *wq;
+ struct socket_wq *wq;
struct file *file;
struct sock *sk;
diff --git a/include/net/sock.h b/include/net/sock.h
index b3b75419eafe..ad85d37c83c8 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1725,7 +1725,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
{
WARN_ON(parent->sk);
write_lock_bh(&sk->sk_callback_lock);
- sk->sk_wq = parent->wq;
+ rcu_assign_pointer(sk->sk_wq, parent->wq);
parent->sk = sk;
sk_set_socket(sk, parent);
sk->sk_uid = SOCK_INODE(parent)->i_uid;
diff --git a/net/socket.c b/net/socket.c
index 85633622c94d..39e0afbdd797 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -251,7 +251,7 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
init_waitqueue_head(&wq->wait);
wq->fasync_list = NULL;
wq->flags = 0;
- RCU_INIT_POINTER(ei->socket.wq, wq);
+ ei->socket.wq = wq;
ei->socket.state = SS_UNCONNECTED;
ei->socket.flags = 0;
@@ -265,11 +265,9 @@ static struct inode *sock_alloc_inode(struct super_block *sb)
static void sock_destroy_inode(struct inode *inode)
{
struct socket_alloc *ei;
- struct socket_wq *wq;
ei = container_of(inode, struct socket_alloc, vfs_inode);
- wq = rcu_dereference_protected(ei->socket.wq, 1);
- kfree_rcu(wq, rcu);
+ kfree_rcu(ei->socket.wq, rcu);
kmem_cache_free(sock_inode_cachep, ei);
}
@@ -603,7 +601,7 @@ static void __sock_release(struct socket *sock, struct inode *inode)
module_put(owner);
}
- if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
+ if (sock->wq->fasync_list)
pr_err("%s: fasync list not empty!\n", __func__);
if (!sock->file) {
@@ -1172,7 +1170,7 @@ static int sock_fasync(int fd, struct file *filp, int on)
return -EINVAL;
lock_sock(sk);
- wq = rcu_dereference_protected(sock->wq, lockdep_sock_is_held(sk));
+ wq = sock->wq;
fasync_helper(fd, filp, on, &wq->fasync_list);
if (!wq->fasync_list)
--
2.18.0
^ permalink raw reply related
* socket poll related cleanups
From: Christoph Hellwig @ 2018-07-27 14:02 UTC (permalink / raw)
To: netdev
A couple of cleanups I stumbled upon when studying the networking
poll code.
^ permalink raw reply
* the editing
From: Jeremy @ 2018-07-27 11:38 UTC (permalink / raw)
To: netdev
I would like to contact the person who manages your images for your
company?
We services such as background image cut out, clipping path, shadow adding
(drop shadow, reflection shadow, natural shadow, mirror effect), image
masking, product image editing.
The following are the kind of services together:
Clipping Path Service
Cut out image,Image Clipping, Clip image
Photo Masking Service
Crop image, Photo cut out
Beauty Retouching, Model retouching
We can give you editing test on your photos.
Also, we also use the most recent application as well as techniques such as
Adobe Photoshop.
Thanks,
Jeremy
^ permalink raw reply
* Re: [PATCH] net/rds/Kconfig: Correct the RDS depends
From: Eric Dumazet @ 2018-07-27 15:03 UTC (permalink / raw)
To: Anders Roxell, santosh.shilimkar, davem, eric.dumazet
Cc: netdev, linux-rdma, rds-devel, linux-kernel
In-Reply-To: <20180727131849.18488-1-anders.roxell@linaro.org>
On 07/27/2018 06:18 AM, Anders Roxell wrote:
> Remove prefix 'CONFIG_' from CONFIG_IPV6
>
> Fixes: ba7d7e2677c0 ("net/rds/Kconfig: RDS should depend on IPV6")
> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
SGTM, thanks !
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply
* company photos
From: Jeremy @ 2018-07-27 8:42 UTC (permalink / raw)
To: netdev
I would like to contact the person who manages your images for your
company?
We services such as background image cut out, clipping path, shadow adding
(drop shadow, reflection shadow, natural shadow, mirror effect), image
masking, product image editing.
The following are the kind of services together:
Clipping Path Service
Cut out image,Image Clipping, Clip image
Photo Masking Service
Crop image, Photo cut out
Beauty Retouching, Model retouching
We can give you editing test on your photos.
Also, we also use the most recent application as well as techniques such as
Adobe Photoshop.
Thanks,
Jeremy
^ permalink raw reply
* KMSAN: uninit-value in iptable_mangle_hook (3)
From: syzbot @ 2018-07-27 13:12 UTC (permalink / raw)
To: coreteam, davem, fw, kadlec, kuznet, linux-kernel, netdev,
netfilter-devel, pablo, syzkaller-bugs, yoshfuji
Hello,
syzbot found the following crash on:
HEAD commit: d1c2a46a46f6 kmsan: update LLVM/Clang patches to r337583.
git tree: https://github.com/google/kmsan.git/master
console output: https://syzkaller.appspot.com/x/log.txt?x=16a2732c400000
kernel config: https://syzkaller.appspot.com/x/.config?x=31cf75cbffdedb44
dashboard link: https://syzkaller.appspot.com/bug?extid=60f2e2b690c5cf94e35d
compiler: clang version 7.0.0 (trunk 334104)
Unfortunately, I don't have any reproducer for this crash yet.
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+60f2e2b690c5cf94e35d@syzkaller.appspotmail.com
==================================================================
BUG: KMSAN: uninit-value in ipt_mangle_out
net/ipv4/netfilter/iptable_mangle.c:64 [inline]
BUG: KMSAN: uninit-value in iptable_mangle_hook+0x622/0x720
net/ipv4/netfilter/iptable_mangle.c:84
CPU: 0 PID: 15708 Comm: syz-executor0 Not tainted 4.18.0-rc5+ #29
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x185/0x1e0 lib/dump_stack.c:113
kmsan_report+0x195/0x2c0 mm/kmsan/kmsan.c:982
__msan_warning+0x7d/0xe0 mm/kmsan/kmsan_instr.c:645
ipt_mangle_out net/ipv4/netfilter/iptable_mangle.c:64 [inline]
iptable_mangle_hook+0x622/0x720 net/ipv4/netfilter/iptable_mangle.c:84
nf_hook_entry_hookfn include/linux/netfilter.h:119 [inline]
nf_hook_slow+0x15d/0x3e0 net/netfilter/core.c:511
nf_hook include/linux/netfilter.h:242 [inline]
__ip_local_out+0x705/0x830 net/ipv4/ip_output.c:113
ip_local_out+0xa4/0x1d0 net/ipv4/ip_output.c:122
iptunnel_xmit+0x854/0xdb0 net/ipv4/ip_tunnel_core.c:91
ip_tunnel_xmit+0x373a/0x3b10 net/ipv4/ip_tunnel.c:778
__gre_xmit net/ipv4/ip_gre.c:449 [inline]
ipgre_xmit+0xe16/0xef0 net/ipv4/ip_gre.c:701
__netdev_start_xmit include/linux/netdevice.h:4148 [inline]
netdev_start_xmit include/linux/netdevice.h:4157 [inline]
xmit_one net/core/dev.c:3034 [inline]
dev_hard_start_xmit+0x60f/0xcc0 net/core/dev.c:3050
__dev_queue_xmit+0x3060/0x3c70 net/core/dev.c:3569
dev_queue_xmit+0x4b/0x60 net/core/dev.c:3602
packet_snd net/packet/af_packet.c:2919 [inline]
packet_sendmsg+0x8469/0x9010 net/packet/af_packet.c:2944
sock_sendmsg_nosec net/socket.c:641 [inline]
sock_sendmsg net/socket.c:651 [inline]
___sys_sendmsg+0xed9/0x1350 net/socket.c:2125
__sys_sendmsg net/socket.c:2163 [inline]
__do_sys_sendmsg net/socket.c:2172 [inline]
__se_sys_sendmsg net/socket.c:2170 [inline]
__x64_sys_sendmsg+0x3b0/0x520 net/socket.c:2170
do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x455ab9
Code: 1d ba fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 eb b9 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fd96a1bfc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fd96a1c06d4 RCX: 0000000000455ab9
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000014
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000004c1066 R14: 00000000004d16c8 R15: 0000000000000000
Uninit was stored to memory at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:256 [inline]
kmsan_save_stack mm/kmsan/kmsan.c:271 [inline]
kmsan_internal_chain_origin+0x13c/0x240 mm/kmsan/kmsan.c:573
__msan_chain_origin+0x76/0xd0 mm/kmsan/kmsan_instr.c:483
iptunnel_xmit+0xa48/0xdb0 net/ipv4/ip_tunnel_core.c:85
ip_tunnel_xmit+0x373a/0x3b10 net/ipv4/ip_tunnel.c:778
__gre_xmit net/ipv4/ip_gre.c:449 [inline]
ipgre_xmit+0xe16/0xef0 net/ipv4/ip_gre.c:701
__netdev_start_xmit include/linux/netdevice.h:4148 [inline]
netdev_start_xmit include/linux/netdevice.h:4157 [inline]
xmit_one net/core/dev.c:3034 [inline]
dev_hard_start_xmit+0x60f/0xcc0 net/core/dev.c:3050
__dev_queue_xmit+0x3060/0x3c70 net/core/dev.c:3569
dev_queue_xmit+0x4b/0x60 net/core/dev.c:3602
packet_snd net/packet/af_packet.c:2919 [inline]
packet_sendmsg+0x8469/0x9010 net/packet/af_packet.c:2944
sock_sendmsg_nosec net/socket.c:641 [inline]
sock_sendmsg net/socket.c:651 [inline]
___sys_sendmsg+0xed9/0x1350 net/socket.c:2125
__sys_sendmsg net/socket.c:2163 [inline]
__do_sys_sendmsg net/socket.c:2172 [inline]
__se_sys_sendmsg net/socket.c:2170 [inline]
__x64_sys_sendmsg+0x3b0/0x520 net/socket.c:2170
do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x63/0xe7
Uninit was created at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:256 [inline]
kmsan_internal_poison_shadow+0xc8/0x1d0 mm/kmsan/kmsan.c:181
kmsan_kmalloc+0xa1/0x120 mm/kmsan/kmsan_hooks.c:91
kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan_hooks.c:100
slab_post_alloc_hook mm/slab.h:446 [inline]
slab_alloc_node mm/slub.c:2720 [inline]
__kmalloc_node_track_caller+0xb48/0x11d0 mm/slub.c:4353
__kmalloc_reserve net/core/skbuff.c:138 [inline]
__alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
alloc_skb include/linux/skbuff.h:988 [inline]
alloc_skb_with_frags+0x1e6/0xb80 net/core/skbuff.c:5271
sock_alloc_send_pskb+0xb59/0x11e0 net/core/sock.c:2095
packet_alloc_skb net/packet/af_packet.c:2776 [inline]
packet_snd net/packet/af_packet.c:2867 [inline]
packet_sendmsg+0x68cb/0x9010 net/packet/af_packet.c:2944
sock_sendmsg_nosec net/socket.c:641 [inline]
sock_sendmsg net/socket.c:651 [inline]
___sys_sendmsg+0xed9/0x1350 net/socket.c:2125
__sys_sendmsg net/socket.c:2163 [inline]
__do_sys_sendmsg net/socket.c:2172 [inline]
__se_sys_sendmsg net/socket.c:2170 [inline]
__x64_sys_sendmsg+0x3b0/0x520 net/socket.c:2170
do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x63/0xe7
==================================================================
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
syzbot.
^ permalink raw reply
* KMSAN: uninit-value in sit_tunnel_xmit
From: syzbot @ 2018-07-27 13:12 UTC (permalink / raw)
To: davem, kuznet, linux-kernel, netdev, syzkaller-bugs, yoshfuji
Hello,
syzbot found the following crash on:
HEAD commit: d1c2a46a46f6 kmsan: update LLVM/Clang patches to r337583.
git tree: https://github.com/google/kmsan.git/master
console output: https://syzkaller.appspot.com/x/log.txt?x=17d4570c400000
kernel config: https://syzkaller.appspot.com/x/.config?x=31cf75cbffdedb44
dashboard link: https://syzkaller.appspot.com/bug?extid=782ee96f9147673d8822
compiler: clang version 7.0.0 (trunk 334104)
Unfortunately, I don't have any reproducer for this crash yet.
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+782ee96f9147673d8822@syzkaller.appspotmail.com
IPVS: Scheduler module ip_vs_mh not found
==================================================================
BUG: KMSAN: uninit-value in __ipv6_prefix_equal64_half
include/net/ipv6.h:522 [inline]
BUG: KMSAN: uninit-value in ipv6_prefix_equal include/net/ipv6.h:539
[inline]
BUG: KMSAN: uninit-value in check_6rd net/ipv6/sit.c:771 [inline]
BUG: KMSAN: uninit-value in try_6rd net/ipv6/sit.c:805 [inline]
BUG: KMSAN: uninit-value in ipip6_tunnel_xmit net/ipv6/sit.c:865 [inline]
BUG: KMSAN: uninit-value in sit_tunnel_xmit+0x1ad3/0x3b00
net/ipv6/sit.c:1029
CPU: 0 PID: 7135 Comm: syz-executor4 Not tainted 4.18.0-rc5+ #29
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x185/0x1e0 lib/dump_stack.c:113
kmsan_report+0x195/0x2c0 mm/kmsan/kmsan.c:982
__msan_warning+0x7d/0xe0 mm/kmsan/kmsan_instr.c:645
IPVS: Scheduler module ip_vs_mh not found
__ipv6_prefix_equal64_half include/net/ipv6.h:522 [inline]
ipv6_prefix_equal include/net/ipv6.h:539 [inline]
check_6rd net/ipv6/sit.c:771 [inline]
try_6rd net/ipv6/sit.c:805 [inline]
ipip6_tunnel_xmit net/ipv6/sit.c:865 [inline]
sit_tunnel_xmit+0x1ad3/0x3b00 net/ipv6/sit.c:1029
__netdev_start_xmit include/linux/netdevice.h:4148 [inline]
netdev_start_xmit include/linux/netdevice.h:4157 [inline]
xmit_one net/core/dev.c:3034 [inline]
dev_hard_start_xmit+0x60f/0xcc0 net/core/dev.c:3050
__dev_queue_xmit+0x3060/0x3c70 net/core/dev.c:3569
dev_queue_xmit+0x4b/0x60 net/core/dev.c:3602
packet_snd net/packet/af_packet.c:2919 [inline]
packet_sendmsg+0x8469/0x9010 net/packet/af_packet.c:2944
sock_sendmsg_nosec net/socket.c:641 [inline]
sock_sendmsg net/socket.c:651 [inline]
___sys_sendmsg+0xed9/0x1350 net/socket.c:2125
__sys_sendmsg net/socket.c:2163 [inline]
__do_sys_sendmsg net/socket.c:2172 [inline]
__se_sys_sendmsg net/socket.c:2170 [inline]
__x64_sys_sendmsg+0x3b0/0x520 net/socket.c:2170
do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x455ab9
Code: 1d ba fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7
48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
ff 0f 83 eb b9 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f68d21b1c68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f68d21b26d4 RCX: 0000000000455ab9
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000013
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 00000000004c1066 R14: 00000000004d16c8 R15: 0000000000000000
Uninit was created at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:256 [inline]
kmsan_internal_poison_shadow+0xc8/0x1d0 mm/kmsan/kmsan.c:181
kmsan_kmalloc+0xa1/0x120 mm/kmsan/kmsan_hooks.c:91
kmsan_slab_alloc+0x10/0x20 mm/kmsan/kmsan_hooks.c:100
slab_post_alloc_hook mm/slab.h:446 [inline]
slab_alloc_node mm/slub.c:2720 [inline]
__kmalloc_node_track_caller+0xb48/0x11d0 mm/slub.c:4353
__kmalloc_reserve net/core/skbuff.c:138 [inline]
__alloc_skb+0x2cb/0x9e0 net/core/skbuff.c:206
alloc_skb include/linux/skbuff.h:988 [inline]
alloc_skb_with_frags+0x1e6/0xb80 net/core/skbuff.c:5271
sock_alloc_send_pskb+0xb59/0x11e0 net/core/sock.c:2095
packet_alloc_skb net/packet/af_packet.c:2776 [inline]
packet_snd net/packet/af_packet.c:2867 [inline]
packet_sendmsg+0x68cb/0x9010 net/packet/af_packet.c:2944
sock_sendmsg_nosec net/socket.c:641 [inline]
sock_sendmsg net/socket.c:651 [inline]
___sys_sendmsg+0xed9/0x1350 net/socket.c:2125
__sys_sendmsg net/socket.c:2163 [inline]
__do_sys_sendmsg net/socket.c:2172 [inline]
__se_sys_sendmsg net/socket.c:2170 [inline]
__x64_sys_sendmsg+0x3b0/0x520 net/socket.c:2170
do_syscall_64+0x15b/0x230 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x63/0xe7
==================================================================
---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
syzbot.
^ permalink raw reply
* Re: [PATCH] net/rds/Kconfig: RDS should depend on IPV6
From: Anders Roxell @ 2018-07-27 13:11 UTC (permalink / raw)
To: eric.dumazet
Cc: David Miller, Santosh Shilimkar, ka-cheong.poon, Networking,
linux-rdma, rds-devel, Linux Kernel Mailing List
In-Reply-To: <68f68676-0d91-125f-5697-31cc459ab24e@gmail.com>
On Fri, 27 Jul 2018 at 13:52, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>
> On 07/25/2018 03:20 PM, Anders Roxell wrote:
> > Build error, implicit declaration of function __inet6_ehashfn shows up
> > When RDS is enabled but not IPV6.
> > net/rds/connection.c: In function ‘rds_conn_bucket’:
> > net/rds/connection.c:67:9: error: implicit declaration of function ‘__inet6_ehashfn’; did you mean ‘__inet_ehashfn’? [-Werror=implicit-function-declaration]
> > hash = __inet6_ehashfn(lhash, 0, fhash, 0, rds_hash_secret);
> > ^~~~~~~~~~~~~~~
> > __inet_ehashfn
> >
> > Current code adds IPV6 as a depends on in config RDS.
> >
> > Fixes: eee2fa6ab322 ("rds: Changing IP address internal representation to struct in6_addr")
> > Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> > ---
> > net/rds/Kconfig | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/rds/Kconfig b/net/rds/Kconfig
> > index 41f75563b54b..607128f10bcd 100644
> > --- a/net/rds/Kconfig
> > +++ b/net/rds/Kconfig
> > @@ -1,7 +1,7 @@
> >
> > config RDS
> > tristate "The RDS Protocol"
> > - depends on INET
> > + depends on INET && CONFIG_IPV6
>
> You probably meant :
>
> depends on INET && IPV6
Hmm... Yes, I'll send out a new patch to fix it.
I'm sorry.
Cheers,
Anders
>
>
> > ---help---
> > The RDS (Reliable Datagram Sockets) protocol provides reliable,
> > sequenced delivery of datagrams over Infiniband or TCP.
> >
^ permalink raw reply
* Re: [PATCH net-next v4 1/4] net/sched: user-space can't set unknown tcfa_action values
From: Paolo Abeni @ 2018-07-27 13:08 UTC (permalink / raw)
To: Marcelo Ricardo Leitner, Jiri Pirko
Cc: netdev, Jamal Hadi Salim, Cong Wang, Daniel Borkmann, Eyal Birger,
David S. Miller
In-Reply-To: <20180727002857.GC20482@localhost.localdomain>
On Thu, 2018-07-26 at 21:28 -0300, Marcelo Ricardo Leitner wrote:
> Hi,
>
> On Thu, Jul 26, 2018 at 04:34:57PM +0200, Paolo Abeni wrote:
> ...
> > @@ -895,6 +904,14 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
> > }
> > }
> >
> > + if (!tcf_action_valid(a->tcfa_action)) {
> > + net_warn_ratelimited("invalid %d action value, using "
> > + "TC_ACT_UNSPEC instead", a->tcfa_action);
>
> Now that it is reporting the error via extack, do we really need this
> warn net_warn?
> extack will be shown as a warning by iproute2 even if the command
> succeeds.
That was requested by Jiri (modulo misinterpretation on my side).
My understanding is that the extact will warn the whoever tryed to push
the bad configuration, while the net_warn is targeting the hosts
administrator.
Jiri, do you have strong opinion on this or did I misinterpret your
wording/ can I drop the net_warn?
Thanks!
> > + NL_SET_ERR_MSG(extack, "invalid action value, using "
> > + "TC_ACT_UNSPEC instead");
>
> Quoted strings shouldn't be broken down into multiple lines..
Thanks,
will fix in v5 :(
Cheers,
Paolo
^ permalink raw reply
* Re: unregister_netdevice: waiting for DEV to become free
From: Tetsuo Handa @ 2018-07-27 13:00 UTC (permalink / raw)
To: Steffen Klassert, Herbert Xu, David S. Miller
Cc: syzbot, ddstreet, dvyukov, linux-kernel, netdev, syzkaller-bugs
In-Reply-To: <000000000000ed9844056a507832@google.com>
Hello.
Since this bug is top crasher (124264 times in 98 days is almost "every minute").
I made a simplified C reproducer based on the C reproducer provided by syzbot.
It seems that setsockopt(SOL_IPV6, IPV6_XFRM_POLICY) is involved to this trouble.
----------------------------------------
#define _GNU_SOURCE
#include <sched.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*
ip6tnl0: flags=128<NOARP> mtu 1452
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
*/
#define IP_DEVNAME "ip6tnl0"
int main(int argc, char *argv[])
{
struct sockaddr_in6 addr = { };
int fd;
if (unshare(CLONE_NEWNET))
return 1;
fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP);
if (system("ip link set dev " IP_DEVNAME " up"))
return 2;
setsockopt(fd, SOL_IPV6, IPV6_XFRM_POLICY, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0\n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\377\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\254\24\24\252\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0+\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\4\0\0\0\0\0\0\0\7\0\0\0\r5M&", 0xe8);
addr.sin6_family = AF_INET6;
inet_pton(AF_INET6, "fe80::bb", &addr.sin6_addr);
addr.sin6_scope_id = 9;
connect(fd, (struct sockaddr *) &addr, sizeof(addr));
return 0;
}
----------------------------------------
^ permalink raw reply
* Re: [PATCH 00/18] xfrm: Add compat layer
From: Florian Westphal @ 2018-07-27 14:19 UTC (permalink / raw)
To: Dmitry Safonov
Cc: Steffen Klassert, Florian Westphal, linux-kernel, David S. Miller,
Herbert Xu, Dmitry Safonov, netdev, Andy Lutomirski,
Ard Biesheuvel, H. Peter Anvin, Ingo Molnar, John Stultz,
Kirill A. Shutemov, Oleg Nesterov, Stephen Boyd, Steven Rostedt,
Thomas Gleixner, x86, linux-efi, Andrew Morton,
Greg Kroah-Hartman
In-Reply-To: <1532700173.2679.18.camel@arista.com>
Dmitry Safonov <dima@arista.com> wrote:
> 1. It will double copy netlink messages, making it O(n) instead of
> O(1), where n - is number of bind()s.. Probably we don't care much.
About those bind() patches, I don't understand why they are needed.
Why can't you just add the compat skb to the native skb when doing
the multicast call?
skb_shinfo(skb)->frag_list = compat_skb;
xfrm_nlmsg_multicast(net, skb, 0, ...
^ permalink raw reply
* Re: net-next boot error
From: Michael S. Tsirkin @ 2018-07-27 14:00 UTC (permalink / raw)
To: Steven Rostedt
Cc: amritha.nambiar, Marc Zyngier, netdev, Tetsuo Handa,
syzkaller-bugs, LKML, David Miller, Peter Zijlstra, Jason Baron,
Josh Poimboeuf, syzbot, Paolo Bonzini, Thomas Gleixner,
Borislav Petkov, virtualization, Ingo Molnar, Dmitry Vyukov
In-Reply-To: <20180726101748.7bbb4805@gandalf.local.home>
On Thu, Jul 26, 2018 at 10:17:48AM -0400, Steven Rostedt wrote:
>
> [ Added Thomas Gleixner ]
>
>
> On Thu, 26 Jul 2018 11:34:39 +0200
> Dmitry Vyukov <dvyukov@google.com> wrote:
>
> > On Thu, Jul 26, 2018 at 11:29 AM, syzbot
> > <syzbot+604f8271211546f5b3c7@syzkaller.appspotmail.com> wrote:
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit: dc66fe43b7eb rds: send: Fix dead code in rds_sendmsg
> > > git tree: net-next
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=127874c8400000
> > > kernel config: https://syzkaller.appspot.com/x/.config?x=f34ce142a9f5f0e8
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=604f8271211546f5b3c7
> > > compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> > >
> > > Unfortunately, I don't have any reproducer for this crash yet.
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+604f8271211546f5b3c7@syzkaller.appspotmail.com
> > >
> > > possible deadlock in static_key_slow_incsd 0:0:1:0: [sda] Attached SCSI disk
> > > MACsec IEEE 802.1AE
> > > tun: Universal TUN/TAP device driver, 1.6
> > >
> > > ============================================
> > > WARNING: possible recursive locking detected
> >
> > +Tetsuo, perhaps this boot lockdep problem then disables lockdep for
> > actual testing. I think lockdep should respect panic_on_warn.
> >
> >
> > > 4.18.0-rc6+ #141 Not tainted
> > > --------------------------------------------
> > > swapper/0/1 is trying to acquire lock:
> > > (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at:
> > > static_key_slow_inc+0x12/0x30 kernel/jump_label.c:124
> > >
> > > but task is already holding lock:
> > > (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: get_online_cpus
> > > include/linux/cpu.h:126 [inline]
> > > (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: init_vqs+0xe1a/0x1520
> > > drivers/net/virtio_net.c:2777
>
> Here init_vqs() does:
>
> get_online_cpus();
> virtnet_set_affinity(vi);
> put_online_cpus();
>
> Which disables cpu hotplug and calls virtnet_set_affinity()
>
> Note, get_online_cpus() is no longer recursive.
>
> > >
> > > other info that might help us debug this:
> > > Possible unsafe locking scenario:
> > >
> > > CPU0
> > > ----
> > > lock(cpu_hotplug_lock.rw_sem);
> > > lock(cpu_hotplug_lock.rw_sem);
> > >
> > > *** DEADLOCK ***
> > >
> > > May be due to missing lock nesting notation
> > >
> > > 3 locks held by swapper/0/1:
> > > #0: (____ptrval____) (&dev->mutex){....}, at: device_lock
> > > include/linux/device.h:1134 [inline]
> > > #0: (____ptrval____) (&dev->mutex){....}, at: __driver_attach+0x15f/0x2f0
> > > drivers/base/dd.c:820
> > > #1: (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at: get_online_cpus
> > > include/linux/cpu.h:126 [inline]
> > > #1: (____ptrval____) (cpu_hotplug_lock.rw_sem){++++}, at:
> > > init_vqs+0xe1a/0x1520 drivers/net/virtio_net.c:2777
> > > #2: (____ptrval____) (xps_map_mutex){+.+.}, at:
> > > __netif_set_xps_queue+0x243/0x23f0 net/core/dev.c:2278
> > >
> > > stack backtrace:
> > > CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.18.0-rc6+ #141
> > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > > Google 01/01/2011
> > > Call Trace:
> > > __dump_stack lib/dump_stack.c:77 [inline]
> > > dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
> > > print_deadlock_bug kernel/locking/lockdep.c:1765 [inline]
> > > check_deadlock kernel/locking/lockdep.c:1809 [inline]
> > > validate_chain kernel/locking/lockdep.c:2405 [inline]
> > > __lock_acquire.cold.65+0x1fb/0x486 kernel/locking/lockdep.c:3435
> > > lock_acquire+0x1e4/0x540 kernel/locking/lockdep.c:3924
> > > percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
> > > percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
> > > cpus_read_lock+0x43/0xa0 kernel/cpu.c:289
> > > static_key_slow_inc+0x12/0x30 kernel/jump_label.c:124
> > > __netif_set_xps_queue+0xaac/0x23f0 net/core/dev.c:2320
>
>
> __netif_set_xps_queue() calls static_key_slow_inc() which will also do
> a get_online_cpus() which will trigger this bug.
>
> There's a static_key_slow_inc_cpuslocked() version that should be used
> when get_online_cpus() is already taken, but I see
> __netif_set_xps_queue() is called from several places, and I doubt it
> is always called with get_online_cpus() held. Thus just using the
> cpuslocked() version is probably not sufficient of a fix.
>
> I don't know the code enough to offer other suggestions.
>
> -- Steve
OK so the guess is it's due to combination of
commit 04157469b7b848f4a9978b63b1ea2ce62ad3a0a3
Author: Amritha Nambiar <amritha.nambiar@intel.com>
Date: Fri Jun 29 21:26:46 2018 -0700
net: Use static_key for XPS maps
which uses static_key_slow_inc and
commit 8af2c06ff4b144064b51b7f688194474123d9c9c
Author: Amritha Nambiar <amritha.nambiar@intel.com>
Date: Fri Jun 29 21:27:07 2018 -0700
net-sysfs: Add interface for Rx queue(s) map per Tx queue
which makes it all user-triggerable.
>
> > > netif_set_xps_queue+0x26/0x30 net/core/dev.c:2455
> > > virtnet_set_affinity+0x2ba/0x4b0 drivers/net/virtio_net.c:1944
> > > init_vqs+0xe22/0x1520 drivers/net/virtio_net.c:2778
> > > virtnet_probe+0x1092/0x2260 drivers/net/virtio_net.c:3016
> > > virtio_dev_probe+0x592/0x942 drivers/virtio/virtio.c:245
> > > really_probe drivers/base/dd.c:446 [inline]
> > > driver_probe_device+0x6ad/0x970 drivers/base/dd.c:588
> > > __driver_attach+0x28b/0x2f0 drivers/base/dd.c:822
> > > bus_for_each_dev+0x15d/0x1f0 drivers/base/bus.c:311
> > > driver_attach+0x3d/0x50 drivers/base/dd.c:841
> > > bus_add_driver+0x4b2/0x600 drivers/base/bus.c:667
> > > driver_register+0x1c8/0x320 drivers/base/driver.c:170
> > > register_virtio_driver+0x79/0xd0 drivers/virtio/virtio.c:296
> > > virtio_net_driver_init+0x8d/0xc9 drivers/net/virtio_net.c:3209
> > > do_one_initcall+0x127/0x913 init/main.c:884
> > > do_initcall_level init/main.c:952 [inline]
> > > do_initcalls init/main.c:960 [inline]
> > > do_basic_setup init/main.c:978 [inline]
> > > kernel_init_freeable+0x49b/0x58e init/main.c:1135
> > > kernel_init+0x11/0x1b3 init/main.c:1061
> > > ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
> > > vcan: Virtual CAN interface driver
> > > vxcan: Virtual CAN Tunnel driver
> > > slcan: serial line CAN interface driver
> > > slcan: 10 dynamic interface channels.
> > > CAN device driver interface
> > > enic: Cisco VIC Ethernet NIC Driver, ver 2.3.0.53
> > > e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
> > > e100: Copyright(c) 1999-2006 Intel Corporation
> > > e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
> > > e1000: Copyright (c) 1999-2006 Intel Corporation.
> > > e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
> > > e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
> > > sky2: driver version 1.30
> > > PPP generic driver version 2.4.2
> > > PPP BSD Compression module registered
> > > PPP Deflate Compression module registered
> > > PPP MPPE Compression module registered
> > > NET: Registered protocol family 24
> > > PPTP driver version 0.8.5
> > > mac80211_hwsim: initializing netlink
> > > ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
> > > ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'
> > > usbcore: registered new interface driver asix
> > > usbcore: registered new interface driver ax88179_178a
> > > usbcore: registered new interface driver cdc_ether
> > > usbcore: registered new interface driver net1080
> > > usbcore: registered new interface driver cdc_subset
> > > usbcore: registered new interface driver zaurus
> > > usbcore: registered new interface driver cdc_ncm
> > > aoe: AoE v85 initialised.
> > > ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
> > > ehci-pci: EHCI PCI platform driver
> > > ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
> > > ohci-pci: OHCI PCI platform driver
> > > uhci_hcd: USB Universal Host Controller Interface driver
> > > usbcore: registered new interface driver usblp
> > > usbcore: registered new interface driver usb-storage
> > > i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
> > > i8042: Warning: Keylock active
> > > serio: i8042 KBD port at 0x60,0x64 irq 1
> > > serio: i8042 AUX port at 0x60,0x64 irq 12
> > > mousedev: PS/2 mouse device common for all mice
> > > rtc_cmos 00:00: RTC can wake from S4
> > > rtc_cmos 00:00: registered as rtc0
> > > rtc_cmos 00:00: alarms up to one day, 114 bytes nvram
> > > i2c /dev entries driver
> > > piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or
> > > use force_addr=0xaddr
> > > i2c-parport-light: adapter type unspecified
> > > usbcore: registered new interface driver RobotFuzz Open Source InterFace,
> > > OSIF
> > > usbcore: registered new interface driver i2c-tiny-usb
> > > device-mapper: ioctl: 4.39.0-ioctl (2018-04-03) initialised:
> > > dm-devel@redhat.com
> > > device-mapper: raid: Loading target version 1.13.2
> > > usbcore: registered new interface driver btusb
> > > usnic_verbs: Cisco VIC (USNIC) Verbs Driver v1.0.3 (December 19, 2013)
> > > usnic_verbs:usnic_uiom_init:585:
> > > IOMMU required but not present or enabled. USNIC QPs will not function w/o
> > > enabling IOMMU
> > > usnic_verbs:usnic_ib_init:649:
> > > Unable to initalize umem with err -1
> > > iscsi: registered transport (iser)
> > > OPA Virtual Network Driver - v1.0
> > > hidraw: raw HID events driver (C) Jiri Kosina
> > > usbcore: registered new interface driver usbhid
> > > usbhid: USB HID core driver
> > > NET: Registered protocol family 40
> > > ashmem: initialized
> > > NET: Registered protocol family 26
> > > Mirror/redirect action on
> > > Simple TC action Loaded
> > > netem: version 1.3
> > > u32 classifier
> > > Actions configured
> > > nf_conntrack_irc: failed to register helpers
> > > nf_conntrack_sane: failed to register helpers
> > > nf_conntrack_sip: failed to register helpers
> > > xt_time: kernel timezone is -0000
> > > IPVS: Registered protocols (TCP, UDP, SCTP, AH, ESP)
> > > IPVS: Connection hash table configured (size=4096, memory=64Kbytes)
> > > IPVS: ipvs loaded.
> > > IPVS: [rr] scheduler registered.
> > > IPVS: [wrr] scheduler registered.
> > > IPVS: [lc] scheduler registered.
> > > IPVS: [wlc] scheduler registered.
> > > IPVS: [fo] scheduler registered.
> > > IPVS: [ovf] scheduler registered.
> > > IPVS: [lblc] scheduler registered.
> > > IPVS: [lblcr] scheduler registered.
> > > IPVS: [dh] scheduler registered.
> > > IPVS: [sh] scheduler registered.
> > > IPVS: [mh] scheduler registered.
> > > IPVS: [sed] scheduler registered.
> > > IPVS: [nq] scheduler registered.
> > > IPVS: ftp: loaded support on port[0] = 21
> > > IPVS: [sip] pe registered.
> > > ipip: IPv4 and MPLS over IPv4 tunneling driver
> > > gre: GRE over IPv4 demultiplexor driver
> > > ip_gre: GRE over IPv4 tunneling driver
> > > IPv4 over IPsec tunneling driver
> > > ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
> > > Initializing XFRM netlink socket
> > > NET: Registered protocol family 10
> > > Segment Routing with IPv6
> > > mip6: Mobile IPv6
> > > sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
> > > ip6_gre: GRE over IPv6 tunneling driver
> > > bpfilter: Loaded bpfilter_umh pid 2080
> > > NET: Registered protocol family 15
> > > Bridge firewalling registered
> > > can: controller area network core (rev 20170425 abi 9)
> > > NET: Registered protocol family 29
> > > can: raw protocol (rev 20170425)
> > > can: broadcast manager protocol (rev 20170425 t)
> > > can: netlink gateway (rev 20170425) max_hops=1
> > > Bluetooth: RFCOMM TTY layer initialized
> > > Bluetooth: RFCOMM socket layer initialized
> > > Bluetooth: RFCOMM ver 1.11
> > > Bluetooth: BNEP (Ethernet Emulation) ver 1.3
> > > Bluetooth: BNEP filters: protocol multicast
> > > Bluetooth: BNEP socket layer initialized
> > > Bluetooth: HIDP (Human Interface Emulation) ver 1.2
> > > Bluetooth: HIDP socket layer initialized
> > > RPC: Registered rdma transport module.
> > > RPC: Registered rdma backchannel transport module.
> > > NET: Registered protocol family 41
> > > lec:lane_module_init: lec.c: initialized
> > > mpoa:atm_mpoa_init: mpc.c: initialized
> > > l2tp_core: L2TP core driver, V2.0
> > > l2tp_ppp: PPPoL2TP kernel driver, V2.0
> > > 8021q: 802.1Q VLAN Support v1.8
> > > input: AT Translated Set 2 keyboard as
> > > /devices/platform/i8042/serio0/input/input2
> > > DCCP: Activated CCID 2 (TCP-like)
> > > DCCP: Activated CCID 3 (TCP-Friendly Rate Control)
> > > sctp: Hash tables configured (bind 64/64)
> > > tipc: Activated (version 2.0.0)
> > > NET: Registered protocol family 30
> > > tipc: Started in single node mode
> > > NET: Registered protocol family 43
> > > 9pnet: Installing 9P2000 support
> > > NET: Registered protocol family 36
> > > Key type dns_resolver registered
> > > Key type ceph registered
> > > libceph: loaded (mon/osd proto 15/24)
> > > openvswitch: Open vSwitch switching datapath
> > > mpls_gso: MPLS GSO support
> > > start plist test
> > > end plist test
> > > AVX2 version of gcm_enc/dec engaged.
> > > AES CTR mode by8 optimization enabled
> > > sched_clock: Marking stable (4559438359, 0)->(6126385605, -1566947246)
> > > registered taskstats version 1
> > > Loading compiled-in X.509 certificates
> > > zswap: default zpool zbud not available
> > > zswap: pool creation failed
> > > Btrfs loaded, crc32c=crc32c-intel
> > > Key type big_key registered
> > > Key type encrypted registered
> > > Magic number: 10:317:168
> > > console [netcon0] enabled
> > > netconsole: network logging started
> > > gtp: GTP module loaded (pdp ctx size 104 bytes)
> > > rdma_rxe: loaded
> > > cfg80211: Loading compiled-in X.509 certificates for regulatory database
> > > cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
> > > platform regulatory.0: Direct firmware load for regulatory.db failed with
> > > error -2
> > > cfg80211: failed to load regulatory.db
> > > ALSA device list:
> > > #0: Dummy 1
> > > #1: Loopback 1
> > > #2: Virtual MIDI Card 1
> > > input: ImExPS/2 Generic Explorer Mouse as
> > > /devices/platform/i8042/serio1/input/input4
> > > md: Waiting for all devices to be available before autodetect
> > > md: If you don't use raid, use raid=noautodetect
> > > md: Autodetecting RAID arrays.
> > > md: autorun ...
> > > md: ... autorun DONE.
> > > EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
> > > VFS: Mounted root (ext4 filesystem) readonly on device 8:1.
> > > devtmpfs: mounted
> > > Freeing unused kernel memory: 3900K
> > > Kernel memory protection disabled.
> > > SELinux: Disabled at runtime.
> > > SELinux: Unregistering netfilter hooks
> > > audit: type=1404 audit(1532588961.277:2): enforcing=0 old_enforcing=0
> > > auid=4294967295 ses=4294967295 enabled=0 old-enabled=1 lsm=selinux res=1
> > > stty (2166) used greatest stack depth: 19664 bytes left
> > > EXT4-fs (sda1): re-mounted. Opts: (null)
> > > logsave (3615) used greatest stack depth: 17632 bytes left
> > > random: dd: uninitialized urandom read (512 bytes read)
> > > ==================================================================
> > > BUG: KASAN: slab-out-of-bounds in virtnet_receive
> > > drivers/net/virtio_net.c:1356 [inline]
> >
> > +virtio maintainers for this one
> > Probably something very recent.
> >
> > > BUG: KASAN: slab-out-of-bounds in virtnet_poll+0x111a/0x1226
> > > drivers/net/virtio_net.c:1421
> > > Read of size 8 at addr ffff8801cee08ff0 by task ip/3969
> > >
> > > CPU: 0 PID: 3969 Comm: ip Not tainted 4.18.0-rc6+ #141
> > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > > Google 01/01/2011
> > > Call Trace:
> > > <IRQ>
> > > __dump_stack lib/dump_stack.c:77 [inline]
> > > dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
> > > print_address_description+0x6c/0x20b mm/kasan/report.c:256
> > > kasan_report_error mm/kasan/report.c:354 [inline]
> > > kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
> > > __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
> > > virtnet_receive drivers/net/virtio_net.c:1356 [inline]
> > > virtnet_poll+0x111a/0x1226 drivers/net/virtio_net.c:1421
> > > napi_poll net/core/dev.c:6214 [inline]
> > > net_rx_action+0x7a5/0x1920 net/core/dev.c:6280
> > > __do_softirq+0x2e8/0xb17 kernel/softirq.c:292
> > > do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1046
> > > </IRQ>
> > > do_softirq.part.18+0x155/0x1a0 kernel/softirq.c:336
> > > do_softirq arch/x86/include/asm/preempt.h:23 [inline]
> > > __local_bh_enable_ip+0x1ec/0x230 kernel/softirq.c:189
> > > local_bh_enable include/linux/bottom_half.h:32 [inline]
> > > virtnet_napi_enable+0x8c/0xb0 drivers/net/virtio_net.c:1264
> > > virtnet_open+0x16d/0x4d0 drivers/net/virtio_net.c:1464
> > > __dev_open+0x26d/0x410 net/core/dev.c:1392
> > > __dev_change_flags+0x739/0x9c0 net/core/dev.c:7434
> > > dev_change_flags+0x89/0x150 net/core/dev.c:7503
> > > do_setlink+0xb16/0x3dd0 net/core/rtnetlink.c:2416
> > > rtnl_newlink+0x138d/0x1d60 net/core/rtnetlink.c:3029
> > > rtnetlink_rcv_msg+0x46e/0xc30 net/core/rtnetlink.c:4705
> > > netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2447
> > > rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4723
> > > netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
> > > netlink_unicast+0x5a0/0x760 net/netlink/af_netlink.c:1336
> > > netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1901
> > > sock_sendmsg_nosec net/socket.c:641 [inline]
> > > sock_sendmsg+0xd5/0x120 net/socket.c:651
> > > ___sys_sendmsg+0x7fd/0x930 net/socket.c:2125
> > > __sys_sendmsg+0x11d/0x290 net/socket.c:2163
> > > __do_sys_sendmsg net/socket.c:2172 [inline]
> > > __se_sys_sendmsg net/socket.c:2170 [inline]
> > > __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2170
> > > do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> > > entry_SYSCALL_64_after_hwframe+0x49/0xbe
> > > RIP: 0033:0x7f318d594320
> > > Code: 02 48 83 c8 ff eb 8d 48 8b 05 14 7b 2a 00 f7 da 64 89 10 48 83 c8 ff
> > > eb c9 90 83 3d d5 d2 2a 00 00 75 10 b8 2e 00 00 00 0f 05 <48> 3d 01 f0 ff ff
> > > 73 31 c3 48 83 ec 08 e8 5e ba 00 00 48 89 04 24
> > > RSP: 002b:00007ffd985d8f38 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
> > > RAX: ffffffffffffffda RBX: 00007ffd985dd030 RCX: 00007f318d594320
> > > RDX: 0000000000000000 RSI: 00007ffd985d8f70 RDI: 0000000000000003
> > > RBP: 00007ffd985d8f70 R08: 0000000000000000 R09: 000000000000000f
> > > R10: 0000000000000000 R11: 0000000000000246 R12: 000000005b5973aa
> > > R13: 0000000000000000 R14: 00000000006395c0 R15: 00007ffd985dd808
> > >
> > > Allocated by task 1:
> > > save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> > > set_track mm/kasan/kasan.c:460 [inline]
> > > kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
> > > __do_kmalloc mm/slab.c:3718 [inline]
> > > __kmalloc+0x14e/0x760 mm/slab.c:3727
> > > kmalloc_array include/linux/slab.h:635 [inline]
> > > kcalloc include/linux/slab.h:646 [inline]
> > > virtnet_alloc_queues drivers/net/virtio_net.c:2731 [inline]
> > > init_vqs+0x127/0x1520 drivers/net/virtio_net.c:2769
> > > virtnet_probe+0x1092/0x2260 drivers/net/virtio_net.c:3016
> > > virtio_dev_probe+0x592/0x942 drivers/virtio/virtio.c:245
> > > really_probe drivers/base/dd.c:446 [inline]
> > > driver_probe_device+0x6ad/0x970 drivers/base/dd.c:588
> > > __driver_attach+0x28b/0x2f0 drivers/base/dd.c:822
> > > bus_for_each_dev+0x15d/0x1f0 drivers/base/bus.c:311
> > > driver_attach+0x3d/0x50 drivers/base/dd.c:841
> > > bus_add_driver+0x4b2/0x600 drivers/base/bus.c:667
> > > driver_register+0x1c8/0x320 drivers/base/driver.c:170
> > > register_virtio_driver+0x79/0xd0 drivers/virtio/virtio.c:296
> > > virtio_net_driver_init+0x8d/0xc9 drivers/net/virtio_net.c:3209
> > > do_one_initcall+0x127/0x913 init/main.c:884
> > > do_initcall_level init/main.c:952 [inline]
> > > do_initcalls init/main.c:960 [inline]
> > > do_basic_setup init/main.c:978 [inline]
> > > kernel_init_freeable+0x49b/0x58e init/main.c:1135
> > > kernel_init+0x11/0x1b3 init/main.c:1061
> > > ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
> > >
> > > Freed by task 0:
> > > (stack is not available)
> > >
> > > The buggy address belongs to the object at ffff8801cee08500
> > > which belongs to the cache kmalloc-4096 of size 4096
> > > The buggy address is located 2800 bytes inside of
> > > 4096-byte region [ffff8801cee08500, ffff8801cee09500)
> > > The buggy address belongs to the page:
> > > page:ffffea00073b8200 count:1 mapcount:0 mapping:ffff8801dac00dc0 index:0x0
> > > compound_mapcount: 0
> > > flags: 0x2fffc0000008100(slab|head)
> > > raw: 02fffc0000008100 ffffea00073b7d88 ffffea00073b8288 ffff8801dac00dc0
> > > raw: 0000000000000000 ffff8801cee08500 0000000100000001 0000000000000000
> > > page dumped because: kasan: bad access detected
> > >
> > > Memory state around the buggy address:
> > > ffff8801cee08e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> > > ffff8801cee08f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> > >>
> > >> ffff8801cee08f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> > >
> > > ^
> > > ffff8801cee09000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> > > ffff8801cee09080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> > > ==================================================================
> > >
> > >
> > > ---
> > > This bug is generated by a bot. It may contain errors.
> > > See https://goo.gl/tpsmEJ for more information about syzbot.
> > > syzbot engineers can be reached at syzkaller@googlegroups.com.
> > >
> > > syzbot will keep track of this bug report. See:
> > > https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
> > > syzbot.
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "syzkaller-bugs" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to syzkaller-bugs+unsubscribe@googlegroups.com.
> > > To view this discussion on the web visit
> > > https://groups.google.com/d/msgid/syzkaller-bugs/000000000000352dc20571e3a0d8%40google.com.
> > > For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply
* [PATCH net-next 8/8] selftests: mlxsw: Add test for trust-DSCP
From: Ido Schimmel @ 2018-07-27 12:27 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
Add a test that exercises the new code. Send DSCP-tagged packets, and
observe how they are prioritized in the switch and the DSCP is updated
on egress again.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../drivers/net/mlxsw/qos_dscp_bridge.sh | 248 ++++++++++++++++++
1 file changed, 248 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
new file mode 100755
index 000000000000..418319f19108
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
@@ -0,0 +1,248 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# Test for DSCP prioritization and rewrite. Packets ingress $swp1 with a DSCP
+# tag and are prioritized according to the map at $swp1. They egress $swp2 and
+# the DSCP value is updated to match the map at that interface. The updated DSCP
+# tag is verified at $h2.
+#
+# ICMP responses are produced with the same DSCP tag that arrived at $h2. They
+# go through prioritization at $swp2 and DSCP retagging at $swp1. The tag is
+# verified at $h1--it should match the original tag.
+#
+# +----------------------+ +----------------------+
+# | H1 | | H2 |
+# | + $h1 | | $h2 + |
+# | | 192.0.2.1/28 | | 192.0.2.2/28 | |
+# +----|-----------------+ +----------------|-----+
+# | |
+# +----|----------------------------------------------------------------|-----+
+# | SW | | |
+# | +-|----------------------------------------------------------------|-+ |
+# | | + $swp1 BR $swp2 + | |
+# | | APP=0,5,10 .. 7,5,17 APP=0,5,20 .. 7,5,27 | |
+# | +--------------------------------------------------------------------+ |
+# +---------------------------------------------------------------------------+
+
+ALL_TESTS="
+ ping_ipv4
+ test_dscp
+"
+
+lib_dir=$(dirname $0)/../../../net/forwarding
+
+NUM_NETIFS=4
+source $lib_dir/lib.sh
+
+__dscp_capture_add_del()
+{
+ local add_del=$1; shift
+ local dev=$1; shift
+ local base=$1; shift
+ local dscp;
+
+ for prio in {0..7}; do
+ dscp=$((base + prio))
+ __icmp_capture_add_del $add_del $dscp "" $dev \
+ "ip_tos $((dscp << 2))"
+ done
+}
+
+dscp_capture_install()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ __dscp_capture_add_del add $dev $base
+}
+
+dscp_capture_uninstall()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ __dscp_capture_add_del del $dev $base
+}
+
+h1_create()
+{
+ local dscp;
+
+ simple_if_init $h1 192.0.2.1/28
+ tc qdisc add dev $h1 clsact
+ dscp_capture_install $h1 10
+}
+
+h1_destroy()
+{
+ dscp_capture_uninstall $h1 10
+ tc qdisc del dev $h1 clsact
+ simple_if_fini $h1 192.0.2.1/28
+}
+
+h2_create()
+{
+ simple_if_init $h2 192.0.2.2/28
+ tc qdisc add dev $h2 clsact
+ dscp_capture_install $h2 20
+}
+
+h2_destroy()
+{
+ dscp_capture_uninstall $h2 20
+ tc qdisc del dev $h2 clsact
+ simple_if_fini $h2 192.0.2.2/28
+}
+
+dscp_map()
+{
+ local base=$1; shift
+
+ for prio in {0..7}; do
+ echo app=$prio,5,$((base + prio))
+ done
+}
+
+lldpad_wait()
+{
+ local dev=$1; shift
+
+ while lldptool -t -i $dev -V APP -c app | grep -q pending; do
+ echo "$dev: waiting for lldpad to push pending APP updates"
+ sleep 5
+ done
+}
+
+switch_create()
+{
+ ip link add name br1 type bridge vlan_filtering 1
+ ip link set dev br1 up
+ ip link set dev $swp1 master br1
+ ip link set dev $swp1 up
+ ip link set dev $swp2 master br1
+ ip link set dev $swp2 up
+
+ lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null
+ lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null
+ lldpad_wait $swp1
+ lldpad_wait $swp2
+}
+
+switch_destroy()
+{
+ lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null
+ lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null
+
+ # Give lldpad a chance to push down the changes. If the device is downed
+ # too soon, the updates will be left pending, but will have been struck
+ # off the lldpad's DB already, and we won't be able to tell. Then on
+ # next test iteration this would cause weirdness as newly-added APP
+ # rules conflict with the old ones, sometimes getting stuck in an
+ # "unknown" state.
+ sleep 5
+
+ ip link set dev $swp2 nomaster
+ ip link set dev $swp1 nomaster
+ ip link del dev br1
+}
+
+setup_prepare()
+{
+ h1=${NETIFS[p1]}
+ swp1=${NETIFS[p2]}
+
+ swp2=${NETIFS[p3]}
+ h2=${NETIFS[p4]}
+
+ vrf_prepare
+
+ h1_create
+ h2_create
+ switch_create
+}
+
+cleanup()
+{
+ pre_cleanup
+
+ switch_destroy
+ h2_destroy
+ h1_destroy
+
+ vrf_cleanup
+}
+
+dscp_fetch_stats()
+{
+ local dev=$1; shift
+ local base=$1; shift
+
+ for prio in {0..7}; do
+ local dscp=$((base + prio))
+ local t=$(tc_rule_stats_get $dev $dscp)
+ echo "[$dscp]=$t "
+ done
+}
+
+ping_ipv4()
+{
+ ping_test $h1 192.0.2.2
+}
+
+dscp_ping_test()
+{
+ local vrf_name=$1; shift
+ local sip=$1; shift
+ local dip=$1; shift
+ local prio=$1; shift
+ local dev_10=$1; shift
+ local dev_20=$1; shift
+
+ local dscp_10=$(((prio + 10) << 2))
+ local dscp_20=$(((prio + 20) << 2))
+
+ RET=0
+
+ local -A t0s
+ eval "t0s=($(dscp_fetch_stats $dev_10 10)
+ $(dscp_fetch_stats $dev_20 20))"
+
+ ip vrf exec $vrf_name \
+ ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \
+ -c 10 -i 0.1 -w 2 &> /dev/null
+
+ local -A t1s
+ eval "t1s=($(dscp_fetch_stats $dev_10 10)
+ $(dscp_fetch_stats $dev_20 20))"
+
+ for key in ${!t0s[@]}; do
+ local expect
+ if ((key == dscp_10 || key == dscp_20)); then
+ expect=10
+ else
+ expect=0
+ fi
+
+ local delta=$((t1s[key] - t0s[key]))
+ ((expect == delta))
+ check_err $? "DSCP $key: Expected to capture $expect packets, got $delta."
+ done
+
+ log_test "DSCP rewrite: $dscp_10-(prio $prio)-$dscp_20"
+}
+
+test_dscp()
+{
+ for prio in {0..7}; do
+ dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2
+ done
+}
+
+trap cleanup EXIT
+
+setup_prepare
+setup_wait
+
+tests_run
+
+exit $EXIT_STATUS
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 5/8] mlxsw: reg: Add QoS ReWrite Enable Register
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
This register configures the rewrite enable (whether PCP or DSCP value
in packet should be updated according to packet priority) per receive
port.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/reg.h | 39 +++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index c50e754dd725..02c0e1531ed2 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3367,6 +3367,44 @@ static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
mlxsw_reg_qeec_next_element_index_set(payload, next_index);
}
+/* QRWE - QoS ReWrite Enable
+ * -------------------------
+ * This register configures the rewrite enable per receive port.
+ */
+#define MLXSW_REG_QRWE_ID 0x400F
+#define MLXSW_REG_QRWE_LEN 0x08
+
+MLXSW_REG_DEFINE(qrwe, MLXSW_REG_QRWE_ID, MLXSW_REG_QRWE_LEN);
+
+/* reg_qrwe_local_port
+ * Local port number.
+ * Access: Index
+ *
+ * Note: CPU port is supported. No support for router port.
+ */
+MLXSW_ITEM32(reg, qrwe, local_port, 0x00, 16, 8);
+
+/* reg_qrwe_dscp
+ * Whether to enable DSCP rewrite (default is 0, don't rewrite).
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, qrwe, dscp, 0x04, 1, 1);
+
+/* reg_qrwe_pcp
+ * Whether to enable PCP and DEI rewrite (default is 0, don't rewrite).
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, qrwe, pcp, 0x04, 0, 1);
+
+static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
+ bool rewrite_pcp, bool rewrite_dscp)
+{
+ MLXSW_REG_ZERO(qrwe, payload);
+ mlxsw_reg_qrwe_local_port_set(payload, local_port);
+ mlxsw_reg_qrwe_pcp_set(payload, rewrite_pcp);
+ mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
+}
+
/* QPDPM - QoS Port DSCP to Priority Mapping Register
* --------------------------------------------------
* This register controls the mapping from DSCP field to
@@ -8632,6 +8670,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
MLXSW_REG(qpcr),
MLXSW_REG(qtct),
MLXSW_REG(qeec),
+ MLXSW_REG(qrwe),
MLXSW_REG(qpdpm),
MLXSW_REG(pmlp),
MLXSW_REG(pmtu),
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 7/8] mlxsw: spectrum: Support ieee_setapp, ieee_delapp
From: Ido Schimmel @ 2018-07-27 12:27 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
The APP TLVs are used for communicating priority-to-protocol ID maps for
a given netdevice. Support the following APP TLVs:
- DSCP (selector 5) to configure priority-to-DSCP code point maps. Use
these maps to configure packet priority on ingress, and DSCP code
point rewrite on egress.
- Default priority (selector 1, PID 0) to configure priority for the
DSCP code points that don't have one assigned by the DSCP selector. In
future this could also be used for assigning default port priority
when a packet arrives without DSCP tagging.
Besides setting up the maps themselves, also configure port trust level
and rewrite bits.
Port trust level determines whether, for a packet arriving through a
certain port, the priority should be determined based on PCP or DSCP
header fields. So far, mlxsw kept the device default of trust-PCP. Now,
as soon as the first DSCP APP TLV is configured, switch to trust-DSCP.
Only when all DSCP APP TLVs are removed, switch back to trust-PCP again.
Note that the default priority APP TLV doesn't impact the trust level
configuration.
Rewrite bits determine whether DSCP and PCP fields of egressing packets
should be updated according to switch priority. When port trust is
switched to DSCP, enable rewrite of DSCP field.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
.../net/ethernet/mellanox/mlxsw/spectrum.h | 4 +-
.../ethernet/mellanox/mlxsw/spectrum_dcb.c | 269 +++++++++++++++++-
2 files changed, 271 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index bc2704193666..13eca1a79d52 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -1,6 +1,6 @@
/*
* drivers/net/ethernet/mellanox/mlxsw/spectrum.h
- * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved.
* Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
* Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
* Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
@@ -54,6 +54,7 @@
#include "core.h"
#include "core_acl_flex_keys.h"
#include "core_acl_flex_actions.h"
+#include "reg.h"
#define MLXSW_SP_FID_8021D_MAX 1024
@@ -243,6 +244,7 @@ struct mlxsw_sp_port {
struct ieee_ets *ets;
struct ieee_maxrate *maxrate;
struct ieee_pfc *pfc;
+ enum mlxsw_reg_qpts_trust_state trust_state;
} dcb;
struct {
u8 module;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
index b6ed7f7c531e..c31aeb25ab5a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
@@ -1,6 +1,6 @@
/*
* drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
- * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved.
* Copyright (c) 2016 Ido Schimmel <idosch@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -255,6 +255,270 @@ static int mlxsw_sp_dcbnl_ieee_setets(struct net_device *dev,
return 0;
}
+static int mlxsw_sp_dcbnl_app_validate(struct net_device *dev,
+ struct dcb_app *app)
+{
+ int prio;
+
+ if (app->priority >= IEEE_8021QAZ_MAX_TCS) {
+ netdev_err(dev, "APP entry with priority value %u is invalid\n",
+ app->priority);
+ return -EINVAL;
+ }
+
+ switch (app->selector) {
+ case IEEE_8021QAZ_APP_SEL_DSCP:
+ if (app->protocol >= 64) {
+ netdev_err(dev, "DSCP APP entry with protocol value %u is invalid\n",
+ app->protocol);
+ return -EINVAL;
+ }
+
+ /* Warn about any DSCP APP entries with the same PID. */
+ prio = fls(dcb_ieee_getapp_mask(dev, app));
+ if (prio--) {
+ if (prio < app->priority)
+ netdev_warn(dev, "Choosing priority %d for DSCP %d in favor of previously-active value of %d\n",
+ app->priority, app->protocol, prio);
+ else if (prio > app->priority)
+ netdev_warn(dev, "Ignoring new priority %d for DSCP %d in favor of current value of %d\n",
+ app->priority, app->protocol, prio);
+ }
+ break;
+
+ case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
+ if (app->protocol) {
+ netdev_err(dev, "EtherType APP entries with protocol value != 0 not supported\n");
+ return -EINVAL;
+ }
+ break;
+
+ default:
+ netdev_err(dev, "APP entries with selector %u not supported\n",
+ app->selector);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static u8
+mlxsw_sp_port_dcb_app_default_prio(struct mlxsw_sp_port *mlxsw_sp_port)
+{
+ u8 prio_mask;
+
+ prio_mask = dcb_ieee_getapp_default_prio_mask(mlxsw_sp_port->dev);
+ if (prio_mask)
+ /* Take the highest configured priority. */
+ return fls(prio_mask) - 1;
+
+ return 0;
+}
+
+static void
+mlxsw_sp_port_dcb_app_dscp_prio_map(struct mlxsw_sp_port *mlxsw_sp_port,
+ u8 default_prio,
+ struct dcb_ieee_app_dscp_map *map)
+{
+ int i;
+
+ dcb_ieee_getapp_dscp_prio_mask_map(mlxsw_sp_port->dev, map);
+ for (i = 0; i < ARRAY_SIZE(map->map); ++i) {
+ if (map->map[i])
+ map->map[i] = fls(map->map[i]) - 1;
+ else
+ map->map[i] = default_prio;
+ }
+}
+
+static bool
+mlxsw_sp_port_dcb_app_prio_dscp_map(struct mlxsw_sp_port *mlxsw_sp_port,
+ struct dcb_ieee_app_prio_map *map)
+{
+ bool have_dscp = false;
+ int i;
+
+ dcb_ieee_getapp_prio_dscp_mask_map(mlxsw_sp_port->dev, map);
+ for (i = 0; i < ARRAY_SIZE(map->map); ++i) {
+ if (map->map[i]) {
+ map->map[i] = fls64(map->map[i]) - 1;
+ have_dscp = true;
+ }
+ }
+
+ return have_dscp;
+}
+
+static int
+mlxsw_sp_port_dcb_app_update_qpts(struct mlxsw_sp_port *mlxsw_sp_port,
+ enum mlxsw_reg_qpts_trust_state ts)
+{
+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+ char qpts_pl[MLXSW_REG_QPTS_LEN];
+
+ mlxsw_reg_qpts_pack(qpts_pl, mlxsw_sp_port->local_port, ts);
+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qpts), qpts_pl);
+}
+
+static int
+mlxsw_sp_port_dcb_app_update_qrwe(struct mlxsw_sp_port *mlxsw_sp_port,
+ bool rewrite_dscp)
+{
+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+ char qrwe_pl[MLXSW_REG_QRWE_LEN];
+
+ mlxsw_reg_qrwe_pack(qrwe_pl, mlxsw_sp_port->local_port,
+ false, rewrite_dscp);
+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qrwe), qrwe_pl);
+}
+
+static int
+mlxsw_sp_port_dcb_toggle_trust(struct mlxsw_sp_port *mlxsw_sp_port,
+ enum mlxsw_reg_qpts_trust_state ts)
+{
+ bool rewrite_dscp = ts == MLXSW_REG_QPTS_TRUST_STATE_DSCP;
+ int err;
+
+ if (mlxsw_sp_port->dcb.trust_state == ts)
+ return 0;
+
+ err = mlxsw_sp_port_dcb_app_update_qpts(mlxsw_sp_port, ts);
+ if (err)
+ return err;
+
+ err = mlxsw_sp_port_dcb_app_update_qrwe(mlxsw_sp_port, rewrite_dscp);
+ if (err)
+ goto err_update_qrwe;
+
+ mlxsw_sp_port->dcb.trust_state = ts;
+ return 0;
+
+err_update_qrwe:
+ mlxsw_sp_port_dcb_app_update_qpts(mlxsw_sp_port,
+ mlxsw_sp_port->dcb.trust_state);
+ return err;
+}
+
+static int
+mlxsw_sp_port_dcb_app_update_qpdpm(struct mlxsw_sp_port *mlxsw_sp_port,
+ struct dcb_ieee_app_dscp_map *map)
+{
+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+ char qpdpm_pl[MLXSW_REG_QPDPM_LEN];
+ short int i;
+
+ mlxsw_reg_qpdpm_pack(qpdpm_pl, mlxsw_sp_port->local_port);
+ for (i = 0; i < ARRAY_SIZE(map->map); ++i)
+ mlxsw_reg_qpdpm_dscp_pack(qpdpm_pl, i, map->map[i]);
+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qpdpm), qpdpm_pl);
+}
+
+static int
+mlxsw_sp_port_dcb_app_update_qpdsm(struct mlxsw_sp_port *mlxsw_sp_port,
+ struct dcb_ieee_app_prio_map *map)
+{
+ struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+ char qpdsm_pl[MLXSW_REG_QPDSM_LEN];
+ short int i;
+
+ mlxsw_reg_qpdsm_pack(qpdsm_pl, mlxsw_sp_port->local_port);
+ for (i = 0; i < ARRAY_SIZE(map->map); ++i)
+ mlxsw_reg_qpdsm_prio_pack(qpdsm_pl, i, map->map[i]);
+ return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(qpdsm), qpdsm_pl);
+}
+
+static int mlxsw_sp_port_dcb_app_update(struct mlxsw_sp_port *mlxsw_sp_port)
+{
+ struct dcb_ieee_app_prio_map prio_map;
+ struct dcb_ieee_app_dscp_map dscp_map;
+ u8 default_prio;
+ bool have_dscp;
+ int err;
+
+ default_prio = mlxsw_sp_port_dcb_app_default_prio(mlxsw_sp_port);
+ have_dscp = mlxsw_sp_port_dcb_app_prio_dscp_map(mlxsw_sp_port,
+ &prio_map);
+
+ if (!have_dscp) {
+ err = mlxsw_sp_port_dcb_toggle_trust(mlxsw_sp_port,
+ MLXSW_REG_QPTS_TRUST_STATE_PCP);
+ if (err)
+ netdev_err(mlxsw_sp_port->dev, "Couldn't switch to trust L2\n");
+ return err;
+ }
+
+ mlxsw_sp_port_dcb_app_dscp_prio_map(mlxsw_sp_port, default_prio,
+ &dscp_map);
+ err = mlxsw_sp_port_dcb_app_update_qpdpm(mlxsw_sp_port,
+ &dscp_map);
+ if (err) {
+ netdev_err(mlxsw_sp_port->dev, "Couldn't configure priority map\n");
+ return err;
+ }
+
+ err = mlxsw_sp_port_dcb_app_update_qpdsm(mlxsw_sp_port,
+ &prio_map);
+ if (err) {
+ netdev_err(mlxsw_sp_port->dev, "Couldn't configure DSCP rewrite map\n");
+ return err;
+ }
+
+ err = mlxsw_sp_port_dcb_toggle_trust(mlxsw_sp_port,
+ MLXSW_REG_QPTS_TRUST_STATE_DSCP);
+ if (err) {
+ /* A failure to set trust DSCP means that the QPDPM and QPDSM
+ * maps installed above are not in effect. And since we are here
+ * attempting to set trust DSCP, we couldn't have attempted to
+ * switch trust to PCP. Thus no cleanup is necessary.
+ */
+ netdev_err(mlxsw_sp_port->dev, "Couldn't switch to trust L3\n");
+ return err;
+ }
+
+ return 0;
+}
+
+static int mlxsw_sp_dcbnl_ieee_setapp(struct net_device *dev,
+ struct dcb_app *app)
+{
+ struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+ int err;
+
+ err = mlxsw_sp_dcbnl_app_validate(dev, app);
+ if (err)
+ return err;
+
+ err = dcb_ieee_setapp(dev, app);
+ if (err)
+ return err;
+
+ err = mlxsw_sp_port_dcb_app_update(mlxsw_sp_port);
+ if (err)
+ goto err_update;
+
+ return 0;
+
+err_update:
+ dcb_ieee_delapp(dev, app);
+ return err;
+}
+
+static int mlxsw_sp_dcbnl_ieee_delapp(struct net_device *dev,
+ struct dcb_app *app)
+{
+ struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
+ int err;
+
+ err = dcb_ieee_delapp(dev, app);
+ if (err)
+ return err;
+
+ err = mlxsw_sp_port_dcb_app_update(mlxsw_sp_port);
+ if (err)
+ netdev_err(dev, "Failed to update DCB APP configuration\n");
+ return 0;
+}
+
static int mlxsw_sp_dcbnl_ieee_getmaxrate(struct net_device *dev,
struct ieee_maxrate *maxrate)
{
@@ -394,6 +658,8 @@ static const struct dcbnl_rtnl_ops mlxsw_sp_dcbnl_ops = {
.ieee_setmaxrate = mlxsw_sp_dcbnl_ieee_setmaxrate,
.ieee_getpfc = mlxsw_sp_dcbnl_ieee_getpfc,
.ieee_setpfc = mlxsw_sp_dcbnl_ieee_setpfc,
+ .ieee_setapp = mlxsw_sp_dcbnl_ieee_setapp,
+ .ieee_delapp = mlxsw_sp_dcbnl_ieee_delapp,
.getdcbx = mlxsw_sp_dcbnl_getdcbx,
.setdcbx = mlxsw_sp_dcbnl_setdcbx,
@@ -467,6 +733,7 @@ int mlxsw_sp_port_dcb_init(struct mlxsw_sp_port *mlxsw_sp_port)
if (err)
goto err_port_pfc_init;
+ mlxsw_sp_port->dcb.trust_state = MLXSW_REG_QPTS_TRUST_STATE_PCP;
mlxsw_sp_port->dev->dcbnl_ops = &mlxsw_sp_dcbnl_ops;
return 0;
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 6/8] mlxsw: reg: Add QoS Priority to DSCP Mapping Register
From: Ido Schimmel @ 2018-07-27 12:27 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
This register controls mapping from Priority to DSCP for purposes of
rewrite. Note that rewrite happens as the packet is transmitted provided
that the DSCP rewrite bit is enabled for the packet.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/reg.h | 89 +++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 02c0e1531ed2..e52841627966 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3405,6 +3405,94 @@ static inline void mlxsw_reg_qrwe_pack(char *payload, u8 local_port,
mlxsw_reg_qrwe_dscp_set(payload, rewrite_dscp);
}
+/* QPDSM - QoS Priority to DSCP Mapping
+ * ------------------------------------
+ * QoS Priority to DSCP Mapping Register
+ */
+#define MLXSW_REG_QPDSM_ID 0x4011
+#define MLXSW_REG_QPDSM_BASE_LEN 0x04 /* base length, without records */
+#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN 0x4 /* record length */
+#define MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT 16
+#define MLXSW_REG_QPDSM_LEN (MLXSW_REG_QPDSM_BASE_LEN + \
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN * \
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_MAX_COUNT)
+
+MLXSW_REG_DEFINE(qpdsm, MLXSW_REG_QPDSM_ID, MLXSW_REG_QPDSM_LEN);
+
+/* reg_qpdsm_local_port
+ * Local Port. Supported for data packets from CPU port.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, qpdsm, local_port, 0x00, 16, 8);
+
+/* reg_qpdsm_prio_entry_color0_e
+ * Enable update of the entry for color 0 and a given port.
+ * Access: WO
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_e,
+ MLXSW_REG_QPDSM_BASE_LEN, 31, 1,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdsm_prio_entry_color0_dscp
+ * DSCP field in the outer label of the packet for color 0 and a given port.
+ * Reserved when e=0.
+ * Access: RW
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color0_dscp,
+ MLXSW_REG_QPDSM_BASE_LEN, 24, 6,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdsm_prio_entry_color1_e
+ * Enable update of the entry for color 1 and a given port.
+ * Access: WO
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_e,
+ MLXSW_REG_QPDSM_BASE_LEN, 23, 1,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdsm_prio_entry_color1_dscp
+ * DSCP field in the outer label of the packet for color 1 and a given port.
+ * Reserved when e=0.
+ * Access: RW
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color1_dscp,
+ MLXSW_REG_QPDSM_BASE_LEN, 16, 6,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdsm_prio_entry_color2_e
+ * Enable update of the entry for color 2 and a given port.
+ * Access: WO
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_e,
+ MLXSW_REG_QPDSM_BASE_LEN, 15, 1,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdsm_prio_entry_color2_dscp
+ * DSCP field in the outer label of the packet for color 2 and a given port.
+ * Reserved when e=0.
+ * Access: RW
+ */
+MLXSW_ITEM32_INDEXED(reg, qpdsm, prio_entry_color2_dscp,
+ MLXSW_REG_QPDSM_BASE_LEN, 8, 6,
+ MLXSW_REG_QPDSM_PRIO_ENTRY_REC_LEN, 0x00, false);
+
+static inline void mlxsw_reg_qpdsm_pack(char *payload, u8 local_port)
+{
+ MLXSW_REG_ZERO(qpdsm, payload);
+ mlxsw_reg_qpdsm_local_port_set(payload, local_port);
+}
+
+static inline void
+mlxsw_reg_qpdsm_prio_pack(char *payload, unsigned short prio, u8 dscp)
+{
+ mlxsw_reg_qpdsm_prio_entry_color0_e_set(payload, prio, 1);
+ mlxsw_reg_qpdsm_prio_entry_color0_dscp_set(payload, prio, dscp);
+ mlxsw_reg_qpdsm_prio_entry_color1_e_set(payload, prio, 1);
+ mlxsw_reg_qpdsm_prio_entry_color1_dscp_set(payload, prio, dscp);
+ mlxsw_reg_qpdsm_prio_entry_color2_e_set(payload, prio, 1);
+ mlxsw_reg_qpdsm_prio_entry_color2_dscp_set(payload, prio, dscp);
+}
+
/* QPDPM - QoS Port DSCP to Priority Mapping Register
* --------------------------------------------------
* This register controls the mapping from DSCP field to
@@ -8671,6 +8759,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
MLXSW_REG(qtct),
MLXSW_REG(qeec),
MLXSW_REG(qrwe),
+ MLXSW_REG(qpdsm),
MLXSW_REG(qpdpm),
MLXSW_REG(pmlp),
MLXSW_REG(pmtu),
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 3/8] mlxsw: reg: Add QoS Port DSCP to Priority Mapping Register
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
The QPDPM register controls the mapping from DSCP field to Switch
Priority for IP packets.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/reg.h | 52 +++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index fd2e3dd166d2..411d06b5aaae 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3329,6 +3329,57 @@ static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port,
mlxsw_reg_qeec_next_element_index_set(payload, next_index);
}
+/* QPDPM - QoS Port DSCP to Priority Mapping Register
+ * --------------------------------------------------
+ * This register controls the mapping from DSCP field to
+ * Switch Priority for IP packets.
+ */
+#define MLXSW_REG_QPDPM_ID 0x4013
+#define MLXSW_REG_QPDPM_BASE_LEN 0x4 /* base length, without records */
+#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN 0x2 /* record length */
+#define MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT 64
+#define MLXSW_REG_QPDPM_LEN (MLXSW_REG_QPDPM_BASE_LEN + \
+ MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN * \
+ MLXSW_REG_QPDPM_DSCP_ENTRY_REC_MAX_COUNT)
+
+MLXSW_REG_DEFINE(qpdpm, MLXSW_REG_QPDPM_ID, MLXSW_REG_QPDPM_LEN);
+
+/* reg_qpdpm_local_port
+ * Local Port. Supported for data packets from CPU port.
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, qpdpm, local_port, 0x00, 16, 8);
+
+/* reg_qpdpm_dscp_e
+ * Enable update of the specific entry. When cleared, the switch_prio and color
+ * fields are ignored and the previous switch_prio and color values are
+ * preserved.
+ * Access: WO
+ */
+MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_e, MLXSW_REG_QPDPM_BASE_LEN, 15, 1,
+ MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
+
+/* reg_qpdpm_dscp_prio
+ * The new Switch Priority value for the relevant DSCP value.
+ * Access: RW
+ */
+MLXSW_ITEM16_INDEXED(reg, qpdpm, dscp_entry_prio,
+ MLXSW_REG_QPDPM_BASE_LEN, 0, 4,
+ MLXSW_REG_QPDPM_DSCP_ENTRY_REC_LEN, 0x00, false);
+
+static inline void mlxsw_reg_qpdpm_pack(char *payload, u8 local_port)
+{
+ MLXSW_REG_ZERO(qpdpm, payload);
+ mlxsw_reg_qpdpm_local_port_set(payload, local_port);
+}
+
+static inline void
+mlxsw_reg_qpdpm_dscp_pack(char *payload, unsigned short dscp, u8 prio)
+{
+ mlxsw_reg_qpdpm_dscp_entry_e_set(payload, dscp, 1);
+ mlxsw_reg_qpdpm_dscp_entry_prio_set(payload, dscp, prio);
+}
+
/* PMLP - Ports Module to Local Port Register
* ------------------------------------------
* Configures the assignment of modules to local ports.
@@ -8542,6 +8593,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
MLXSW_REG(qpcr),
MLXSW_REG(qtct),
MLXSW_REG(qeec),
+ MLXSW_REG(qpdpm),
MLXSW_REG(pmlp),
MLXSW_REG(pmtu),
MLXSW_REG(ptys),
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 4/8] mlxsw: reg: Add QoS Priority Trust State Register
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
The QPTS register controls the port policy to calculate the switch
priority and packet color based on incoming packet fields.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/reg.h | 39 +++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 411d06b5aaae..c50e754dd725 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -3017,6 +3017,44 @@ static inline void mlxsw_reg_iedr_rec_pack(char *payload, int rec_index,
mlxsw_reg_iedr_rec_index_start_set(payload, rec_index, rec_index_start);
}
+/* QPTS - QoS Priority Trust State Register
+ * ----------------------------------------
+ * This register controls the port policy to calculate the switch priority and
+ * packet color based on incoming packet fields.
+ */
+#define MLXSW_REG_QPTS_ID 0x4002
+#define MLXSW_REG_QPTS_LEN 0x8
+
+MLXSW_REG_DEFINE(qpts, MLXSW_REG_QPTS_ID, MLXSW_REG_QPTS_LEN);
+
+/* reg_qpts_local_port
+ * Local port number.
+ * Access: Index
+ *
+ * Note: CPU port is supported.
+ */
+MLXSW_ITEM32(reg, qpts, local_port, 0x00, 16, 8);
+
+enum mlxsw_reg_qpts_trust_state {
+ MLXSW_REG_QPTS_TRUST_STATE_PCP = 1,
+ MLXSW_REG_QPTS_TRUST_STATE_DSCP = 2, /* For MPLS, trust EXP. */
+};
+
+/* reg_qpts_trust_state
+ * Trust state for a given port.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, qpts, trust_state, 0x04, 0, 3);
+
+static inline void mlxsw_reg_qpts_pack(char *payload, u8 local_port,
+ enum mlxsw_reg_qpts_trust_state ts)
+{
+ MLXSW_REG_ZERO(qpts, payload);
+
+ mlxsw_reg_qpts_local_port_set(payload, local_port);
+ mlxsw_reg_qpts_trust_state_set(payload, ts);
+}
+
/* QPCR - QoS Policer Configuration Register
* -----------------------------------------
* The QPCR register is used to create policers - that limit
@@ -8590,6 +8628,7 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
MLXSW_REG(percr),
MLXSW_REG(pererp),
MLXSW_REG(iedr),
+ MLXSW_REG(qpts),
MLXSW_REG(qpcr),
MLXSW_REG(qtct),
MLXSW_REG(qeec),
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 2/8] net: dcb: Add priority-to-DSCP map getters
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
On ingress, a network device such as a switch assigns to packets
priority based on various criteria. Common options include interpreting
PCP and DSCP fields according to user configuration. When a packet
egresses the switch, a reverse process may rewrite PCP and/or DSCP
values according to packet priority.
The following three functions support a) obtaining a DSCP-to-priority
map or vice versa, and b) finding default-priority entries in APP
database.
The DCB subsystem supports for APP entries a very generous M:N mapping
between priorities and protocol identifiers. Understandably,
several (say) DSCP values can map to the same priority. But this
asymmetry holds the other way around as well--one priority can map to
several DSCP values. For this reason, the following functions operate in
terms of bitmaps, with ones in positions that match some APP entry.
- dcb_ieee_getapp_dscp_prio_mask_map() to compute for a given netdevice
a map of DSCP-to-priority-mask, which gives for each DSCP value a
bitmap of priorities related to that DSCP value by APP, along the
lines of dcb_ieee_getapp_mask().
- dcb_ieee_getapp_prio_dscp_mask_map() similarly to compute for a given
netdevice a map from priorities to a bitmap of DSCPs.
- dcb_ieee_getapp_default_prio_mask() which finds all default-priority
rules for a given port in APP database, and returns a mask of
priorities allowed by these default-priority rules.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
include/net/dcbnl.h | 13 +++++++
net/dcb/dcbnl.c | 86 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 0e5e91be2d30..e22a8a3c089b 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -34,6 +34,19 @@ int dcb_ieee_setapp(struct net_device *, struct dcb_app *);
int dcb_ieee_delapp(struct net_device *, struct dcb_app *);
u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *);
+struct dcb_ieee_app_prio_map {
+ u64 map[IEEE_8021QAZ_MAX_TCS];
+};
+void dcb_ieee_getapp_prio_dscp_mask_map(const struct net_device *dev,
+ struct dcb_ieee_app_prio_map *p_map);
+
+struct dcb_ieee_app_dscp_map {
+ u8 map[64];
+};
+void dcb_ieee_getapp_dscp_prio_mask_map(const struct net_device *dev,
+ struct dcb_ieee_app_dscp_map *p_map);
+u8 dcb_ieee_getapp_default_prio_mask(const struct net_device *dev);
+
int dcbnl_ieee_notify(struct net_device *dev, int event, int cmd,
u32 seq, u32 pid);
int dcbnl_cee_notify(struct net_device *dev, int event, int cmd,
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 013fdb6fa07a..a556cd708885 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1958,6 +1958,92 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
}
EXPORT_SYMBOL(dcb_ieee_delapp);
+/**
+ * dcb_ieee_getapp_prio_dscp_mask_map - For a given device, find mapping from
+ * priorities to the DSCP values assigned to that priority. Initialize p_map
+ * such that each map element holds a bit mask of DSCP values configured for
+ * that priority by APP entries.
+ */
+void dcb_ieee_getapp_prio_dscp_mask_map(const struct net_device *dev,
+ struct dcb_ieee_app_prio_map *p_map)
+{
+ int ifindex = dev->ifindex;
+ struct dcb_app_type *itr;
+ u8 prio;
+
+ memset(p_map->map, 0, sizeof(p_map->map));
+
+ spin_lock_bh(&dcb_lock);
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->ifindex == ifindex &&
+ itr->app.selector == IEEE_8021QAZ_APP_SEL_DSCP &&
+ itr->app.protocol < 64 &&
+ itr->app.priority < IEEE_8021QAZ_MAX_TCS) {
+ prio = itr->app.priority;
+ p_map->map[prio] |= 1ULL << itr->app.protocol;
+ }
+ }
+ spin_unlock_bh(&dcb_lock);
+}
+EXPORT_SYMBOL(dcb_ieee_getapp_prio_dscp_mask_map);
+
+/**
+ * dcb_ieee_getapp_dscp_prio_mask_map - For a given device, find mapping from
+ * DSCP values to the priorities assigned to that DSCP value. Initialize p_map
+ * such that each map element holds a bit mask of priorities configured for a
+ * given DSCP value by APP entries.
+ */
+void
+dcb_ieee_getapp_dscp_prio_mask_map(const struct net_device *dev,
+ struct dcb_ieee_app_dscp_map *p_map)
+{
+ int ifindex = dev->ifindex;
+ struct dcb_app_type *itr;
+
+ memset(p_map->map, 0, sizeof(p_map->map));
+
+ spin_lock_bh(&dcb_lock);
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->ifindex == ifindex &&
+ itr->app.selector == IEEE_8021QAZ_APP_SEL_DSCP &&
+ itr->app.protocol < 64 &&
+ itr->app.priority < IEEE_8021QAZ_MAX_TCS)
+ p_map->map[itr->app.protocol] |= 1 << itr->app.priority;
+ }
+ spin_unlock_bh(&dcb_lock);
+}
+EXPORT_SYMBOL(dcb_ieee_getapp_dscp_prio_mask_map);
+
+/**
+ * Per 802.1Q-2014, the selector value of 1 is used for matching on Ethernet
+ * type, with valid PID values >= 1536. A special meaning is then assigned to
+ * protocol value of 0: "default priority. For use when priority is not
+ * otherwise specified".
+ *
+ * dcb_ieee_getapp_default_prio_mask - For a given device, find all APP entries
+ * of the form {$PRIO, ETHERTYPE, 0} and construct a bit mask of all default
+ * priorities set by these entries.
+ */
+u8 dcb_ieee_getapp_default_prio_mask(const struct net_device *dev)
+{
+ int ifindex = dev->ifindex;
+ struct dcb_app_type *itr;
+ u8 mask = 0;
+
+ spin_lock_bh(&dcb_lock);
+ list_for_each_entry(itr, &dcb_app_list, list) {
+ if (itr->ifindex == ifindex &&
+ itr->app.selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
+ itr->app.protocol == 0 &&
+ itr->app.priority < IEEE_8021QAZ_MAX_TCS)
+ mask |= 1 << itr->app.priority;
+ }
+ spin_unlock_bh(&dcb_lock);
+
+ return mask;
+}
+EXPORT_SYMBOL(dcb_ieee_getapp_default_prio_mask);
+
static int __init dcbnl_init(void)
{
INIT_LIST_HEAD(&dcb_app_list);
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 1/8] net: dcb: For wild-card lookups, use priority -1, not 0
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
In-Reply-To: <20180727122702.17995-1-idosch@mellanox.com>
From: Petr Machata <petrm@mellanox.com>
The function dcb_app_lookup walks the list of specified DCB APP entries,
looking for one that matches a given criteria: ifindex, selector,
protocol ID and optionally also priority. The "don't care" value for
priority is set to 0, because that priority has not been allowed under
CEE regime, which predates the IEEE standardization.
Under IEEE, 0 is a valid priority number. But because dcb_app_lookup
considers zero a wild card, attempts to add an APP entry with priority 0
fail when other entries exist for a given ifindex / selector / PID
triplet.
Fix by changing the wild-card value to -1.
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
net/dcb/dcbnl.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 2589a6b78aa1..013fdb6fa07a 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1786,7 +1786,7 @@ static struct dcb_app_type *dcb_app_lookup(const struct dcb_app *app,
if (itr->app.selector == app->selector &&
itr->app.protocol == app->protocol &&
itr->ifindex == ifindex &&
- (!prio || itr->app.priority == prio))
+ ((prio == -1) || itr->app.priority == prio))
return itr;
}
@@ -1821,7 +1821,8 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
u8 prio = 0;
spin_lock_bh(&dcb_lock);
- if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
+ itr = dcb_app_lookup(app, dev->ifindex, -1);
+ if (itr)
prio = itr->app.priority;
spin_unlock_bh(&dcb_lock);
@@ -1849,7 +1850,8 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
spin_lock_bh(&dcb_lock);
/* Search for existing match and replace */
- if ((itr = dcb_app_lookup(new, dev->ifindex, 0))) {
+ itr = dcb_app_lookup(new, dev->ifindex, -1);
+ if (itr) {
if (new->priority)
itr->app.priority = new->priority;
else {
@@ -1882,7 +1884,8 @@ u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
u8 prio = 0;
spin_lock_bh(&dcb_lock);
- if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
+ itr = dcb_app_lookup(app, dev->ifindex, -1);
+ if (itr)
prio |= 1 << itr->app.priority;
spin_unlock_bh(&dcb_lock);
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 0/8] mlxsw: Support DSCP prioritization and rewrite
From: Ido Schimmel @ 2018-07-27 12:26 UTC (permalink / raw)
To: netdev; +Cc: davem, jiri, petrm, mlxsw, john.fastabend, Ido Schimmel
Petr says:
On ingress, a network device such as a switch assigns to packets
priority based on various criteria. Common options include interpreting
PCP and DSCP fields according to user configuration. When a packet
egresses the switch, a reverse process may rewrite PCP and/or DSCP
headers according to packet priority.
So far, mlxsw has supported prioritization based on PCP (802.1p priority
tag). This patch set introduces support for prioritization based on
DSCP, and DSCP rewrite.
To configure the DSCP-to-priority maps, the user is expected to invoke
ieee_setapp and ieee_delapp DCBNL ops, e.g. by using lldptool:
# lldptool -T -i sw1p6 -V APP app=3,5,24 # (priority 3, DSCP, 24)
To decide whether or not to pay attention to DSCP values, the Spectrum
switch recognize a per-port configuration of trust level. Until the
first APP rule is added for a given port, this port's trust level stays
at PCP, meaning that PCP is used for packet prioritization. With the
first DSCP APP rule, the port is configured to trust DSCP instead, and
it stays there until all DSCP APP rules are removed again.
Besides the DSCP (value 5) selector, another selector that plays into
packet prioritization is Ethernet type (value 1) with PID of 0. Such APP
entries denote default priority[1]:
# lldptool -T -i sw1p6 -V APP app=3,1,0 # (default priority 3)
With this patch set, mlxsw uses these values to configure priority for
DSCP values not explicitly specified in DSCP APP map. In the future we
expect to also use this to configure default port priority for untagged
packets.
Access to DSCP-to-priority map, priority-to-DSCP map, and default
priority for a port is exposed through three new DCB helpers. Like the
already-existing dcb_ieee_getapp_mask() helper, these helpers operate in
terms of bitmaps, to support the arbitrary M:N mapping that the APP
rules allow. Such interface presents all the relevant information from
the APP database without necessitating exposition of iterators, locking
or other complex primitives. It is up to the driver to then digest the
mapping in a way that the device supports. In this patch set, mlxsw
resolves conflicts by favoring higher-numbered DSCP values and
priorities.
In this patchset:
- Patch #1 fixes a bug in DCB APP database management.
- Patch #2 adds the getters described above.
- Patches #3-#6 add Spectrum configuration registers.
- Patch #7 adds the mlxsw logic that configures the device according to
APP rules.
- Patch #8 adds a self-test. The test is added to the subdirectory
drivers/net/mlxsw. Even though it's not particularly specific to
mlxsw, it's not suitable for running on soft devices (which don't
support the ieee_getapp et.al.), and thus isn't a good fit for the
general net/forwarding directory.
[1] 802.1Q-2014, Table D-9
Petr Machata (8):
net: dcb: For wild-card lookups, use priority -1, not 0
net: dcb: Add priority-to-DSCP map getters
mlxsw: reg: Add QoS Port DSCP to Priority Mapping Register
mlxsw: reg: Add QoS Priority Trust State Register
mlxsw: reg: Add QoS ReWrite Enable Register
mlxsw: reg: Add QoS Priority to DSCP Mapping Register
mlxsw: spectrum: Support ieee_setapp, ieee_delapp
selftests: mlxsw: Add test for trust-DSCP
drivers/net/ethernet/mellanox/mlxsw/reg.h | 219 ++++++++++++++
.../net/ethernet/mellanox/mlxsw/spectrum.h | 4 +-
.../ethernet/mellanox/mlxsw/spectrum_dcb.c | 269 +++++++++++++++++-
include/net/dcbnl.h | 13 +
net/dcb/dcbnl.c | 97 ++++++-
.../drivers/net/mlxsw/qos_dscp_bridge.sh | 248 ++++++++++++++++
6 files changed, 844 insertions(+), 6 deletions(-)
create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh
--
2.17.1
^ permalink raw reply
* Re: [PATCH 06/18] netlink: Do not subscribe to non-existent groups
From: Dmitry Safonov @ 2018-07-27 13:43 UTC (permalink / raw)
To: David Miller; +Cc: linux-kernel, herbert, steffen.klassert, 0x7f454c46, netdev
In-Reply-To: <20180725.212258.182134114222639499.davem@davemloft.net>
On Wed, 2018-07-25 at 21:22 -0700, David Miller wrote:
> From: Dmitry Safonov <dima@arista.com>
> Date: Thu, 26 Jul 2018 03:31:32 +0100
>
> > Make ABI more strict about subscribing to group > ngroups.
> > Code doesn't check for that and it looks bogus.
> > (one can subscribe to non-existing group)
> > Still, it's possible to bind() to all possible groups with (-1)
> >
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Herbert Xu <herbert@gondor.apana.org.au>
> > Cc: Steffen Klassert <steffen.klassert@secunet.com>
> > Cc: netdev@vger.kernel.org
> > Signed-off-by: Dmitry Safonov <dima@arista.com>
>
> This really has nothing to do with adding a compat layer for xfrm,
> and is a bug fix that should be submitted separately in it's own
> right.
Sure, will do.
--
Thanks,
Dmitry
^ permalink raw reply
* RE: [PATCH] net: phy: use generic clause 45 autonegotiation done
From: Camelia Alexandra Groza @ 2018-07-27 13:41 UTC (permalink / raw)
To: andrew@lunn.ch, f.fainelli@gmail.com, rmk+kernel@armlinux.org.uk,
davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Camelia Alexandra Groza
In-Reply-To: <1531919535-20269-1-git-send-email-camelia.groza@nxp.com>
> -----Original Message-----
> From: Camelia Groza [mailto:camelia.groza@nxp.com]
> Sent: Wednesday, July 18, 2018 16:12
> To: andrew@lunn.ch; f.fainelli@gmail.com; davem@davemloft.net
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Camelia
> Alexandra Groza <camelia.groza@nxp.com>
> Subject: [PATCH] net: phy: use generic clause 45 autonegotiation done
>
> Only Clause 22 PHYs can use genphy_aneg_done(). Use
> genphy_c45_aneg_done() for PHYs that implement Clause 45 without the
> Clause 22 register set.
>
> This change follows the model of phy_restart_aneg() which differentiates
> between the two implementations in a similar way.
>
> Fixes: 41408ad519f7 ("net: phy: avoid genphy_aneg_done() for PHYs without
> clause 22 support")
> Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
> ---
> drivers/net/phy/phy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index
> 537297d..4fcc703 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -151,7 +151,7 @@ int phy_aneg_done(struct phy_device *phydev)
> * implement Clause 22 registers
> */
> if (phydev->is_c45 && !(phydev->c45_ids.devices_in_package &
> BIT(0)))
> - return -EINVAL;
> + return genphy_c45_aneg_done(phydev);
>
> return genphy_aneg_done(phydev);
> }
> --
> 1.9.1
Hi
A reminder for the original patch above. Since I sent the second patch for phy_config_aneg() against a different tree [1], I didn't see the need to resubmit this patch. If you need me to resubmit it, please let me know.
[1] https://patchwork.ozlabs.org/patch/947831/
Thank you,
Camelia
^ 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