[<prev] [next>] [day] [month] [year] [list]
Message-ID: <AANLkTi=H16k81X9yiAyxOO0Au2cK97o03hR008UUyxhL@mail.gmail.com>
Date: Wed, 27 Oct 2010 17:28:07 +0400
From: Dmitry Popov <dp@...hloadlab.com>
To: "David S. Miller" <davem@...emloft.net>,
William.Allen.Simpson@...il.com,
Eric Dumazet <eric.dumazet@...il.com>,
Andreas Petlund <apetlund@...ula.no>,
Shan Wei <shanwei@...fujitsu.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Octavian Purdila <opurdila@...acom.com>,
Ilpo Järvinen <ilpo.jarvinen@...sinki.fi>,
Alexey Dobriyan <adobriyan@...il.com>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
"Pekka Savola (ipv6)" <pekkas@...core.fi>,
James Morris <jmorris@...ei.org>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Patrick McHardy <kaber@...sh.net>,
Evgeniy Polyakov <zbr@...emap.net>,
Laurent Chavey <chavey@...gle.com>,
Gilad Ben-Yossef <gilad@...efidence.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
"Steven J. Magnani" <steve@...idescorp.com>,
Joe Perches <joe@...ches.com>,
Stephen Hemminger <shemminger@...tta.com>,
Yony Amit <yony@...sleep.com>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, Artyom Gavrichenkov <ag@...hloadlab.com>
Subject: [PATCH 2/5] tcp: small user_mss code change
From: Dmitry Popov <dp@...hloadlab.com>
No double access to user_mss part of socket.
This is done to prevent possible race conditions if accessed without
socket lock.
Signed-off-by: Dmitry Popov <dp@...hloadlab.com>
---
net/ipv4/tcp_ipv4.c | 7 ++++---
net/ipv4/tcp_output.c | 6 ++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 3de881e..c7e9b2a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1510,6 +1510,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock
*sk, struct sk_buff *skb,
struct inet_sock *newinet;
struct tcp_sock *newtp;
struct sock *newsk;
+ int user_mss;
#ifdef CONFIG_TCP_MD5SIG
struct tcp_md5sig_key *key;
#endif
@@ -1545,9 +1546,9 @@ struct sock *tcp_v4_syn_recv_sock(struct sock
*sk, struct sk_buff *skb,
tcp_mtup_init(newsk);
tcp_sync_mss(newsk, dst_mtu(dst));
newtp->advmss = dst_metric(dst, RTAX_ADVMSS);
- if (tcp_sk(sk)->rx_opt.user_mss &&
- tcp_sk(sk)->rx_opt.user_mss < newtp->advmss)
- newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
+ user_mss = tcp_sk(sk)->rx_opt.user_mss;
+ if (user_mss && user_mss < newtp->advmss)
+ newtp->advmss = user_mss;
tcp_initialize_rcv_mss(newsk);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index eef2d66..561a7f3 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2416,6 +2416,7 @@ struct sk_buff *tcp_make_synack(struct sock *sk,
struct dst_entry *dst,
struct tcp_md5sig_key *md5;
int tcp_header_size;
int mss;
+ int user_mss;
int s_data_desired;
rcu_read_lock();
@@ -2439,8 +2440,9 @@ struct sk_buff *tcp_make_synack(struct sock *sk,
struct dst_entry *dst,
skb_dst_set(skb, dst_clone(dst));
mss = dst_metric(dst, RTAX_ADVMSS);
- if (tp->rx_opt.user_mss && tp->rx_opt.user_mss < mss)
- mss = tp->rx_opt.user_mss;
+ user_mss = tp->rx_opt.user_mss;
+ if (user_mss && user_mss < mss)
+ mss = user_mss;
if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */
__u8 rcv_wscale;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists