Re: [PATCH iproute2] ss: add support for bytes_sent, bytes_retrans, dsack_dups and reord_seen

2018-11-29 Thread Wei Wang
On Thu, Nov 29, 2018 at 2:28 AM Eric Dumazet wrote: > > Wei Wang added these fields in linux-4.19 > > Tested: > > ss -ti ... > > ts sack cubic wscale:8,8 rto:7 rtt:2.678/0.267 mss:1428 pmtu:1500 > rcvmss:536 advmss:1428 cwnd:91 ssthresh:65 > (*) bytes_

[PATCH net] ipv6: take rcu lock in rawv6_send_hdrinc()

2018-10-04 Thread Wei Wang
From: Wei Wang In rawv6_send_hdrinc(), in order to avoid an extra dst_hold(), we directly assign the dst to skb and set passed in dst to NULL to avoid double free. However, in error case, we free skb and then do stats update with the dst pointer passed in. This causes use-after-free on the dst

Re: [PATCH net 2/2] ipv6: fix memory leak on dst->_metrics

2018-09-18 Thread Wei Wang
On Tue, Sep 18, 2018 at 4:25 PM David Ahern wrote: > > On 9/18/18 1:45 PM, Wei Wang wrote: > > From: Wei Wang > > > > When dst->_metrics and f6i->fib6_metrics share the same memory, both > > take reference count on the dst_metrics structure. However, when d

[PATCH net 2/2] ipv6: fix memory leak on dst->_metrics

2018-09-18 Thread Wei Wang
From: Wei Wang When dst->_metrics and f6i->fib6_metrics share the same memory, both take reference count on the dst_metrics structure. However, when dst is destroyed, ip6_dst_destroy() only invokes dst_destroy_metrics_generic() which does not take care of READONLY metrics and does not r

[PATCH net 1/2] Revert "ipv6: fix double refcount of fib6_metrics"

2018-09-18 Thread Wei Wang
From: Wei Wang This reverts commit e70a3aad44cc8b24986687ffc98c4a4f6ecf25ea. This change causes use-after-free on dst->_metrics. The crash trace looks like this: [ 97.763269] BUG: KASAN: use-after-free in ip6_mtu+0x116/0x140 [ 97.769038] Read of size 4 at addr 881781d2cf84 by t

[PATCH net 0/2] ipv6: fix issues on accessing fib6_metrics

2018-09-18 Thread Wei Wang
From: Wei Wang The latest fix on the memory leak of fib6_metrics still causes use-after-free. This patch series first revert the previous fix and propose a new fix that is more inline with ipv4 logic and is tested to fix the use-after-free issue reported. Wei Wang (2): Revert "ipv6

Re: BUG: unable to handle kernel paging request in fib6_node_lookup_1

2018-09-05 Thread Wei Wang
On Tue, Sep 4, 2018 at 11:11 PM Song Liu wrote: > > We are debugging an issue with fib6_node_lookup_1(). > > We use a 4.16 based kernel, and we have back ported most upstream > patches in ip6_fib.{c.h}. The only major differences I can spot are > > 8b7f2731bd68d83940714ce92381d1a72596407c >

[PATCH net v2] l2tp: use sk_dst_check() to avoid race on sk->sk_dst_cache

2018-08-10 Thread Wei Wang
From: Wei Wang In l2tp code, if it is a L2TP_UDP_ENCAP tunnel, tunnel->sk points to a UDP socket. User could call sendmsg() on both this tunnel and the UDP socket itself concurrently. As l2tp_xmit_skb() holds socket lock and call __sk_dst_check() to refresh sk->sk_dst_cache, while udpv6_s

[PATCH net] l2tp: use sk_dst_check() to avoid race on sk->sk_dst_cache

2018-08-09 Thread Wei Wang
From: Wei Wang In l2tp code, if it is a L2TP_UDP_ENCAP tunnel, tunnel->sk points to a UDP socket. User could call sendmsg() on both this tunnel and the UDP socket itself concurrently. As l2tp_xmit_skb() holds socket lock and call __sk_dst_check() to refresh sk->sk_dst_cache, while udpv6_s

