* Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk
From: Paolo Abeni @ 2018-07-06 8:59 UTC (permalink / raw)
To: NeilBrown, Thomas Graf, Herbert Xu, Tom Herbert; +Cc: netdev, linux-kernel
In-Reply-To: <153086109256.2825.15329014177598382684.stgit@noble>
On Fri, 2018-07-06 at 17:11 +1000, NeilBrown wrote:
> If the sequence:
> obj = rhashtable_walk_next(iter);
> rhashtable_walk_stop(iter);
> rhashtable_remove_fast(ht, &obj->head, params);
> rhashtable_walk_start(iter);
>
> races with another thread inserting or removing
> an object on the same hash chain, a subsequent
> rhashtable_walk_next() is not guaranteed to get the "next"
> object. It is possible that an object could be
> repeated, or missed.
The above scenario is very similar to the one I'm running:
rhashtable_walk_next(iter);
rhashtable_walk_stop(iter);
// rhashtable change not yet identified, could be either
// remove, insert or even rehash
rhashtable_walk_start(iter);
rhashtable_walk_next(iter);
but I'm seeing use-after-free there. I'll try this patch to see if
solves my issue.
Note: the code under test is a pending new patch I'm holding due to the
above issue, I can send it as RFC to share the code if you think it may
help.
> @@ -867,15 +866,39 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter)
> bool rhlist = ht->rhlist;
>
> if (p) {
> - if (!rhlist || !(list = rcu_dereference(list->next))) {
> - p = rcu_dereference(p->next);
> - list = container_of(p, struct rhlist_head, rhead);
> - }
> - if (!rht_is_a_nulls(p)) {
> - iter->skip++;
> - iter->p = p;
> - iter->list = list;
> - return rht_obj(ht, rhlist ? &list->rhead : p);
> + if (!rhlist && iter->p_is_unsafe) {
> + /*
> + * First time next() was called after start().
> + * Need to find location of 'p' in the list.
> + */
> + struct rhash_head *p;
> +
> + iter->skip = 0;
> + rht_for_each_rcu(p, iter->walker.tbl, iter->slot) {
> + iter->skip++;
> + if (p <= iter->p)
> + continue;
Out of sheer ignorance, I really don't understand the goal of the above
conditional ?!?
Should it possibly be something like:
if (p != iter->p->next)
instead?
But I think we can't safely dereference 'p' yet ?!?
I'm sorry for the possibly dumb comments, rhashtable internals are
somewhat obscure to me, but I'm really interested in this topic.
Cheers,
Paolo
^ permalink raw reply
* Re: [PATCH v2 net-next 1/3] rds: Changing IP address internal representation to struct in6_addr
From: Ka-Cheong Poon @ 2018-07-06 9:08 UTC (permalink / raw)
To: Santosh Shilimkar, netdev; +Cc: davem, rds-devel
In-Reply-To: <c5d7497c-2761-8941-19df-dcae087d10ce@oracle.com>
On 07/06/2018 01:58 AM, Santosh Shilimkar wrote:
>> --- a/net/rds/bind.c
>> +++ b/net/rds/bind.c
>> @@ -42,42 +43,58 @@
>> static const struct rhashtable_params ht_parms = {
>> .nelem_hint = 768,
>> - .key_len = sizeof(u64),
>> + .key_len = RDS_BOUND_KEY_LEN,
> Do we really need the scope id to be part of the key ? With link
> local/global, do you see any collisions. Please educate me
> on the actual usecase. This can avoid bunch of changes and hence
> the question.
Yes, because link local address is not unique. The
same address can be in two different links. The scope
ID is used to differentiate that.
>
>> @@ -114,7 +132,7 @@ static int rds_add_bound(struct rds_sock *rs,
>> __be32 addr, __be16 *port)
>> rs, &addr, (int)ntohs(*port));
>> break;
>> } else {
>> - rs->rs_bound_addr = 0;
>> + rs->rs_bound_addr = in6addr_any;
> Can you elaborate why 0 is not ok ?
The type of rs_bound_addr is struct in6_addr. So 0
cannot be used.
>> int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
>> {
>> struct sock *sk = sock->sk;
>> - struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
>> struct rds_sock *rs = rds_sk_to_rs(sk);
>> + struct in6_addr v6addr, *binding_addr;
>> struct rds_transport *trans;
>> + __u32 scope_id = 0;
>> int ret = 0;
>> + __be16 port;
>> + /* We only allow an RDS socket to be bound to and IPv4 address. IPv6
> s/'bound to and IPv4'/'bound to an IPv4'
Changed. But this comment will be removed in patch #2
anyway.
>> + * address support will be added later.
>> + */
>> + if (addr_len == sizeof(struct sockaddr_in)) {
>> + struct sockaddr_in *sin = (struct sockaddr_in *)uaddr;
>> +
>> + if (sin->sin_family != AF_INET ||
>> + sin->sin_addr.s_addr == htonl(INADDR_ANY))
>> + return -EINVAL;
>> + ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &v6addr);
>> + binding_addr = &v6addr;
>> + port = sin->sin_port;
>> + } else if (addr_len == sizeof(struct sockaddr_in6)) {
>> + return -EPROTONOSUPPORT;
>> + } else {
>> + return -EINVAL;
>> + }
>> lock_sock(sk);
>> - if (addr_len != sizeof(struct sockaddr_in) ||
>> - sin->sin_family != AF_INET ||
>> - rs->rs_bound_addr ||
>> - sin->sin_addr.s_addr == htonl(INADDR_ANY)) {
>> + /* RDS socket does not allow re-binding. */
>> + if (!ipv6_addr_any(&rs->rs_bound_addr)) {
>> ret = -EINVAL;
>> goto out;
>> }
> Seems new behavior you are adding. The statement itself is
> true but if we return silently for already bind address, its
> ok. May be am missing something above.
This is the existing behavior. The old code checks if
rs_bound_addr is non-zero or not. If it is non-zero,
it returns an error.
>> diff --git a/net/rds/connection.c b/net/rds/connection.c
>> index abef75d..ca72563 100644
>> --- a/net/rds/connection.c
>> +++ b/net/rds/connection.c
>
>> @@ -142,9 +151,12 @@ static void __rds_conn_path_init(struct
>> rds_connection *conn,
>> * are torn down as the module is removed, if ever.
>> */
>> static struct rds_connection *__rds_conn_create(struct net *net,
>> - __be32 laddr, __be32 faddr,
>> - struct rds_transport *trans, gfp_t gfp,
>> - int is_outgoing)
>> + const struct in6_addr *laddr,
>> + const struct in6_addr *faddr,
>> + struct rds_transport *trans,
>> + gfp_t gfp,
>> + int is_outgoing,
>> + int dev_if)
> Am just wondering if we can handle local link address case differently
> instead of pushing the interface index everywhere. Did you think about
> any alternative. This can also avoid bunch of changes again and hence
> the question. Am trying to see if we can minimize the changes to
> absolute must have to support IPv6.
If link local address is supported, scoped ID must be used.
Unless we remove the support of link local address, we need
to keep scope ID.
>> diff --git a/net/rds/ib.h b/net/rds/ib.h
>> index a6f4d7d..12f96b3 100644
>> --- a/net/rds/ib.h
>> +++ b/net/rds/ib.h
>> +union rds_ib_conn_priv {
>> + struct rds_ib_connect_private ricp_v4;
>> + struct rds6_ib_connect_private ricp_v6;
>> };
> This change was invetiable. Just add a comment saying the priviate
> data size for v6 vs v4 is different. Also for IPv6 priviate data,
> I suggest add some resrve fields for any future extensions so
> that things can be added without breaking wire protocol. With IPv4,
> we ended up in bit of mess.
Will add some comments. Unfortunately the IB private data
exchange has only a limited space. I don't think there is
any more space left for reserved field. I think we should
think of a different way to handle extensions in future.
>> --- a/net/rds/ib_cm.c
>> +++ b/net/rds/ib_cm.c
>> @@ -1,5 +1,5 @@
>> /*
>> - * Copyright (c) 2006 Oracle. All rights reserved.
>> + * Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights
>> reserved.
>> *
>> * This software is available to you under a choice of one of two
>> * licenses. You may choose to be licensed under the terms of the GNU
>> @@ -35,10 +35,12 @@
>> #include <linux/slab.h>
>> #include <linux/vmalloc.h>
>> #include <linux/ratelimit.h>
>> +#include <net/addrconf.h>
>> #include "rds_single_path.h"
>> #include "rds.h"
>> #include "ib.h"
>> +#include "tcp.h"
>>
> Hmm. Why do you need to include tcp header in ib transport
> code ? If there is any common function just move to core
> common file and use it.
I think it can be removed as it is left over from earlier
changes when the IB IPv6 listener port was RDS_TCP_PORT.
Now all the port definitions are in rds.h.
>> diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c
>> index fc59821..aef73e7 100644
>> --- a/net/rds/rdma_transport.c
>> +++ b/net/rds/rdma_transport.c
>
>> +/* Initialize the RDS RDMA listeners. We create two listeners for
>> + * compatibility reason. The one on RDS_PORT is used for IPv4
>> + * requests only. The one on RDS_TCP_PORT is used for IPv6 requests
>> + * only. So only IPv6 enabled RDS module will communicate using this
>> + * port.
>> + */
> You did above ti facilitate both v4 and v6 connections to co-exist
> together ? Even though potentially there is no practical usecase,
> its nice to have this possibility.
Yes, as there is no way to differentiate the IB private
data exchange. So another port is used for IPv6 IB private
exchange. Doing this allow both IPv4 and IPv6 connections
to coexist.
>> diff --git a/net/rds/send.c b/net/rds/send.c
>> index 94c7f74..6ed2e92 100644
>> --- a/net/rds/send.c
>> +++ b/net/rds/send.c
>> @@ -1081,27 +1085,59 @@ int rds_sendmsg(struct socket *sock, struct
>> msghdr *msg, size_t payload_len)
>> goto out;
>> }
>> - if (msg->msg_namelen) {
>> - /* XXX fail non-unicast destination IPs? */
>> - if (msg->msg_namelen < sizeof(*usin) || usin->sin_family !=
>> AF_INET) {
>> + namelen = msg->msg_namelen;
>> + if (namelen != 0) {
>> + if (namelen < sizeof(*usin)) {
>> + ret = -EINVAL;
>> + goto out;
>> + }
>> + switch (namelen) {
>> + case sizeof(*usin):
>> + if (usin->sin_family != AF_INET ||
>> + usin->sin_addr.s_addr == htonl(INADDR_ANY) ||
>> + usin->sin_addr.s_addr == htonl(INADDR_BROADCAST) ||
>> + IN_MULTICAST(ntohl(usin->sin_addr.s_addr))) {
>> + ret = -EINVAL;
> The idea was to fail non-unicast IP someday but can you not add this
> change as part of v6 series. We can look at it later unless you need
> this change for v6. Again the question is mainly to add only necessary
> check and leave the existing behavior as is so please re-check all below
> checks too.
This is to match the same IPv6 check. In IPv6 code, it checks
if the address is a unicast address. I can remove the IPv4
checks but if an app does send to a multicast address, the
connection will be stuck forever.
>> diff --git a/net/rds/transport.c b/net/rds/transport.c
>> index 0b188dd..c9788db 100644
>> --- a/net/rds/transport.c
>> +++ b/net/rds/transport.c
>
>> + if (ipv6_addr_v4mapped(addr)) {
>
> Dave already commented on ipv6_addr_v4mapped(). Apart from
> some of those comments questions, rest of the patch looks
> really good and nicely done. Will also look at your
> subsequent two patches and try to send you comments in next
> few days.
Do you mean using mapped address to create IPv4 connections?
I already have it in my work space. Will be in v3.
--
K. Poon
ka-cheong.poon@oracle.com
^ permalink raw reply
* Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk
From: kbuild test robot @ 2018-07-06 9:25 UTC (permalink / raw)
To: NeilBrown
Cc: kbuild-all, Thomas Graf, Herbert Xu, Tom Herbert, netdev,
linux-kernel
In-Reply-To: <153086109256.2825.15329014177598382684.stgit@noble>
[-- Attachment #1: Type: text/plain, Size: 4475 bytes --]
Hi NeilBrown,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[also build test ERROR on next-20180706]
[cannot apply to linus/master linux-sof-driver/master v4.18-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/NeilBrown/rhashtable-replace-rhashtable_walk_peek-implementation/20180706-153705
config: i386-randconfig-a0-07060846 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
In file included from net/core/xdp.c:10:0:
include/linux/rhashtable.h: In function '__rhashtable_insert_fast':
>> include/linux/rhashtable.h:624:6: error: 'headp' undeclared (first use in this function)
headp = &head->next;
^
include/linux/rhashtable.h:624:6: note: each undeclared identifier is reported only once for each function it appears in
vim +/headp +624 include/linux/rhashtable.h
570
571 /* Internal function, please use rhashtable_insert_fast() instead. This
572 * function returns the existing element already in hashes in there is a clash,
573 * otherwise it returns an error via ERR_PTR().
574 */
575 static inline void *__rhashtable_insert_fast(
576 struct rhashtable *ht, const void *key, struct rhash_head *obj,
577 const struct rhashtable_params params, bool rhlist)
578 {
579 struct rhashtable_compare_arg arg = {
580 .ht = ht,
581 .key = key,
582 };
583 struct rhash_head __rcu **pprev;
584 struct bucket_table *tbl;
585 struct rhash_head *head;
586 spinlock_t *lock;
587 unsigned int hash;
588 int elasticity;
589 void *data;
590
591 rcu_read_lock();
592
593 tbl = rht_dereference_rcu(ht->tbl, ht);
594 hash = rht_head_hashfn(ht, tbl, obj, params);
595 lock = rht_bucket_lock(tbl, hash);
596 spin_lock_bh(lock);
597
598 if (unlikely(rcu_access_pointer(tbl->future_tbl))) {
599 slow_path:
600 spin_unlock_bh(lock);
601 rcu_read_unlock();
602 return rhashtable_insert_slow(ht, key, obj);
603 }
604
605 elasticity = RHT_ELASTICITY;
606 pprev = rht_bucket_insert(ht, tbl, hash);
607 data = ERR_PTR(-ENOMEM);
608 if (!pprev)
609 goto out;
610
611 rht_for_each_continue(head, *pprev, tbl, hash) {
612 struct rhlist_head *plist;
613 struct rhlist_head *list;
614
615 elasticity--;
616 if (!key ||
617 (params.obj_cmpfn ?
618 params.obj_cmpfn(&arg, rht_obj(ht, head)) :
619 rhashtable_compare(&arg, rht_obj(ht, head)))) {
620 if (rhlist) {
621 pprev = &head->next;
622 } else {
623 if (head < obj)
> 624 headp = &head->next;
625 }
626 continue;
627 }
628
629 data = rht_obj(ht, head);
630
631 if (!rhlist)
632 goto out;
633
634
635 list = container_of(obj, struct rhlist_head, rhead);
636 plist = container_of(head, struct rhlist_head, rhead);
637
638 RCU_INIT_POINTER(list->next, plist);
639 head = rht_dereference_bucket(head->next, tbl, hash);
640 RCU_INIT_POINTER(list->rhead.next, head);
641 rcu_assign_pointer(*pprev, obj);
642
643 goto good;
644 }
645
646 if (elasticity <= 0)
647 goto slow_path;
648
649 data = ERR_PTR(-E2BIG);
650 if (unlikely(rht_grow_above_max(ht, tbl)))
651 goto out;
652
653 if (unlikely(rht_grow_above_100(ht, tbl)))
654 goto slow_path;
655
656 head = rht_dereference_bucket(*pprev, tbl, hash);
657
658 RCU_INIT_POINTER(obj->next, head);
659 if (rhlist) {
660 struct rhlist_head *list;
661
662 list = container_of(obj, struct rhlist_head, rhead);
663 RCU_INIT_POINTER(list->next, NULL);
664 }
665
666 rcu_assign_pointer(*pprev, obj);
667
668 atomic_inc(&ht->nelems);
669 if (rht_grow_above_75(ht, tbl))
670 schedule_work(&ht->run_work);
671
672 good:
673 data = NULL;
674
675 out:
676 spin_unlock_bh(lock);
677 rcu_read_unlock();
678
679 return data;
680 }
681
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27167 bytes --]
^ permalink raw reply
* Re: [PATCH v2 bpf-next 03/14] bpf: pass a pointer to a cgroup storage using pcpu variable
From: kbuild test robot @ 2018-07-06 9:25 UTC (permalink / raw)
To: Roman Gushchin
Cc: kbuild-all, netdev, linux-kernel, kernel-team, tj, Roman Gushchin,
Alexei Starovoitov, Daniel Borkmann
In-Reply-To: <20180705205139.3462-4-guro@fb.com>
[-- Attachment #1: Type: text/plain, Size: 23155 bytes --]
Hi Roman,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Roman-Gushchin/bpf-cgroup-local-storage/20180706-055938
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: um-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=um
All error/warnings (new ones prefixed by >>):
In file included from include/linux/bpf-cgroup.h:6:0,
from kernel/bpf/local_storage.c:2:
>> include/linux/percpu-defs.h:49:34: error: 'PER_CPU_BASE_SECTION' undeclared here (not in a function); did you mean 'PER_CPU_FIRST_SECTION'?
__percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
^
>> include/linux/percpu-defs.h:87:9: note: in expansion of macro '__PCPU_ATTRS'
extern __PCPU_ATTRS(sec) __typeof__(type) name
^~~~~~~~~~~~
include/linux/percpu-defs.h:113:2: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'
DECLARE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/bpf-cgroup.h:24:1: note: in expansion of macro 'DECLARE_PER_CPU'
DECLARE_PER_CPU(void*, bpf_cgroup_storage);
^~~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:113:38: error: expected ')' before string constant
DECLARE_PER_CPU_SECTION(type, name, "")
^
include/linux/percpu-defs.h:49:55: note: in definition of macro '__PCPU_ATTRS'
__percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
^~~
include/linux/percpu-defs.h:113:2: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'
DECLARE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/bpf-cgroup.h:24:1: note: in expansion of macro 'DECLARE_PER_CPU'
DECLARE_PER_CPU(void*, bpf_cgroup_storage);
^~~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:49:59: error: expected identifier or '(' before ')' token
__percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
^
>> include/linux/percpu-defs.h:87:9: note: in expansion of macro '__PCPU_ATTRS'
extern __PCPU_ATTRS(sec) __typeof__(type) name
^~~~~~~~~~~~
include/linux/percpu-defs.h:113:2: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'
DECLARE_PER_CPU_SECTION(type, name, "")
^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/bpf-cgroup.h:24:1: note: in expansion of macro 'DECLARE_PER_CPU'
DECLARE_PER_CPU(void*, bpf_cgroup_storage);
^~~~~~~~~~~~~~~
include/linux/bpf-cgroup.h: In function 'bpf_cgroup_storage_set':
include/linux/bpf-cgroup.h:110:17: error: 'bpf_cgroup_storage' undeclared (first use in this function)
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^
include/linux/percpu-defs.h:221:47: note: in definition of macro '__verify_pcpu_ptr'
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
^~~
include/linux/percpu-defs.h:510:34: note: in expansion of macro '__pcpu_size_call'
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^~~~~~~~~~~~~~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
include/linux/bpf-cgroup.h:110:17: note: each undeclared identifier is reported only once for each function it appears in
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^
include/linux/percpu-defs.h:221:47: note: in definition of macro '__verify_pcpu_ptr'
const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
^~~
include/linux/percpu-defs.h:510:34: note: in expansion of macro '__pcpu_size_call'
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^~~~~~~~~~~~~~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:510:51: error: implicit declaration of function 'this_cpu_write_1'; did you mean 'this_cpu_write'? [-Werror=implicit-function-declaration]
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^
include/linux/percpu-defs.h:379:11: note: in definition of macro '__pcpu_size_call'
case 1: stem##1(variable, __VA_ARGS__);break; \
^~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:510:51: error: implicit declaration of function 'this_cpu_write_2'; did you mean 'this_cpu_write'? [-Werror=implicit-function-declaration]
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^
include/linux/percpu-defs.h:380:11: note: in definition of macro '__pcpu_size_call'
case 2: stem##2(variable, __VA_ARGS__);break; \
^~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:510:51: error: implicit declaration of function 'this_cpu_write_4'; did you mean 'this_cpu_write'? [-Werror=implicit-function-declaration]
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^
include/linux/percpu-defs.h:381:11: note: in definition of macro '__pcpu_size_call'
case 4: stem##4(variable, __VA_ARGS__);break; \
^~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:510:51: error: implicit declaration of function 'this_cpu_write_8'; did you mean 'this_cpu_write'? [-Werror=implicit-function-declaration]
#define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
^
include/linux/percpu-defs.h:382:11: note: in definition of macro '__pcpu_size_call'
case 8: stem##8(variable, __VA_ARGS__);break; \
^~~~
include/linux/bpf-cgroup.h:110:2: note: in expansion of macro 'this_cpu_write'
this_cpu_write(bpf_cgroup_storage, &buf->data[0]);
^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +49 include/linux/percpu-defs.h
62fde54123 Tejun Heo 2014-06-17 37
5028eaa97d David Howells 2009-04-21 38 /*
5028eaa97d David Howells 2009-04-21 39 * Base implementations of per-CPU variable declarations and definitions, where
5028eaa97d David Howells 2009-04-21 40 * the section in which the variable is to be placed is provided by the
7c756e6e19 Tejun Heo 2009-06-24 41 * 'sec' argument. This may be used to affect the parameters governing the
5028eaa97d David Howells 2009-04-21 42 * variable's storage.
5028eaa97d David Howells 2009-04-21 43 *
5028eaa97d David Howells 2009-04-21 44 * NOTE! The sections for the DECLARE and for the DEFINE must match, lest
5028eaa97d David Howells 2009-04-21 45 * linkage errors occur due the compiler generating the wrong code to access
5028eaa97d David Howells 2009-04-21 46 * that section.
5028eaa97d David Howells 2009-04-21 47 */
7c756e6e19 Tejun Heo 2009-06-24 48 #define __PCPU_ATTRS(sec) \
e0fdb0e050 Rusty Russell 2009-10-29 @49 __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
7c756e6e19 Tejun Heo 2009-06-24 50 PER_CPU_ATTRIBUTES
7c756e6e19 Tejun Heo 2009-06-24 51
7c756e6e19 Tejun Heo 2009-06-24 52 #define __PCPU_DUMMY_ATTRS \
7c756e6e19 Tejun Heo 2009-06-24 53 __attribute__((section(".discard"), unused))
7c756e6e19 Tejun Heo 2009-06-24 54
7c756e6e19 Tejun Heo 2009-06-24 55 /*
7c756e6e19 Tejun Heo 2009-06-24 56 * s390 and alpha modules require percpu variables to be defined as
7c756e6e19 Tejun Heo 2009-06-24 57 * weak to force the compiler to generate GOT based external
7c756e6e19 Tejun Heo 2009-06-24 58 * references for them. This is necessary because percpu sections
7c756e6e19 Tejun Heo 2009-06-24 59 * will be located outside of the usually addressable area.
7c756e6e19 Tejun Heo 2009-06-24 60 *
7c756e6e19 Tejun Heo 2009-06-24 61 * This definition puts the following two extra restrictions when
7c756e6e19 Tejun Heo 2009-06-24 62 * defining percpu variables.
7c756e6e19 Tejun Heo 2009-06-24 63 *
7c756e6e19 Tejun Heo 2009-06-24 64 * 1. The symbol must be globally unique, even the static ones.
7c756e6e19 Tejun Heo 2009-06-24 65 * 2. Static percpu variables cannot be defined inside a function.
7c756e6e19 Tejun Heo 2009-06-24 66 *
7c756e6e19 Tejun Heo 2009-06-24 67 * Archs which need weak percpu definitions should define
7c756e6e19 Tejun Heo 2009-06-24 68 * ARCH_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary.
7c756e6e19 Tejun Heo 2009-06-24 69 *
7c756e6e19 Tejun Heo 2009-06-24 70 * To ensure that the generic code observes the above two
7c756e6e19 Tejun Heo 2009-06-24 71 * restrictions, if CONFIG_DEBUG_FORCE_WEAK_PER_CPU is set weak
7c756e6e19 Tejun Heo 2009-06-24 72 * definition is used for all cases.
7c756e6e19 Tejun Heo 2009-06-24 73 */
7c756e6e19 Tejun Heo 2009-06-24 74 #if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PER_CPU)
7c756e6e19 Tejun Heo 2009-06-24 75 /*
7c756e6e19 Tejun Heo 2009-06-24 76 * __pcpu_scope_* dummy variable is used to enforce scope. It
7c756e6e19 Tejun Heo 2009-06-24 77 * receives the static modifier when it's used in front of
7c756e6e19 Tejun Heo 2009-06-24 78 * DEFINE_PER_CPU() and will trigger build failure if
7c756e6e19 Tejun Heo 2009-06-24 79 * DECLARE_PER_CPU() is used for the same variable.
7c756e6e19 Tejun Heo 2009-06-24 80 *
7c756e6e19 Tejun Heo 2009-06-24 81 * __pcpu_unique_* dummy variable is used to enforce symbol uniqueness
7c756e6e19 Tejun Heo 2009-06-24 82 * such that hidden weak symbol collision, which will cause unrelated
7c756e6e19 Tejun Heo 2009-06-24 83 * variables to share the same address, can be detected during build.
7c756e6e19 Tejun Heo 2009-06-24 84 */
7c756e6e19 Tejun Heo 2009-06-24 85 #define DECLARE_PER_CPU_SECTION(type, name, sec) \
7c756e6e19 Tejun Heo 2009-06-24 86 extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
dd17c8f729 Rusty Russell 2009-10-29 @87 extern __PCPU_ATTRS(sec) __typeof__(type) name
7c756e6e19 Tejun Heo 2009-06-24 88
7c756e6e19 Tejun Heo 2009-06-24 89 #define DEFINE_PER_CPU_SECTION(type, name, sec) \
7c756e6e19 Tejun Heo 2009-06-24 90 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
0f5e4816db Tejun Heo 2009-10-29 91 extern __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
7c756e6e19 Tejun Heo 2009-06-24 92 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
b1a0fbfdde Tejun Heo 2013-12-04 93 extern __PCPU_ATTRS(sec) __typeof__(type) name; \
c43768cbb7 Tejun Heo 2009-07-04 94 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
dd17c8f729 Rusty Russell 2009-10-29 95 __typeof__(type) name
7c756e6e19 Tejun Heo 2009-06-24 96 #else
7c756e6e19 Tejun Heo 2009-06-24 97 /*
7c756e6e19 Tejun Heo 2009-06-24 98 * Normal declaration and definition macros.
7c756e6e19 Tejun Heo 2009-06-24 99 */
7c756e6e19 Tejun Heo 2009-06-24 100 #define DECLARE_PER_CPU_SECTION(type, name, sec) \
dd17c8f729 Rusty Russell 2009-10-29 101 extern __PCPU_ATTRS(sec) __typeof__(type) name
7c756e6e19 Tejun Heo 2009-06-24 102
7c756e6e19 Tejun Heo 2009-06-24 103 #define DEFINE_PER_CPU_SECTION(type, name, sec) \
c43768cbb7 Tejun Heo 2009-07-04 104 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
dd17c8f729 Rusty Russell 2009-10-29 105 __typeof__(type) name
7c756e6e19 Tejun Heo 2009-06-24 106 #endif
5028eaa97d David Howells 2009-04-21 107
5028eaa97d David Howells 2009-04-21 108 /*
5028eaa97d David Howells 2009-04-21 109 * Variant on the per-CPU variable declaration/definition theme used for
5028eaa97d David Howells 2009-04-21 110 * ordinary per-CPU variables.
5028eaa97d David Howells 2009-04-21 111 */
5028eaa97d David Howells 2009-04-21 112 #define DECLARE_PER_CPU(type, name) \
5028eaa97d David Howells 2009-04-21 @113 DECLARE_PER_CPU_SECTION(type, name, "")
5028eaa97d David Howells 2009-04-21 114
5028eaa97d David Howells 2009-04-21 115 #define DEFINE_PER_CPU(type, name) \
5028eaa97d David Howells 2009-04-21 116 DEFINE_PER_CPU_SECTION(type, name, "")
5028eaa97d David Howells 2009-04-21 117
5028eaa97d David Howells 2009-04-21 118 /*
5028eaa97d David Howells 2009-04-21 119 * Declaration/definition used for per-CPU variables that must come first in
5028eaa97d David Howells 2009-04-21 120 * the set of variables.
5028eaa97d David Howells 2009-04-21 121 */
5028eaa97d David Howells 2009-04-21 122 #define DECLARE_PER_CPU_FIRST(type, name) \
5028eaa97d David Howells 2009-04-21 123 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
5028eaa97d David Howells 2009-04-21 124
5028eaa97d David Howells 2009-04-21 125 #define DEFINE_PER_CPU_FIRST(type, name) \
5028eaa97d David Howells 2009-04-21 126 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_FIRST_SECTION)
5028eaa97d David Howells 2009-04-21 127
5028eaa97d David Howells 2009-04-21 128 /*
5028eaa97d David Howells 2009-04-21 129 * Declaration/definition used for per-CPU variables that must be cacheline
5028eaa97d David Howells 2009-04-21 130 * aligned under SMP conditions so that, whilst a particular instance of the
5028eaa97d David Howells 2009-04-21 131 * data corresponds to a particular CPU, inefficiencies due to direct access by
5028eaa97d David Howells 2009-04-21 132 * other CPUs are reduced by preventing the data from unnecessarily spanning
5028eaa97d David Howells 2009-04-21 133 * cachelines.
5028eaa97d David Howells 2009-04-21 134 *
5028eaa97d David Howells 2009-04-21 135 * An example of this would be statistical data, where each CPU's set of data
5028eaa97d David Howells 2009-04-21 136 * is updated by that CPU alone, but the data from across all CPUs is collated
5028eaa97d David Howells 2009-04-21 137 * by a CPU processing a read from a proc file.
5028eaa97d David Howells 2009-04-21 138 */
5028eaa97d David Howells 2009-04-21 139 #define DECLARE_PER_CPU_SHARED_ALIGNED(type, name) \
5028eaa97d David Howells 2009-04-21 140 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
5028eaa97d David Howells 2009-04-21 141 ____cacheline_aligned_in_smp
5028eaa97d David Howells 2009-04-21 142
5028eaa97d David Howells 2009-04-21 143 #define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
5028eaa97d David Howells 2009-04-21 144 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
5028eaa97d David Howells 2009-04-21 145 ____cacheline_aligned_in_smp
5028eaa97d David Howells 2009-04-21 146
53f824520b Jeremy Fitzhardinge 2009-09-03 147 #define DECLARE_PER_CPU_ALIGNED(type, name) \
53f824520b Jeremy Fitzhardinge 2009-09-03 148 DECLARE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
53f824520b Jeremy Fitzhardinge 2009-09-03 149 ____cacheline_aligned
53f824520b Jeremy Fitzhardinge 2009-09-03 150
53f824520b Jeremy Fitzhardinge 2009-09-03 151 #define DEFINE_PER_CPU_ALIGNED(type, name) \
53f824520b Jeremy Fitzhardinge 2009-09-03 152 DEFINE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION) \
53f824520b Jeremy Fitzhardinge 2009-09-03 153 ____cacheline_aligned
53f824520b Jeremy Fitzhardinge 2009-09-03 154
5028eaa97d David Howells 2009-04-21 155 /*
5028eaa97d David Howells 2009-04-21 156 * Declaration/definition used for per-CPU variables that must be page aligned.
5028eaa97d David Howells 2009-04-21 157 */
5028eaa97d David Howells 2009-04-21 158 #define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \
3d9a854c2d Denys Vlasenko 2010-02-20 159 DECLARE_PER_CPU_SECTION(type, name, "..page_aligned") \
3e352aa8ee Tejun Heo 2009-08-03 160 __aligned(PAGE_SIZE)
5028eaa97d David Howells 2009-04-21 161
5028eaa97d David Howells 2009-04-21 162 #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
3d9a854c2d Denys Vlasenko 2010-02-20 163 DEFINE_PER_CPU_SECTION(type, name, "..page_aligned") \
3e352aa8ee Tejun Heo 2009-08-03 164 __aligned(PAGE_SIZE)
5028eaa97d David Howells 2009-04-21 165
5028eaa97d David Howells 2009-04-21 166 /*
c957ef2c59 Shaohua Li 2010-10-20 167 * Declaration/definition used for per-CPU variables that must be read mostly.
c957ef2c59 Shaohua Li 2010-10-20 168 */
c957ef2c59 Shaohua Li 2010-10-20 169 #define DECLARE_PER_CPU_READ_MOSTLY(type, name) \
330d282216 Zhengyu He 2014-07-01 170 DECLARE_PER_CPU_SECTION(type, name, "..read_mostly")
c957ef2c59 Shaohua Li 2010-10-20 171
c957ef2c59 Shaohua Li 2010-10-20 172 #define DEFINE_PER_CPU_READ_MOSTLY(type, name) \
330d282216 Zhengyu He 2014-07-01 173 DEFINE_PER_CPU_SECTION(type, name, "..read_mostly")
c957ef2c59 Shaohua Li 2010-10-20 174
c957ef2c59 Shaohua Li 2010-10-20 175 /*
ac26963a11 Brijesh Singh 2017-10-20 176 * Declaration/definition used for per-CPU variables that should be accessed
ac26963a11 Brijesh Singh 2017-10-20 177 * as decrypted when memory encryption is enabled in the guest.
ac26963a11 Brijesh Singh 2017-10-20 178 */
ac26963a11 Brijesh Singh 2017-10-20 179 #if defined(CONFIG_VIRTUALIZATION) && defined(CONFIG_AMD_MEM_ENCRYPT)
ac26963a11 Brijesh Singh 2017-10-20 180
ac26963a11 Brijesh Singh 2017-10-20 181 #define DECLARE_PER_CPU_DECRYPTED(type, name) \
ac26963a11 Brijesh Singh 2017-10-20 182 DECLARE_PER_CPU_SECTION(type, name, "..decrypted")
ac26963a11 Brijesh Singh 2017-10-20 183
ac26963a11 Brijesh Singh 2017-10-20 184 #define DEFINE_PER_CPU_DECRYPTED(type, name) \
ac26963a11 Brijesh Singh 2017-10-20 185 DEFINE_PER_CPU_SECTION(type, name, "..decrypted")
ac26963a11 Brijesh Singh 2017-10-20 186 #else
ac26963a11 Brijesh Singh 2017-10-20 187 #define DEFINE_PER_CPU_DECRYPTED(type, name) DEFINE_PER_CPU(type, name)
ac26963a11 Brijesh Singh 2017-10-20 188 #endif
ac26963a11 Brijesh Singh 2017-10-20 189
ac26963a11 Brijesh Singh 2017-10-20 190 /*
545695fb41 Tejun Heo 2009-10-29 191 * Intermodule exports for per-CPU variables. sparse forgets about
545695fb41 Tejun Heo 2009-10-29 192 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to
545695fb41 Tejun Heo 2009-10-29 193 * noop if __CHECKER__.
5028eaa97d David Howells 2009-04-21 194 */
545695fb41 Tejun Heo 2009-10-29 195 #ifndef __CHECKER__
dd17c8f729 Rusty Russell 2009-10-29 196 #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(var)
dd17c8f729 Rusty Russell 2009-10-29 197 #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(var)
545695fb41 Tejun Heo 2009-10-29 198 #else
545695fb41 Tejun Heo 2009-10-29 199 #define EXPORT_PER_CPU_SYMBOL(var)
545695fb41 Tejun Heo 2009-10-29 200 #define EXPORT_PER_CPU_SYMBOL_GPL(var)
545695fb41 Tejun Heo 2009-10-29 201 #endif
5028eaa97d David Howells 2009-04-21 202
62fde54123 Tejun Heo 2014-06-17 203 /*
62fde54123 Tejun Heo 2014-06-17 204 * Accessors and operations.
62fde54123 Tejun Heo 2014-06-17 205 */
62fde54123 Tejun Heo 2014-06-17 206 #ifndef __ASSEMBLY__
62fde54123 Tejun Heo 2014-06-17 207
9c28278a24 Tejun Heo 2014-06-17 208 /*
6fbc07bbe2 Tejun Heo 2014-06-17 209 * __verify_pcpu_ptr() verifies @ptr is a percpu pointer without evaluating
6fbc07bbe2 Tejun Heo 2014-06-17 210 * @ptr and is invoked once before a percpu area is accessed by all
6fbc07bbe2 Tejun Heo 2014-06-17 211 * accessors and operations. This is performed in the generic part of
6fbc07bbe2 Tejun Heo 2014-06-17 212 * percpu and arch overrides don't need to worry about it; however, if an
6fbc07bbe2 Tejun Heo 2014-06-17 213 * arch wants to implement an arch-specific percpu accessor or operation,
6fbc07bbe2 Tejun Heo 2014-06-17 214 * it may use __verify_pcpu_ptr() to verify the parameters.
9c28278a24 Tejun Heo 2014-06-17 215 *
9c28278a24 Tejun Heo 2014-06-17 216 * + 0 is required in order to convert the pointer type from a
9c28278a24 Tejun Heo 2014-06-17 217 * potential array type to a pointer to a single item of the array.
9c28278a24 Tejun Heo 2014-06-17 218 */
eba117889a Tejun Heo 2014-06-17 219 #define __verify_pcpu_ptr(ptr) \
eba117889a Tejun Heo 2014-06-17 220 do { \
9c28278a24 Tejun Heo 2014-06-17 @221 const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
9c28278a24 Tejun Heo 2014-06-17 222 (void)__vpp_verify; \
9c28278a24 Tejun Heo 2014-06-17 223 } while (0)
9c28278a24 Tejun Heo 2014-06-17 224
:::::: The code at line 49 was first introduced by commit
:::::: e0fdb0e050eae331046385643618f12452aa7e73 percpu: add __percpu for sparse.
:::::: TO: Rusty Russell <rusty@rustcorp.com.au>
:::::: CC: Tejun Heo <tj@kernel.org>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 19734 bytes --]
^ permalink raw reply
* [PATCH][net-next] net: replace num_possible_cpus with nr_cpu_ids
From: Li RongQing @ 2018-07-06 9:33 UTC (permalink / raw)
To: netdev
The return of num_possible_cpus() is same as nr_cpu_ids, but
nr_cpu_ids can reduce cpu computation
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
net/core/dev.c | 4 ++--
net/ipv4/inet_hashtables.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 89825c1eccdc..05c7bc6e4ce6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2189,7 +2189,7 @@ static void netif_reset_xps_queues(struct net_device *dev, u16 offset,
if (!dev_maps)
goto out_no_maps;
- if (num_possible_cpus() > 1)
+ if (nr_cpu_ids > 1)
possible_mask = cpumask_bits(cpu_possible_mask);
nr_ids = nr_cpu_ids;
clean_xps_maps(dev, possible_mask, dev_maps, nr_ids, offset, count,
@@ -2273,7 +2273,7 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
nr_ids = dev->num_rx_queues;
} else {
maps_sz = XPS_CPU_DEV_MAPS_SIZE(num_tc);
- if (num_possible_cpus() > 1) {
+ if (nr_cpu_ids > 1) {
online_mask = cpumask_bits(cpu_online_mask);
possible_mask = cpumask_bits(cpu_possible_mask);
}
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 3647167c8fa3..80cadf06fd3f 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -825,7 +825,7 @@ int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo)
if (locksz != 0) {
/* allocate 2 cache lines or at least one spinlock per cpu */
nblocks = max(2U * L1_CACHE_BYTES / locksz, 1U);
- nblocks = roundup_pow_of_two(nblocks * num_possible_cpus());
+ nblocks = roundup_pow_of_two(nblocks * nr_cpu_ids);
/* no more locks than number of hash buckets */
nblocks = min(nblocks, hashinfo->ehash_mask + 1);
--
2.16.2
^ permalink raw reply related
* Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk
From: NeilBrown @ 2018-07-06 9:50 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, Thomas Graf, Herbert Xu, Tom Herbert, netdev,
linux-kernel
In-Reply-To: <201807061601.oe0LkaJd%fengguang.wu@intel.com>
[-- Attachment #1: Type: text/plain, Size: 569 bytes --]
On Fri, Jul 06 2018, kbuild test robot wrote:
> Hi NeilBrown,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on net-next/master]
> [also build test ERROR on next-20180705]
> [cannot apply to linus/master linux-sof-driver/master v4.18-rc3]
> [if your patch is applied to the wrong git tree, please drop us a note
> to help improve the system]
Patch is against net-next, plus "rhashtable: detect when object movement
might have invalidated a lookup" which was posted earlier (this
dependency wasn't made explicit).
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply
* Re: [PATCHv2 net-next 2/2] selftests: add a selftest for directed broadcast forwarding
From: Xin Long @ 2018-07-06 9:50 UTC (permalink / raw)
To: David Ahern; +Cc: network dev, davem, Davide Caratti, Ido Schimmel
In-Reply-To: <CADvbK_fcgH7OM2Z8Wsvz=7svt=UZ6+QfE2Yw1+J7E9RXCVm1PQ@mail.gmail.com>
On Thu, Jul 5, 2018 at 10:07 PM, Xin Long <lucien.xin@gmail.com> wrote:
> On Thu, Jul 5, 2018 at 9:18 PM, David Ahern <dsahern@gmail.com> wrote:
>> On 7/5/18 1:57 AM, Xin Long wrote:
>>> On Thu, Jul 5, 2018 at 2:36 AM, David Ahern <dsahern@gmail.com> wrote:
>>>> On 7/4/18 11:56 AM, Xin Long wrote:
>>>>
>>>>>> your commands are not a proper test. The test should succeed and fail
>>>>>> based on the routing lookup, not iptables rules.
>>>>> A proper test can be done easily with netns, as vrf can't isolate much.
>>>>> I don't want to bother forwarding/ directory with netns, so I will probably
>>>>> just drop this selftest, and let the feature patch go first.
>>>>>
>>>>
>>>> BTW, VRF isolates at the routing layer and this is a routing change. We
>>>> need to understand why it does not work with VRF. Perhaps another tweak
>>>> is needed for VRF.
>>> One problem was that the peer may not use the address on the dev
>>> that echo_request comes from as the src IP of echo_reply when the
>>> echo_request's dst IP is broadcast, but try to get another one by
>>> looking up a route without ".flowi4_oif" set. See:
>>>
>>> icmp_reply()->fib_compute_spec_dst():
>>> struct flowi4 fl4 = {
>>> .flowi4_iif = LOOPBACK_IFINDEX,
>>> .daddr = ip_hdr(skb)->saddr,
>>> .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
>>> .flowi4_scope = scope,
>>> .flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0,
>>> };
>>> if (!fib_lookup(net, &fl4, &res, 0))
>>> return FIB_RES_PREFSRC(net, res);
>>>
>>>
>>> Without ".flowi4_oif" set, it won't match the vrf route. That's why
>>> I had to make h2 NOT into a vrf so that h1 can get the echo_reply.
>>> But it can't tell if this echo_reply is from h2 or r1, as r1's echo_reply
>>> will also use the same src IP which is actually got from main route
>>> space as ".flowi4_oif" is not set.
>>> (hope I this description is clear to you) :)
>>>
>>> So i'm not sure if we can do any tweak for VRF.
>>>
>>
>> Try this:
>>
>> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
>> index b21833651394..e46cdd310e5f 100644
>> --- a/net/ipv4/fib_frontend.c
>> +++ b/net/ipv4/fib_frontend.c
>> @@ -300,6 +300,7 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
>> if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
>> struct flowi4 fl4 = {
>> .flowi4_iif = LOOPBACK_IFINDEX,
>> + .flowi4_oif = l3mdev_master_ifindex_rcu(dev),
>> .daddr = ip_hdr(skb)->saddr,
>> .flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
>> .flowi4_scope = scope,
If this patch can be applied, I would be able to make a proper selftest like:
...
ping_test_from()
{
local oif=$1
local dip=$2
local from=$3
local fail=$4
RET=0
ip vrf exec $(master_name_get $oif) \
$PING -I $oif $dip -c 10 -i 0.1 -w 2 -b 2>&1 | grep $from &> /dev/null
check_err_fail $fail $?
log_test "ping_test_from"
}
ping_ipv4()
{
sysctl_set net.ipv4.icmp_echo_ignore_broadcasts 0
bc_forwarding_disable
ping_test_from $h1 198.51.100.255 192.0.2.1
ping_test_from $h1 198.51.200.255 192.0.2.1
ping_test_from $h1 192.0.2.255 192.0.2.1
ping_test_from $h1 255.255.255.255 192.0.2.1
ping_test_from $h2 192.0.2.255 198.51.100.1
ping_test_from $h2 198.51.200.255 198.51.100.1
ping_test_from $h2 198.51.100.255 198.51.100.1
ping_test_from $h2 255.255.255.255 198.51.100.1
bc_forwarding_restore
bc_forwarding_enable
ping_test_from $h1 198.51.100.255 198.51.100.2
ping_test_from $h1 198.51.200.255 198.51.200.2
ping_test_from $h1 192.0.2.255 192.0.2.1 1
ping_test_from $h1 255.255.255.255 192.0.2.1
ping_test_from $h2 192.0.2.255 192.0.2.2
ping_test_from $h2 198.51.200.255 198.51.200.2
ping_test_from $h2 198.51.100.255 198.51.100.1 1
ping_test_from $h2 255.255.255.255 198.51.100.1
bc_forwarding_restore
sysctl_restore net.ipv4.icmp_echo_ignore_broadcasts
}
> Great, with your fix, I can extend more for this selftest.
> but I hope no side effects would be caused.
>
> Thank you.
^ permalink raw reply
* Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk
From: NeilBrown @ 2018-07-06 9:55 UTC (permalink / raw)
To: Paolo Abeni, Thomas Graf, Herbert Xu, Tom Herbert; +Cc: netdev, linux-kernel
In-Reply-To: <0a44916eacea6c3899152a07321ff69d96ed8c52.camel@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3125 bytes --]
On Fri, Jul 06 2018, Paolo Abeni wrote:
> On Fri, 2018-07-06 at 17:11 +1000, NeilBrown wrote:
>> If the sequence:
>> obj = rhashtable_walk_next(iter);
>> rhashtable_walk_stop(iter);
>> rhashtable_remove_fast(ht, &obj->head, params);
>> rhashtable_walk_start(iter);
>>
>> races with another thread inserting or removing
>> an object on the same hash chain, a subsequent
>> rhashtable_walk_next() is not guaranteed to get the "next"
>> object. It is possible that an object could be
>> repeated, or missed.
>
> The above scenario is very similar to the one I'm running:
>
> rhashtable_walk_next(iter);
> rhashtable_walk_stop(iter);
> // rhashtable change not yet identified, could be either
> // remove, insert or even rehash
> rhashtable_walk_start(iter);
> rhashtable_walk_next(iter);
>
> but I'm seeing use-after-free there. I'll try this patch to see if
> solves my issue.
>
> Note: the code under test is a pending new patch I'm holding due to the
> above issue, I can send it as RFC to share the code if you think it may
> help.
I'd suggest post it. I may not get a chance to look at it, but if you
don't post it, then I definitely won't :-)
>
>> @@ -867,15 +866,39 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter)
>> bool rhlist = ht->rhlist;
>>
>> if (p) {
>> - if (!rhlist || !(list = rcu_dereference(list->next))) {
>> - p = rcu_dereference(p->next);
>> - list = container_of(p, struct rhlist_head, rhead);
>> - }
>> - if (!rht_is_a_nulls(p)) {
>> - iter->skip++;
>> - iter->p = p;
>> - iter->list = list;
>> - return rht_obj(ht, rhlist ? &list->rhead : p);
>> + if (!rhlist && iter->p_is_unsafe) {
>> + /*
>> + * First time next() was called after start().
>> + * Need to find location of 'p' in the list.
>> + */
>> + struct rhash_head *p;
>> +
>> + iter->skip = 0;
>> + rht_for_each_rcu(p, iter->walker.tbl, iter->slot) {
>> + iter->skip++;
>> + if (p <= iter->p)
>> + continue;
>
> Out of sheer ignorance, I really don't understand the goal of the above
> conditional ?!?
I hoped the patch description would cover that:
With this patch:
- a new object is always inserted after the last object with a
smaller address, or at the start. This preserves the property,
important when allowing objects to be removed and re-added, that
an object is never inserted *after* a position that it previously
held in the list.
The items in each table slot are stored in order of the address of the
item. So to find the first item in a slot that was not before the
previously returned item (iter->p), we step forward while this item is
<= that one.
Does that help at all?
NeilBrown
>
> Should it possibly be something like:
> if (p != iter->p->next)
>
> instead?
> But I think we can't safely dereference 'p' yet ?!?
>
> I'm sorry for the possibly dumb comments, rhashtable internals are
> somewhat obscure to me, but I'm really interested in this topic.
>
> Cheers,
>
> Paolo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply
* Re: general protection fault in bpf_tcp_close
From: syzbot @ 2018-07-06 10:02 UTC (permalink / raw)
To: ast, daniel, dvyukov, john.fastabend, linux-kernel, netdev,
syzkaller-bugs
In-Reply-To: <00000000000098e65b056d184a11@google.com>
syzbot has found a reproducer for the following crash on:
HEAD commit: 6fcf9b1d4d6c r8169: fix runtime suspend
git tree: bpf-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1600b10c400000
kernel config: https://syzkaller.appspot.com/x/.config?x=d264f2b04177ca7c
dashboard link: https://syzkaller.appspot.com/bug?extid=0ce137753c78f7b6acc1
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=15ba0a1c400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=100c8170400000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+0ce137753c78f7b6acc1@syzkaller.appspotmail.com
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
IPv6: ADDRCONF(NETDEV_UP): team0: link is not ready
8021q: adding VLAN 0 to HW filter on device team0
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
CPU: 1 PID: 4705 Comm: syz-executor133 Not tainted 4.18.0-rc3+ #47
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:bpf_tcp_close+0x215/0x1050 kernel/bpf/sockmap.c:327
Code:
------------[ cut here ]------------
Bad or missing usercopy whitelist? Kernel memory overwrite attempt detected
to SLAB object 'TCPv6' (offset 704, size 64)!
WARNING: CPU: 1 PID: 4705 at mm/usercopy.c:81 usercopy_warn+0xf5/0x120
mm/usercopy.c:76
Kernel panic - not syncing: panic_on_warn set ...
Dumping ftrace buffer:
(ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..
^ permalink raw reply
* Re: [PATCH wpan 1/2] net: 6lowpan: fix reserved space for single frames
From: Stefan Schmidt @ 2018-07-06 10:06 UTC (permalink / raw)
To: Alexander Aring, stefan; +Cc: linux-wpan, netdev, kernel
In-Reply-To: <20180702203203.21316-1-aring@mojatatu.com>
Hello.
On 02.07.2018 22:32, Alexander Aring wrote:
> This patch fixes patch add handling to take care tail and headroom for
The "patch add" text here is form some patch managing? Please fix this
when doing the re-spin for the problem below.
> single 6lowpan frames. We need to be sure we have a skb with the right
> head and tailroom for single frames. This patch do it by using
> skb_copy_expand() if head and tailroom is not enough allocated by upper
> layer.
>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195059
> Reported-by: David Palma <david.palma@ntnu.no>
> Reported-by: Rabi Narayan Sahoo <rabinarayans0828@gmail.com>
> Signed-off-by: Alexander Aring <aring@mojatatu.com>
> ---
> net/ieee802154/6lowpan/tx.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan/tx.c b/net/ieee802154/6lowpan/tx.c
> index e6ff5128e61a..d0c4d220de08 100644
> --- a/net/ieee802154/6lowpan/tx.c
> +++ b/net/ieee802154/6lowpan/tx.c
> @@ -265,9 +265,24 @@ netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *ldev)
> /* We must take a copy of the skb before we modify/replace the ipv6
> * header as the header could be used elsewhere
> */
> - skb = skb_unshare(skb, GFP_ATOMIC);
> - if (!skb)
> - return NET_XMIT_DROP;
> + if (unlikely(skb_headroom(skb) < ldev->needed_headroom ||
> + skb_tailroom(skb) < ldev->needed_tailroom)) {
> + struct sk_buff *nskb;
> +
> + nskb = skb_copy_expand(skb, ldev->needed_headroom,
> + ldev->needed_tailroom, GFP_ATOMIC);
> + if (likely(skb)) {
I think you wanted to check for nskb here.
> + consume_skb(skb);
> + skb = nskb;
> + } else {
> + kfree_skb(skb);
> + return NET_XMIT_DROP;
> + }
> + } else {
> + skb = skb_unshare(skb, GFP_ATOMIC);
> + if (!skb)
> + return NET_XMIT_DROP;
> + }
>
> ret = lowpan_header(skb, ldev, &dgram_size, &dgram_offset);
> if (ret < 0) {
>
The rest looks fine to me.
regards
Stefan Schmidt
^ permalink raw reply
* Re: [PATCH net-next] tcp: remove SG-related comment in tcp_sendmsg()
From: Eric Dumazet @ 2018-07-06 10:08 UTC (permalink / raw)
To: Julian Wiedmann, David Miller, Eric Dumazet; +Cc: netdev
In-Reply-To: <20180706071910.65958-1-jwi@linux.ibm.com>
On 07/06/2018 12:19 AM, Julian Wiedmann wrote:
> Since commit 74d4a8f8d378 ("tcp: remove sk_can_gso() use"), the code
> doesn't care whether the interface supports SG.
>
> Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
> ---
> net/ipv4/tcp.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index bf461fa77ed6..516e89b57603 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1275,9 +1275,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> int linear;
>
> new_segment:
> - /* Allocate new segment. If the interface is SG,
> - * allocate skb fitting to single page.
> - */
> + /* Allocate new segment. */
Hi Julian
Please remove the comment completely then, it is really just redundant after this label.
Thanks.
^ permalink raw reply
* [RFC PATCH] ip: re-introduce fragments cache worker
From: Paolo Abeni @ 2018-07-06 10:10 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Eric Dumazet, Florian Westphal, NeilBrown
Currently, the ip frag cache is fragile to overload. With
flow control disabled:
./super_netperf.sh 10 -H 192.168.101.2 -t UDP_STREAM -l 60
9618.08
./super_netperf.sh 200 -H 192.168.101.2 -t UDP_STREAM -l 60
28.66
Once that the overload condition is reached, the system does not
recover until it's almost completely idle:
./super_netperf.sh 200 -H 192.168.101.2 -t UDP_STREAM -l 60 &
sleep 4; I=0;
for P in `pidof netperf`; do kill -9 $P; I=$((I+1)); [ $I -gt 190 ] && break; done
13.72
This is due to the removal of the fragment cache worker, which
was responsible to free some IP fragment cache memory when the
high threshold was reached, allowing the system to cope successfully
with the next fragmented packets.
This commit re-introduces the worker, on a per netns basis. Thanks
to rhashtable walkers we can block the bh only for an entry removal.
After this commit (and before IP frag worker removal):
./super_netperf.sh 10 -H 192.168.101.2 -t UDP_STREAM -l 60
9618.08
./super_netperf.sh 200 -H 192.168.101.2 -t UDP_STREAM -l 60
8599.77
./super_netperf.sh 200 -H 192.168.101.2 -t UDP_STREAM -l 60 &
sleep 4; I=0;
for P in `pidof netperf`; do kill -9 $P; I=$((I+1)); [ $I -gt 190 ] && break; done
9623.12
Fixes: 648700f76b03 ("inet: frags: use rhashtables for reassembly units")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
Note: tweaking ipfrag sysfs does not solve completely the issue:
- raising ipfrag_high_thresh increases the number of parallels
connections required to degrade the tput, but reached the IP
fragment cache capacity the good-put still goes almost to 0,
with the worker we get much more nice behaviour.
- setting ipfrag_time to 2 increases the change to recover from
overload (the 2# test above), but with several experiments
in such test, I got an average of 50% the expected tput with a very
large variance, with the worker we always see the expected/
line rate tput.
---
include/net/inet_frag.h | 8 ++---
net/ipv4/inet_fragment.c | 72 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index ed07e3786d98..1f12692d7f7d 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -11,6 +11,8 @@ struct netns_frags {
int timeout;
int max_dist;
struct inet_frags *f;
+ struct work_struct frags_work;
+ struct rhashtable_iter iter;
struct rhashtable rhashtable ____cacheline_aligned_in_smp;
@@ -101,11 +103,7 @@ struct inet_frags {
int inet_frags_init(struct inet_frags *);
void inet_frags_fini(struct inet_frags *);
-static inline int inet_frags_init_net(struct netns_frags *nf)
-{
- atomic_long_set(&nf->mem, 0);
- return rhashtable_init(&nf->rhashtable, &nf->f->rhash_params);
-}
+int inet_frags_init_net(struct netns_frags *nf);
void inet_frags_exit_net(struct netns_frags *nf);
void inet_frag_kill(struct inet_frag_queue *q);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index c9e35b81d093..0f5b29ce96de 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -88,10 +88,76 @@ static void inet_frags_free_cb(void *ptr, void *arg)
inet_frag_put(fq);
}
+static void inet_frag_schedule_worker(struct netns_frags *nf)
+{
+ if (unlikely(!work_pending(&nf->frags_work)))
+ schedule_work(&nf->frags_work);
+}
+
+#define INETFRAGS_EVICT_MAX 64
+static void inet_frag_worker(struct work_struct *work)
+{
+ struct netns_frags *nf;
+ bool reschedule;
+ int evicted = 0;
+
+ nf = container_of(work, struct netns_frags, frags_work);
+
+ rhashtable_walk_start(&nf->iter);
+
+ while ((reschedule = (frag_mem_limit(nf) > nf->low_thresh))) {
+ struct inet_frag_queue *fq = rhashtable_walk_next(&nf->iter);
+
+ if (IS_ERR(fq) && PTR_ERR(fq) == -EAGAIN)
+ continue;
+ if (!fq) {
+ /* end of table, restart the walk */
+ rhashtable_walk_stop(&nf->iter);
+ rhashtable_walk_exit(&nf->iter);
+ rhashtable_walk_enter(&nf->rhashtable, &nf->iter);
+ rhashtable_walk_start(&nf->iter);
+ continue;
+ }
+ if (!refcount_inc_not_zero(&fq->refcnt))
+ continue;
+
+ spin_lock_bh(&fq->lock);
+ inet_frag_kill(fq);
+ spin_unlock_bh(&fq->lock);
+ inet_frag_put(fq);
+
+ /* limit the amount of work we can do before a reschedule,
+ * to avoid starving others queued works
+ */
+ if (++evicted > INETFRAGS_EVICT_MAX)
+ break;
+ }
+
+ rhashtable_walk_stop(&nf->iter);
+
+ if (reschedule)
+ inet_frag_schedule_worker(nf);
+}
+
+int inet_frags_init_net(struct netns_frags *nf)
+{
+ int ret;
+
+ atomic_long_set(&nf->mem, 0);
+ INIT_WORK(&nf->frags_work, inet_frag_worker);
+ ret = rhashtable_init(&nf->rhashtable, &nf->f->rhash_params);
+ if (ret)
+ return ret;
+ rhashtable_walk_enter(&nf->rhashtable, &nf->iter);
+ return ret;
+}
+EXPORT_SYMBOL(inet_frags_init_net);
+
void inet_frags_exit_net(struct netns_frags *nf)
{
nf->low_thresh = 0; /* prevent creation of new frags */
-
+ cancel_work_sync(&nf->frags_work);
+ rhashtable_walk_exit(&nf->iter);
rhashtable_free_and_destroy(&nf->rhashtable, inet_frags_free_cb, NULL);
}
EXPORT_SYMBOL(inet_frags_exit_net);
@@ -157,8 +223,10 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
{
struct inet_frag_queue *q;
- if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh)
+ if (!nf->high_thresh || frag_mem_limit(nf) > nf->high_thresh) {
+ inet_frag_schedule_worker(nf);
return NULL;
+ }
q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC);
if (!q)
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 1/3] rhashtable: further improve stability of rhashtable_walk
From: Paolo Abeni @ 2018-07-06 10:12 UTC (permalink / raw)
To: NeilBrown, Thomas Graf, Herbert Xu, Tom Herbert; +Cc: netdev, linux-kernel
In-Reply-To: <87d0w0y9gg.fsf@notabene.neil.brown.name>
On Fri, 2018-07-06 at 19:55 +1000, NeilBrown wrote:
> On Fri, Jul 06 2018, Paolo Abeni wrote:
>
> > Note: the code under test is a pending new patch I'm holding due to the
> > above issue, I can send it as RFC to share the code if you think it may
> > help.
>
> I'd suggest post it. I may not get a chance to look at it, but if you
> don't post it, then I definitely won't :-)
Oks, thanks, I just spammed the list (and you ;)
> > > @@ -867,15 +866,39 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter)
> > > bool rhlist = ht->rhlist;
> > >
> > > if (p) {
> > > - if (!rhlist || !(list = rcu_dereference(list->next))) {
> > > - p = rcu_dereference(p->next);
> > > - list = container_of(p, struct rhlist_head, rhead);
> > > - }
> > > - if (!rht_is_a_nulls(p)) {
> > > - iter->skip++;
> > > - iter->p = p;
> > > - iter->list = list;
> > > - return rht_obj(ht, rhlist ? &list->rhead : p);
> > > + if (!rhlist && iter->p_is_unsafe) {
> > > + /*
> > > + * First time next() was called after start().
> > > + * Need to find location of 'p' in the list.
> > > + */
> > > + struct rhash_head *p;
> > > +
> > > + iter->skip = 0;
> > > + rht_for_each_rcu(p, iter->walker.tbl, iter->slot) {
> > > + iter->skip++;
> > > + if (p <= iter->p)
> > > + continue;
> >
> > Out of sheer ignorance, I really don't understand the goal of the above
> > conditional ?!?
>
> I hoped the patch description would cover that:
> With this patch:
> - a new object is always inserted after the last object with a
> smaller address, or at the start. This preserves the property,
> important when allowing objects to be removed and re-added, that
> an object is never inserted *after* a position that it previously
> held in the list.
>
> The items in each table slot are stored in order of the address of the
> item. So to find the first item in a slot that was not before the
> previously returned item (iter->p), we step forward while this item is
> <= that one.
>
> Does that help at all?
Yes, it's very clear. Before I dumbly skipped some slices of the patch.
Thanks,
Paolo
^ permalink raw reply
* Re: [PATCH v2 net-next 1/3] rds: Changing IP address internal representation to struct in6_addr
From: Sowmini Varadhan @ 2018-07-06 10:15 UTC (permalink / raw)
To: Santosh Shilimkar, davem; +Cc: Ka-Cheong Poon, netdev, rds-devel
In-Reply-To: <6a7b0951-d950-1555-a5b2-622d6f7b9f8f@oracle.com>
On (07/06/18 17:08), Ka-Cheong Poon wrote:
> >Hmm. Why do you need to include tcp header in ib transport
> >code ? If there is any common function just move to core
> >common file and use it.
>
> I think it can be removed as it is left over from earlier
> changes when the IB IPv6 listener port was RDS_TCP_PORT.
> Now all the port definitions are in rds.h.
Transport specific information such as port numbers should not
be smeared into the common rds-module. Please fix that.
If IB is also piggybacking on port 16385 (why?), please use your
own definitions for it in IB specific header files.
Santosh, David, I have to NACK this if it is not changed.
--Sowmini
^ permalink raw reply
* Re: Crash due to destroying TCP request sockets using SOCK_DESTROY
From: Eric Dumazet @ 2018-07-06 10:24 UTC (permalink / raw)
To: Lorenzo Colitti, Subash Abhinov Kasiviswanathan
Cc: netdev, Eric Dumazet, Alistair Strachan, David Ahern
In-Reply-To: <CAKD1Yr0aVtWt_oFaeMPO_p1VAZNNQ2zdEQx-BDH_JNUTk38-ww@mail.gmail.com>
On 07/05/2018 09:46 PM, Lorenzo Colitti wrote:
> On Fri, Jul 6, 2018 at 11:37 AM Subash Abhinov Kasiviswanathan
> <subashab@codeaurora.org> wrote:
>>
>> From the call stack, a TCP socket is being destroyed using netlink_diag.
>> The memory dump showed that the socket was an inet request socket (in
>> state TCP_NEW_SYN_RECV) with refcount of 0.
>> [...]
>> 13232.479820: <2> refcount_t: underflow; use-after-free.
>> 13232.479838: <6> ------------[ cut here ]------------
>> 13232.479843: <6> kernel BUG at kernel/msm-4.14/lib/refcount.c:204!
>> 13232.479849: <6> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
>> [...]
>> 13232.479996: <6> Process netd (pid: 648, stack limit =
>> 0xffffff801cf98000)
>> 13232.479998: <2> Call trace:
>> 13232.480000: <2> refcount_sub_and_test+0x64/0x78
>> 13232.480002: <2> refcount_dec_and_test+0x18/0x24
>> 13232.480005: <2> sock_gen_put+0x1c/0xb0
>> 13232.480009: <2> tcp_diag_destroy+0x54/0x68
>> [...]
>
> Looks like for a TCP_NEW_SYN_RECV socket, sock_diag_destroy
> essentially ends up doing:
>
> struct request_sock *req = inet_reqsk(sk);
>
> local_bh_disable();
> inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
> req);
> local_bh_enable();
> ...
>
> sock_gen_put(sk);
>
> It looks like inet_csk_reqsk_queue_drop_and_put calls reqsk_put(req),
> which frees the socket, and at that point sock_gen_put is a UAF. Do we
> just need:
>
> - inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
> - req);
> + inet_csk_reqsk_queue_drop(req->rsk_listener, req);
>
> since sock_gen_put will also end up calling reqsk_put() for a
> TCP_SYN_RECV socket?
>
> Alastair - you're able to reproduce this UAF using net_test on qemu,
> right? If so, could you try that two-line patch above?
>
Hi Lorenzo
Your patch makes sense to me, please submit it formally with :
Fixes: d7226c7a4dd1 ("net: diag: Fix refcnt leak in error path destroying socket")
Cc: David Ahern <dsa@cumulusnetworks.com>
Thanks !
^ permalink raw reply
* [PATCH net-next 00/10] Misc. bug fixes & cleanups for HNS3 driver
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm
This patch-set presents some miscellaneous bug fixes and cleanups
for the HNS3 driver.
Fuyun Liang (1):
net: hns3: Fix for mailbox message truncated problem
Huazhong Tan (1):
net: hns3: Prevent sending command during global or core reset
Jian Shen (1):
net: hns3: Add configure for mac minimal frame size
Peng Li (1):
net: hns3: Remove the warning when clear reset cause
Yunsheng Lin (6):
net: hns3: Fix tc setup when netdev is first up
net: hns3: Fix for mac pause not disable in pfc mode
net: hns3: Fix for waterline not setting correctly
net: hns3: Fix for l4 checksum offload bug
net: hns3: Fix warning bug when doing lp selftest
net: hns3: Fix get_vector ops in hclgevf_main module
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 84 +++++++++-------------
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 4 +-
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 3 +-
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 27 +++----
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 +
.../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 9 ++-
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 11 ++-
.../ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 3 +-
9 files changed, 70 insertions(+), 74 deletions(-)
--
2.7.4
^ permalink raw reply
* [PATCH net-next 01/10] net: hns3: Fix tc setup when netdev is first up
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Yunsheng Lin
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Yunsheng Lin <linyunsheng@huawei.com>
Currently, tc related configuration is not setup when the
netdev is first up, which cause the stack only using tc 0
problem.
This patch fixes it by setting the tc related configuration
using the info from NCL_CONFIG when netdev is first up.
Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 78 ++++++++++---------------
1 file changed, 31 insertions(+), 47 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index f73c9df..e5e51e8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -239,7 +239,28 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev)
struct hnae3_handle *h = hns3_get_handle(netdev);
struct hnae3_knic_private_info *kinfo = &h->kinfo;
unsigned int queue_size = kinfo->rss_size * kinfo->num_tc;
- int ret;
+ int i, ret;
+
+ if (kinfo->num_tc <= 1) {
+ netdev_reset_tc(netdev);
+ } else {
+ ret = netdev_set_num_tc(netdev, kinfo->num_tc);
+ if (ret) {
+ netdev_err(netdev,
+ "netdev_set_num_tc fail, ret=%d!\n", ret);
+ return ret;
+ }
+
+ for (i = 0; i < HNAE3_MAX_TC; i++) {
+ if (!kinfo->tc_info[i].enable)
+ continue;
+
+ netdev_set_tc_queue(netdev,
+ kinfo->tc_info[i].tc,
+ kinfo->tc_info[i].tqp_count,
+ kinfo->tc_info[i].tqp_offset);
+ }
+ }
ret = netif_set_real_num_tx_queues(netdev, queue_size);
if (ret) {
@@ -312,7 +333,9 @@ static int hns3_nic_net_up(struct net_device *netdev)
static int hns3_nic_net_open(struct net_device *netdev)
{
struct hns3_nic_priv *priv = netdev_priv(netdev);
- int ret;
+ struct hnae3_handle *h = hns3_get_handle(netdev);
+ struct hnae3_knic_private_info *kinfo;
+ int i, ret;
netif_carrier_off(netdev);
@@ -327,6 +350,12 @@ static int hns3_nic_net_open(struct net_device *netdev)
return ret;
}
+ kinfo = &h->kinfo;
+ for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) {
+ netdev_set_prio_tc_map(netdev, i,
+ kinfo->prio_tc[i]);
+ }
+
priv->ae_handle->last_reset_time = jiffies;
return 0;
}
@@ -1307,7 +1336,6 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)
u16 mode = mqprio_qopt->mode;
u8 hw = mqprio_qopt->qopt.hw;
bool if_running;
- unsigned int i;
int ret;
if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS &&
@@ -1331,24 +1359,6 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data)
if (ret)
goto out;
- if (tc <= 1) {
- netdev_reset_tc(netdev);
- } else {
- ret = netdev_set_num_tc(netdev, tc);
- if (ret)
- goto out;
-
- for (i = 0; i < HNAE3_MAX_TC; i++) {
- if (!kinfo->tc_info[i].enable)
- continue;
-
- netdev_set_tc_queue(netdev,
- kinfo->tc_info[i].tc,
- kinfo->tc_info[i].tqp_count,
- kinfo->tc_info[i].tqp_offset);
- }
- }
-
ret = hns3_nic_set_real_num_queue(netdev);
out:
@@ -3202,7 +3212,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
struct net_device *ndev = kinfo->netdev;
bool if_running;
int ret;
- u8 i;
if (tc > HNAE3_MAX_TC)
return -EINVAL;
@@ -3212,10 +3221,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
if_running = netif_running(ndev);
- ret = netdev_set_num_tc(ndev, tc);
- if (ret)
- return ret;
-
if (if_running) {
(void)hns3_nic_net_stop(ndev);
msleep(100);
@@ -3226,27 +3231,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc)
if (ret)
goto err_out;
- if (tc <= 1) {
- netdev_reset_tc(ndev);
- goto out;
- }
-
- for (i = 0; i < HNAE3_MAX_TC; i++) {
- struct hnae3_tc_info *tc_info = &kinfo->tc_info[i];
-
- if (tc_info->enable)
- netdev_set_tc_queue(ndev,
- tc_info->tc,
- tc_info->tqp_count,
- tc_info->tqp_offset);
- }
-
- for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) {
- netdev_set_prio_tc_map(ndev, i,
- kinfo->prio_tc[i]);
- }
-
-out:
ret = hns3_nic_set_real_num_queue(ndev);
err_out:
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 02/10] net: hns3: Fix for mac pause not disable in pfc mode
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Yunsheng Lin
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Yunsheng Lin <linyunsheng@huawei.com>
When pfc pause mode is enable, the mac pause mode need to be
disabled, otherwise the pfc pause packet will not be sent when
congestion happens.
This patch fixes by disabling the mac pause when pfc pause is
enabled.
Fixes: 848440544b41 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index 82bc30f..e2acf3b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -1223,6 +1223,10 @@ static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
tx_en = true;
rx_en = true;
break;
+ case HCLGE_FC_PFC:
+ tx_en = false;
+ rx_en = false;
+ break;
default:
tx_en = true;
rx_en = true;
@@ -1240,8 +1244,9 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev)
if (ret)
return ret;
- if (hdev->tm_info.fc_mode != HCLGE_FC_PFC)
- return hclge_mac_pause_setup_hw(hdev);
+ ret = hclge_mac_pause_setup_hw(hdev);
+ if (ret)
+ return ret;
/* Only DCB-supported dev supports qset back pressure and pfc cmd */
if (!hnae3_dev_dcb_supported(hdev))
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 03/10] net: hns3: Fix for waterline not setting correctly
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Yunsheng Lin
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Yunsheng Lin <linyunsheng@huawei.com>
The HCLGE_RX_PRIV_EN_B is used to tell the firmware whether
to update the specific waterline value, if the is not set,
the firmware will ignore the value.
This patch fixes by setting the HCLGE_RX_PRIV_EN_B even if
the updated value is zero.
Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
.../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 6fffc69..dae1aa5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1834,8 +1834,6 @@ static int hclge_rx_priv_buf_alloc(struct hclge_dev *hdev,
return 0;
}
-#define HCLGE_PRIV_ENABLE(a) ((a) > 0 ? 1 : 0)
-
static int hclge_rx_priv_wl_config(struct hclge_dev *hdev,
struct hclge_pkt_buf_alloc *buf_alloc)
{
@@ -1863,13 +1861,11 @@ static int hclge_rx_priv_wl_config(struct hclge_dev *hdev,
req->tc_wl[j].high =
cpu_to_le16(priv->wl.high >> HCLGE_BUF_UNIT_S);
req->tc_wl[j].high |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(priv->wl.high) <<
- HCLGE_RX_PRIV_EN_B);
+ cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
req->tc_wl[j].low =
cpu_to_le16(priv->wl.low >> HCLGE_BUF_UNIT_S);
req->tc_wl[j].low |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(priv->wl.low) <<
- HCLGE_RX_PRIV_EN_B);
+ cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
}
}
@@ -1911,13 +1907,11 @@ static int hclge_common_thrd_config(struct hclge_dev *hdev,
req->com_thrd[j].high =
cpu_to_le16(tc->high >> HCLGE_BUF_UNIT_S);
req->com_thrd[j].high |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(tc->high) <<
- HCLGE_RX_PRIV_EN_B);
+ cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
req->com_thrd[j].low =
cpu_to_le16(tc->low >> HCLGE_BUF_UNIT_S);
req->com_thrd[j].low |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(tc->low) <<
- HCLGE_RX_PRIV_EN_B);
+ cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
}
}
@@ -1943,14 +1937,10 @@ static int hclge_common_wl_config(struct hclge_dev *hdev,
req = (struct hclge_rx_com_wl *)desc.data;
req->com_wl.high = cpu_to_le16(buf->self.high >> HCLGE_BUF_UNIT_S);
- req->com_wl.high |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(buf->self.high) <<
- HCLGE_RX_PRIV_EN_B);
+ req->com_wl.high |= cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
req->com_wl.low = cpu_to_le16(buf->self.low >> HCLGE_BUF_UNIT_S);
- req->com_wl.low |=
- cpu_to_le16(HCLGE_PRIV_ENABLE(buf->self.low) <<
- HCLGE_RX_PRIV_EN_B);
+ req->com_wl.low |= cpu_to_le16(BIT(HCLGE_RX_PRIV_EN_B));
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) {
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 04/10] net: hns3: Fix for l4 checksum offload bug
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Yunsheng Lin
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Yunsheng Lin <linyunsheng@huawei.com>
Hardware only support tcp/udp/sctp l4 checksum offload, but
the driver currently tell hardware to do l4 checksum offlad when
l3 is IPv4 or IPv6, which may cause checksumm error.
This patch fixes it by only enabling the l4 offload when l4 is
tcp/udp/sctp.
Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index e5e51e8..c211450 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -791,16 +791,14 @@ static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto,
*/
if (skb_is_gso(skb))
hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L3CS_B, 1);
-
- hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
} else if (l3.v6->version == 6) {
hnae3_set_field(*type_cs_vlan_tso, HNS3_TXD_L3T_M,
HNS3_TXD_L3T_S, HNS3_L3T_IPV6);
- hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
}
switch (l4_proto) {
case IPPROTO_TCP:
+ hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
hnae3_set_field(*type_cs_vlan_tso,
HNS3_TXD_L4T_M,
HNS3_TXD_L4T_S,
@@ -810,12 +808,14 @@ static int hns3_set_l3l4_type_csum(struct sk_buff *skb, u8 ol4_proto,
if (hns3_tunnel_csum_bug(skb))
break;
+ hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
hnae3_set_field(*type_cs_vlan_tso,
HNS3_TXD_L4T_M,
HNS3_TXD_L4T_S,
HNS3_L4T_UDP);
break;
case IPPROTO_SCTP:
+ hnae3_set_bit(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
hnae3_set_field(*type_cs_vlan_tso,
HNS3_TXD_L4T_M,
HNS3_TXD_L4T_S,
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 05/10] net: hns3: Fix for mailbox message truncated problem
From: Salil Mehta @ 2018-07-06 10:27 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Fuyun Liang
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Fuyun Liang <liangfuyun1@huawei.com>
The payload of mailbox message is 16 byte and the value of
HCLGE_MBX_MAX_ARQ_MSG_SIZE is 8. A message truncated problem will
happen when mailbox message is converted to ARQ message. This patch
replaces HCLGE_MBX_MAX_ARQ_MSG_SIZE with the size of ARQ message in
hclgevf_mbx_handler to fix this problem.
Fixes: b11a0bb231f3 ("net: hns3: Add mailbox support to VF driver")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
index 173ca27..e9d5a4f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
@@ -208,7 +208,8 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
/* tail the async message in arq */
msg_q = hdev->arq.msg_q[hdev->arq.tail];
- memcpy(&msg_q[0], req->msg, HCLGE_MBX_MAX_ARQ_MSG_SIZE);
+ memcpy(&msg_q[0], req->msg,
+ HCLGE_MBX_MAX_ARQ_MSG_SIZE * sizeof(u16));
hclge_mbx_tail_ptr_move_arq(hdev->arq);
hdev->arq.count++;
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 06/10] net: hns3: Add configure for mac minimal frame size
From: Salil Mehta @ 2018-07-06 10:28 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Jian Shen
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Jian Shen <shenjian15@huawei.com>
When change the mtu, the minimal frame size of mac will be set
to zero, it is incorrect. This patch fixes it by set it to the
default value.
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 3 ++-
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index d9aaa76..656c3e6 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -571,7 +571,8 @@ struct hclge_config_auto_neg_cmd {
struct hclge_config_max_frm_size_cmd {
__le16 max_frm_size;
- u8 rsv[22];
+ u8 min_frm_size;
+ u8 rsv[21];
};
enum hclge_mac_vlan_tbl_opcode {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index dae1aa5..df6a7a1 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4987,6 +4987,7 @@ static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mtu)
req = (struct hclge_config_max_frm_size_cmd *)desc.data;
req->max_frm_size = cpu_to_le16(max_frm_size);
+ req->min_frm_size = HCLGE_MAC_MIN_FRAME;
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) {
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 07/10] net: hns3: Fix warning bug when doing lp selftest
From: Salil Mehta @ 2018-07-06 10:28 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Yunsheng Lin
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Yunsheng Lin <linyunsheng@huawei.com>
The napi_alloc_skb is excepted to be called under the
non-preemptible code path when it is called by hns3_clean_rx_ring
during loopback selftest, otherwise the below warning will be
logged:
[ 92.420780] BUG: using smp_processor_id() in preemptible
[00000000] code: ethtool/1873
<SNIP>
[ 92.463202] check_preemption_disabled+0xf8/0x100
[ 92.467893] debug_smp_processor_id+0x1c/0x28
[ 92.472239] __napi_alloc_skb+0x30/0x130
[ 92.476158] hns3_clean_rx_ring+0x118/0x5f0 [hns3]
[ 92.480941] hns3_self_test+0x32c/0x4d0 [hns3]
[ 92.485375] ethtool_self_test+0xdc/0x1e8
[ 92.489372] dev_ethtool+0x1020/0x1da8
[ 92.493109] dev_ioctl+0x188/0x3a0
[ 92.496499] sock_do_ioctl+0xf4/0x208
[ 92.500148] sock_ioctl+0x228/0x3e8
[ 92.503626] do_vfs_ioctl+0xc4/0x880
[ 92.507189] SyS_ioctl+0x94/0xa8
[ 92.510404] el0_svc_naked+0x30/0x34
This patch fix it by disabling preemption when calling
hns3_clean_rx_ring during loopback selftest.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 40c0425..11620e0 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -201,7 +201,9 @@ static u32 hns3_lb_check_rx_ring(struct hns3_nic_priv *priv, u32 budget)
rx_group = &ring->tqp_vector->rx_group;
pre_rx_pkt = rx_group->total_packets;
+ preempt_disable();
hns3_clean_rx_ring(ring, budget, hns3_lb_check_skb_data);
+ preempt_enable();
rcv_good_pkt_total += (rx_group->total_packets - pre_rx_pkt);
rx_group->total_packets = pre_rx_pkt;
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 09/10] net: hns3: Remove the warning when clear reset cause
From: Salil Mehta @ 2018-07-06 10:28 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Peng Li <lipeng321@huawei.com>
Only the core/global/IMP reset need clear cause, other type does not
need do it. The warning may be treated as error as it is normal. This
patch removes the warning.
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index df6a7a1..4ca3e6b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2805,8 +2805,6 @@ static void hclge_clear_reset_cause(struct hclge_dev *hdev)
clearval = BIT(HCLGE_VECTOR0_CORERESET_INT_B);
break;
default:
- dev_warn(&hdev->pdev->dev, "Unsupported reset event to clear:%d",
- hdev->reset_type);
break;
}
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 10/10] net: hns3: Prevent sending command during global or core reset
From: Salil Mehta @ 2018-07-06 10:28 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil, netdev,
linux-kernel, linuxarm, Huazhong Tan
In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com>
From: Huazhong Tan <tanhuazhong@huawei.com>
According to hardware's description, driver should not send command to
IMP while hardware doing global or core reset.
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 4 +++-
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
index 82cf12a..eca4b23 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c
@@ -206,7 +206,8 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
spin_lock_bh(&hw->cmq.csq.lock);
- if (num > hclge_ring_space(&hw->cmq.csq)) {
+ if (num > hclge_ring_space(&hw->cmq.csq) ||
+ test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) {
spin_unlock_bh(&hw->cmq.csq.lock);
return -EBUSY;
}
@@ -346,6 +347,7 @@ int hclge_cmd_init(struct hclge_dev *hdev)
spin_lock_init(&hdev->hw.cmq.crq.lock);
hclge_cmd_init_regs(&hdev->hw);
+ clear_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
ret = hclge_cmd_query_firmware_version(&hdev->hw, &version);
if (ret) {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 4ca3e6b..8bbf4e5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -2507,12 +2507,14 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval)
/* check for vector0 reset event sources */
if (BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B) & rst_src_reg) {
+ set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
set_bit(HNAE3_GLOBAL_RESET, &hdev->reset_pending);
*clearval = BIT(HCLGE_VECTOR0_GLOBALRESET_INT_B);
return HCLGE_VECTOR0_EVENT_RST;
}
if (BIT(HCLGE_VECTOR0_CORERESET_INT_B) & rst_src_reg) {
+ set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state);
set_bit(HNAE3_CORE_RESET, &hdev->reset_pending);
*clearval = BIT(HCLGE_VECTOR0_CORERESET_INT_B);
return HCLGE_VECTOR0_EVENT_RST;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 71d38b8..20abe82 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -128,6 +128,7 @@ enum HCLGE_DEV_STATE {
HCLGE_STATE_MBX_SERVICE_SCHED,
HCLGE_STATE_MBX_HANDLING,
HCLGE_STATE_STATISTICS_UPDATING,
+ HCLGE_STATE_CMD_DISABLE,
HCLGE_STATE_MAX
};
--
2.7.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox