aboutsummaryrefslogtreecommitdiff
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-03-22 16:56:51 -0700
committerDavid S. Miller <davem@davemloft.net>2008-03-22 16:56:51 -0700
commitfc8717baa8f52dd8d1b90df9008300ef3ec794ed (patch)
tree149c5e1c8db5bcf2af47caeb732f900bc722875f /net/ipv4/raw.c
parent6ba5a3c52da00015e739469e3b00cd6d0d4c5c67 (diff)
[RAW]: Add raw_hashinfo member on struct proto.
Sorry for the patch sequence confusion :| but I found that the similar thing can be done for raw sockets easily too late. Expand the proto.h union with the raw_hashinfo member and use it in raw_prot and rawv6_prot. This allows to drop the protocol specific versions of hash and unhash callbacks. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index e10ef6c2202..b433b485a88 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -84,8 +84,9 @@ static struct raw_hashinfo raw_v4_hashinfo = {
.lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock),
};
-void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h)
+void raw_hash_sk(struct sock *sk)
{
+ struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
struct hlist_head *head;
head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)];
@@ -97,8 +98,10 @@ void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h)
}
EXPORT_SYMBOL_GPL(raw_hash_sk);
-void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h)
+void raw_unhash_sk(struct sock *sk)
{
+ struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
+
write_lock_bh(&h->lock);
if (sk_del_node_init(sk))
sock_prot_inuse_add(sk->sk_prot, -1);
@@ -106,16 +109,6 @@ void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h)
}
EXPORT_SYMBOL_GPL(raw_unhash_sk);
-static void raw_v4_hash(struct sock *sk)
-{
- raw_hash_sk(sk, &raw_v4_hashinfo);
-}
-
-static void raw_v4_unhash(struct sock *sk)
-{
- raw_unhash_sk(sk, &raw_v4_hashinfo);
-}
-
static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
unsigned short num, __be32 raddr, __be32 laddr, int dif)
{
@@ -841,9 +834,10 @@ struct proto raw_prot = {
.recvmsg = raw_recvmsg,
.bind = raw_bind,
.backlog_rcv = raw_rcv_skb,
- .hash = raw_v4_hash,
- .unhash = raw_v4_unhash,
+ .hash = raw_hash_sk,
+ .unhash = raw_unhash_sk,
.obj_size = sizeof(struct raw_sock),
+ .h.raw_hash = &raw_v4_hashinfo,
#ifdef CONFIG_COMPAT
.compat_setsockopt = compat_raw_setsockopt,
.compat_getsockopt = compat_raw_getsockopt,