A new RTF_CACHE route can be created with the socket's dst cache
update between the below calls in udpv6_sendmsg(), when datagram
sending results to ICMPV6_PKT_TOOBIG error:
dst = ip6_sk_dst_lookup_flow(...)
...
release_dst:
if (dst) {
if (connected)
ip6_dst_store(sk, dst)
Therefore, the new socket's dst cache reset to the old one on
"release_dst:".
The first two patches prepare the code to store dst cache
with ip6_sk_dst_lookup_flow() in udpv6_sendmsg():
* the first patch adds new wrapper ip6_dst_store_flow() to
increase readability of the code and the changes.
* the second patch adds new argument to ip6_sk_dst_lookup_flow()
and ability to store dst in the socket's cache. Also, the two
users of the function are updated without enabling the new
behavior: pingv6_sendmsg() and udpv6_sendmsg().
The last patch contains the actual fix that removes sk dst cache
update in the end of udpv6_sendmsg(), and allows to do it in
ip6_sk_dst_lookup_flow().
v3: * instead of moving ip6_dst_store() above udp_v6_send_skb(),
update socket's dst cache inside ip6_sk_dst_lookup_flow()
if the current one is invalid.
* the issue not reproduced in 4.1, but starting from 4.2. Add
one more 'Fixes:' commit that creates new RTF_CACHE route.
Though, it is also mentioned in the first one.
Alexey Kodanev (3):
ipv6: move ip6_dst_store() calls with flowi6 checks to a wrapper
ipv6: allow to cache dst for connected sk in ip6_sk_dst_lookup_flow()
ipv6: udp6: set dst cache for a connected sk if current not valid
include/net/ip6_route.h | 17 +++++++++++++++++
include/net/ipv6.h | 3 ++-
net/ipv6/datagram.c | 9 +--------
net/ipv6/ip6_output.c | 15 ++++++++++++---
net/ipv6/ping.c | 2 +-
net/ipv6/udp.c | 21 ++-------------------
6 files changed, 35 insertions(+), 32 deletions(-)
--
1.8.3.1
Add 'connected' argument to ip6_sk_dst_lookup_flow() and
update the cache only if ip6_sk_dst_check() returns NULL
and a socket is connected.
The function is used as before, the new behavior for UDP
sockets in udpv6_sendmsg() will be enabled in the next
patch.
Signed-off-by: Alexey Kodanev <redacted>
---
include/net/ipv6.h | 3 ++-
net/ipv6/ip6_output.c | 15 ++++++++++++---
net/ipv6/ping.c | 2 +-
net/ipv6/udp.c | 2 +-
4 files changed, 16 insertions(+), 6 deletions(-)
Move commonly used pattern of ip6_dst_store() usage to a separate
function - ip6_dst_store_flow(), which will check the addresses
for equality before saving them.
There is no functional changes in this patch, the new wrapper
will be used in the next patch, in ip6_sk_dst_lookup_flow().
Signed-off-by: Alexey Kodanev <redacted>
---
include/net/ip6_route.h | 17 +++++++++++++++++
net/ipv6/datagram.c | 9 +--------
2 files changed, 18 insertions(+), 8 deletions(-)
A new RTF_CACHE route can be created in udpv6_sendmsg() between
ip6_sk_dst_lookup_flow() and ip6_dst_store() calls when datagram
sending results to ICMPV6_PKT_TOOBIG error:
udp_v6_send_skb(), for example with vti6 tunnel:
vti6_xmit(), get ICMPV6_PKT_TOOBIG error
skb_dst_update_pmtu(), can create a RTF_CACHE clone
icmpv6_send()
...
udpv6_err()
ip6_sk_update_pmtu()
ip6_update_pmtu(), can create a RTF_CACHE clone
...
ip6_datagram_dst_update()
ip6_dst_store()
And after commit 33c162a980fe ("ipv6: datagram: Update dst cache
of a connected datagram sk during pmtu update"), the UDPv6 error
handler can update socket's dst cache, but it can happen before
the update in end of udpv6_sendmsg(), preventing getting updated
dst cache on the next udpv6_sendmsg() calls.
In order to fix it, we should save dst for a connected socket
in udpv6_sendmsg(), only if the previous socket's cache is not
valid.
Fixes: 33c162a980fe ("ipv6: datagram: Update dst cache of a connected datagram sk during pmtu update")
Fixes: 45e4fd26683c ("ipv6: Only create RTF_CACHE routes after encountering pmtu exception")
Signed-off-by: Alexey Kodanev <redacted>
---
net/ipv6/udp.c | 21 ++-------------------
1 file changed, 2 insertions(+), 19 deletions(-)
From: kbuild test robot <hidden> Date: 2018-03-30 10:15:33
Hi Alexey,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net/master]
url: https://github.com/0day-ci/linux/commits/Alexey-Kodanev/ipv6-move-ip6_dst_store-calls-with-flowi6-checks-to-a-wrapper/20180330-173050
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All warnings (new ones prefixed by >>):
In file included from include/linux/tcp.h:23:0,
from include/linux/ipv6.h:87,
from include/net/ipv6.h:16,
from include/net/inetpeer.h:16,
from include/net/route.h:28,
from drivers/infiniband/core/addr.c:43:
include/net/ip6_route.h: In function 'ip6_dst_store_flow':
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
quoted
include/net/ip6_route.h:221:43: note: in expansion of macro 'sk_v6_daddr'
ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ?
^~~~~~~~~~~
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
include/net/ip6_route.h:222:14: note: in expansion of macro 'sk_v6_daddr'
&sk->sk_v6_daddr : NULL,
^~~~~~~~~~~
vim +/sk_v6_daddr +221 include/net/ip6_route.h
219
220 ip6_dst_store(sk, dst,
> 221 ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ?
222 &sk->sk_v6_daddr : NULL,
223 #ifdef CONFIG_IPV6_SUBTREES
224 ipv6_addr_equal(&fl6->saddr, &np->saddr) ?
225 &np->saddr :
226 #endif
227 NULL);
228 }
229
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Alexey,
I love your patch! Perhaps something to improve:
[auto build test WARNING on net/master]
url: https://github.com/0day-ci/linux/commits/Alexey-Kodanev/ipv6-move-ip6_dst_store-calls-with-flowi6-checks-to-a-wrapper/20180330-173050
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All warnings (new ones prefixed by >>):
In file included from include/linux/tcp.h:23:0,
from include/linux/ipv6.h:87,
from include/net/ipv6.h:16,
from include/net/inetpeer.h:16,
from include/net/route.h:28,
from drivers/infiniband/core/addr.c:43:
include/net/ip6_route.h: In function 'ip6_dst_store_flow':
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
quoted
quoted
include/net/ip6_route.h:221:43: note: in expansion of macro 'sk_v6_daddr'
ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ?
^~~~~~~~~~~
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
include/net/ip6_route.h:222:14: note: in expansion of macro 'sk_v6_daddr'
&sk->sk_v6_daddr : NULL
^~~~~~~~~~~
This is because CONFIG_IPV6 is not enabled, no sk_v6_daddr member,
I'll fix it in the new version.
Thanks,
Alexey
From: kbuild test robot <hidden> Date: 2018-03-30 15:58:49
Hi Alexey,
I love your patch! Yet something to improve:
[auto build test ERROR on net/master]
url: https://github.com/0day-ci/linux/commits/Alexey-Kodanev/ipv6-move-ip6_dst_store-calls-with-flowi6-checks-to-a-wrapper/20180330-173050
config: x86_64-kexec (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
In file included from include/linux/tcp.h:23:0,
from drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.c:33:
include/net/ip6_route.h: In function 'ip6_dst_store_flow':
quoted
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
include/net/ip6_route.h:221:43: note: in expansion of macro 'sk_v6_daddr'
ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ?
^~~~~~~~~~~
quoted
include/net/sock.h:349:34: error: 'struct sock_common' has no member named 'skc_v6_daddr'; did you mean 'skc_daddr'?
#define sk_v6_daddr __sk_common.skc_v6_daddr
^
include/net/ip6_route.h:222:14: note: in expansion of macro 'sk_v6_daddr'
&sk->sk_v6_daddr : NULL,
^~~~~~~~~~~
vim +349 include/net/sock.h
4dc6dc716 Eric Dumazet 2009-07-15 329
68835aba4 Eric Dumazet 2010-11-30 330 #define sk_dontcopy_begin __sk_common.skc_dontcopy_begin
68835aba4 Eric Dumazet 2010-11-30 331 #define sk_dontcopy_end __sk_common.skc_dontcopy_end
4dc6dc716 Eric Dumazet 2009-07-15 332 #define sk_hash __sk_common.skc_hash
508054668 Eric Dumazet 2013-10-02 333 #define sk_portpair __sk_common.skc_portpair
05dbc7b59 Eric Dumazet 2013-10-03 334 #define sk_num __sk_common.skc_num
05dbc7b59 Eric Dumazet 2013-10-03 335 #define sk_dport __sk_common.skc_dport
508054668 Eric Dumazet 2013-10-02 336 #define sk_addrpair __sk_common.skc_addrpair
508054668 Eric Dumazet 2013-10-02 337 #define sk_daddr __sk_common.skc_daddr
508054668 Eric Dumazet 2013-10-02 338 #define sk_rcv_saddr __sk_common.skc_rcv_saddr
^1da177e4 Linus Torvalds 2005-04-16 339 #define sk_family __sk_common.skc_family
^1da177e4 Linus Torvalds 2005-04-16 340 #define sk_state __sk_common.skc_state
^1da177e4 Linus Torvalds 2005-04-16 341 #define sk_reuse __sk_common.skc_reuse
055dc21a1 Tom Herbert 2013-01-22 342 #define sk_reuseport __sk_common.skc_reuseport
9fe516ba3 Eric Dumazet 2014-06-27 343 #define sk_ipv6only __sk_common.skc_ipv6only
26abe1437 Eric W. Biederman 2015-05-08 344 #define sk_net_refcnt __sk_common.skc_net_refcnt
^1da177e4 Linus Torvalds 2005-04-16 345 #define sk_bound_dev_if __sk_common.skc_bound_dev_if
^1da177e4 Linus Torvalds 2005-04-16 346 #define sk_bind_node __sk_common.skc_bind_node
8feaf0c0a Arnaldo Carvalho de Melo 2005-08-09 347 #define sk_prot __sk_common.skc_prot
07feaebfc Eric W. Biederman 2007-09-12 348 #define sk_net __sk_common.skc_net
efe4208f4 Eric Dumazet 2013-10-03 @349 #define sk_v6_daddr __sk_common.skc_v6_daddr
efe4208f4 Eric Dumazet 2013-10-03 350 #define sk_v6_rcv_saddr __sk_common.skc_v6_rcv_saddr
33cf7c90f Eric Dumazet 2015-03-11 351 #define sk_cookie __sk_common.skc_cookie
70da268b5 Eric Dumazet 2015-10-08 352 #define sk_incoming_cpu __sk_common.skc_incoming_cpu
8e5eb54d3 Eric Dumazet 2015-10-08 353 #define sk_flags __sk_common.skc_flags
ed53d0ab7 Eric Dumazet 2015-10-08 354 #define sk_rxhash __sk_common.skc_rxhash
efe4208f4 Eric Dumazet 2013-10-03 355
^1da177e4 Linus Torvalds 2005-04-16 356 socket_lock_t sk_lock;
9115e8cd2 Eric Dumazet 2016-12-03 357 atomic_t sk_drops;
9115e8cd2 Eric Dumazet 2016-12-03 358 int sk_rcvlowat;
9115e8cd2 Eric Dumazet 2016-12-03 359 struct sk_buff_head sk_error_queue;
b178bb3df Eric Dumazet 2010-11-16 360 struct sk_buff_head sk_receive_queue;
fa438ccfd Eric Dumazet 2007-03-04 361 /*
fa438ccfd Eric Dumazet 2007-03-04 362 * The backlog queue is special, it is always used with
fa438ccfd Eric Dumazet 2007-03-04 363 * the per-socket spinlock held and requires low latency
fa438ccfd Eric Dumazet 2007-03-04 364 * access. Therefore we special case it's implementation.
b178bb3df Eric Dumazet 2010-11-16 365 * Note : rmem_alloc is in this structure to fill a hole
b178bb3df Eric Dumazet 2010-11-16 366 * on 64bit arches, not because its logically part of
b178bb3df Eric Dumazet 2010-11-16 367 * backlog.
fa438ccfd Eric Dumazet 2007-03-04 368 */
fa438ccfd Eric Dumazet 2007-03-04 369 struct {
b178bb3df Eric Dumazet 2010-11-16 370 atomic_t rmem_alloc;
b178bb3df Eric Dumazet 2010-11-16 371 int len;
fa438ccfd Eric Dumazet 2007-03-04 372 struct sk_buff *head;
fa438ccfd Eric Dumazet 2007-03-04 373 struct sk_buff *tail;
fa438ccfd Eric Dumazet 2007-03-04 374 } sk_backlog;
b178bb3df Eric Dumazet 2010-11-16 375 #define sk_rmem_alloc sk_backlog.rmem_alloc
2c8c56e15 Eric Dumazet 2014-11-11 376
9115e8cd2 Eric Dumazet 2016-12-03 377 int sk_forward_alloc;
e0d1095ae Cong Wang 2013-08-01 378 #ifdef CONFIG_NET_RX_BUSY_POLL
dafcc4380 Eliezer Tamir 2013-06-14 379 unsigned int sk_ll_usec;
9115e8cd2 Eric Dumazet 2016-12-03 380 /* ===== mostly read cache line ===== */
9115e8cd2 Eric Dumazet 2016-12-03 381 unsigned int sk_napi_id;
060212928 Eliezer Tamir 2013-06-10 382 #endif
b178bb3df Eric Dumazet 2010-11-16 383 int sk_rcvbuf;
b178bb3df Eric Dumazet 2010-11-16 384
b178bb3df Eric Dumazet 2010-11-16 385 struct sk_filter __rcu *sk_filter;
ceb5d58b2 Eric Dumazet 2015-11-29 386 union {
eaefd1105 Eric Dumazet 2011-02-18 387 struct socket_wq __rcu *sk_wq;
ceb5d58b2 Eric Dumazet 2015-11-29 388 struct socket_wq *sk_wq_raw;
ceb5d58b2 Eric Dumazet 2015-11-29 389 };
def8b4faf Alexey Dobriyan 2008-10-28 390 #ifdef CONFIG_XFRM
d188ba86d Eric Dumazet 2015-12-08 391 struct xfrm_policy __rcu *sk_policy[2];
def8b4faf Alexey Dobriyan 2008-10-28 392 #endif
deaa58542 Eric Dumazet 2012-06-24 393 struct dst_entry *sk_rx_dst;
0e36cbb34 Cong Wang 2013-01-22 394 struct dst_entry __rcu *sk_dst_cache;
^1da177e4 Linus Torvalds 2005-04-16 395 atomic_t sk_omem_alloc;
4e07a91c3 Arnaldo Carvalho de Melo 2007-05-29 396 int sk_sndbuf;
9115e8cd2 Eric Dumazet 2016-12-03 397
9115e8cd2 Eric Dumazet 2016-12-03 398 /* ===== cache line for TX ===== */
9115e8cd2 Eric Dumazet 2016-12-03 399 int sk_wmem_queued;
14afee4b6 Reshetova, Elena 2017-06-30 400 refcount_t sk_wmem_alloc;
9115e8cd2 Eric Dumazet 2016-12-03 401 unsigned long sk_tsq_flags;
75c119afe Eric Dumazet 2017-10-05 402 union {
9115e8cd2 Eric Dumazet 2016-12-03 403 struct sk_buff *sk_send_head;
75c119afe Eric Dumazet 2017-10-05 404 struct rb_root tcp_rtx_queue;
75c119afe Eric Dumazet 2017-10-05 405 };
^1da177e4 Linus Torvalds 2005-04-16 406 struct sk_buff_head sk_write_queue;
9115e8cd2 Eric Dumazet 2016-12-03 407 __s32 sk_peek_off;
9115e8cd2 Eric Dumazet 2016-12-03 408 int sk_write_pending;
9b8805a32 Julian Anastasov 2017-02-06 409 __u32 sk_dst_pending_confirm;
218af599f Eric Dumazet 2017-05-16 410 u32 sk_pacing_status; /* see enum sk_pacing */
9115e8cd2 Eric Dumazet 2016-12-03 411 long sk_sndtimeo;
9115e8cd2 Eric Dumazet 2016-12-03 412 struct timer_list sk_timer;
9115e8cd2 Eric Dumazet 2016-12-03 413 __u32 sk_priority;
9115e8cd2 Eric Dumazet 2016-12-03 414 __u32 sk_mark;
9115e8cd2 Eric Dumazet 2016-12-03 415 u32 sk_pacing_rate; /* bytes per second */
9115e8cd2 Eric Dumazet 2016-12-03 416 u32 sk_max_pacing_rate;
9115e8cd2 Eric Dumazet 2016-12-03 417 struct page_frag sk_frag;
9115e8cd2 Eric Dumazet 2016-12-03 418 netdev_features_t sk_route_caps;
9115e8cd2 Eric Dumazet 2016-12-03 419 netdev_features_t sk_route_nocaps;
9115e8cd2 Eric Dumazet 2016-12-03 420 int sk_gso_type;
9115e8cd2 Eric Dumazet 2016-12-03 421 unsigned int sk_gso_max_size;
9115e8cd2 Eric Dumazet 2016-12-03 422 gfp_t sk_allocation;
9115e8cd2 Eric Dumazet 2016-12-03 423 __u32 sk_txhash;
fc64869c4 Andrey Ryabinin 2016-05-18 424
fc64869c4 Andrey Ryabinin 2016-05-18 425 /*
fc64869c4 Andrey Ryabinin 2016-05-18 426 * Because of non atomicity rules, all
fc64869c4 Andrey Ryabinin 2016-05-18 427 * changes are protected by socket lock.
fc64869c4 Andrey Ryabinin 2016-05-18 428 */
aa4c1037a David Ahern 2016-12-01 429 unsigned int __sk_flags_offset[0];
aa4c1037a David Ahern 2016-12-01 430 #ifdef __BIG_ENDIAN_BITFIELD
aa4c1037a David Ahern 2016-12-01 431 #define SK_FL_PROTO_SHIFT 16
aa4c1037a David Ahern 2016-12-01 432 #define SK_FL_PROTO_MASK 0x00ff0000
aa4c1037a David Ahern 2016-12-01 433
:::::: The code at line 349 was first introduced by commit
:::::: efe4208f47f907b86f528788da711e8ab9dea44d ipv6: make lookups simpler and faster
:::::: TO: Eric Dumazet [off-list ref]
:::::: CC: David S. Miller [off-list ref]
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation