aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2019-05-28 17:16:22 -0400
committerIngo Molnar <mingo@kernel.org>2019-05-28 17:16:22 -0400
commit849e96f30068d4f6f8352715e02a10533a46deba (patch)
treedef395835d94b580b1b6225b4441b8b820bcba87 /net
parent5322ea58a06da2e69c5ef36a9b4d4b9255edd423 (diff)
parenta7350998a25ac10cdca5b33dee1d343a74debbfe (diff)
Merge tag 'perf-urgent-for-mingo-5.2-20190528' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes: BPF: Jiri Olsa: - Fixup determination of end of kernel map, to avoid having BPF programs, that are after the kernel headers and just before module texts mixed up in the kernel map. tools UAPI header copies: Arnaldo Carvalho de Melo: - Update copy of files related to new fspick, fsmount, fsconfig, fsopen, move_mount and open_tree syscalls. - Sync cpufeatures.h, sched.h, fs.h, drm.h, i915_drm.h and kvm.h headers. Namespaces: Namhyung Kim: - Add missing byte swap ops for namespace events when processing records from perf.data files that could have been recorded in a arch with a different endianness. - Fix access to the thread namespaces list by using the namespaces_lock. perf data: Shawn Landden: - Fix 'strncat may truncate' build failure with recent gcc. s/390 Thomas Richter: - Fix s390 missing module symbol and warning for non-root users in 'perf record'. arm64: Vitaly Chikunov: - Fix mksyscalltbl when system kernel headers are ahead of the kernel. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/caif/cfdbgl.c2
-rw-r--r--net/caif/cfdgml.c3
-rw-r--r--net/caif/cfutill.c2
-rw-r--r--net/caif/cfveil.c2
-rw-r--r--net/caif/cfvidl.c2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/flow_offload.c7
-rw-r--r--net/core/rtnetlink.c16
-rw-r--r--net/core/skmsg.c7
-rw-r--r--net/ipv4/bpfilter/sockopt.c6
-rw-r--r--net/ipv4/ping.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_bpf.c7
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/datagram.c2
-rw-r--r--net/ipv6/ip6_fib.c12
-rw-r--r--net/ipv6/route.c58
-rw-r--r--net/netlink/af_netlink.c2
-rw-r--r--net/phonet/socket.c2
-rw-r--r--net/socket.c34
-rw-r--r--net/tipc/core.c14
-rw-r--r--net/vmw_vsock/hyperv_transport.c108
-rw-r--r--net/vmw_vsock/virtio_transport.c13
-rw-r--r--net/vmw_vsock/virtio_transport_common.c7
-rw-r--r--net/xfrm/xfrm_policy.c24
27 files changed, 214 insertions, 129 deletions
diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c
index 7aae0b56829e..cce839bf49f7 100644
--- a/net/caif/cfdbgl.c
+++ b/net/caif/cfdbgl.c
@@ -26,7 +26,7 @@ struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info)
26 cfsrvl_init(dbg, channel_id, dev_info, false); 26 cfsrvl_init(dbg, channel_id, dev_info, false);
27 dbg->layer.receive = cfdbgl_receive; 27 dbg->layer.receive = cfdbgl_receive;
28 dbg->layer.transmit = cfdbgl_transmit; 28 dbg->layer.transmit = cfdbgl_transmit;
29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); 29 snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ, "dbg%d", channel_id);
30 return &dbg->layer; 30 return &dbg->layer;
31} 31}
32 32
diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c
index 3bdddb32d55a..58fdb99a390f 100644
--- a/net/caif/cfdgml.c
+++ b/net/caif/cfdgml.c
@@ -33,8 +33,7 @@ struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(dgm, channel_id, dev_info, true); 33 cfsrvl_init(dgm, channel_id, dev_info, true);
34 dgm->layer.receive = cfdgml_receive; 34 dgm->layer.receive = cfdgml_receive;
35 dgm->layer.transmit = cfdgml_transmit; 35 dgm->layer.transmit = cfdgml_transmit;
36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ - 1, "dgm%d", channel_id); 36 snprintf(dgm->layer.name, CAIF_LAYER_NAME_SZ, "dgm%d", channel_id);
37 dgm->layer.name[CAIF_LAYER_NAME_SZ - 1] = '\0';
38 return &dgm->layer; 37 return &dgm->layer;
39} 38}
40 39
diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c
index 1728fa4471cf..be7c43a92ead 100644
--- a/net/caif/cfutill.c
+++ b/net/caif/cfutill.c
@@ -33,7 +33,7 @@ struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
33 cfsrvl_init(util, channel_id, dev_info, true); 33 cfsrvl_init(util, channel_id, dev_info, true);
34 util->layer.receive = cfutill_receive; 34 util->layer.receive = cfutill_receive;
35 util->layer.transmit = cfutill_transmit; 35 util->layer.transmit = cfutill_transmit;
36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); 36 snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
37 return &util->layer; 37 return &util->layer;
38} 38}
39 39
diff --git a/net/caif/cfveil.c b/net/caif/cfveil.c
index 262224581efa..35dd3a600dd1 100644
--- a/net/caif/cfveil.c
+++ b/net/caif/cfveil.c
@@ -32,7 +32,7 @@ struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
32 cfsrvl_init(vei, channel_id, dev_info, true); 32 cfsrvl_init(vei, channel_id, dev_info, true);
33 vei->layer.receive = cfvei_receive; 33 vei->layer.receive = cfvei_receive;
34 vei->layer.transmit = cfvei_transmit; 34 vei->layer.transmit = cfvei_transmit;
35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ - 1, "vei%d", channel_id); 35 snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
36 return &vei->layer; 36 return &vei->layer;
37} 37}
38 38
diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c
index b3b110e8a350..73615e3b3b58 100644
--- a/net/caif/cfvidl.c
+++ b/net/caif/cfvidl.c
@@ -29,7 +29,7 @@ struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info)
29 cfsrvl_init(vid, channel_id, dev_info, false); 29 cfsrvl_init(vid, channel_id, dev_info, false);
30 vid->layer.receive = cfvidl_receive; 30 vid->layer.receive = cfvidl_receive;
31 vid->layer.transmit = cfvidl_transmit; 31 vid->layer.transmit = cfvidl_transmit;
32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ - 1, "vid1"); 32 snprintf(vid->layer.name, CAIF_LAYER_NAME_SZ, "vid1");
33 return &vid->layer; 33 return &vid->layer;
34} 34}
35 35
diff --git a/net/core/dev.c b/net/core/dev.c
index 108ac8137b9b..b6b8505cfb3e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8927,7 +8927,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
8927 8927
8928 refcnt = netdev_refcnt_read(dev); 8928 refcnt = netdev_refcnt_read(dev);
8929 8929
8930 if (time_after(jiffies, warning_time + 10 * HZ)) { 8930 if (refcnt && time_after(jiffies, warning_time + 10 * HZ)) {
8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n", 8931 pr_emerg("unregister_netdevice: waiting for %s to become free. Usage count = %d\n",
8932 dev->name, refcnt); 8932 dev->name, refcnt);
8933 warning_time = jiffies; 8933 warning_time = jiffies;
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index c3a00eac4804..5ce7d47a960e 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -54,6 +54,13 @@ void flow_rule_match_vlan(const struct flow_rule *rule,
54} 54}
55EXPORT_SYMBOL(flow_rule_match_vlan); 55EXPORT_SYMBOL(flow_rule_match_vlan);
56 56
57void flow_rule_match_cvlan(const struct flow_rule *rule,
58 struct flow_match_vlan *out)
59{
60 FLOW_DISSECTOR_MATCH(rule, FLOW_DISSECTOR_KEY_CVLAN, out);
61}
62EXPORT_SYMBOL(flow_rule_match_cvlan);
63
57void flow_rule_match_ipv4_addrs(const struct flow_rule *rule, 64void flow_rule_match_ipv4_addrs(const struct flow_rule *rule,
58 struct flow_match_ipv4_addrs *out) 65 struct flow_match_ipv4_addrs *out)
59{ 66{
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2bd12afb9297..adcc045952c2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1496,14 +1496,15 @@ static int put_master_ifindex(struct sk_buff *skb, struct net_device *dev)
1496 return ret; 1496 return ret;
1497} 1497}
1498 1498
1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev) 1499static int nla_put_iflink(struct sk_buff *skb, const struct net_device *dev,
1500 bool force)
1500{ 1501{
1501 int ifindex = dev_get_iflink(dev); 1502 int ifindex = dev_get_iflink(dev);
1502 1503
1503 if (dev->ifindex == ifindex) 1504 if (force || dev->ifindex != ifindex)
1504 return 0; 1505 return nla_put_u32(skb, IFLA_LINK, ifindex);
1505 1506
1506 return nla_put_u32(skb, IFLA_LINK, ifindex); 1507 return 0;
1507} 1508}
1508 1509
1509static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb, 1510static noinline_for_stack int nla_put_ifalias(struct sk_buff *skb,
@@ -1520,6 +1521,8 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1520 const struct net_device *dev, 1521 const struct net_device *dev,
1521 struct net *src_net) 1522 struct net *src_net)
1522{ 1523{
1524 bool put_iflink = false;
1525
1523 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) { 1526 if (dev->rtnl_link_ops && dev->rtnl_link_ops->get_link_net) {
1524 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev); 1527 struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
1525 1528
@@ -1528,10 +1531,12 @@ static int rtnl_fill_link_netnsid(struct sk_buff *skb,
1528 1531
1529 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id)) 1532 if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
1530 return -EMSGSIZE; 1533 return -EMSGSIZE;
1534
1535 put_iflink = true;
1531 } 1536 }
1532 } 1537 }
1533 1538
1534 return 0; 1539 return nla_put_iflink(skb, dev, put_iflink);
1535} 1540}
1536 1541
1537static int rtnl_fill_link_af(struct sk_buff *skb, 1542static int rtnl_fill_link_af(struct sk_buff *skb,
@@ -1617,7 +1622,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
1617#ifdef CONFIG_RPS 1622#ifdef CONFIG_RPS
1618 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || 1623 nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
1619#endif 1624#endif
1620 nla_put_iflink(skb, dev) ||
1621 put_master_ifindex(skb, dev) || 1625 put_master_ifindex(skb, dev) ||
1622 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || 1626 nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
1623 (dev->qdisc && 1627 (dev->qdisc &&
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index cc94d921476c..93bffaad2135 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -411,6 +411,7 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb)
411 sk_mem_charge(sk, skb->len); 411 sk_mem_charge(sk, skb->len);
412 copied = skb->len; 412 copied = skb->len;
413 msg->sg.start = 0; 413 msg->sg.start = 0;
414 msg->sg.size = copied;
414 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge; 415 msg->sg.end = num_sge == MAX_MSG_FRAGS ? 0 : num_sge;
415 msg->skb = skb; 416 msg->skb = skb;
416 417
@@ -554,8 +555,10 @@ static void sk_psock_destroy_deferred(struct work_struct *gc)
554 struct sk_psock *psock = container_of(gc, struct sk_psock, gc); 555 struct sk_psock *psock = container_of(gc, struct sk_psock, gc);
555 556
556 /* No sk_callback_lock since already detached. */ 557 /* No sk_callback_lock since already detached. */
557 strp_stop(&psock->parser.strp); 558
558 strp_done(&psock->parser.strp); 559 /* Parser has been stopped */
560 if (psock->progs.skb_parser)
561 strp_done(&psock->parser.strp);
559 562
560 cancel_work_sync(&psock->work); 563 cancel_work_sync(&psock->work);
561 564
diff --git a/net/ipv4/bpfilter/sockopt.c b/net/ipv4/bpfilter/sockopt.c
index 15427163a041..0480918bfc7c 100644
--- a/net/ipv4/bpfilter/sockopt.c
+++ b/net/ipv4/bpfilter/sockopt.c
@@ -30,13 +30,11 @@ static int bpfilter_mbox_request(struct sock *sk, int optname,
30 mutex_lock(&bpfilter_ops.lock); 30 mutex_lock(&bpfilter_ops.lock);
31 if (!bpfilter_ops.sockopt) { 31 if (!bpfilter_ops.sockopt) {
32 mutex_unlock(&bpfilter_ops.lock); 32 mutex_unlock(&bpfilter_ops.lock);
33 err = request_module("bpfilter"); 33 request_module("bpfilter");
34 mutex_lock(&bpfilter_ops.lock); 34 mutex_lock(&bpfilter_ops.lock);
35 35
36 if (err)
37 goto out;
38 if (!bpfilter_ops.sockopt) { 36 if (!bpfilter_ops.sockopt) {
39 err = -ECHILD; 37 err = -ENOPROTOOPT;
40 goto out; 38 goto out;
41 } 39 }
42 } 40 }
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 7ccb5f87f70b..834be7daeb32 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1113,7 +1113,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1113 __u16 srcp = ntohs(inet->inet_sport); 1113 __u16 srcp = ntohs(inet->inet_sport);
1114 1114
1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 1115 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 1116 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
1117 bucket, src, srcp, dest, destp, sp->sk_state, 1117 bucket, src, srcp, dest, destp, sp->sk_state,
1118 sk_wmem_alloc_get(sp), 1118 sk_wmem_alloc_get(sp),
1119 sk_rmem_alloc_get(sp), 1119 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index dc91c27bb788..0e482f07b37f 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -1076,7 +1076,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
1076 srcp = inet->inet_num; 1076 srcp = inet->inet_num;
1077 1077
1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X" 1078 seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1079 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1080 i, src, srcp, dest, destp, sp->sk_state, 1080 i, src, srcp, dest, destp, sp->sk_state,
1081 sk_wmem_alloc_get(sp), 1081 sk_wmem_alloc_get(sp),
1082 sk_rmem_alloc_get(sp), 1082 sk_rmem_alloc_get(sp),
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1fa15beb8380..53d61ca3ac4b 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -855,7 +855,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
855 855
856 if (likely(!size)) { 856 if (likely(!size)) {
857 skb = sk->sk_tx_skb_cache; 857 skb = sk->sk_tx_skb_cache;
858 if (skb && !skb_cloned(skb)) { 858 if (skb) {
859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); 859 skb->truesize = SKB_TRUESIZE(skb_end_offset(skb));
860 sk->sk_tx_skb_cache = NULL; 860 sk->sk_tx_skb_cache = NULL;
861 pskb_trim(skb, 0); 861 pskb_trim(skb, 0);
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 1bb7321a256d..3d1e15401384 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -27,7 +27,10 @@ static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
27 int flags, long timeo, int *err) 27 int flags, long timeo, int *err)
28{ 28{
29 DEFINE_WAIT_FUNC(wait, woken_wake_function); 29 DEFINE_WAIT_FUNC(wait, woken_wake_function);
30 int ret; 30 int ret = 0;
31
32 if (!timeo)
33 return ret;
31 34
32 add_wait_queue(sk_sleep(sk), &wait); 35 add_wait_queue(sk_sleep(sk), &wait);
33 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); 36 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
@@ -528,8 +531,6 @@ static void tcp_bpf_remove(struct sock *sk, struct sk_psock *psock)
528{ 531{
529 struct sk_psock_link *link; 532 struct sk_psock_link *link;
530 533
531 sk_psock_cork_free(psock);
532 __sk_psock_purge_ingress_msg(psock);
533 while ((link = sk_psock_link_pop(psock))) { 534 while ((link = sk_psock_link_pop(psock))) {
534 sk_psock_unlink(sk, link); 535 sk_psock_unlink(sk, link);
535 sk_psock_free_link(link); 536 sk_psock_free_link(link);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 20f6fac5882e..c61edd023b35 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6024,6 +6024,9 @@ reset_and_undo:
6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk) 6024static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)
6025{ 6025{
6026 tcp_try_undo_loss(sk, false); 6026 tcp_try_undo_loss(sk, false);
6027
6028 /* Reset rtx states to prevent spurious retransmits_timed_out() */
6029 tcp_sk(sk)->retrans_stamp = 0;
6027 inet_csk(sk)->icsk_retransmits = 0; 6030 inet_csk(sk)->icsk_retransmits = 0;
6028 6031
6029 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1, 6032 /* Once we leave TCP_SYN_RECV or TCP_FIN_WAIT_1,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3c58ba02af7d..8fb250ed53d4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2883,7 +2883,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
2883 __u16 srcp = ntohs(inet->inet_sport); 2883 __u16 srcp = ntohs(inet->inet_sport);
2884 2884
2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X" 2885 seq_printf(f, "%5d: %08X:%04X %08X:%04X"
2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", 2886 " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u",
2887 bucket, src, srcp, dest, destp, sp->sk_state, 2887 bucket, src, srcp, dest, destp, sp->sk_state,
2888 sk_wmem_alloc_get(sp), 2888 sk_wmem_alloc_get(sp),
2889 udp_rqueue_get(sp), 2889 udp_rqueue_get(sp),
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index ee4a4e54d016..f07fb24f4ba1 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -1034,7 +1034,7 @@ void __ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
1034 src = &sp->sk_v6_rcv_saddr; 1034 src = &sp->sk_v6_rcv_saddr;
1035 seq_printf(seq, 1035 seq_printf(seq,
1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " 1036 "%5d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d\n", 1037 "%02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %u\n",
1038 bucket, 1038 bucket,
1039 src->s6_addr32[0], src->s6_addr32[1], 1039 src->s6_addr32[0], src->s6_addr32[1],
1040 src->s6_addr32[2], src->s6_addr32[3], srcp, 1040 src->s6_addr32[2], src->s6_addr32[3], srcp,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 08e0390e001c..008421b550c6 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -904,6 +904,12 @@ static void fib6_drop_pcpu_from(struct fib6_info *f6i,
904{ 904{
905 int cpu; 905 int cpu;
906 906
907 /* Make sure rt6_make_pcpu_route() wont add other percpu routes
908 * while we are cleaning them here.
909 */
910 f6i->fib6_destroying = 1;
911 mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
912
907 /* release the reference to this fib entry from 913 /* release the reference to this fib entry from
908 * all of its cached pcpu routes 914 * all of its cached pcpu routes
909 */ 915 */
@@ -927,6 +933,9 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
927{ 933{
928 struct fib6_table *table = rt->fib6_table; 934 struct fib6_table *table = rt->fib6_table;
929 935
936 if (rt->rt6i_pcpu)
937 fib6_drop_pcpu_from(rt, table);
938
930 if (refcount_read(&rt->fib6_ref) != 1) { 939 if (refcount_read(&rt->fib6_ref) != 1) {
931 /* This route is used as dummy address holder in some split 940 /* This route is used as dummy address holder in some split
932 * nodes. It is not leaked, but it still holds other resources, 941 * nodes. It is not leaked, but it still holds other resources,
@@ -948,9 +957,6 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
948 fn = rcu_dereference_protected(fn->parent, 957 fn = rcu_dereference_protected(fn->parent,
949 lockdep_is_held(&table->tb6_lock)); 958 lockdep_is_held(&table->tb6_lock));
950 } 959 }
951
952 if (rt->rt6i_pcpu)
953 fib6_drop_pcpu_from(rt, table);
954 } 960 }
955} 961}
956 962
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 23a20d62daac..7a014ca877ed 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -111,8 +111,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
111 int iif, int type, u32 portid, u32 seq, 111 int iif, int type, u32 portid, u32 seq,
112 unsigned int flags); 112 unsigned int flags);
113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 113static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
114 struct in6_addr *daddr, 114 const struct in6_addr *daddr,
115 struct in6_addr *saddr); 115 const struct in6_addr *saddr);
116 116
117#ifdef CONFIG_IPV6_ROUTE_INFO 117#ifdef CONFIG_IPV6_ROUTE_INFO
118static struct fib6_info *rt6_add_route_info(struct net *net, 118static struct fib6_info *rt6_add_route_info(struct net *net,
@@ -1295,6 +1295,13 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,
1295 prev = cmpxchg(p, NULL, pcpu_rt); 1295 prev = cmpxchg(p, NULL, pcpu_rt);
1296 BUG_ON(prev); 1296 BUG_ON(prev);
1297 1297
1298 if (res->f6i->fib6_destroying) {
1299 struct fib6_info *from;
1300
1301 from = xchg((__force struct fib6_info **)&pcpu_rt->from, NULL);
1302 fib6_info_release(from);
1303 }
1304
1298 return pcpu_rt; 1305 return pcpu_rt;
1299} 1306}
1300 1307
@@ -1566,31 +1573,44 @@ out:
1566 * Caller has to hold rcu_read_lock() 1573 * Caller has to hold rcu_read_lock()
1567 */ 1574 */
1568static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res, 1575static struct rt6_info *rt6_find_cached_rt(const struct fib6_result *res,
1569 struct in6_addr *daddr, 1576 const struct in6_addr *daddr,
1570 struct in6_addr *saddr) 1577 const struct in6_addr *saddr)
1571{ 1578{
1579 const struct in6_addr *src_key = NULL;
1572 struct rt6_exception_bucket *bucket; 1580 struct rt6_exception_bucket *bucket;
1573 struct in6_addr *src_key = NULL;
1574 struct rt6_exception *rt6_ex; 1581 struct rt6_exception *rt6_ex;
1575 struct rt6_info *ret = NULL; 1582 struct rt6_info *ret = NULL;
1576 1583
1577 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1578
1579#ifdef CONFIG_IPV6_SUBTREES 1584#ifdef CONFIG_IPV6_SUBTREES
1580 /* fib6i_src.plen != 0 indicates f6i is in subtree 1585 /* fib6i_src.plen != 0 indicates f6i is in subtree
1581 * and exception table is indexed by a hash of 1586 * and exception table is indexed by a hash of
1582 * both fib6_dst and fib6_src. 1587 * both fib6_dst and fib6_src.
1583 * Otherwise, the exception table is indexed by 1588 * However, the src addr used to create the hash
1584 * a hash of only fib6_dst. 1589 * might not be exactly the passed in saddr which
1590 * is a /128 addr from the flow.
1591 * So we need to use f6i->fib6_src to redo lookup
1592 * if the passed in saddr does not find anything.
1593 * (See the logic in ip6_rt_cache_alloc() on how
1594 * rt->rt6i_src is updated.)
1585 */ 1595 */
1586 if (res->f6i->fib6_src.plen) 1596 if (res->f6i->fib6_src.plen)
1587 src_key = saddr; 1597 src_key = saddr;
1598find_ex:
1588#endif 1599#endif
1600 bucket = rcu_dereference(res->f6i->rt6i_exception_bucket);
1589 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key); 1601 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
1590 1602
1591 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i)) 1603 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
1592 ret = rt6_ex->rt6i; 1604 ret = rt6_ex->rt6i;
1593 1605
1606#ifdef CONFIG_IPV6_SUBTREES
1607 /* Use fib6_src as src_key and redo lookup */
1608 if (!ret && src_key && src_key != &res->f6i->fib6_src.addr) {
1609 src_key = &res->f6i->fib6_src.addr;
1610 goto find_ex;
1611 }
1612#endif
1613
1594 return ret; 1614 return ret;
1595} 1615}
1596 1616
@@ -2665,12 +2685,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2665 const struct in6_addr *daddr, 2685 const struct in6_addr *daddr,
2666 const struct in6_addr *saddr) 2686 const struct in6_addr *saddr)
2667{ 2687{
2668 struct rt6_exception_bucket *bucket;
2669 const struct fib6_nh *nh = res->nh; 2688 const struct fib6_nh *nh = res->nh;
2670 struct fib6_info *f6i = res->f6i; 2689 struct fib6_info *f6i = res->f6i;
2671 const struct in6_addr *src_key;
2672 struct rt6_exception *rt6_ex;
2673 struct inet6_dev *idev; 2690 struct inet6_dev *idev;
2691 struct rt6_info *rt;
2674 u32 mtu = 0; 2692 u32 mtu = 0;
2675 2693
2676 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) { 2694 if (unlikely(fib6_metric_locked(f6i, RTAX_MTU))) {
@@ -2679,18 +2697,10 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
2679 goto out; 2697 goto out;
2680 } 2698 }
2681 2699
2682 src_key = NULL; 2700 rt = rt6_find_cached_rt(res, daddr, saddr);
2683#ifdef CONFIG_IPV6_SUBTREES 2701 if (unlikely(rt)) {
2684 if (f6i->fib6_src.plen) 2702 mtu = dst_metric_raw(&rt->dst, RTAX_MTU);
2685 src_key = saddr; 2703 } else {
2686#endif
2687
2688 bucket = rcu_dereference(f6i->rt6i_exception_bucket);
2689 rt6_ex = __rt6_find_exception_rcu(&bucket, daddr, src_key);
2690 if (rt6_ex && !rt6_check_expired(rt6_ex->rt6i))
2691 mtu = dst_metric_raw(&rt6_ex->rt6i->dst, RTAX_MTU);
2692
2693 if (likely(!mtu)) {
2694 struct net_device *dev = nh->fib_nh_dev; 2704 struct net_device *dev = nh->fib_nh_dev;
2695 2705
2696 mtu = IPV6_MIN_MTU; 2706 mtu = IPV6_MIN_MTU;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 216ab915dd54..718a97d5f1fd 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2642,7 +2642,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
2642 struct sock *s = v; 2642 struct sock *s = v;
2643 struct netlink_sock *nlk = nlk_sk(s); 2643 struct netlink_sock *nlk = nlk_sk(s);
2644 2644
2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n", 2645 seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8u %-8lu\n",
2646 s, 2646 s,
2647 s->sk_protocol, 2647 s->sk_protocol,
2648 nlk->portid, 2648 nlk->portid,
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 30187990257f..2567af2fbd6f 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -607,7 +607,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
607 struct pn_sock *pn = pn_sk(sk); 607 struct pn_sock *pn = pn_sk(sk);
608 608
609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu " 609 seq_printf(seq, "%2d %04X:%04X:%02X %02X %08X:%08X %5d %lu "
610 "%d %pK %d", 610 "%d %pK %u",
611 sk->sk_protocol, pn->sobject, pn->dobject, 611 sk->sk_protocol, pn->sobject, pn->dobject,
612 pn->resource, sk->sk_state, 612 pn->resource, sk->sk_state,
613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk), 613 sk_wmem_alloc_get(sk), sk_rmem_alloc_get(sk),
diff --git a/net/socket.c b/net/socket.c
index 472fbefa5d9b..72372dc5dd70 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -645,14 +645,6 @@ void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags)
645} 645}
646EXPORT_SYMBOL(__sock_tx_timestamp); 646EXPORT_SYMBOL(__sock_tx_timestamp);
647 647
648/**
649 * sock_sendmsg - send a message through @sock
650 * @sock: socket
651 * @msg: message to send
652 *
653 * Sends @msg through @sock, passing through LSM.
654 * Returns the number of bytes sent, or an error code.
655 */
656INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *, 648INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *,
657 size_t)); 649 size_t));
658static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) 650static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
@@ -663,6 +655,14 @@ static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
663 return ret; 655 return ret;
664} 656}
665 657
658/**
659 * sock_sendmsg - send a message through @sock
660 * @sock: socket
661 * @msg: message to send
662 *
663 * Sends @msg through @sock, passing through LSM.
664 * Returns the number of bytes sent, or an error code.
665 */
666int sock_sendmsg(struct socket *sock, struct msghdr *msg) 666int sock_sendmsg(struct socket *sock, struct msghdr *msg)
667{ 667{
668 int err = security_socket_sendmsg(sock, msg, 668 int err = security_socket_sendmsg(sock, msg,
@@ -875,15 +875,6 @@ void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
875} 875}
876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); 876EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops);
877 877
878/**
879 * sock_recvmsg - receive a message from @sock
880 * @sock: socket
881 * @msg: message to receive
882 * @flags: message flags
883 *
884 * Receives @msg from @sock, passing through LSM. Returns the total number
885 * of bytes received, or an error.
886 */
887INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *, 878INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *,
888 size_t , int )); 879 size_t , int ));
889static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, 880static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
@@ -893,6 +884,15 @@ static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
893 msg_data_left(msg), flags); 884 msg_data_left(msg), flags);
894} 885}
895 886
887/**
888 * sock_recvmsg - receive a message from @sock
889 * @sock: socket
890 * @msg: message to receive
891 * @flags: message flags
892 *
893 * Receives @msg from @sock, passing through LSM. Returns the total number
894 * of bytes received, or an error.
895 */
896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) 896int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags)
897{ 897{
898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags); 898 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 27cccd101ef6..ddd2e0f67c07 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -131,10 +131,6 @@ static int __init tipc_init(void)
131 if (err) 131 if (err)
132 goto out_netlink_compat; 132 goto out_netlink_compat;
133 133
134 err = tipc_socket_init();
135 if (err)
136 goto out_socket;
137
138 err = tipc_register_sysctl(); 134 err = tipc_register_sysctl();
139 if (err) 135 if (err)
140 goto out_sysctl; 136 goto out_sysctl;
@@ -143,6 +139,10 @@ static int __init tipc_init(void)
143 if (err) 139 if (err)
144 goto out_pernet; 140 goto out_pernet;
145 141
142 err = tipc_socket_init();
143 if (err)
144 goto out_socket;
145
146 err = tipc_bearer_setup(); 146 err = tipc_bearer_setup();
147 if (err) 147 if (err)
148 goto out_bearer; 148 goto out_bearer;
@@ -150,12 +150,12 @@ static int __init tipc_init(void)
150 pr_info("Started in single node mode\n"); 150 pr_info("Started in single node mode\n");
151 return 0; 151 return 0;
152out_bearer: 152out_bearer:
153 tipc_socket_stop();
154out_socket:
153 unregister_pernet_subsys(&tipc_net_ops); 155 unregister_pernet_subsys(&tipc_net_ops);
154out_pernet: 156out_pernet:
155 tipc_unregister_sysctl(); 157 tipc_unregister_sysctl();
156out_sysctl: 158out_sysctl:
157 tipc_socket_stop();
158out_socket:
159 tipc_netlink_compat_stop(); 159 tipc_netlink_compat_stop();
160out_netlink_compat: 160out_netlink_compat:
161 tipc_netlink_stop(); 161 tipc_netlink_stop();
@@ -167,10 +167,10 @@ out_netlink:
167static void __exit tipc_exit(void) 167static void __exit tipc_exit(void)
168{ 168{
169 tipc_bearer_cleanup(); 169 tipc_bearer_cleanup();
170 tipc_socket_stop();
170 unregister_pernet_subsys(&tipc_net_ops); 171 unregister_pernet_subsys(&tipc_net_ops);
171 tipc_netlink_stop(); 172 tipc_netlink_stop();
172 tipc_netlink_compat_stop(); 173 tipc_netlink_compat_stop();
173 tipc_socket_stop();
174 tipc_unregister_sysctl(); 174 tipc_unregister_sysctl();
175 175
176 pr_info("Deactivated\n"); 176 pr_info("Deactivated\n");
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index a827547aa102..982a8dc49e03 100644
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -35,6 +35,9 @@
35/* The MTU is 16KB per the host side's design */ 35/* The MTU is 16KB per the host side's design */
36#define HVS_MTU_SIZE (1024 * 16) 36#define HVS_MTU_SIZE (1024 * 16)
37 37
38/* How long to wait for graceful shutdown of a connection */
39#define HVS_CLOSE_TIMEOUT (8 * HZ)
40
38struct vmpipe_proto_header { 41struct vmpipe_proto_header {
39 u32 pkt_type; 42 u32 pkt_type;
40 u32 data_size; 43 u32 data_size;
@@ -305,19 +308,32 @@ static void hvs_channel_cb(void *ctx)
305 sk->sk_write_space(sk); 308 sk->sk_write_space(sk);
306} 309}
307 310
308static void hvs_close_connection(struct vmbus_channel *chan) 311static void hvs_do_close_lock_held(struct vsock_sock *vsk,
312 bool cancel_timeout)
309{ 313{
310 struct sock *sk = get_per_channel_state(chan); 314 struct sock *sk = sk_vsock(vsk);
311 struct vsock_sock *vsk = vsock_sk(sk);
312
313 lock_sock(sk);
314 315
315 sk->sk_state = TCP_CLOSE;
316 sock_set_flag(sk, SOCK_DONE); 316 sock_set_flag(sk, SOCK_DONE);
317 vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN; 317 vsk->peer_shutdown = SHUTDOWN_MASK;
318 318 if (vsock_stream_has_data(vsk) <= 0)
319 sk->sk_state = TCP_CLOSING;
319 sk->sk_state_change(sk); 320 sk->sk_state_change(sk);
321 if (vsk->close_work_scheduled &&
322 (!cancel_timeout || cancel_delayed_work(&vsk->close_work))) {
323 vsk->close_work_scheduled = false;
324 vsock_remove_sock(vsk);
320 325
326 /* Release the reference taken while scheduling the timeout */
327 sock_put(sk);
328 }
329}
330
331static void hvs_close_connection(struct vmbus_channel *chan)
332{
333 struct sock *sk = get_per_channel_state(chan);
334
335 lock_sock(sk);
336 hvs_do_close_lock_held(vsock_sk(sk), true);
321 release_sock(sk); 337 release_sock(sk);
322} 338}
323 339
@@ -452,50 +468,80 @@ static int hvs_connect(struct vsock_sock *vsk)
452 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id); 468 return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id);
453} 469}
454 470
471static void hvs_shutdown_lock_held(struct hvsock *hvs, int mode)
472{
473 struct vmpipe_proto_header hdr;
474
475 if (hvs->fin_sent || !hvs->chan)
476 return;
477
478 /* It can't fail: see hvs_channel_writable_bytes(). */
479 (void)hvs_send_data(hvs->chan, (struct hvs_send_buf *)&hdr, 0);
480 hvs->fin_sent = true;
481}
482
455static int hvs_shutdown(struct vsock_sock *vsk, int mode) 483static int hvs_shutdown(struct vsock_sock *vsk, int mode)
456{ 484{
457 struct sock *sk = sk_vsock(vsk); 485 struct sock *sk = sk_vsock(vsk);
458 struct vmpipe_proto_header hdr;
459 struct hvs_send_buf *send_buf;
460 struct hvsock *hvs;
461 486
462 if (!(mode & SEND_SHUTDOWN)) 487 if (!(mode & SEND_SHUTDOWN))
463 return 0; 488 return 0;
464 489
465 lock_sock(sk); 490 lock_sock(sk);
491 hvs_shutdown_lock_held(vsk->trans, mode);
492 release_sock(sk);
493 return 0;
494}
466 495
467 hvs = vsk->trans; 496static void hvs_close_timeout(struct work_struct *work)
468 if (hvs->fin_sent) 497{
469 goto out; 498 struct vsock_sock *vsk =
470 499 container_of(work, struct vsock_sock, close_work.work);
471 send_buf = (struct hvs_send_buf *)&hdr; 500 struct sock *sk = sk_vsock(vsk);
472 501
473 /* It can't fail: see hvs_channel_writable_bytes(). */ 502 sock_hold(sk);
474 (void)hvs_send_data(hvs->chan, send_buf, 0); 503 lock_sock(sk);
504 if (!sock_flag(sk, SOCK_DONE))
505 hvs_do_close_lock_held(vsk, false);
475 506
476 hvs->fin_sent = true; 507 vsk->close_work_scheduled = false;
477out:
478 release_sock(sk); 508 release_sock(sk);
479 return 0; 509 sock_put(sk);
480} 510}
481 511
482static void hvs_release(struct vsock_sock *vsk) 512/* Returns true, if it is safe to remove socket; false otherwise */
513static bool hvs_close_lock_held(struct vsock_sock *vsk)
483{ 514{
484 struct sock *sk = sk_vsock(vsk); 515 struct sock *sk = sk_vsock(vsk);
485 struct hvsock *hvs = vsk->trans;
486 struct vmbus_channel *chan;
487 516
488 lock_sock(sk); 517 if (!(sk->sk_state == TCP_ESTABLISHED ||
518 sk->sk_state == TCP_CLOSING))
519 return true;
489 520
490 sk->sk_state = TCP_CLOSING; 521 if ((sk->sk_shutdown & SHUTDOWN_MASK) != SHUTDOWN_MASK)
491 vsock_remove_sock(vsk); 522 hvs_shutdown_lock_held(vsk->trans, SHUTDOWN_MASK);
492 523
493 release_sock(sk); 524 if (sock_flag(sk, SOCK_DONE))
525 return true;
494 526
495 chan = hvs->chan; 527 /* This reference will be dropped by the delayed close routine */
496 if (chan) 528 sock_hold(sk);
497 hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN); 529 INIT_DELAYED_WORK(&vsk->close_work, hvs_close_timeout);
530 vsk->close_work_scheduled = true;
531 schedule_delayed_work(&vsk->close_work, HVS_CLOSE_TIMEOUT);
532 return false;
533}
498 534
535static void hvs_release(struct vsock_sock *vsk)
536{
537 struct sock *sk = sk_vsock(vsk);
538 bool remove_sock;
539
540 lock_sock(sk);
541 remove_sock = hvs_close_lock_held(vsk);
542 release_sock(sk);
543 if (remove_sock)
544 vsock_remove_sock(vsk);
499} 545}
500 546
501static void hvs_destruct(struct vsock_sock *vsk) 547static void hvs_destruct(struct vsock_sock *vsk)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index 15eb5d3d4750..96ab344f17bb 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -702,28 +702,27 @@ static int __init virtio_vsock_init(void)
702 if (!virtio_vsock_workqueue) 702 if (!virtio_vsock_workqueue)
703 return -ENOMEM; 703 return -ENOMEM;
704 704
705 ret = register_virtio_driver(&virtio_vsock_driver); 705 ret = vsock_core_init(&virtio_transport.transport);
706 if (ret) 706 if (ret)
707 goto out_wq; 707 goto out_wq;
708 708
709 ret = vsock_core_init(&virtio_transport.transport); 709 ret = register_virtio_driver(&virtio_vsock_driver);
710 if (ret) 710 if (ret)
711 goto out_vdr; 711 goto out_vci;
712 712
713 return 0; 713 return 0;
714 714
715out_vdr: 715out_vci:
716 unregister_virtio_driver(&virtio_vsock_driver); 716 vsock_core_exit();
717out_wq: 717out_wq:
718 destroy_workqueue(virtio_vsock_workqueue); 718 destroy_workqueue(virtio_vsock_workqueue);
719 return ret; 719 return ret;
720
721} 720}
722 721
723static void __exit virtio_vsock_exit(void) 722static void __exit virtio_vsock_exit(void)
724{ 723{
725 vsock_core_exit();
726 unregister_virtio_driver(&virtio_vsock_driver); 724 unregister_virtio_driver(&virtio_vsock_driver);
725 vsock_core_exit();
727 destroy_workqueue(virtio_vsock_workqueue); 726 destroy_workqueue(virtio_vsock_workqueue);
728} 727}
729 728
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 602715fc9a75..f3f3d06cb6d8 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -786,12 +786,19 @@ static bool virtio_transport_close(struct vsock_sock *vsk)
786 786
787void virtio_transport_release(struct vsock_sock *vsk) 787void virtio_transport_release(struct vsock_sock *vsk)
788{ 788{
789 struct virtio_vsock_sock *vvs = vsk->trans;
790 struct virtio_vsock_pkt *pkt, *tmp;
789 struct sock *sk = &vsk->sk; 791 struct sock *sk = &vsk->sk;
790 bool remove_sock = true; 792 bool remove_sock = true;
791 793
792 lock_sock(sk); 794 lock_sock(sk);
793 if (sk->sk_type == SOCK_STREAM) 795 if (sk->sk_type == SOCK_STREAM)
794 remove_sock = virtio_transport_close(vsk); 796 remove_sock = virtio_transport_close(vsk);
797
798 list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) {
799 list_del(&pkt->list);
800 virtio_transport_free_pkt(pkt);
801 }
795 release_sock(sk); 802 release_sock(sk);
796 803
797 if (remove_sock) 804 if (remove_sock)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 410233c5681e..7a43ae6b2a44 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -3264,7 +3264,8 @@ static void
3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse) 3264decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3265{ 3265{
3266 const struct iphdr *iph = ip_hdr(skb); 3266 const struct iphdr *iph = ip_hdr(skb);
3267 u8 *xprth = skb_network_header(skb) + iph->ihl * 4; 3267 int ihl = iph->ihl;
3268 u8 *xprth = skb_network_header(skb) + ihl * 4;
3268 struct flowi4 *fl4 = &fl->u.ip4; 3269 struct flowi4 *fl4 = &fl->u.ip4;
3269 int oif = 0; 3270 int oif = 0;
3270 3271
@@ -3275,6 +3276,11 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3275 fl4->flowi4_mark = skb->mark; 3276 fl4->flowi4_mark = skb->mark;
3276 fl4->flowi4_oif = reverse ? skb->skb_iif : oif; 3277 fl4->flowi4_oif = reverse ? skb->skb_iif : oif;
3277 3278
3279 fl4->flowi4_proto = iph->protocol;
3280 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3281 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3282 fl4->flowi4_tos = iph->tos;
3283
3278 if (!ip_is_fragment(iph)) { 3284 if (!ip_is_fragment(iph)) {
3279 switch (iph->protocol) { 3285 switch (iph->protocol) {
3280 case IPPROTO_UDP: 3286 case IPPROTO_UDP:
@@ -3286,7 +3292,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3286 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3292 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3287 __be16 *ports; 3293 __be16 *ports;
3288 3294
3289 xprth = skb_network_header(skb) + iph->ihl * 4; 3295 xprth = skb_network_header(skb) + ihl * 4;
3290 ports = (__be16 *)xprth; 3296 ports = (__be16 *)xprth;
3291 3297
3292 fl4->fl4_sport = ports[!!reverse]; 3298 fl4->fl4_sport = ports[!!reverse];
@@ -3298,7 +3304,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3298 pskb_may_pull(skb, xprth + 2 - skb->data)) { 3304 pskb_may_pull(skb, xprth + 2 - skb->data)) {
3299 u8 *icmp; 3305 u8 *icmp;
3300 3306
3301 xprth = skb_network_header(skb) + iph->ihl * 4; 3307 xprth = skb_network_header(skb) + ihl * 4;
3302 icmp = xprth; 3308 icmp = xprth;
3303 3309
3304 fl4->fl4_icmp_type = icmp[0]; 3310 fl4->fl4_icmp_type = icmp[0];
@@ -3310,7 +3316,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3310 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3316 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3311 __be32 *ehdr; 3317 __be32 *ehdr;
3312 3318
3313 xprth = skb_network_header(skb) + iph->ihl * 4; 3319 xprth = skb_network_header(skb) + ihl * 4;
3314 ehdr = (__be32 *)xprth; 3320 ehdr = (__be32 *)xprth;
3315 3321
3316 fl4->fl4_ipsec_spi = ehdr[0]; 3322 fl4->fl4_ipsec_spi = ehdr[0];
@@ -3321,7 +3327,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3321 pskb_may_pull(skb, xprth + 8 - skb->data)) { 3327 pskb_may_pull(skb, xprth + 8 - skb->data)) {
3322 __be32 *ah_hdr; 3328 __be32 *ah_hdr;
3323 3329
3324 xprth = skb_network_header(skb) + iph->ihl * 4; 3330 xprth = skb_network_header(skb) + ihl * 4;
3325 ah_hdr = (__be32 *)xprth; 3331 ah_hdr = (__be32 *)xprth;
3326 3332
3327 fl4->fl4_ipsec_spi = ah_hdr[1]; 3333 fl4->fl4_ipsec_spi = ah_hdr[1];
@@ -3332,7 +3338,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3332 pskb_may_pull(skb, xprth + 4 - skb->data)) { 3338 pskb_may_pull(skb, xprth + 4 - skb->data)) {
3333 __be16 *ipcomp_hdr; 3339 __be16 *ipcomp_hdr;
3334 3340
3335 xprth = skb_network_header(skb) + iph->ihl * 4; 3341 xprth = skb_network_header(skb) + ihl * 4;
3336 ipcomp_hdr = (__be16 *)xprth; 3342 ipcomp_hdr = (__be16 *)xprth;
3337 3343
3338 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1])); 3344 fl4->fl4_ipsec_spi = htonl(ntohs(ipcomp_hdr[1]));
@@ -3344,7 +3350,7 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3344 __be16 *greflags; 3350 __be16 *greflags;
3345 __be32 *gre_hdr; 3351 __be32 *gre_hdr;
3346 3352
3347 xprth = skb_network_header(skb) + iph->ihl * 4; 3353 xprth = skb_network_header(skb) + ihl * 4;
3348 greflags = (__be16 *)xprth; 3354 greflags = (__be16 *)xprth;
3349 gre_hdr = (__be32 *)xprth; 3355 gre_hdr = (__be32 *)xprth;
3350 3356
@@ -3360,10 +3366,6 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
3360 break; 3366 break;
3361 } 3367 }
3362 } 3368 }
3363 fl4->flowi4_proto = iph->protocol;
3364 fl4->daddr = reverse ? iph->saddr : iph->daddr;
3365 fl4->saddr = reverse ? iph->daddr : iph->saddr;
3366 fl4->flowi4_tos = iph->tos;
3367} 3369}
3368 3370
3369#if IS_ENABLED(CONFIG_IPV6) 3371#if IS_ENABLED(CONFIG_IPV6)