Skip to content

Commit ba804bb

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The per-network-namespace loopback device, and thus its namespace, can have its teardown deferred for a long time if a kernel created TCP socket closes and the namespace is exiting meanwhile. The kernel keeps trying to finish the close sequence until it times out (which takes quite some time). Fix this by forcing the socket closed in this situation, from Dan Streetman. 2) Fix regression where we're trying to invoke the update_pmtu method on route types (in this case metadata tunnel routes) that don't implement the dst_ops method. Fix from Nicolas Dichtel. 3) Fix long standing memory corruption issues in r8169 driver by performing the chip statistics DMA programming more correctly. From Francois Romieu. 4) Handle local broadcast sends over VRF routes properly, from David Ahern. 5) Don't refire the DCCP CCID2 timer endlessly, otherwise the socket can never be released. From Alexey Kodanev. 6) Set poll flags properly in VSOCK protocol layer, from Stefan Hajnoczi. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: VSOCK: set POLLOUT | POLLWRNORM for TCP_CLOSING dccp: don't restart ccid2_hc_tx_rto_expire() if sk in closed state net: vrf: Add support for sends to local broadcast address r8169: fix memory corruption on retrieval of hardware statistics. net: don't call update_pmtu unconditionally net: tcp: close sock if net namespace is exiting
2 parents db21854 + ba3169f commit ba804bb

File tree

16 files changed

+57
-28
lines changed

16 files changed

+57
-28
lines changed

drivers/infiniband/ulp/ipoib/ipoib_cm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,7 @@ void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
14561456
struct ipoib_dev_priv *priv = ipoib_priv(dev);
14571457
int e = skb_queue_empty(&priv->cm.skb_queue);
14581458

1459-
if (skb_dst(skb))
1460-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
1459+
skb_dst_update_pmtu(skb, mtu);
14611460

14621461
skb_queue_tail(&priv->cm.skb_queue, skb);
14631462
if (e)

drivers/net/ethernet/realtek/r8169.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,19 +2244,14 @@ static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
22442244
void __iomem *ioaddr = tp->mmio_addr;
22452245
dma_addr_t paddr = tp->counters_phys_addr;
22462246
u32 cmd;
2247-
bool ret;
22482247

22492248
RTL_W32(CounterAddrHigh, (u64)paddr >> 32);
2249+
RTL_R32(CounterAddrHigh);
22502250
cmd = (u64)paddr & DMA_BIT_MASK(32);
22512251
RTL_W32(CounterAddrLow, cmd);
22522252
RTL_W32(CounterAddrLow, cmd | counter_cmd);
22532253

2254-
ret = rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000);
2255-
2256-
RTL_W32(CounterAddrLow, 0);
2257-
RTL_W32(CounterAddrHigh, 0);
2258-
2259-
return ret;
2254+
return rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000);
22602255
}
22612256

22622257
static bool rtl8169_reset_counters(struct net_device *dev)

drivers/net/geneve.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
829829
int mtu = dst_mtu(&rt->dst) - sizeof(struct iphdr) -
830830
GENEVE_BASE_HLEN - info->options_len - 14;
831831

832-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
832+
skb_dst_update_pmtu(skb, mtu);
833833
}
834834

835835
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
@@ -875,7 +875,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
875875
int mtu = dst_mtu(dst) - sizeof(struct ipv6hdr) -
876876
GENEVE_BASE_HLEN - info->options_len - 14;
877877

878-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
878+
skb_dst_update_pmtu(skb, mtu);
879879
}
880880

881881
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);

drivers/net/vrf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,9 @@ static struct sk_buff *vrf_ip_out(struct net_device *vrf_dev,
673673
struct sock *sk,
674674
struct sk_buff *skb)
675675
{
676-
/* don't divert multicast */
677-
if (ipv4_is_multicast(ip_hdr(skb)->daddr))
676+
/* don't divert multicast or local broadcast */
677+
if (ipv4_is_multicast(ip_hdr(skb)->daddr) ||
678+
ipv4_is_lbcast(ip_hdr(skb)->daddr))
678679
return skb;
679680

680681
if (qdisc_tx_is_default(vrf_dev))

drivers/net/vxlan.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,8 +2158,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
21582158
if (skb_dst(skb)) {
21592159
int mtu = dst_mtu(ndst) - VXLAN_HEADROOM;
21602160

2161-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL,
2162-
skb, mtu);
2161+
skb_dst_update_pmtu(skb, mtu);
21632162
}
21642163

21652164
tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
@@ -2200,8 +2199,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
22002199
if (skb_dst(skb)) {
22012200
int mtu = dst_mtu(ndst) - VXLAN6_HEADROOM;
22022201

2203-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL,
2204-
skb, mtu);
2202+
skb_dst_update_pmtu(skb, mtu);
22052203
}
22062204

22072205
tos = ip_tunnel_ecn_encap(tos, old_iph, skb);

include/net/dst.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,4 +521,12 @@ static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
521521
}
522522
#endif
523523

524+
static inline void skb_dst_update_pmtu(struct sk_buff *skb, u32 mtu)
525+
{
526+
struct dst_entry *dst = skb_dst(skb);
527+
528+
if (dst && dst->ops->update_pmtu)
529+
dst->ops->update_pmtu(dst, NULL, skb, mtu);
530+
}
531+
524532
#endif /* _NET_DST_H */

include/net/net_namespace.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ int net_eq(const struct net *net1, const struct net *net2)
223223
return net1 == net2;
224224
}
225225

