Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Wei Wang
On Sun, Jun 2, 2019 at 9:08 PM David Ahern wrote: > > From: David Ahern > > Add struct nexthop and nh_list list_head to fib6_info. nh_list is the > fib6_info side of the nexthop <-> fib_info relationship. Since a fib6_info > referencing a nexthop object can not have 'sibling' entries (the old way

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Wei Wang
On Mon, Jun 3, 2019 at 1:42 PM David Ahern wrote: > > On 6/3/19 12:09 PM, Wei Wang wrote: > >> diff --git a/net/ipv6/route.c b/net/ipv6/route.c > >> index fada5a13bcb2..51cb5cb027ae 100644 > >> --- a/net/ipv6/route.c > >> +++ b/net/ipv6/route.c > &

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Wei Wang
On Mon, Jun 3, 2019 at 3:35 PM David Ahern wrote: > > On 6/3/19 3:58 PM, Wei Wang wrote: > > Hmm... I am still a bit concerned with the ip6_create_rt_rcu() call. > > If we have a blackholed nexthop, the lookup code here always tries to > > create an rt cache entry for ev

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Wei Wang
On Mon, Jun 3, 2019 at 4:18 PM David Ahern wrote: > > On 6/3/19 5:05 PM, Wei Wang wrote: > > On Mon, Jun 3, 2019 at 3:35 PM David Ahern wrote: > >> > >> On 6/3/19 3:58 PM, Wei Wang wrote: > >>> Hmm... I am still a bit concerned with the ip6_create_rt

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-04 Thread Wei Wang
On Tue, Jun 4, 2019 at 2:13 PM David Ahern wrote: > > On 6/4/19 3:06 PM, Martin Lau wrote: > > On Tue, Jun 04, 2019 at 02:17:28PM -0600, David Ahern wrote: > >> On 6/3/19 11:29 PM, Martin Lau wrote: > >>> On Mon, Jun 03, 2019 at 07:36:06PM -0600, David Ahern wrote: > On 6/3/19 6:58 PM, Martin

Re: [PATCH v2 net-next 07/20] ipv6: Handle all fib6_nh in a nexthop in exception handling

2019-06-07 Thread Wei Wang
On Fri, Jun 7, 2019 at 8:09 AM David Ahern wrote: > > From: David Ahern > > Add a hook in rt6_flush_exceptions, rt6_remove_exception_rt, > rt6_update_exception_stamp_rt, and rt6_age_exceptions to handle > nexthop struct in a fib6_info. > > Signed-off-by: David Ahern > --- > net/ipv6/route.c | 1

Re: [PATCH v3 net-next 09/20] ipv6: Handle all fib6_nh in a nexthop in rt6_do_redirect

2019-06-07 Thread Wei Wang
On Fri, Jun 7, 2019 at 4:06 PM David Ahern wrote: > > From: David Ahern > > Use nexthop_for_each_fib6_nh and fib6_nh_find_match to find the > fib6_nh in a nexthop that correlates to the device and gateway > in the rt6_info. > > Signed-off-by: David Ahern > --- > net/ipv6/route.c | 20 ++

Re: [PATCH v4 net-next 00/20] net: Enable nexthop objects with IPv4 and IPv6 routes

2019-06-09 Thread Wei Wang
| 31 +- > net/ipv6/route.c | 458 > +++-- > .../selftests/net/fib_nexthop_multiprefix.sh | 290 + > .../selftests/net/forwarding/router_mpath_nh.sh| 359 ++++++++ > tools/testing/selftests/net/icmp_redirect.sh | 49 +++ > tools/testing/selftests/net/pmtu.sh| 237 --- > 12 files changed, 1672 insertions(+), 113 deletions(-) > create mode 100755 tools/testing/selftests/net/fib_nexthop_multiprefix.sh > create mode 100755 tools/testing/selftests/net/forwarding/router_mpath_nh.sh > > -- > 2.11.0 > For all ipv6 patches: Reviewed-By: Wei Wang

[PATCH net v3] net: fix race between napi kthread mode and busy poll

2021-03-02 Thread Wei Wang
y: Martin Zaharinov Suggested-by: Jakub Kicinski Signed-off-by: Wei Wang Cc: Alexander Duyck Cc: Eric Dumazet Cc: Paolo Abeni Cc: Hannes Frederic Sowa --- include/linux/netdevice.h | 2 ++ net/core/dev.c| 14 +- 2 files changed, 15 insertions(+), 1 deletion(-) d

[PATCH net-next 3/5] ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic

2019-06-18 Thread Wei Wang
From: Wei Wang This patch specifically converts the rule lookup logic to honor this flag and not release refcnt when traversing each rule and calling lookup() on each routing table. Similar to previous patch, we also need some special handling of dst entries in uncached list because there is

[PATCH net-next 0/5] ipv6: avoid taking refcnt on dst during route lookup

2019-06-18 Thread Wei Wang
From: Wei Wang Ipv6 route lookup code always grabs refcnt on the dst for the caller. But for certain cases, grabbing refcnt is not always necessary if the call path is rcu protected and the caller does not cache the dst. Another issue in the route lookup logic is: When there are multiple custom

[PATCH net-next 1/5] ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route()

2019-06-18 Thread Wei Wang
From: Wei Wang This new flag is to instruct the route lookup function to not take refcnt on the dst entry. The user which does route lookup with this flag must properly use rcu protection. ip6_pol_route() is the major route lookup function for both tx and rx path. In this function: Do not take

[PATCH net-next 4/5] ipv6: convert rx data path to not take refcnt on dst

2019-06-18 Thread Wei Wang
From: Wei Wang ip6_route_input() is the key function to do the route lookup in the rx data path. All the callers to this function are already holding rcu lock. So it is fairly easy to convert it to not take refcnt on the dst: We pass in flag RT6_LOOKUP_F_DST_NOREF and do skb_dst_set_noref

[PATCH net-next 2/5] ipv6: initialize rt6->rt6i_uncached in all pre-allocated dst entries

2019-06-18 Thread Wei Wang
From: Wei Wang Initialize rt6->rt6i_uncached on the following pre-allocated dsts: net->ipv6.ip6_null_entry net->ipv6.ip6_prohibit_entry net->ipv6.ip6_blk_hole_entry This is a preparation patch for later commits to be able to distinguish dst entries in uncached list by doing: !li

[PATCH net-next 5/5] ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF

2019-06-18 Thread Wei Wang
From: Wei Wang For tx path, in most cases, we still have to take refcnt on the dst cause the caller is caching the dst somewhere. But it still is beneficial to make use of RT6_LOOKUP_F_DST_NOREF flag while doing the route lookup. It is cause this flag prevents manipulating refcnt on net->i

Re: [PATCH net-next 3/5] ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic

2019-06-19 Thread Wei Wang
On Wed, Jun 19, 2019 at 9:07 AM David Miller wrote: > > From: Wei Wang > Date: Tue, 18 Jun 2019 11:25:41 -0700 > > > @@ -237,13 +240,16 @@ static int __fib6_rule_action(struct fib_rule *rule, > > struct flowi *flp, > > goto out; > >

[PATCH v2 net-next 2/5] ipv6: initialize rt6->rt6i_uncached in all pre-allocated dst entries

2019-06-19 Thread Wei Wang
From: Wei Wang Initialize rt6->rt6i_uncached on the following pre-allocated dsts: net->ipv6.ip6_null_entry net->ipv6.ip6_prohibit_entry net->ipv6.ip6_blk_hole_entry This is a preparation patch for later commits to be able to distinguish dst entries in uncached list by doing: !li

[PATCH v2 net-next 4/5] ipv6: convert rx data path to not take refcnt on dst

2019-06-19 Thread Wei Wang
From: Wei Wang ip6_route_input() is the key function to do the route lookup in the rx data path. All the callers to this function are already holding rcu lock. So it is fairly easy to convert it to not take refcnt on the dst: We pass in flag RT6_LOOKUP_F_DST_NOREF and do skb_dst_set_noref

[PATCH v2 net-next 3/5] ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic

2019-06-19 Thread Wei Wang
From: Wei Wang This patch specifically converts the rule lookup logic to honor this flag and not release refcnt when traversing each rule and calling lookup() on each routing table. Similar to previous patch, we also need some special handling of dst entries in uncached list because there is

[PATCH v2 net-next 5/5] ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF

2019-06-19 Thread Wei Wang
From: Wei Wang For tx path, in most cases, we still have to take refcnt on the dst cause the caller is caching the dst somewhere. But it still is beneficial to make use of RT6_LOOKUP_F_DST_NOREF flag while doing the route lookup. It is cause this flag prevents manipulating refcnt on net->i

[PATCH v2 net-next 1/5] ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route()

2019-06-19 Thread Wei Wang
From: Wei Wang This new flag is to instruct the route lookup function to not take refcnt on the dst entry. The user which does route lookup with this flag must properly use rcu protection. ip6_pol_route() is the major route lookup function for both tx and rx path. In this function: Do not take

[PATCH v2 net-next 0/5] ipv6: avoid taking refcnt on dst during route lookup

2019-06-19 Thread Wei Wang
From: Wei Wang Ipv6 route lookup code always grabs refcnt on the dst for the caller. But for certain cases, grabbing refcnt is not always necessary if the call path is rcu protected and the caller does not cache the dst. Another issue in the route lookup logic is: When there are multiple custom

Re: [PATCH v2 net-next 3/5] ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic

2019-06-19 Thread Wei Wang
On Wed, Jun 19, 2019 at 4:12 PM David Ahern wrote: > > On 6/19/19 4:31 PM, Wei Wang wrote: > > diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c > > index bcfae13409b5..d22b6c140f23 100644 > > --- a/net/ipv6/fib6_rules.c > > +++ b/net/ipv6/fib6_rules.c &g

Re: [PATCH v2 net-next 5/5] ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF

2019-06-19 Thread Wei Wang
On Wed, Jun 19, 2019 at 4:21 PM David Ahern wrote: > > On 6/19/19 4:31 PM, Wei Wang wrote: > > diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h > > index e942372b077b..d8c37317bb86 100644 > > --- a/include/net/l3mdev.h > > +++ b/include/net/l3mdev.h > >

Re: [PATCH net-next] ipv6: Convert gateway validation to use fib6_info

2019-06-20 Thread Wei Wang
On Thu, Jun 20, 2019 at 12:05 PM David Ahern wrote: > > From: David Ahern > > Gateway validation does not need a dst_entry, it only needs the fib > entry to validate the gateway resolution and egress device. So, > convert ip6_nh_lookup_table from ip6_pol_route to fib6_table_lookup > and ip6_route

[PATCH v3 net-next 5/5] ipv6: convert major tx path to use RT6_LOOKUP_F_DST_NOREF

2019-06-20 Thread Wei Wang
From: Wei Wang For tx path, in most cases, we still have to take refcnt on the dst cause the caller is caching the dst somewhere. But it still is beneficial to make use of RT6_LOOKUP_F_DST_NOREF flag while doing the route lookup. It is cause this flag prevents manipulating refcnt on net->i

[PATCH v3 net-next 0/5] ipv6: avoid taking refcnt on dst during route lookup

2019-06-20 Thread Wei Wang
From: Wei Wang Ipv6 route lookup code always grabs refcnt on the dst for the caller. But for certain cases, grabbing refcnt is not always necessary if the call path is rcu protected and the caller does not cache the dst. Another issue in the route lookup logic is: When there are multiple custom

[PATCH v3 net-next 1/5] ipv6: introduce RT6_LOOKUP_F_DST_NOREF flag in ip6_pol_route()

2019-06-20 Thread Wei Wang
From: Wei Wang This new flag is to instruct the route lookup function to not take refcnt on the dst entry. The user which does route lookup with this flag must properly use rcu protection. ip6_pol_route() is the major route lookup function for both tx and rx path. In this function: Do not take

[PATCH v3 net-next 4/5] ipv6: convert rx data path to not take refcnt on dst

2019-06-20 Thread Wei Wang
From: Wei Wang ip6_route_input() is the key function to do the route lookup in the rx data path. All the callers to this function are already holding rcu lock. So it is fairly easy to convert it to not take refcnt on the dst: We pass in flag RT6_LOOKUP_F_DST_NOREF and do skb_dst_set_noref

[PATCH v3 net-next 2/5] ipv6: initialize rt6->rt6i_uncached in all pre-allocated dst entries

2019-06-20 Thread Wei Wang
From: Wei Wang Initialize rt6->rt6i_uncached on the following pre-allocated dsts: net->ipv6.ip6_null_entry net->ipv6.ip6_prohibit_entry net->ipv6.ip6_blk_hole_entry This is a preparation patch for later commits to be able to distinguish dst entries in uncached list by doing: !li

[PATCH v3 net-next 3/5] ipv6: honor RT6_LOOKUP_F_DST_NOREF in rule lookup logic

2019-06-20 Thread Wei Wang
From: Wei Wang This patch specifically converts the rule lookup logic to honor this flag and not release refcnt when traversing each rule and calling lookup() on each routing table. Similar to previous patch, we also need some special handling of dst entries in uncached list because there is

Re: [PATCH v2 net-next] ipv6: Convert gateway validation to use fib6_info

2019-06-25 Thread Wei Wang
fib-onlink-tests.sh and fib_tests.sh are used to > verify the changes. > > Signed-off-by: David Ahern Reviewed-by: Wei Wang > --- > v2 > - use in6_dev_get versus __in6_dev_get + in6_dev_hold (comment from Wei) > - updated commit message > > net/ipv6/route.c | 118 &g

[PATCH net-next] tcp: remove mss check in tcp_select_initial_window()

2018-04-26 Thread Wei Wang
From: Wei Wang In tcp_select_initial_window(), we only set rcv_wnd to tcp_default_init_rwnd() if current mss > (1 << wscale). Otherwise, rcv_wnd is kept at the full receive space of the socket which is a value way larger than tcp_default_init_rwnd(). With larger initial rcv_wnd value

Re: [PATCH net] ipv6: fix possible deadlock in rt6_age_examine_exception()

2018-03-23 Thread Wei Wang
_call_chain+0x2d/0x40 kernel/notifier.c:401 > call_netdevice_notifiers_info+0x32/0x70 net/core/dev.c:1707 > call_netdevice_notifiers net/core/dev.c:1725 [inline] > __dev_notify_flags+0x262/0x430 net/core/dev.c:6960 > dev_change_flags+0xf5/0x140 net/core/dev.c:6994 > devinet_ioc

[PATCH net] ipv6: reset fn->rr_ptr when replacing route

2017-08-16 Thread Wei Wang
From: Wei Wang syzcaller reported the following use-after-free issue in rt6_select(): BUG: KASAN: use-after-free in rt6_select net/ipv6/route.c:755 [inline] at addr 8800bc6994e8 BUG: KASAN: use-after-free in ip6_pol_route.isra.46+0x1429/0x1470 net/ipv6/route.c:1084 at addr 8800bc6994e8

[PATCH net] ipv6: repair fib6 tree in failure case

2017-08-18 Thread Wei Wang
From: Wei Wang In fib6_add(), it is possible that fib6_add_1() picks an intermediate node and sets the node's fn->leaf to NULL in order to add this new route. However, if fib6_add_rt2node() fails to add the new route for some reason, fn->leaf will be left as NULL and could potent

[PATCH net] ipv6: add rcu grace period before freeing fib6_node

2017-08-18 Thread Wei Wang
From: Wei Wang We currently keep rt->rt6i_node pointing to the fib6_node for the route. And some functions make use of this pointer to dereference the fib6_node from rt structure, e.g. rt6_check(). However, as there is neither refcount nor rcu taken when dereferencing rt->rt6i_node, it

Re: [PATCH net] ipv6: add rcu grace period before freeing fib6_node

2017-08-19 Thread Wei Wang
>> + return status; >> + > extra newline. > Thanks. Will remove it in v2. Wei On Fri, Aug 18, 2017 at 7:20 PM, Martin KaFai Lau wrote: > On Fri, Aug 18, 2017 at 05:36:55PM -0700, Wei Wang wrote: >> From: Wei Wang >> >> We currently keep rt->r

[PATCH net v2] ipv6: add rcu grace period before freeing fib6_node

2017-08-19 Thread Wei Wang
From: Wei Wang We currently keep rt->rt6i_node pointing to the fib6_node for the route. And some functions make use of this pointer to dereference the fib6_node from rt structure, e.g. rt6_check(). However, as there is neither refcount nor rcu taken when dereferencing rt->rt6i_node, it

Re: [PATCH net v2] ipv6: add rcu grace period before freeing fib6_node

2017-08-21 Thread Wei Wang
e my change and resubmit. Sorry for the confusion. Thanks. Wei On Sun, Aug 20, 2017 at 7:59 PM, David Miller wrote: > From: Wei Wang > Date: Sat, 19 Aug 2017 17:34:08 -0700 > >> From: Wei Wang >> >> We currently keep rt->rt6i_node pointing to the fib6_node for the

[PATCH net v3] ipv6: add rcu grace period before freeing fib6_node

2017-08-21 Thread Wei Wang
From: Wei Wang We currently keep rt->rt6i_node pointing to the fib6_node for the route. And some functions make use of this pointer to dereference the fib6_node from rt structure, e.g. rt6_check(). However, as there is neither refcount nor rcu taken when dereferencing rt->rt6i_node, it

Re: [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use.

2017-08-23 Thread Wei Wang
te the dst_hold performed by xfrm_lookup > when a per-socket policy is in use. This means that when a > socket policy is in use, dst entries returned by xfrm_lookup have > a refcount of 2, and are not freed when no longer in use. > > Cc: Wei Wang > Fixes: 52df157f17 ("xfrm: take re

[PATCH net] ipv6: fix sparse warning on rt6i_node

2017-08-25 Thread Wei Wang
From: Wei Wang Commit c5cff8561d2d adds rcu grace period before freeing fib6_node. This generates a new sparse warning on rt->rt6i_node related code: net/ipv6/route.c:1394:30: error: incompatible types in comparison expression (different address spaces) ./include/net/ip6_fib.h:187

Re: [PATCH net] ipv6: make ip6_create_rt_rcu return ip6_null_entry instead of NULL

2019-03-18 Thread Wei Wang
On Mon, Mar 18, 2019 at 12:48 PM David Ahern wrote: > > On 3/18/19 12:36 PM, Xin Long wrote: > > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > > index 4ef4bbd..754777d 100644 > > --- a/net/ipv6/route.c > > +++ b/net/ipv6/route.c > > @@ -1040,13 +1040,17 @@ static struct rt6_info *ip6_create_r

Re: [PATCHv2 net] ipv6: make ip6_create_rt_rcu return ip6_null_entry instead of NULL

2019-03-20 Thread Wei Wang
> > So we fix it by simply making ip6_create_rt_rcu() return ip6_null_entry > instead of NULL. > > v1->v2: > - move down 'fallback:' to make it more readable. > > Fixes: e873e4b9cc7e ("ipv6: use fib6_info_hold_safe() when necessary") > Reported-by:

Re: [PATCH net-next] ipv6: Remove fallback argument from ip6_hold_safe

2019-03-20 Thread Wei Wang
On Wed, Mar 20, 2019 at 9:24 AM David Ahern wrote: > > From: David Ahern > > net and null_fallback are redundant. Remove null_fallback in favor of > !net check. > > Signed-off-by: David Ahern > --- Acked-by: Wei Wang > net/ipv6/route.c | 13 ++--- >

Re: [PATCH net-next] net: dst: remove gc leftovers

2019-03-20 Thread Wei Wang
On Wed, Mar 20, 2019 at 12:03 PM Julian Wiedmann wrote: > > Get rid of some obsolete gc-related documentation and macros that were > missed in commit 5b7c9a8ff828 ("net: remove dst gc related code"). > > CC: Wei Wang > Signed-off-by: Julian Wiedmann > --- Acked-b

Re: [PATCH net] ipv6: fix races in ip6_dst_destroy()

2019-04-29 Thread Wei Wang
c R09: 0004c0d1 > R10: 02341940 R11: 000000000246 R12: > R13: 7ffeafc2a7f0 R14: 0004c065 R15: 7ffeafc2a800 > > Fixes: a68886a69180 ("net/ipv6: Make from in rt6_info rcu protected") > Signed-off-by: Eric

Re: [PATCH net] ipv6: A few fixes on dereferencing rt->from

2019-04-30 Thread Wei Wang
king is also needed on rt->from for a similar reason. >Note that inet6_rtm_getroute() is using RTNL_FLAG_DOIT_UNLOCKED. > > Fixes: a68886a69180 ("net/ipv6: Make from in rt6_info rcu protected") > Signed-off-by: Martin KaFai Lau > --- Acked-by: Wei Wang Nice fix. Tha

Re: IPv6 PMTU discovery fails with source-specific routing

2019-05-13 Thread Wei Wang
Thanks Mikael for reporting this issue. And thanks David for the bisection. Let me spend some time to reproduce it and see what is going on. From: David Ahern Date: Mon, May 13, 2019 at 8:35 PM To: Mikael Magnusson, , Martin KaFai Lau, Wei Wang > On 5/13/19 1:22 PM, Mikael Magnusson wr

Re: IPv6 PMTU discovery fails with source-specific routing

2019-05-14 Thread Wei Wang
#endif } Why do we need to check that the route is not gateway and has next hop for updating rt6i_src? I checked the git history and it seems this part was there from very early on (with some refactor in between)... From: Stefano Brivio Date: Tue, May 14, 2019 at 7:33 AM To: Mikael Mag

[PATCH net] ipv6: fix src addr routing with the exception table

2019-05-14 Thread Wei Wang
From: Wei Wang When inserting route cache into the exception table, the key is generated with both src_addr and dest_addr with src addr routing. However, current logic always assumes the src_addr used to generate the key is a /128 host address. This is not true in the following scenarios: 1

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Wei Wang
) calls rt6_find_cached_rt() to find the cached route first. And rt6_find_cached_rt() is taken care of to find the cached route according to both passed in src addr and f6i->fib6_src. So I think we are good here. From: David Ahern Date: Wed, May 15, 2019 at 9:38 AM To: Wei Wang, David Miller,

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Wei Wang
From: Wei Wang Date: Wed, May 15, 2019 at 10:25 AM To: David Ahern Cc: Wei Wang, David Miller, Linux Kernel Network Developers, Martin KaFai Lau, Mikael Magnusson, Eric Dumazet > > > > What about rt6_remove_exception_rt? > > > > You can add a 'cache' hook to

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Wei Wang
From: David Ahern Date: Wed, May 15, 2019 at 10:33 AM To: Wei Wang Cc: Wei Wang, David Miller, Linux Kernel Network Developers, Martin KaFai Lau, Mikael Magnusson, Eric Dumazet > On 5/15/19 11:28 AM, Wei Wang wrote: > > From: Wei Wang > > Date: Wed, May 15, 2019 at 10:25 AM >

Re: IPv6 PMTU discovery fails with source-specific routing

2019-05-15 Thread Wei Wang
On Wed, May 15, 2019 at 11:06 AM Martin Lau wrote: > > On Tue, May 14, 2019 at 12:33:25PM -0700, Wei Wang wrote: > > I think the bug is because when creating exceptions, src_addr is not > > always set even though fib6_info is in the subtree. (because of > > rt6_is

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Wei Wang
On Wed, May 15, 2019 at 2:51 PM Martin Lau wrote: > > On Tue, May 14, 2019 at 05:46:10PM -0700, Wei Wang wrote: > > From: Wei Wang > > > > When inserting route cache into the exception table, the key is > > generated with both src_addr and dest_addr with src addr

Re: [PATCH net] ipv6: prevent possible fib6 leaks

2019-05-15 Thread Wei Wang
> > I decided to add another boolean (fib6_destroying) instead > of reusing/renaming exception_bucket_flushed to ease stable backports, > and properly document the memory barriers used to implement this fix. > > This patch has been co-developped with Wei Wang. > > Fixes: 93531c674315 (&

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Wei Wang
On Wed, May 15, 2019 at 5:07 PM David Ahern wrote: > > On 5/15/19 6:03 PM, Wei Wang wrote: > > Thanks Martin. > > Changing __rt6_find_exception_xxx() might not be easy cause other > > callers of this function does not really need to back off and use > > another sa

[PATCH v2 net] ipv6: fix src addr routing with the exception table

2019-05-16 Thread Wei Wang
From: Wei Wang When inserting route cache into the exception table, the key is generated with both src_addr and dest_addr with src addr routing. However, current logic always assumes the src_addr used to generate the key is a /128 host address. This is not true in the following scenarios: 1

Re: [PATCH v2 net] ipv6: fix src addr routing with the exception table

2019-05-16 Thread Wei Wang
On Thu, May 16, 2019 at 12:15 PM Martin Lau wrote: > > On Thu, May 16, 2019 at 11:16:20AM -0700, Wei Wang wrote: > > From: Wei Wang > > > > When inserting route cache into the exception table, the key is > > generated with both src_addr and dest_addr with src addr

[PATCH v3 net] ipv6: fix src addr routing with the exception table

2019-05-16 Thread Wei Wang
From: Wei Wang When inserting route cache into the exception table, the key is generated with both src_addr and dest_addr with src addr routing. However, current logic always assumes the src_addr used to generate the key is a /128 host address. This is not true in the following scenarios: 1

[PATCH net-next 04/16] ipv6: prepare rt6_mtu_change() for exception table

2017-10-06 Thread Wei Wang
From: Wei Wang If we move all cached dst into the exception table under the main route, current rt6_mtu_change() will no longer be able to access them. This commit makes rt6_mtu_change_route() function to also go through all cached routes in the exception table under the main route and do proper

[PATCH net-next 07/16] ipv6: prepare fib6_locate() for exception table

2017-10-06 Thread Wei Wang
From: Wei Wang fib6_locate() is used to find the fib6_node according to the passed in prefix address key. It currently tries to find the fib6_node with the exact match of the passed in key. However, when we move cached routes into the exception table, fib6_locate() will fail to find the

[PATCH net-next 00/16] ipv6: replace rwlock with rcu and spinlock in fib6 table

2017-10-06 Thread Wei Wang
From: Wei Wang Currently, fib6 table is protected by rwlock. During route lookup, reader lock is taken and during route insertion, deletion or modification, writer lock is taken. This is a very inefficient implementation because the fastpath always has to do the operation to grab the reader lock

[PATCH net-next 02/16] ipv6: introduce a hash table to store dst cache

2017-10-06 Thread Wei Wang
From: Wei Wang Add a hash table into struct rt6_info in order to store dst caches created by pmtu discovery and ip redirect in ipv6 routing code. APIs to add dst cache, delete dst cache, find dst cache and update dst cache in the hash table are implemented and will be used in later commits. This

[PATCH net-next 12/16] ipv6: update fn_sernum after route is inserted to tree

2017-10-06 Thread Wei Wang
From: Wei Wang fib6_add() logic currently calls fib6_add_1() to figure out what node should be used for the newly added route and then call fib6_add_rt2node() to insert the route to the node. And during the call of fib6_add_1(), fn_sernum is updated for all nodes that share the same prefix as

[PATCH net-next 14/16] ipv6: add key length check into rt6_select()

2017-10-06 Thread Wei Wang
From: Wei Wang After rwlock is replaced with rcu and spinlock, fib6_lookup() could potentially return an intermediate node if other thread is doing fib6_del() on a route which is the only route on the node so that fib6_repair_tree() will be called on this node and potentially assigns fn->leaf

[PATCH net-next 08/16] ipv6: hook up exception table to store dst cache

2017-10-06 Thread Wei Wang
From: Wei Wang This commit makes use of the exception hash table implementation to store dst caches created by pmtu discovery and ip redirect into the hash table under the rt_info and no longer inserts these routes into fib6 tree. This makes the fib6 tree only contain static configured routes

[PATCH net-next 16/16] ipv6: take care of rt6_stats

2017-10-06 Thread Wei Wang
From: Wei Wang Currently, most of the rt6_stats are not hooked up correctly. As the last part of this patch series, hook up all existing rt6_stats and add one new stat fib_rt_uncache to indicate the number of routes in the uncached list. For details of the stats, please refer to the comments

[PATCH net-next 13/16] ipv6: check fn->leaf before it is used

2017-10-06 Thread Wei Wang
From: Wei Wang If rwlock is replaced with rcu and spinlock, it is possible that the reader thread will see fn->leaf as NULL in the following scenarios: 1. fib6_add() is in progress and we have already inserted a new node but not yet inserted the route. 2. fib6_del_route() is in progress and

[PATCH net-next 15/16] ipv6: replace rwlock with rcu and spinlock in fib6_table

2017-10-06 Thread Wei Wang
From: Wei Wang With all the preparation work before, we are now ready to replace rwlock with rcu and spinlock in fib6_table. That means now all fib6_node in fib6_table are protected by rcu. And when freeing fib6_node, call_rcu() is used to wait for the rcu grace period before releasing the

[PATCH net-next 09/16] ipv6: grab rt->rt6i_ref before allocating pcpu rt

2017-10-06 Thread Wei Wang
From: Wei Wang After rwlock is replaced with rcu and spinlock, ip6_pol_route() will be called with only rcu held. That means rt6 route deletion could happen simultaneously with rt6_make_pcpu_rt(). This could potentially cause memory leak if rt6_release() is called right before rt6_make_pcpu_rt

[PATCH net-next 10/16] ipv6: don't release rt->rt6i_pcpu memory during rt6_release()

2017-10-06 Thread Wei Wang
From: Wei Wang After rwlock is replaced with rcu and spinlock, route lookup can happen simultanously with route deletion. This patch removes the call to free_percpu(rt->rt6i_pcpu) from rt6_release() to avoid the race condition between rt6_release() and rt6_get_pcpu_route(). And as free_percpu

[PATCH net-next 03/16] ipv6: prepare fib6_remove_prefsrc() for exception table

2017-10-06 Thread Wei Wang
From: Wei Wang After we move cached dst entries into the exception table under its parent route, current fib6_remove_prefsrc() no longer can access them. This commit makes fib6_remove_prefsrc() also go through all routes in the exception table to remove the pref src. This is a preparation patch

[PATCH net-next 05/16] ipv6: prepare rt6_clean_tohost() for exception table

2017-10-06 Thread Wei Wang
From: Wei Wang If we move all cached dst into the exception table under the main route, current rt6_clean_tohost() will no longer be able to access them. This commit makes fib6_clean_tohost() to also go through all cached routes in exception table and removes cached gateway routes to the passed

[PATCH net-next 01/16] ipv6: introduce a new function fib6_update_sernum()

2017-10-06 Thread Wei Wang
From: Wei Wang This function takes a route as input and tries to update the sernum in the fib6_node this route is associated with. It will be used in later commit when adding a cached route into the exception table under that route. Signed-off-by: Wei Wang Signed-off-by: Martin KaFai Lau

[PATCH net-next 06/16] ipv6: prepare fib6_age() for exception table

2017-10-06 Thread Wei Wang
From: Wei Wang If all dst cache entries are stored in the exception table under the main route, we have to go through them during fib6_age() when doing garbage collecting. Introduce a new function rt6_age_exception() which goes through all dst entries in the exception table and remove those

[PATCH net-next 11/16] ipv6: replace dst_hold() with dst_hold_safe() in routing code

2017-10-06 Thread Wei Wang
From: Wei Wang With rwlock, it is safe to call dst_hold() in the read thread because read thread is guaranteed to be separated from write thread. However, after we replace rwlock with rcu, it is no longer safe to use dst_hold(). A dst might already have been deleted but is waiting for the rcu

Re: [PATCH net-next 11/16] ipv6: replace dst_hold() with dst_hold_safe() in routing code

2017-10-06 Thread Wei Wang
On Fri, Oct 6, 2017 at 4:57 PM, 吉藤英明 wrote: > Hi, > > 2017-10-07 4:06 GMT+09:00 Wei Wang : >> diff --git a/net/ipv6/route.c b/net/ipv6/route.c >> index 941c062389d2..aeb349aea429 100644 >> --- a/net/ipv6/route.c >> +++ b/net/ipv6/route.c > : >&g

[PATCH net-next] ipv6: use rcu_dereference_bh() in ipv6_route_seq_next()

2017-10-09 Thread Wei Wang
From: Wei Wang This patch replaces rcu_deference() with rcu_dereference_bh() in ipv6_route_seq_next() to avoid the following warning: [ 19.431685] WARNING: suspicious RCU usage [ 19.433451] 4.14.0-rc3-00914-g66f5d6c #118 Not tainted [ 19.435509] - [ 19.437267

Re: [PATCH][net-next] ipv6: fix incorrect bitwise operator used on rt6i_flags

2017-10-10 Thread Wei Wang
er suspect to me. I >> believe this is fixed by using & instead to just check the >> RTF_CACHE entry bit. > Good catch. LGTM. If rt does not have RTF_CACHE set, it should not be in the > exception table. > > Acked-by: Martin KaFai Lau > Thanks a lot for catching this

Re: [PATCH][V2] ipv6: fix incorrect bitwise operator used on rt6i_flags

2017-10-10 Thread Wei Wang
1457734, #1457747 ("Wrong operator used") > > Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache") > Signed-off-by: Colin Ian King > --- Acked-by: Wei Wang > net/ipv6/route.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(

[PATCH net-next] ipv6: check fn before doing FIB6_SUBTREE(fn)

2017-10-13 Thread Wei Wang
From: Wei Wang In fib6_locate(), we need to first make sure fn is not NULL before doing FIB6_SUBTREE(fn) to avoid crash. This fixes the following static checker warning: net/ipv6/ip6_fib.c:1462 fib6_locate() warn: variable dereferenced before check 'fn' (see line 1459)

[PATCH net-next] ipv6: only update __use and lastusetime once per jiffy at most

2017-10-13 Thread Wei Wang
From: Wei Wang In order to not dirty the cacheline too often, we try to only update dst->__use and dst->lastusetime at most once per jiffy. As dst->lastusetime is only used by ipv6 garbage collector, it should be good enough time resolution. And __use is only used in ipv6_route_seq_

Re: [PATCH net-next 1/3] ipv6: fix route cache dump

2017-10-17 Thread Wei Wang
On Tue, Oct 17, 2017 at 10:40 AM, Paolo Abeni wrote: > After the commit 2b760fcf5cfb ("ipv6: hook up exception table to > store dst cache"), entries in the routing cache are not shown by: > > ip route show cache > > because the per route exception table containing such routes is not > traversed by

Re: [PATCH net-next 2/3] ipv6: start fib6 gc on RTF_CACHE dst creation

2017-10-17 Thread Wei Wang
timer will run for whatever time needed to properly > clean the table. > > Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache") > Signed-off-by: Paolo Abeni > --- Acked-by: Wei Wang Totally true. Thanks for catching this. > net/ipv6/route.c | 4 +

Re: [PATCH net-next 3/3] ipv6: obsolete cached dst when removing them from fib tree

2017-10-17 Thread Wei Wang
On Tue, Oct 17, 2017 at 10:40 AM, Paolo Abeni wrote: > The commit 2b760fcf5cfb ("ipv6: hook up exception table to store > dst cache") partially reverted 1e2ea8ad37be ("ipv6: set > dst.obsolete when a cached route has expired"). > > This change brings back the dst obsoleting and push it a step > fa

Re: [PATCH net-next 3/3] ipv6: obsolete cached dst when removing them from fib tree

2017-10-17 Thread Wei Wang
On Tue, Oct 17, 2017 at 1:02 PM, Paolo Abeni wrote: > On Tue, 2017-10-17 at 11:58 -0700, Wei Wang wrote: >> On Tue, Oct 17, 2017 at 10:40 AM, Paolo Abeni wrote: >> > The commit 2b760fcf5cfb ("ipv6: hook up exception table to store >> > dst cache") partia

[PATCH net-next] tcp: ignore rcv_rtt sample with old ts ecr value

2018-06-19 Thread Wei Wang
From: Wei Wang When receiving multiple packets with the same ts ecr value, only try to compute rcv_rtt sample with the earliest received packet. This is because the rcv_rtt calculated by later received packets could possibly include long idle time or other types of delay. For example: (1) server

Re: [PATCH RFC net-next 07/20] net/ipv6: Move nexthop data to fib6_nh

2018-02-26 Thread Wei Wang
On Sun, Feb 25, 2018 at 11:47 AM, David Ahern wrote: > Introduce fib6_nh structure and move nexthop related data from > rt6_info and rt6_info.dst to fib6_nh. References to dev, gateway or > lwtstate from a FIB lookup perspective are converted to use fib6_nh; > datapath references to dst version ar

Re: [PATCH RFC net-next 10/20] net/ipv6: move expires into rt6_info

2018-02-26 Thread Wei Wang
On Sun, Feb 25, 2018 at 11:47 AM, David Ahern wrote: > Add expires to rt6_info for FIB entries, and add fib6 helpers to > manage it. Data path use of dst.expires remains. > > Signed-off-by: David Ahern > --- > include/net/ip6_fib.h | 26 +- > net/ipv6/addrconf.c | 6 ++

Re: [PATCH RFC net-next 16/20] net/ipv6: Cleanup exception route handling

2018-02-26 Thread Wei Wang
On Sun, Feb 25, 2018 at 11:47 AM, David Ahern wrote: > IPv6 FIB will only contain FIB entries with exception routes added to > the FIB entry. Remove CACHE and dst checks from fib6 add and delete since > they can never happen once the data type changes. > > Fixup the lookup functions to use a f6i n

Re: [PATCH RFC net-next 07/20] net/ipv6: Move nexthop data to fib6_nh

2018-02-26 Thread Wei Wang
On Mon, Feb 26, 2018 at 2:47 PM, David Ahern wrote: > On 2/26/18 3:28 PM, Wei Wang wrote: >> On Sun, Feb 25, 2018 at 11:47 AM, David Ahern wrote: >>> Introduce fib6_nh structure and move nexthop related data from >>> rt6_info and rt6_info.dst to fib6_nh. Re

Re: [PATCH RFC net-next 10/20] net/ipv6: move expires into rt6_info

2018-02-26 Thread Wei Wang
On Mon, Feb 26, 2018 at 2:55 PM, David Ahern wrote: > On 2/26/18 3:28 PM, Wei Wang wrote: >>> @@ -213,11 +234,6 @@ static inline void rt6_set_expires(struct rt6_info >>> *rt, unsigned long expires) >>> >>> static inline void rt6_update_ex

Re: [PATCH RFC net-next 16/20] net/ipv6: Cleanup exception route handling

2018-02-26 Thread Wei Wang
On Mon, Feb 26, 2018 at 3:02 PM, David Ahern wrote: > On 2/26/18 3:29 PM, Wei Wang wrote: >> On Sun, Feb 25, 2018 at 11:47 AM, David Ahern wrote: >>> IPv6 FIB will only contain FIB entries with exception routes added to >>> the FIB entry. Remove CACHE and dst chec

Re: Latest net-next from GIT panic

2017-09-20 Thread Wei Wang
>> This is why I suggested to replace the BUG() in another mail >> >> So : >> >> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h >> index >> f535779d9dc1dfe36934c2abba4e43d053ac5d6f..220cd12456754876edf2d3ef13195e82d70d5c74 >> 100644 >> --- a/include/linux/netdevice.h >> +++ b/in

Re: Latest net-next from GIT panic

2017-09-20 Thread Wei Wang
>>> bisected again and same result: >>> b838d5e1c5b6e57b10ec8af2268824041e3ea911 is the first bad commit >>> commit b838d5e1c5b6e57b10ec8af2268824041e3ea911 >>> Author: Wei Wang >>> Date: Sat Jun 17 10:42:32 2017 -0700 >>> >>&g

Re: Latest net-next from GIT panic

2017-09-20 Thread Wei Wang
,7 +271,7 @@ static inline void dst_use_noref(struct dst_entry *dst, unsigned long time) static inline struct dst_entry *dst_clone(struct dst_entry *dst) { if (dst) - atomic_inc(&dst->__refcnt); + dst_hold(dst); return dst; } Thanks. We

Re: [PATCH net] net: prevent dst uses after free

2017-09-21 Thread Wei Wang
up to commit 44ebe79149ff ("net: add debug > atomic_inc_not_zero() in dst_hold()") > > In net-next we will convert dst atomic_t to refcount_t for peace of > mind. > > Fixes: a4c2fd7f7891 ("net: remove DST_NOCACHE flag") > Signed-off-by: Eric Dumazet > Cc

  1   2   3   >