33 #include <linux/module.h>
34 #include <linux/errno.h>
35 #include <linux/kernel.h>
38 #include <linux/poll.h>
45 if ((index < elements) && array[index])
54 static unsigned long rds_sock_count;
69 struct sock *
sk = sock->
sk;
75 rs = rds_sk_to_rs(sk);
96 spin_lock_bh(&rds_sock_lock);
99 spin_unlock_bh(&rds_sock_lock);
123 __rds_wake_sk_sleep(rds_rs_to_sk(rs));
128 int *uaddr_len,
int peer)
133 memset(sin->sin_zero, 0,
sizeof(sin->sin_zero));
149 *uaddr_len =
sizeof(*sin);
170 static unsigned int rds_poll(
struct file *
file,
struct socket *sock,
173 struct sock *sk = sock->
sk;
174 struct rds_sock *rs = rds_sk_to_rs(sk);
175 unsigned int mask = 0;
178 poll_wait(file, sk_sleep(sk), wait);
181 poll_wait(file, &rds_poll_waitq, wait);
210 static int rds_ioctl(
struct socket *sock,
unsigned int cmd,
unsigned long arg)
215 static int rds_cancel_sent_to(
struct rds_sock *rs,
char __user *optval,
242 static int rds_set_bool_option(
unsigned char *optvar,
char __user *optval,
247 if (optlen <
sizeof(
int))
249 if (
get_user(value, (
int __user *) optval))
255 static int rds_cong_monitor(
struct rds_sock *rs,
char __user *optval,
273 static int rds_setsockopt(
struct socket *sock,
int level,
int optname,
274 char __user *optval,
unsigned int optlen)
286 ret = rds_cancel_sent_to(rs, optval, optlen);
298 ret = rds_set_bool_option(&rs->
rs_recverr, optval, optlen);
301 ret = rds_cong_monitor(rs, optval, optlen);
310 static int rds_getsockopt(
struct socket *sock,
int level,
int optname,
311 char __user *optval,
int __user *optlen)
331 if (len <
sizeof(
int))
349 static int rds_connect(
struct socket *sock,
struct sockaddr *uaddr,
350 int addr_len,
int flags)
352 struct sock *sk = sock->
sk;
354 struct rds_sock *rs = rds_sk_to_rs(sk);
382 static struct proto rds_proto = {
385 .obj_size =
sizeof(
struct rds_sock),
388 static const struct proto_ops rds_proto_ops = {
391 .release = rds_release,
393 .connect = rds_connect,
396 .getname = rds_getname,
401 .setsockopt = rds_setsockopt,
402 .getsockopt = rds_getsockopt,
409 static int __rds_create(
struct socket *sock,
struct sock *sk,
int protocol)
414 sock->
ops = &rds_proto_ops;
417 rs = rds_sk_to_rs(sk);
427 spin_lock_bh(&rds_sock_lock);
430 spin_unlock_bh(&rds_sock_lock);
447 return __rds_create(sock, sk, protocol);
452 sock_hold(rds_rs_to_sk(rs));
457 sock_put(rds_rs_to_sk(rs));
462 .create = rds_create,
466 static void rds_sock_inc_info(
struct socket *sock,
unsigned int len,
472 unsigned int total = 0;
476 spin_lock_bh(&rds_sock_lock);
492 spin_unlock_bh(&rds_sock_lock);
498 static void rds_sock_info(
struct socket *sock,
unsigned int len,
507 spin_lock_bh(&rds_sock_lock);
509 if (len < rds_sock_count)
513 sinfo.sndbuf = rds_sk_sndbuf(rs);
514 sinfo.rcvbuf = rds_sk_rcvbuf(rs);
525 lens->
nr = rds_sock_count;
528 spin_unlock_bh(&rds_sock_lock);
531 static void rds_exit(
void)
546 static int rds_init(
void)
591 #define DRV_VERSION "4.0"
592 #define DRV_RELDATE "Feb 12, 2009"