[PATCH v2 net-next 0/5] tcp: add 4 new stats

2018-07-31 Thread Wei Wang
From: Wei Wang This patch series adds 3 RFC4898 stats: 1. tcpEStatsPerfHCDataOctetsOut 2. tcpEStatsPerfOctetsRetrans 3. tcpEStatsStackDSACKDups and an addtional stat to record the number of data packet reordering events seen: 4. tcp_reord_seen Together with the existing stats, application can

[PATCH v2 net-next 5/5] tcp: add stat of data packet reordering events

2018-07-31 Thread Wei Wang
From: Wei Wang Introduce a new TCP stats to record the number of reordering events seen and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Application can use this stats to track the frequency of the reordering events in addition to the existing reordering

[PATCH v2 net-next 2/5] tcp: add data bytes sent stats

2018-07-31 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of bytes sent (RFC4898 tcpEStatsPerfHCDataOctetsOut) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked-by: Soheil

[PATCH v2 net-next 4/5] tcp: add dsack blocks received stats

2018-07-31 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of DSACK blocks received (RFC4989 tcpEStatsStackDSACKDups) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked

[PATCH v2 net-next 3/5] tcp: add data bytes retransmitted stats

2018-07-31 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of bytes retransmitted (RFC4898 tcpEStatsPerfOctetsRetrans) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked

[PATCH v2 net-next 1/5] tcp: add a helper to calculate size of opt_stats

2018-07-31 Thread Wei Wang
From: Wei Wang This is to refactor the calculation of the size of opt_stats to a helper function to make the code cleaner and easier for later changes. Suggested-by: Stephen Hemminger Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked-by: Soheil Hassas Yeganeh

Re: [PATCH net-next 2/4] tcp: add data bytes retransmitted stats

