netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Eric Dumazet <edumazet@gmail.com>
Subject: [PATCH net-next 03/17] inet: constify ip_route_output_flow() socket argument
Date: Fri, 25 Sep 2015 07:39:10 -0700	[thread overview]
Message-ID: <1443191964-923-4-git-send-email-edumazet@google.com> (raw)
In-Reply-To: <1443191964-923-1-git-send-email-edumazet@google.com>

Very soon, TCP stack might call inet_csk_route_req(), which
calls inet_csk_route_req() with an unlocked listener socket,
so we need to make sure ip_route_output_flow() is not trying to
change any field from its socket argument.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/dst.h      | 9 +++++----
 include/net/route.h    | 2 +-
 net/ipv4/route.c       | 2 +-
 net/xfrm/xfrm_policy.c | 6 +++---
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index df0481a07029..779206c15f8b 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -489,7 +489,8 @@ struct flowi;
 #ifndef CONFIG_XFRM
 static inline struct dst_entry *xfrm_lookup(struct net *net,
 					    struct dst_entry *dst_orig,
-					    const struct flowi *fl, struct sock *sk,
+					    const struct flowi *fl,
+					    const struct sock *sk,
 					    int flags)
 {
 	return dst_orig;
@@ -498,7 +499,7 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
 static inline struct dst_entry *xfrm_lookup_route(struct net *net,
 						  struct dst_entry *dst_orig,
 						  const struct flowi *fl,
-						  struct sock *sk,
+						  const struct sock *sk,
 						  int flags)
 {
 	return dst_orig;
@@ -511,11 +512,11 @@ static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
 
 #else
 struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
-			      const struct flowi *fl, struct sock *sk,
+			      const struct flowi *fl, const struct sock *sk,
 			      int flags);
 
 struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
-				    const struct flowi *fl, struct sock *sk,
+				    const struct flowi *fl, const struct sock *sk,
 				    int flags);
 
 /* skb attached with this dst needs transformation if dst->xfrm is valid */
diff --git a/include/net/route.h b/include/net/route.h
index 10a7d21a211c..414beadc619f 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -114,7 +114,7 @@ void rt_cache_flush(struct net *net);
 void rt_flush_dev(struct net_device *dev);
 struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp);
 struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp,
-				    struct sock *sk);
+				    const struct sock *sk);
 struct dst_entry *ipv4_blackhole_route(struct net *net,
 				       struct dst_entry *dst_orig);
 
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 80f7c5b7b832..f7afcba8b1a1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2291,7 +2291,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
 }
 
 struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
-				    struct sock *sk)
+				    const struct sock *sk)
 {
 	struct rtable *rt = __ip_route_output_key(net, flp4);
 
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index e7f64bcb78a8..418daa038edf 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1208,7 +1208,7 @@ static inline int policy_to_flow_dir(int dir)
 	}
 }
 
-static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir,
+static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
 						 const struct flowi *fl)
 {
 	struct xfrm_policy *pol;
@@ -2185,7 +2185,7 @@ static struct dst_entry *make_blackhole(struct net *net, u16 family,
  */
 struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 			      const struct flowi *fl,
-			      struct sock *sk, int flags)
+			      const struct sock *sk, int flags)
 {
 	struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
 	struct flow_cache_object *flo;
@@ -2333,7 +2333,7 @@ EXPORT_SYMBOL(xfrm_lookup);
  */
 struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
 				    const struct flowi *fl,
-				    struct sock *sk, int flags)
+				    const struct sock *sk, int flags)
 {
 	struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk,
 					    flags | XFRM_LOOKUP_QUEUE |
-- 
2.6.0.rc2.230.g3dd15c0

  parent reply	other threads:[~2015-09-25 14:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 14:39 [PATCH net-next 00/17] dccp/tcp: constify listener sock Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 01/17] tcp: constify listener socket in tcp_v[46]_init_req() Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 02/17] tcp: constify tcp_openreq_init_rwin() Eric Dumazet
2015-09-25 14:39 ` Eric Dumazet [this message]
2015-09-25 14:39 ` [PATCH net-next 04/17] inet: constify inet_csk_route_req() socket argument Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 05/17] ipv6: constify ip6_dst_lookup_{flow|tail}() sock arguments Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 06/17] ipv6: constify inet6_csk_route_req() socket argument Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 07/17] inet: constify ip_dont_fragment() arguments Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 08/17] tcp: md5: constify tcp_md5_do_lookup() socket argument Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 09/17] ip: constify ip_build_and_send_pkt() " Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 10/17] tcp: remove tcp_synack_options() " Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 11/17] tcp: remove tcp_ecn_make_synack() " Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 12/17] tcp: constify tcp_make_synack() " Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 13/17] ipv6: constify ip6_xmit() sock argument Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 14/17] tcp: constify tcp_v{4|6}_send_synack() socket argument Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 15/17] dccp: constify dccp_make_response() " Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 16/17] tcp/dccp: constify rtx_synack() and friends Eric Dumazet
2015-09-25 14:39 ` [PATCH net-next 17/17] inet: constify inet_rtx_syn_ack() sock argument Eric Dumazet
2015-09-25 20:42 ` [PATCH net-next 00/17] dccp/tcp: constify listener sock David Miller
2015-09-25 21:03   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443191964-923-4-git-send-email-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).