Skip to content

Commit 8ba3846

Browse files
sowminivdavem330
authored andcommitted
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: Sowmini Varadhan <sowmini.varadhan@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d97dac5 commit 8ba3846

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

net/rds/af_rds.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ static int rds_getsockopt(struct socket *sock, int level, int optname,
339339
{
340340
struct rds_sock *rs = rds_sk_to_rs(sock->sk);
341341
int ret = -ENOPROTOOPT, len;
342+
int trans;
342343

343344
if (level != SOL_RDS)
344345
goto out;
@@ -364,6 +365,19 @@ static int rds_getsockopt(struct socket *sock, int level, int optname,
364365
else
365366
ret = 0;
366367
break;
368+
case SO_RDS_TRANSPORT:
369+
if (len < sizeof(int)) {
370+
ret = -EINVAL;
371+
break;
372+
}
373+
trans = (rs->rs_transport ? rs->rs_transport->t_type :
374+
RDS_TRANS_NONE); /* unbound */
375+
if (put_user(trans, (int __user *)optval) ||
376+
put_user(sizeof(int), optlen))
377+
ret = -EFAULT;
378+
else
379+
ret = 0;
380+
break;
367381
default:
368382
break;
369383
}

0 commit comments

Comments
 (0)