Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Pavel Emelyanov and committed by
David S. Miller
fc8717ba 6ba5a3c5

+15 -29
+2 -2
include/net/raw.h
··· 53 53 54 54 #endif 55 55 56 - void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h); 57 - void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h); 56 + void raw_hash_sk(struct sock *sk); 57 + void raw_unhash_sk(struct sock *sk); 58 58 59 59 #endif /* _RAW_H */
+2
include/net/sock.h
··· 504 504 struct request_sock_ops; 505 505 struct timewait_sock_ops; 506 506 struct inet_hashinfo; 507 + struct raw_hashinfo; 507 508 508 509 /* Networking protocol blocks we attach to sockets. 509 510 * socket layer -> transport layer interface ··· 590 589 union { 591 590 struct inet_hashinfo *hashinfo; 592 591 struct hlist_head *udp_hash; 592 + struct raw_hashinfo *raw_hash; 593 593 } h; 594 594 595 595 struct module *owner;
+8 -14
net/ipv4/raw.c
··· 84 84 .lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock), 85 85 }; 86 86 87 - void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h) 87 + void raw_hash_sk(struct sock *sk) 88 88 { 89 + struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; 89 90 struct hlist_head *head; 90 91 91 92 head = &h->ht[inet_sk(sk)->num & (RAW_HTABLE_SIZE - 1)]; ··· 98 97 } 99 98 EXPORT_SYMBOL_GPL(raw_hash_sk); 100 99 101 - void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h) 100 + void raw_unhash_sk(struct sock *sk) 102 101 { 102 + struct raw_hashinfo *h = sk->sk_prot->h.raw_hash; 103 + 103 104 write_lock_bh(&h->lock); 104 105 if (sk_del_node_init(sk)) 105 106 sock_prot_inuse_add(sk->sk_prot, -1); 106 107 write_unlock_bh(&h->lock); 107 108 } 108 109 EXPORT_SYMBOL_GPL(raw_unhash_sk); 109 - 110 - static void raw_v4_hash(struct sock *sk) 111 - { 112 - raw_hash_sk(sk, &raw_v4_hashinfo); 113 - } 114 - 115 - static void raw_v4_unhash(struct sock *sk) 116 - { 117 - raw_unhash_sk(sk, &raw_v4_hashinfo); 118 - } 119 110 120 111 static struct sock *__raw_v4_lookup(struct net *net, struct sock *sk, 121 112 unsigned short num, __be32 raddr, __be32 laddr, int dif) ··· 834 841 .recvmsg = raw_recvmsg, 835 842 .bind = raw_bind, 836 843 .backlog_rcv = raw_rcv_skb, 837 - .hash = raw_v4_hash, 838 - .unhash = raw_v4_unhash, 844 + .hash = raw_hash_sk, 845 + .unhash = raw_unhash_sk, 839 846 .obj_size = sizeof(struct raw_sock), 847 + .h.raw_hash = &raw_v4_hashinfo, 840 848 #ifdef CONFIG_COMPAT 841 849 .compat_setsockopt = compat_raw_setsockopt, 842 850 .compat_getsockopt = compat_raw_getsockopt,
+3 -13
net/ipv6/raw.c
··· 65 65 .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock), 66 66 }; 67 67 68 - static void raw_v6_hash(struct sock *sk) 69 - { 70 - raw_hash_sk(sk, &raw_v6_hashinfo); 71 - } 72 - 73 - static void raw_v6_unhash(struct sock *sk) 74 - { 75 - raw_unhash_sk(sk, &raw_v6_hashinfo); 76 - } 77 - 78 - 79 68 static struct sock *__raw_v6_lookup(struct net *net, struct sock *sk, 80 69 unsigned short num, struct in6_addr *loc_addr, 81 70 struct in6_addr *rmt_addr, int dif) ··· 1190 1201 .recvmsg = rawv6_recvmsg, 1191 1202 .bind = rawv6_bind, 1192 1203 .backlog_rcv = rawv6_rcv_skb, 1193 - .hash = raw_v6_hash, 1194 - .unhash = raw_v6_unhash, 1204 + .hash = raw_hash_sk, 1205 + .unhash = raw_unhash_sk, 1195 1206 .obj_size = sizeof(struct raw6_sock), 1207 + .h.raw_hash = &raw_v6_hashinfo, 1196 1208 #ifdef CONFIG_COMPAT 1197 1209 .compat_setsockopt = compat_rawv6_setsockopt, 1198 1210 .compat_getsockopt = compat_rawv6_getsockopt,