aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-03-22 19:56:51 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-22 19:56:51 -0400
commitfc8717baa8f52dd8d1b90df9008300ef3ec794ed (patch)
tree149c5e1c8db5bcf2af47caeb732f900bc722875f
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>
-rw-r--r--include/net/raw.h4
-rw-r--r--include/net/sock.h2
-rw-r--r--net/ipv4/raw.c22
-rw-r--r--net/ipv6/raw.c16
4 files changed, 15 insertions, 29 deletions
diff --git a/include/net/raw.h b/include/net/raw.h
index 1828f81fe374..6c14a656357a 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -53,7 +53,7 @@ int raw_seq_open(struct inode *ino, struct file *file,
53 53
54#endif 54#endif
55 55
56void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h); 56void raw_hash_sk(struct sock *sk);
57void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h); 57void raw_unhash_sk(struct sock *sk);
58 58
59#endif /* _RAW_H */ 59#endif /* _RAW_H */
diff --git a/include/net/sock.h b/include/net/sock.h
index c3175c400b79..b433b1ed203d 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -504,6 +504,7 @@ extern int sk_wait_data(struct sock *sk, long *timeo);
504struct request_sock_ops; 504struct request_sock_ops;
505struct timewait_sock_ops; 505struct timewait_sock_ops;
506struct inet_hashinfo; 506struct inet_hashinfo;
507struct raw_hashinfo;
507 508
508/* Networking protocol blocks we attach to sockets. 509/* Networking protocol blocks we attach to sockets.
509 * socket layer -> transport layer interface 510 * socket layer -> transport layer interface
@@ -589,6 +590,7 @@ struct proto {
589 union { 590 union {
590 struct inet_hashinfo *hashinfo; 591 struct inet_hashinfo *hashinfo;
591 struct hlist_head *udp_hash; 592 struct hlist_head *udp_hash;
593 struct raw_hashinfo *raw_hash;
592 } h; 594 } h;
593 595
594 struct module *owner; 596 struct module *owner;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index e10ef6c2202a..b433b485a883 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -84,8 +84,9 @@ static struct raw_hashinfo raw_v4_hashinfo = {
84 .lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock), 84 .lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock),
85}; 85};
86 86
87void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h) 87void raw_hash_sk(struct sock *sk)
88{ 88{
89 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
89 struct hlist_head *head; 90 struct hlist_head *head;
90 91
91 head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)]; 92 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)
97} 98}
98EXPORT_SYMBOL_GPL(raw_hash_sk); 99EXPORT_SYMBOL_GPL(raw_hash_sk);
99 100
100void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h) 101void raw_unhash_sk(struct sock *sk)
101{ 102{
103 struct raw_hashinfo *h = sk->sk_prot->h.raw_hash;
104
102 write_lock_bh(&h->lock); 105 write_lock_bh(&h->lock);
103 if (sk_del_node_init(sk)) 106 if (sk_del_node_init(sk))
104 sock_prot_inuse_add(sk->sk_prot, -1); 107 sock_prot_inuse_add(sk->sk_prot, -1);
@@ -106,16 +109,6 @@ void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h)
106} 109}
107EXPORT_SYMBOL_GPL(raw_unhash_sk); 110EXPORT_SYMBOL_GPL(raw_unhash_sk);
108 111
109static void raw_v4_hash(struct sock *sk)
110{
111 raw_hash_sk(sk, &raw_v4_hashinfo);
112}
113
114static void raw_v4_unhash(struct sock *sk)
115{
116 raw_unhash_sk(sk, &raw_v4_hashinfo);
117}
118
119static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk, 112static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
120 unsigned short num, __be32 raddr, __be32 laddr, int dif) 113 unsigned short num, __be32 raddr, __be32 laddr, int dif)
121{ 114{
@@ -841,9 +834,10 @@ struct proto raw_prot = {
841 .recvmsg = raw_recvmsg, 834 .recvmsg = raw_recvmsg,
842 .bind = raw_bind, 835 .bind = raw_bind,
843 .backlog_rcv = raw_rcv_skb, 836 .backlog_rcv = raw_rcv_skb,
844 .hash = raw_v4_hash, 837 .hash = raw_hash_sk,
845 .unhash = raw_v4_unhash, 838 .unhash = raw_unhash_sk,
846 .obj_size = sizeof(struct raw_sock), 839 .obj_size = sizeof(struct raw_sock),
840 .h.raw_hash = &raw_v4_hashinfo,
847#ifdef CONFIG_COMPAT 841#ifdef CONFIG_COMPAT
848 .compat_setsockopt = compat_raw_setsockopt, 842 .compat_setsockopt = compat_raw_setsockopt,
849 .compat_getsockopt = compat_raw_getsockopt, 843 .compat_getsockopt = compat_raw_getsockopt,
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d6afa0216759..a9e4235157a2 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -65,17 +65,6 @@ static struct raw_hashinfo raw_v6_hashinfo = {
65 .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock), 65 .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock),
66}; 66};
67 67
68static void raw_v6_hash(struct sock *sk)
69{
70 raw_hash_sk(sk, &raw_v6_hashinfo);
71}
72
73static void raw_v6_unhash(struct sock *sk)
74{
75 raw_unhash_sk(sk, &raw_v6_hashinfo);
76}
77
78
79static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk, 68static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
80 unsigned short num, struct in6_addr *loc_addr, 69 unsigned short num, struct in6_addr *loc_addr,
81 struct in6_addr *rmt_addr, int dif) 70 struct in6_addr *rmt_addr, int dif)
@@ -1201,9 +1190,10 @@ struct proto rawv6_prot = {
1201 .recvmsg = rawv6_recvmsg, 1190 .recvmsg = rawv6_recvmsg,
1202 .bind = rawv6_bind, 1191 .bind = rawv6_bind,
1203 .backlog_rcv = rawv6_rcv_skb, 1192 .backlog_rcv = rawv6_rcv_skb,
1204 .hash = raw_v6_hash, 1193 .hash = raw_hash_sk,
1205 .unhash = raw_v6_unhash, 1194 .unhash = raw_unhash_sk,
1206 .obj_size = sizeof(struct raw6_sock), 1195 .obj_size = sizeof(struct raw6_sock),
1196 .h.raw_hash = &raw_v6_hashinfo,
1207#ifdef CONFIG_COMPAT 1197#ifdef CONFIG_COMPAT
1208 .compat_setsockopt = compat_rawv6_setsockopt, 1198 .compat_setsockopt = compat_rawv6_setsockopt,
1209 .compat_getsockopt = compat_rawv6_getsockopt, 1199 .compat_getsockopt = compat_rawv6_getsockopt,