2018-07-30 Thread Wei Wang
On Mon, Jul 30, 2018 at 3:14 PM Stephen Hemminger wrote: > > On Mon, 30 Jul 2018 14:59:09 -0700 > Wei Wang wrote: > > > + stats = alloc_skb(9 * nla_total_size_64bit(sizeof(u64)) + > > 7 * nla_total_size(sizeof(u32)) + > >

[PATCH net-next 0/4] tcp: add 4 new stats

2018-07-30 Thread Wei Wang
From: Wei Wang This patch series adds 3 RFC4898 stats: 1. tcpEStatsPerfHCDataOctetsOut 2. tcpEStatsPerfOctetsRetrans 3. tcpEStatsStackDSACKDups and an addtional stat to record the number of data packet reordering events seen: 4. tcp_reord_seen Together with the existing stats, application can

[PATCH net-next 2/4] tcp: add data bytes retransmitted stats

2018-07-30 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of bytes retransmitted (RFC4898 tcpEStatsPerfOctetsRetrans) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked

[PATCH net-next 1/4] tcp: add data bytes sent stats

2018-07-30 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of bytes sent (RFC4898 tcpEStatsPerfHCDataOctetsOut) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked-by: Soheil

[PATCH net-next 3/4] tcp: add dsack blocks received stats

2018-07-30 Thread Wei Wang
From: Wei Wang Introduce a new TCP stat to record the number of DSACK blocks received (RFC4989 tcpEStatsStackDSACKDups) and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Signed-off-by: Wei Wang Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Acked

[PATCH net-next 4/4] tcp: add stat of data packet reordering events

2018-07-30 Thread Wei Wang
From: Wei Wang Introduce a new TCP stats to record the number of reordering events seen and expose it in both tcp_info (TCP_INFO) and opt_stats (SOF_TIMESTAMPING_OPT_STATS). Application can use this stats to track the frequency of the reordering events in addition to the existing reordering

[PATCH net] ipv6: use fib6_info_hold_safe() when necessary

2018-07-21 Thread Wei Wang
From: Wei Wang In the code path where only rcu read lock is held, e.g. in the route lookup code path, it is not safe to directly call fib6_info_hold() because the fib6_info may already have been deleted but still exists in the rcu grace period. Holding reference to it could cause double free

[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

[PATCH bpf-next] bpf: prevent non-IPv4 socket to be added into sock hash

2018-05-30 Thread Wei Wang
From: Wei Wang Sock hash only supports IPv4 socket proto right now. If a non-IPv4 socket gets stored in the BPF map, sk->sk_prot gets overwritten with the v4 tcp prot. Syskaller reported the following related issue on an IPv6 socket: BUG: KASAN: slab-out-of-bounds in ip6_dst_idev include/

[PATCH bpf] bpf: prevent non-ipv4 socket to be added into sock map

2018-05-30 Thread Wei Wang
From: Wei Wang Sock map only supports IPv4 socket proto right now. If a non-IPv4 socket gets stored in the BPF map, sk->sk_prot gets overwritten with the v4 tcp prot. It could potentially cause issues when invoking functions from sk->sk_prot later in the stack. Fixes: 174a79ff9515

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

2018-04-26 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2018-03-23 Thread Wei Wang
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_ioctl+0x126a/0x1ac0 net/ipv4/devinet.c:1080 > inet_ioctl+0x184/0x310

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 <dsah...@gmail.com> wrote: > On 2/26/18 3:29 PM, Wei Wang wrote: >> On Sun, Feb 25, 2018 at 11:47 AM, David Ahern <dsah...@gmail.com> wrote: >>> IPv6 FIB will only contain FIB entries with exception routes added to &

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 <dsah...@gmail.com> 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

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 <dsah...@gmail.com> wrote: > On 2/26/18 3:28 PM, Wei Wang wrote: >> On Sun, Feb 25, 2018 at 11:47 AM, David Ahern <dsah...@gmail.com> wrote: >>> Introduce fib6_nh structure and move nexthop related data from >>&g

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

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

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

Re: [vhost:vhost 20/20] ERROR: "page_poisoning_enabled" [drivers/virtio/virtio_balloon.ko] undefined!

2018-02-06 Thread Wei Wang
On 02/07/2018 09:26 AM, kbuild test robot wrote: tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost head: 96bcd04462b99e2c80e09f6537770a0ca6b288d0 commit: 96bcd04462b99e2c80e09f6537770a0ca6b288d0 [20/20] virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT config:

Re: suspicious RCU usage at net/ipv6/ip6_fib.c:LINE

2018-02-01 Thread Wei Wang
On Thu, Feb 1, 2018 at 2:56 PM, Eric Biggers wrote: > +wei...@google.com > > On Tue, Jan 02, 2018 at 03:58:02PM -0800, syzbot wrote: >> Hello, >> >> syzkaller hit the following crash on >> 6bb8824732f69de0f233ae6b1a8158e149627b38 >>

Re: general protection fault in fib6_add (2)

2018-01-30 Thread Wei Wang
On Tue, Jan 30, 2018 at 5:16 PM, Eric Biggers <ebigge...@gmail.com> wrote: > On Wed, Jan 03, 2018 at 10:53:02AM -0800, 'Wei Wang' via syzkaller-bugs wrote: >> On Wed, Jan 3, 2018 at 8:16 AM, David Ahern <dsah...@gmail.com> wrote: >> > [ +wei...@google.com ] >&

Re: [PATCH net] ipv6: change route cache aging logic

2018-01-26 Thread Wei Wang
On Fri, Jan 26, 2018 at 12:05 PM, Martin KaFai Lau <ka...@fb.com> wrote: > On Fri, Jan 26, 2018 at 11:40:17AM -0800, Wei Wang wrote: >> From: Wei Wang <wei...@google.com> >> >> In current route cache aging logic, if a route has both RTF_EXPIRE and >> RTF_GATE

[PATCH net] ipv6: change route cache aging logic

2018-01-26 Thread Wei Wang
From: Wei Wang <wei...@google.com> In current route cache aging logic, if a route has both RTF_EXPIRE and RTF_GATEWAY set, the route will only be removed if the neighbor cache has no RTN_ROUTE flag. Otherwise, even if the route has expired, it won't get deleted. Fix this logic to always

Re: [PATCH net] ipv6: don't let tb6_root node share routes with other node

2018-01-19 Thread Wei Wang
On Fri, Jan 19, 2018 at 1:36 PM, Wei Wang <wei...@google.com> wrote: > > > On Fri, Jan 19, 2018 at 1:13 PM, Ido Schimmel <ido...@idosch.org> wrote: >> Hi Wei, Martin, >> >> On Thu, Jan 18, 2018 at 03:31:29PM -0800, Wei Wang wrote: >>> On Thu, Jan 18,

Re: [PATCH net] ipv6: don't let tb6_root node share routes with other node

2018-01-18 Thread Wei Wang
On Thu, Jan 18, 2018 at 2:47 PM, Martin KaFai Lau <ka...@fb.com> wrote: > On Thu, Jan 18, 2018 at 10:40:03AM -0800, Wei Wang wrote: >> From: Wei Wang <wei...@google.com> >> >> After commit 4512c43eac7e, if we add a route to the subtree of tb6_root >>

[PATCH net] ipv6: don't let tb6_root node share routes with other node

2018-01-18 Thread Wei Wang
From: Wei Wang <wei...@google.com> After commit 4512c43eac7e, if we add a route to the subtree of tb6_root which does not have any route attached to it yet, the current code will let tb6_root and the node in the subtree share the same route. This could cause problem cause tb6_root has RT

Re: KASAN: slab-out-of-bounds Write in tcp_v6_syn_recv_sock

2018-01-17 Thread Wei Wang
On Wed, Jan 3, 2018 at 3:31 PM, Cong Wang wrote: > > On Wed, Jan 3, 2018 at 12:55 PM, Ozgur wrote: > > > > > > 03.01.2018, 21:57, "Cong Wang" : > >> On Tue, Jan 2, 2018 at 3:58 PM, syzbot > >>

Re: [bisected] Forwarded packets occasionally has loopback output interface in Netfilter

2018-01-11 Thread Wei Wang
On Thu, Jan 11, 2018 at 9:25 AM, Anders K. Pedersen | Cohaesio wrote: > On tir, 2017-12-26 at 12:05 +0100, Anders K. Pedersen | Cohaesio wrote: >> Hello, >> >> On one of our border routers, Netfilter is occasionally logging packets >> with "OUT=lo" (output interface lo) even

[PATCH net v2] ipv6: remove null_entry before adding default route

2018-01-08 Thread Wei Wang
From: Wei Wang <wei...@google.com> In the current code, when creating a new fib6 table, tb6_root.leaf gets initialized to net->ipv6.ip6_null_entry. If a default route is being added with rt->rt6i_metric = 0x, fib6_add() will add this route after net->ipv6.ip6_null_entry

Re: [PATCH net] ipv6: remove null_entry before adding default route

2018-01-07 Thread Wei Wang
On Sat, Jan 6, 2018 at 10:16 PM, Martin KaFai Lau <ka...@fb.com> wrote: > On Sat, Jan 06, 2018 at 05:41:28PM -0800, Wei Wang wrote: >> On Fri, Jan 5, 2018 at 11:42 PM, Martin KaFai Lau <ka...@fb.com> wrote: >> > On Fri, Jan 05, 2018 at 05:38:35PM -0800, Wei Wang wr

Re: [PATCH net] ipv6: remove null_entry before adding default route

2018-01-06 Thread Wei Wang
On Fri, Jan 5, 2018 at 11:42 PM, Martin KaFai Lau <ka...@fb.com> wrote: > On Fri, Jan 05, 2018 at 05:38:35PM -0800, Wei Wang wrote: >> From: Wei Wang <wei...@google.com> >> >> In the current code, when creating a new fib6 table, tb6_root.leaf gets >>

[PATCH net] ipv6: remove null_entry before adding default route

2018-01-05 Thread Wei Wang
From: Wei Wang <wei...@google.com> In the current code, when creating a new fib6 table, tb6_root.leaf gets initialized to net->ipv6.ip6_null_entry. If a default route is being added with rt->rt6i_metric = 0x, fib6_add() will add this route after net->ipv6.ip6_null_entry

[PATCH net] ipv6: fix general protection fault in fib6_add()

2018-01-03 Thread Wei Wang
From: Wei Wang <wei...@google.com> In fib6_add(), pn could be NULL if fib6_add_1() failed to return a fib6 node. Checking pn != fn before accessing pn->leaf makes sure pn is not NULL. This fixes the following GPF reported by syzkaller: general protection fault: [#1] SMP KASAN Dumpi

Re: general protection fault in fib6_add (2)

2018-01-03 Thread Wei Wang
On Wed, Jan 3, 2018 at 8:16 AM, David Ahern wrote: > [ +wei...@google.com ] > > On 1/2/18 3:58 PM, syzbot wrote: >> Hello, >> >> syzkaller hit the following crash on >> 61233580f1f33c50e159c50e24d80ffd2ba2e06b >>

Re: dst refcount is -1

2017-12-19 Thread Wei Wang
On Tue, Dec 19, 2017 at 2:56 AM, Ortwin Glück wrote: > Hi, > > On 4.14.6 I just got this (on a busy firewall): > [Tue Dec 19 11:15:59 2017] dst_release: dst:9bb7aca0d6c0 refcnt:-1 > > Are you sure the refcounting is now correct? > > Ortwin Would you give more details under what

[PATCH net] tcp: fix potential underestimation on rcv_rtt

2017-12-12 Thread Wei Wang
From: Wei Wang <wei...@google.com> When ms timestamp is used, current logic uses 1us in tcp_rcv_rtt_update() when the real rcv_rtt is within 1 - 999us. This could cause rcv_rtt underestimation. Fix it by always using a min value of 1ms if ms timestamp is used. Fixes: 645f4c6f2ebd ("

[iproute2] ss: print tcpi_rcv_ssthresh

2017-12-07 Thread Wei Wang
From: Wei Wang <wei...@google.com> tcpi_rcv_ssthresh is an important stats when debugging receive side behavior. Add it to the ss output. Signed-off-by: Wei Wang <wei...@google.com> Signed-off-by: Eric Dumazet <eduma...@google.com> --- misc/ss.c | 4 1 file changed, 4 i

Re: [PULL] virtio: last minute bugfix

2017-11-07 Thread Wei Wang
On 11/08/2017 03:23 AM, Michael S. Tsirkin wrote: On Tue, Nov 07, 2017 at 08:13:10PM +0200, Michael S. Tsirkin wrote: On Tue, Nov 07, 2017 at 09:29:59AM -0800, Linus Torvalds wrote: On Tue, Nov 7, 2017 at 9:23 AM, Linus Torvalds wrote: I guess I'll take it, but

[PATCH net-next] ipv6: prevent user from adding cached routes

2017-10-27 Thread Wei Wang
From: Wei Wang <wei...@google.com> Cached routes should only be created by the system when receiving pmtu discovery or ip redirect msg. Users should not be allowed to create cached routes. Furthermore, after the patch series to move cached routes into exception table, user added cached

[PATCH net-next] ipv6: add ip6_null_entry check in rt6_select()

2017-10-23 Thread Wei Wang
From: Wei Wang <wei...@google.com> In rt6_select(), fn->leaf could be pointing to net->ipv6.ip6_null_entry. In this case, we should directly return instead of trying to carry on with the rest of the process. If not, we could crash at: spin_lock_bh(>rt6i_table->rt6_lock);

Re: [PATCH net-next v3 2/2] ipv6: remove from fib tree aged out RTF_CACHE dst

2017-10-19 Thread Wei Wang
60fcf5cfb ("ipv6: hook up exception table to store dst cache") > Signed-off-by: Paolo Abeni <pab...@redhat.com> > --- Acked-by: Wei Wang <wei...@google.com> > net/ipv6/route.c | 12 +++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > dif

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

2017-10-19 Thread Wei Wang
> the gc timer will run for whatever time needed to properly > clean the table. > > v2 -> v3: > - clarified the commit message > > Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache") > Signed-off-by: Paolo Abeni <pab...@redhat.com> &

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

2017-10-18 Thread Wei Wang
On Wed, Oct 18, 2017 at 6:03 AM, Paolo Abeni <pab...@redhat.com> wrote: > On Tue, 2017-10-17 at 13:48 -0700, Wei Wang wrote: >> On Tue, Oct 17, 2017 at 1:02 PM, Paolo Abeni <pab...@redhat.com> wrote: >> > Meanwhile others sockets may grab more references to (and u

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 <pab...@redhat.com> wrote: > On Tue, 2017-10-17 at 11:58 -0700, Wei Wang wrote: >> On Tue, Oct 17, 2017 at 10:40 AM, Paolo Abeni <pab...@redhat.com> wrote: >> > The commit 2b760fcf5cfb ("ipv6: hook up exception table

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

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

2017-10-17 Thread Wei Wang
re that > the gc 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 <pab...@redhat.com> > --- Acked-by: Wei Wang <wei...@google.com>

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

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

2017-10-13 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 __u

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

2017-10-13 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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' (se

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

2017-10-10 Thread Wei Wang
F_CACHE entry bit. > > Detected by CoverityScan, CID#1457734, #1457747 ("Wrong operator used") > > Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache") > Signed-off-by: Colin Ian King <colin.k...@canonical.com> > --- Acked-by: Wei

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

2017-10-10 Thread Wei Wang
Martin KaFai Lau <ka...@fb.com> > Thanks a lot for catching this. Yes. It should have been '&' instead of '|'. Acked-by: Wei Wang <wei...@google.com> >> >> Detected by CoverityScan, CID#1457747 ("Wrong operator used") >> >> Fixes: 35732d01fe31 (&q

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

2017-10-09 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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.

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, 吉藤英明 <hideaki.yoshif...@miraclelinux.com> wrote: > Hi, > > 2017-10-07 4:06 GMT+09:00 Wei Wang <wei...@google.com>: >> diff --git a/net/ipv6/route.c b/net/ipv6/route.c >> index 941c062389d2..aeb349aea429 100644 >> --- a/net

[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 <wei...@google.com> 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 d

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 g

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 <wei...@g

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

[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 <wei...@google.com> 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_p

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 pr

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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_

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 poten

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 ope

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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() wil

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 b

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

2017-10-06 Thread Wei Wang
From: Wei Wang <wei...@google.com> 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 th

[PATCH v2 net-next 2/2] tcp: clean up TFO server's initial tcp_rearm_rto() call

2017-10-04 Thread Wei Wang
From: Wei Wang <wei...@google.com> This commit does a cleanup and moves tcp_rearm_rto() call in the TFO server case into a previous spot in tcp_rcv_state_process() to make it more compact. This is only a cosmetic change. Suggested-by: Yuchung Cheng <ych...@google.com> Signed-off-

[PATCH v2 net-next 1/2] tcp: uniform the set up of sockets after successful connection

2017-10-04 Thread Wei Wang
From: Wei Wang <wei...@google.com> Currently in the TCP code, the initialization sequence for cached metrics, congestion control, BPF, etc, after successful connection is very inconsistent. This introduces inconsistent bevhavior and is prone to bugs. The current call sequence is as follow

Re: [PATCH net-next 1/2] tcp: uniform the set up of sockets after successful connection

2017-10-03 Thread Wei Wang
On Tue, Oct 3, 2017 at 9:28 PM, David Miller <da...@davemloft.net> wrote: > From: Wei Wang <wei...@google.com> > Date: Mon, 2 Oct 2017 10:01:35 -0700 > >> @@ -456,6 +456,19 @@ void tcp_init_sock(struct sock *sk) >> } >> EXPORT_SYMBOL(tcp_init_sock); >&g

[PATCH net-next 2/2] tcp: clean up TFO server's initial tcp_rearm_rto() call

2017-10-02 Thread Wei Wang
From: Wei Wang <wei...@google.com> This commit does a cleanup and moves tcp_rearm_rto() call in the TFO server case into a previous spot in tcp_rcv_state_process() to make it more compact. This is only a cosmetic change. Suggested-by: Yuchung Cheng <ych...@google.com> Signed-off-

[PATCH net-next 1/2] tcp: uniform the set up of sockets after successful connection

2017-10-02 Thread Wei Wang
From: Wei Wang <wei...@google.com> Currently in the TCP code, the initialization sequence for cached metrics, congestion control, BPF, etc, after successful connection is very inconsistent. This introduces inconsistent bevhavior and is prone to bugs. The current call sequence is as follow

Re: [PATCH net] ipv6: remove incorrect WARN_ON() in fib6_del()

2017-09-27 Thread Wei Wang
On Tue, Sep 26, 2017 at 6:20 AM, Eric Dumazet <eduma...@google.com> wrote: > On Mon, Sep 25, 2017 at 10:52 PM, Wei Wang <wei...@google.com> wrote: >> On Mon, Sep 25, 2017 at 7:23 PM, Eric Dumazet <eduma...@google.com> wrote: >>> On Mon, Sep 25, 2017 at 7:0

Re: [PATCH net-next] ipv6: do lazy dst->__use update when per cpu dst is available

2017-09-27 Thread Wei Wang
On Wed, Sep 27, 2017 at 10:14 AM, Paolo Abeni wrote: > When a host is under high ipv6 load, the updates of the ingress > route '__use' field are a source of relevant contention: such > field is updated for each packet and several cores can access > concurrently the dst, even if

Re: [PATCH net] ipv6: remove incorrect WARN_ON() in fib6_del()

2017-09-25 Thread Wei Wang
On Mon, Sep 25, 2017 at 7:23 PM, Eric Dumazet wrote: > On Mon, Sep 25, 2017 at 7:07 PM, Martin KaFai Lau wrote: > >> I am probably still missing something. >> >> Considering the del operation should be under the writer lock, >> if rt->rt6i_node should be NULL

Re: [PATCH net] ipv6: remove incorrect WARN_ON() in fib6_del()

2017-09-25 Thread Wei Wang
On Mon, Sep 25, 2017 at 5:56 PM, Martin KaFai Lau <ka...@fb.com> wrote: > On Mon, Sep 25, 2017 at 05:35:22PM +0000, Wei Wang wrote: >> From: Wei Wang <wei...@google.com> >> >> fib6_del() generates WARN_ON() when rt->dst.obsolete > 0. This does n

[PATCH net] ipv6: remove incorrect WARN_ON() in fib6_del()

2017-09-25 Thread Wei Wang
From: Wei Wang <wei...@google.com> fib6_del() generates WARN_ON() when rt->dst.obsolete > 0. This does not make sense because it is possible that the route passed in is already deleted by some other thread and rt->dst.obsolete is set to DST_OBSOLETE_DEAD. So this commit delet

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

2017-09-21 Thread Wei Wang
old() helper to have additional > debugging, as a follow 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: rem

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(>__refcnt); + dst_hold(dst); return dst; } Thanks. Wei On Wed, Sep

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 <wei...@google.com> >>> Date: Sat Jun 17 10:42:32 2017 -0700 >&

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 >> +++

Re: [PATCH net] ipv4: Don't override return code from ip_route_input_noref()

2017-08-31 Thread Wei Wang
skb_dst_force_safe() and one to > skb_dst() in case the ip_route_input_noref() check fails. > > Reported-by: Sabrina Dubroca <sdubr...@redhat.com> > Fixes: ad65a2f05695 ("ipv4: call dst_hold_safe() properly") > Signed-off-by: Stefano Brivio <sbri...@redhat.com> Acked-

  1   2   3   >