Skip to content

Commit 8e2aadd

Browse files
nealcardwellJiri Slaby
authored andcommitted
tcp: fix tcp_release_cb() to dispatch via address family for mtu_reduced()
[ Upstream commit 4fab907 ] Make sure we use the correct address-family-specific function for handling MTU reductions from within tcp_release_cb(). Previously AF_INET6 sockets were incorrectly always using the IPv6 code path when sometimes they were handling IPv4 traffic and thus had an IPv4 dst. Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Diagnosed-by: Willem de Bruijn <willemb@google.com> Fixes: 563d34d ("tcp: dont drop MTU reduction indications") Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
1 parent 38268e2 commit 8e2aadd

6 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎include/net/inet_connection_sock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct inet_connection_sock_af_ops {
6262
void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
6363
int (*bind_conflict)(const struct sock *sk,
6464
const struct inet_bind_bucket *tb, bool relax);
65+
void (*mtu_reduced)(struct sock *sk);
6566
};
6667

6768
/** inet_connection_sock - INET connection oriented sock

‎include/net/sock.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ struct proto {
938938
struct sk_buff *skb);
939939

940940
void (*release_cb)(struct sock *sk);
941-
void (*mtu_reduced)(struct sock *sk);
942941

943942
/* Keeping track of sk's, looking them up, and port selection methods. */
944943
void (*hash)(struct sock *sk);

‎include/net/tcp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ extern const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
454454
*/
455455

456456
extern void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
457+
void tcp_v4_mtu_reduced(struct sock *sk);
457458
extern int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
458459
extern struct sock * tcp_create_openreq_child(struct sock *sk,
459460
struct request_sock *req,

‎net/ipv4/tcp_ipv4.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(tcp_v4_connect);
269269
* It can be called through tcp_release_cb() if socket was owned by user
270270
* at the time tcp_v4_err() was called to handle ICMP message.
271271
*/
272-
static void tcp_v4_mtu_reduced(struct sock *sk)
272+
void tcp_v4_mtu_reduced(struct sock *sk)
273273
{
274274
struct dst_entry *dst;
275275
struct inet_sock *inet = inet_sk(sk);
@@ -299,6 +299,7 @@ static void tcp_v4_mtu_reduced(struct sock *sk)
299299
tcp_simple_retransmit(sk);
300300
} /* else let the usual retransmit timer handle it */
301301
}
302+
EXPORT_SYMBOL(tcp_v4_mtu_reduced);
302303

303304
static void do_redirect(struct sk_buff *skb, struct sock *sk)
304305
{
@@ -2117,6 +2118,7 @@ const struct inet_connection_sock_af_ops ipv4_specific = {
21172118
.compat_setsockopt = compat_ip_setsockopt,
21182119
.compat_getsockopt = compat_ip_getsockopt,
21192120
#endif
2121+
.mtu_reduced = tcp_v4_mtu_reduced,
21202122
};
21212123
EXPORT_SYMBOL(ipv4_specific);
21222124

@@ -2796,7 +2798,6 @@ struct proto tcp_prot = {
27962798
.sendpage = tcp_sendpage,
27972799
.backlog_rcv = tcp_v4_do_rcv,
27982800
.release_cb = tcp_release_cb,
2799-
.mtu_reduced = tcp_v4_mtu_reduced,
28002801
.hash = inet_hash,
28012802
.unhash = inet_unhash,
28022803
.get_port = inet_csk_get_port,

‎net/ipv4/tcp_output.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ void tcp_release_cb(struct sock *sk)
785785
__sock_put(sk);
786786
}
787787
if (flags & (1UL << TCP_MTU_REDUCED_DEFERRED)) {
788-
sk->sk_prot->mtu_reduced(sk);
788+
inet_csk(sk)->icsk_af_ops->mtu_reduced(sk);
789789
__sock_put(sk);
790790
}
791791
}

‎net/ipv6/tcp_ipv6.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,7 @@ static const struct inet_connection_sock_af_ops ipv6_specific = {
16511651
.compat_setsockopt = compat_ipv6_setsockopt,
16521652
.compat_getsockopt = compat_ipv6_getsockopt,
16531653
#endif
1654+
.mtu_reduced = tcp_v6_mtu_reduced,
16541655
};
16551656

16561657
#ifdef CONFIG_TCP_MD5SIG
@@ -1682,6 +1683,7 @@ static const struct inet_connection_sock_af_ops ipv6_mapped = {
16821683
.compat_setsockopt = compat_ipv6_setsockopt,
16831684
.compat_getsockopt = compat_ipv6_getsockopt,
16841685
#endif
1686+
.mtu_reduced = tcp_v4_mtu_reduced,
16851687
};
16861688

16871689
#ifdef CONFIG_TCP_MD5SIG
@@ -1919,7 +1921,6 @@ struct proto tcpv6_prot = {
19191921
.sendpage = tcp_sendpage,
19201922
.backlog_rcv = tcp_v6_do_rcv,
19211923
.release_cb = tcp_release_cb,
1922-
.mtu_reduced = tcp_v6_mtu_reduced,
19231924
.hash = tcp_v6_hash,
19241925
.unhash = inet_unhash,
19251926
.get_port = inet_csk_get_port,

0 commit comments

Comments
 (0)