diff mbox

[-next,1/3] net: add inet_sk_transparent() helper

Message ID 1450729766-14926-2-git-send-email-fw@strlen.de
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Florian Westphal Dec. 21, 2015, 8:29 p.m. UTC
Avoids cluttering tcp_v4_send_reset when followup patch extends
it to deal with timewait sockets.

Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 include/net/request_sock.h |  2 +-
 include/net/tcp.h          | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

Eric Dumazet Dec. 22, 2015, 7:04 p.m. UTC | #1
On Mon, 2015-12-21 at 21:29 +0100, Florian Westphal wrote:
> Avoids cluttering tcp_v4_send_reset when followup patch extends
> it to deal with timewait sockets.
> 
> Suggested-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Frederic Sowa Dec. 22, 2015, 9:46 p.m. UTC | #2
On 21.12.2015 21:29, Florian Westphal wrote:
> Avoids cluttering tcp_v4_send_reset when followup patch extends
> it to deal with timewait sockets.
> 
> Suggested-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Florian Westphal <fw@strlen.de>

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index a0dde04..f49759d 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -68,7 +68,7 @@  struct request_sock {
 	u32				peer_secid;
 };
 
-static inline struct request_sock *inet_reqsk(struct sock *sk)
+static inline struct request_sock *inet_reqsk(const struct sock *sk)
 {
 	return (struct request_sock *)sk;
 }
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3077735b..f33fecf 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1620,6 +1620,18 @@  static inline void tcp_highest_sack_combine(struct sock *sk,
 		tcp_sk(sk)->highest_sack = new;
 }
 
+/* This helper checks if socket has IP_TRANSPARENT set */
+static inline bool inet_sk_transparent(const struct sock *sk)
+{
+	switch (sk->sk_state) {
+	case TCP_TIME_WAIT:
+		return inet_twsk(sk)->tw_transparent;
+	case TCP_NEW_SYN_RECV:
+		return inet_rsk(inet_reqsk(sk))->no_srccheck;
+	}
+	return inet_sk(sk)->transparent;
+}
+
 /* Determines whether this is a thin stream (which may suffer from
  * increased latency). Used to trigger latency-reducing mechanisms.
  */