Commit 4b9d07a4 authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

net: introduce keepalive function in struct proto

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: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
Reviewed-by: default avatarUtz Bacher <utz.bacher@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c8584b3f
...@@ -1024,6 +1024,7 @@ struct proto { ...@@ -1024,6 +1024,7 @@ struct proto {
int (*getsockopt)(struct sock *sk, int level, int (*getsockopt)(struct sock *sk, int level,
int optname, char __user *optval, int optname, char __user *optval,
int __user *option); int __user *option);
void (*keepalive)(struct sock *sk, int valbool);
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
int (*compat_setsockopt)(struct sock *sk, int (*compat_setsockopt)(struct sock *sk,
int level, int level,
......
...@@ -762,11 +762,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -762,11 +762,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
goto set_rcvbuf; goto set_rcvbuf;
case SO_KEEPALIVE: case SO_KEEPALIVE:
#ifdef CONFIG_INET if (sk->sk_prot->keepalive)
if (sk->sk_protocol == IPPROTO_TCP && sk->sk_prot->keepalive(sk, valbool);
sk->sk_type == SOCK_STREAM)
tcp_set_keepalive(sk, valbool);
#endif
sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
break; break;
......
...@@ -2376,6 +2376,7 @@ struct proto tcp_prot = { ...@@ -2376,6 +2376,7 @@ struct proto tcp_prot = {
.shutdown = tcp_shutdown, .shutdown = tcp_shutdown,
.setsockopt = tcp_setsockopt, .setsockopt = tcp_setsockopt,
.getsockopt = tcp_getsockopt, .getsockopt = tcp_getsockopt,
.keepalive = tcp_set_keepalive,
.recvmsg = tcp_recvmsg, .recvmsg = tcp_recvmsg,
.sendmsg = tcp_sendmsg, .sendmsg = tcp_sendmsg,
.sendpage = tcp_sendpage, .sendpage = tcp_sendpage,
......
...@@ -617,6 +617,7 @@ void tcp_set_keepalive(struct sock *sk, int val) ...@@ -617,6 +617,7 @@ void tcp_set_keepalive(struct sock *sk, int val)
else if (!val) else if (!val)
inet_csk_delete_keepalive_timer(sk); inet_csk_delete_keepalive_timer(sk);
} }
EXPORT_SYMBOL_GPL(tcp_set_keepalive);
static void tcp_keepalive_timer (unsigned long data) static void tcp_keepalive_timer (unsigned long data)
......
...@@ -1889,6 +1889,7 @@ struct proto tcpv6_prot = { ...@@ -1889,6 +1889,7 @@ struct proto tcpv6_prot = {
.shutdown = tcp_shutdown, .shutdown = tcp_shutdown,
.setsockopt = tcp_setsockopt, .setsockopt = tcp_setsockopt,
.getsockopt = tcp_getsockopt, .getsockopt = tcp_getsockopt,
.keepalive = tcp_set_keepalive,
.recvmsg = tcp_recvmsg, .recvmsg = tcp_recvmsg,
.sendmsg = tcp_sendmsg, .sendmsg = tcp_sendmsg,
.sendpage = tcp_sendpage, .sendpage = tcp_sendpage,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment