From: Ursula Braun <ubraun@linux.vnet.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
utz.bacher@de.ibm.com, ubraun@linux.vnet.ibm.com
Subject: [PATCH V3 net-next 01/15] net: introduce keepalive function in struct proto
Date: Thu, 24 Nov 2016 16:06:31 +0100 [thread overview]
Message-ID: <20161124150645.90881-2-ubraun@linux.vnet.ibm.com> (raw)
In-Reply-To: <20161124150645.90881-1-ubraun@linux.vnet.ibm.com>
Direct call of tcp_set_keepalive() function from protocol-agnostic
sock_setsockopt() function in net/core/sock.c violates network
layering. And newly introduced protocol (SMC-R) will need its own
keepalive function. Therefore, add "keepalive" function pointer
to "struct proto", and call it from sock_setsockopt() via this pointer.
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: Utz Bacher <utz.bacher@de.ibm.com>
---
include/net/sock.h | 1 +
net/core/sock.c | 7 ++-----
net/ipv4/tcp_ipv4.c | 1 +
net/ipv4/tcp_timer.c | 1 +
net/ipv6/tcp_ipv6.c | 1 +
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 442cbb1..cb4359b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -993,6 +993,7 @@ struct proto {
int (*getsockopt)(struct sock *sk, int level,
int optname, char __user *optval,
int __user *option);
+ void (*keepalive)(struct sock *sk, int valbool);
#ifdef CONFIG_COMPAT
int (*compat_setsockopt)(struct sock *sk,
int level,
diff --git a/net/core/sock.c b/net/core/sock.c
index 14e6145..ac8137d 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -762,11 +762,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
goto set_rcvbuf;
case SO_KEEPALIVE:
-#ifdef CONFIG_INET
- if (sk->sk_protocol == IPPROTO_TCP &&
- sk->sk_type == SOCK_STREAM)
- tcp_set_keepalive(sk, valbool);
-#endif
+ if (sk->sk_prot->keepalive)
+ sk->sk_prot->keepalive(sk, valbool);
sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
break;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5555eb8..70f5524 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2375,6 +2375,7 @@ struct proto tcp_prot = {
.shutdown = tcp_shutdown,
.setsockopt = tcp_setsockopt,
.getsockopt = tcp_getsockopt,
+ .keepalive = tcp_set_keepalive,
.recvmsg = tcp_recvmsg,
.sendmsg = tcp_sendmsg,
.sendpage = tcp_sendpage,
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 3ea1cf8..9b1602a 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -617,6 +617,7 @@ void tcp_set_keepalive(struct sock *sk, int val)
else if (!val)
inet_csk_delete_keepalive_timer(sk);
}
+EXPORT_SYMBOL(tcp_set_keepalive);
static void tcp_keepalive_timer (unsigned long data)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 28ec0a2..5d4f58f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1886,6 +1886,7 @@ struct proto tcpv6_prot = {
.shutdown = tcp_shutdown,
.setsockopt = tcp_setsockopt,
.getsockopt = tcp_getsockopt,
+ .keepalive = tcp_set_keepalive,
.recvmsg = tcp_recvmsg,
.sendmsg = tcp_sendmsg,
.sendpage = tcp_sendpage,
--
2.8.4
next prev parent reply other threads:[~2016-11-24 15:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 15:06 [PATCH V3 net-next 00/15] net/smc: Shared Memory Communications - RDMA Ursula Braun
2016-11-24 15:06 ` Ursula Braun [this message]
2016-11-26 1:41 ` [PATCH V3 net-next 01/15] net: introduce keepalive function in struct proto David Miller
2016-11-24 15:06 ` [PATCH V3 net-next 02/15] smc: establish new socket family Ursula Braun
2016-11-26 1:47 ` David Miller
2016-11-24 15:06 ` [PATCH V3 net-next 03/15] smc: establish pnet table management Ursula Braun
2016-11-26 1:51 ` David Miller
2016-11-24 15:06 ` [PATCH V3 net-next 04/15] smc: introduce SMC as an IB-client Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 05/15] smc: CLC handshake (incl. preparation steps) Ursula Braun
2016-11-26 1:53 ` David Miller
2016-11-24 15:06 ` [PATCH V3 net-next 06/15] smc: connection and link group creation Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 07/15] smc: remote memory buffers (RMBs) Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 08/15] smc: work request (WR) base for use by LLC and CDC Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 09/15] smc: initialize IB transport incl. PD, MR, QP, CQ, event, WR Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 10/15] smc: link layer control (LLC) Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 11/15] smc: connection data control (CDC) Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 12/15] smc: send data (through RDMA) Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 13/15] smc: receive data from RMBE Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 14/15] smc: socket closing and linkgroup cleanup Ursula Braun
2016-11-24 15:06 ` [PATCH V3 net-next 15/15] smc: netlink interface for SMC sockets Ursula Braun
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=20161124150645.90881-2-ubraun@linux.vnet.ibm.com \
--to=ubraun@linux.vnet.ibm.com \
--cc=davem@davemloft.net \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--cc=utz.bacher@de.ibm.com \
/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).