226+
static inline int check_net(const struct net *net)
227+
{
228+
return atomic_read(&net->count) != 0;
229+
}
230+
226231
void net_drop_ns(void *);
227232

228233
#else
@@ -247,6 +252,11 @@ int net_eq(const struct net *net1, const struct net *net2)
247252
return 1;
248253
}
249254

255+
static inline int check_net(const struct net *net)
256+
{
257+
return 1;
258+
}
259+
250260
#define net_drop_ns NULL
251261
#endif
252262

net/dccp/ccids/ccid2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ static void ccid2_hc_tx_rto_expire(struct timer_list *t)
140140

141141
ccid2_pr_debug("RTO_EXPIRE\n");
142142

143+
if (sk->sk_state == DCCP_CLOSED)
144+
goto out;
145+
143146
/* back-off timer */
144147
hc->tx_rto <<= 1;
145148
if (hc->tx_rto > DCCP_RTO_MAX)

net/ipv4/ip_tunnel.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
520520
else
521521
mtu = skb_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu;
522522

523-
if (skb_dst(skb))
524-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
523+
skb_dst_update_pmtu(skb, mtu);
525524

526525
if (skb->protocol == htons(ETH_P_IP)) {
527526
if (!skb_is_gso(skb) &&

net/ipv4/ip_vti.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
200200

201201
mtu = dst_mtu(dst);
202202
if (skb->len > mtu) {
203-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
203+
skb_dst_update_pmtu(skb, mtu);
204204
if (skb->protocol == htons(ETH_P_IP)) {
205205
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
206206
htonl(mtu));

net/ipv4/tcp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,9 @@ void tcp_close(struct sock *sk, long timeout)
22982298
tcp_send_active_reset(sk, GFP_ATOMIC);
22992299
__NET_INC_STATS(sock_net(sk),
23002300
LINUX_MIB_TCPABORTONMEMORY);
2301+
} else if (!check_net(sock_net(sk))) {
2302+
/* Not possible to send reset; just close */
2303+
tcp_set_state(sk, TCP_CLOSE);
23012304
}
23022305
}
23032306

net/ipv4/tcp_timer.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,19 @@ static void tcp_write_err(struct sock *sk)
4848
* to prevent DoS attacks. It is called when a retransmission timeout
4949
* or zero probe timeout occurs on orphaned socket.
5050
*
51+
* Also close if our net namespace is exiting; in that case there is no
52+
* hope of ever communicating again since all netns interfaces are already
53+
* down (or about to be down), and we need to release our dst references,
54+
* which have been moved to the netns loopback interface, so the namespace
55+
* can finish exiting. This condition is only possible if we are a kernel
56+
* socket, as those do not hold references to the namespace.
57+
*
5158
* Criteria is still not confirmed experimentally and may change.
5259
* We kill the socket, if:
5360
* 1. If number of orphaned sockets exceeds an administratively configured
5461
* limit.
5562
* 2. If we have strong memory pressure.
63+
* 3. If our net namespace is exiting.
5664
*/
5765
static int tcp_out_of_resources(struct sock *sk, bool do_reset)
5866
{
@@ -81,6 +89,13 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
8189
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
8290
return 1;
8391
}
92+
93+
if (!check_net(sock_net(sk))) {
94+
/* Not possible to send reset; just close */
95+
tcp_done(sk);
96+
return 1;
97+
}
98+
8499
return 0;
85100
}
86101

net/ipv6/ip6_tunnel.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
642642
if (rel_info > dst_mtu(skb_dst(skb2)))
643643
goto out;
644644

645-
skb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), NULL, skb2,
646-
rel_info);
645+
skb_dst_update_pmtu(skb2, rel_info);
647646
}
648647

649648
icmp_send(skb2, rel_type, rel_code, htonl(rel_info));
@@ -1131,8 +1130,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
11311130
mtu = 576;
11321131
}
11331132

1134-
if (skb_dst(skb) && !t->parms.collect_md)
1135-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
1133+
skb_dst_update_pmtu(skb, mtu);
11361134
if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) {
11371135
*pmtu = mtu;
11381136
err = -EMSGSIZE;

net/ipv6/ip6_vti.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
483483

484484
mtu = dst_mtu(dst);
485485
if (!skb->ignore_df && skb->len > mtu) {
486-
skb_dst(skb)->ops->update_pmtu(dst, NULL, skb, mtu);
486+
skb_dst_update_pmtu(skb, mtu);
487487

488488
if (skb->protocol == htons(ETH_P_IPV6)) {
489489
if (mtu < IPV6_MIN_MTU)

net/ipv6/sit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
934934
df = 0;
935935
}
936936

937-
if (tunnel->parms.iph.daddr && skb_dst(skb))
938-
skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
937+
if (tunnel->parms.iph.daddr)
938+
skb_dst_update_pmtu(skb, mtu);
939939

940940
if (skb->len > mtu && !skb_is_gso(skb)) {
941941
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);

net/vmw_vsock/af_vsock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static unsigned int vsock_poll(struct file *file, struct socket *sock,
951951
* POLLOUT|POLLWRNORM when peer is closed and nothing to read,
952952
* but local send is not shutdown.
953953
*/
954-
if (sk->sk_state == TCP_CLOSE) {
954+
if (sk->sk_state == TCP_CLOSE || sk->sk_state == TCP_CLOSING) {
955955
if (!(sk->sk_shutdown & SEND_SHUTDOWN))
956956
mask |= POLLOUT | POLLWRNORM;
957957

0 commit comments

Comments
 (0)