Commit 8ba38460 authored by Sowmini Varadhan's avatar Sowmini Varadhan Committed by David S. Miller

net/rds Add getsockopt support for SO_RDS_TRANSPORT

The currently attached transport for a PF_RDS socket may be obtained
from user space by invoking getsockopt(2) using the SO_RDS_TRANSPORT
option at the SOL_RDS level. The integer optval returned will be one
of the RDS_TRANS_* constants defined in linux/rds.h.
Signed-off-by: default avatarSowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d97dac54
...@@ -339,6 +339,7 @@ static int rds_getsockopt(struct socket *sock, int level, int optname, ...@@ -339,6 +339,7 @@ static int rds_getsockopt(struct socket *sock, int level, int optname,
{ {
struct rds_sock *rs = rds_sk_to_rs(sock->sk); struct rds_sock *rs = rds_sk_to_rs(sock->sk);
int ret = -ENOPROTOOPT, len; int ret = -ENOPROTOOPT, len;
int trans;
if (level != SOL_RDS) if (level != SOL_RDS)
goto out; goto out;
...@@ -364,6 +365,19 @@ static int rds_getsockopt(struct socket *sock, int level, int optname, ...@@ -364,6 +365,19 @@ static int rds_getsockopt(struct socket *sock, int level, int optname,
else else
ret = 0; ret = 0;
break; break;
case SO_RDS_TRANSPORT:
if (len < sizeof(int)) {
ret = -EINVAL;
break;
}
trans = (rs->rs_transport ? rs->rs_transport->t_type :
RDS_TRANS_NONE); /* unbound */
if (put_user(trans, (int __user *)optval) ||
put_user(sizeof(int), optlen))
ret = -EFAULT;
else
ret = 0;
break;
default: default:
break; break;
} }
......
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