Skip to content

Commit

Permalink
RDS: add a sock_destruct callback debug aid
Browse files Browse the repository at this point in the history
This helps to detect the accidental processes/apps trying to destroy
the RDS socket which they are sharing with other processes/apps.

Reviewed-by: Ajaykumar Hotchandani <[email protected]>
Signed-off-by: Santosh Shilimkar <[email protected]>
Signed-off-by: Santosh Shilimkar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
SantoshShilimkar authored and davem330 committed Aug 25, 2015
1 parent 0c48424 commit 0df5f9a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/rds/af_rds.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,22 @@ static const struct proto_ops rds_proto_ops = {
.sendpage = sock_no_sendpage,
};

static void rds_sock_destruct(struct sock *sk)
{
struct rds_sock *rs = rds_sk_to_rs(sk);

WARN_ON((&rs->rs_item != rs->rs_item.next ||
&rs->rs_item != rs->rs_item.prev));
}

static int __rds_create(struct socket *sock, struct sock *sk, int protocol)
{
struct rds_sock *rs;

sock_init_data(sock, sk);
sock->ops = &rds_proto_ops;
sk->sk_protocol = protocol;
sk->sk_destruct = rds_sock_destruct;

rs = rds_sk_to_rs(sk);
spin_lock_init(&rs->rs_lock);
Expand Down

0 comments on commit 0df5f9a

Please sign in to comment.