diff options
Diffstat (limited to 'net/ipv6/raw.c')
-rw-r--r-- | net/ipv6/raw.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 53f01b4982c7..15c72a6365a6 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -54,34 +54,34 @@ | |||
54 | #include <net/mip6.h> | 54 | #include <net/mip6.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #include <net/raw.h> | ||
57 | #include <net/rawv6.h> | 58 | #include <net/rawv6.h> |
58 | #include <net/xfrm.h> | 59 | #include <net/xfrm.h> |
59 | 60 | ||
60 | #include <linux/proc_fs.h> | 61 | #include <linux/proc_fs.h> |
61 | #include <linux/seq_file.h> | 62 | #include <linux/seq_file.h> |
62 | 63 | ||
63 | #define RAWV6_HTABLE_SIZE MAX_INET_PROTOS | 64 | static struct raw_hashinfo raw_v6_hashinfo = { |
64 | 65 | .lock = __RW_LOCK_UNLOCKED(), | |
65 | static struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; | 66 | }; |
66 | static DEFINE_RWLOCK(raw_v6_lock); | ||
67 | 67 | ||
68 | static void raw_v6_hash(struct sock *sk) | 68 | static void raw_v6_hash(struct sock *sk) |
69 | { | 69 | { |
70 | struct hlist_head *list = &raw_v6_htable[inet_sk(sk)->num & | 70 | struct hlist_head *list = &raw_v6_hashinfo.ht[inet_sk(sk)->num & |
71 | (RAWV6_HTABLE_SIZE - 1)]; | 71 | (RAW_HTABLE_SIZE - 1)]; |
72 | 72 | ||
73 | write_lock_bh(&raw_v6_lock); | 73 | write_lock_bh(&raw_v6_hashinfo.lock); |
74 | sk_add_node(sk, list); | 74 | sk_add_node(sk, list); |
75 | sock_prot_inc_use(sk->sk_prot); | 75 | sock_prot_inc_use(sk->sk_prot); |
76 | write_unlock_bh(&raw_v6_lock); | 76 | write_unlock_bh(&raw_v6_hashinfo.lock); |
77 | } | 77 | } |
78 | 78 | ||
79 | static void raw_v6_unhash(struct sock *sk) | 79 | static void raw_v6_unhash(struct sock *sk) |
80 | { | 80 | { |
81 | write_lock_bh(&raw_v6_lock); | 81 | write_lock_bh(&raw_v6_hashinfo.lock); |
82 | if (sk_del_node_init(sk)) | 82 | if (sk_del_node_init(sk)) |
83 | sock_prot_dec_use(sk->sk_prot); | 83 | sock_prot_dec_use(sk->sk_prot); |
84 | write_unlock_bh(&raw_v6_lock); | 84 | write_unlock_bh(&raw_v6_hashinfo.lock); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
@@ -180,8 +180,8 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr) | |||
180 | 180 | ||
181 | hash = nexthdr & (MAX_INET_PROTOS - 1); | 181 | hash = nexthdr & (MAX_INET_PROTOS - 1); |
182 | 182 | ||
183 | read_lock(&raw_v6_lock); | 183 | read_lock(&raw_v6_hashinfo.lock); |
184 | sk = sk_head(&raw_v6_htable[hash]); | 184 | sk = sk_head(&raw_v6_hashinfo.ht[hash]); |
185 | 185 | ||
186 | /* | 186 | /* |
187 | * The first socket found will be delivered after | 187 | * The first socket found will be delivered after |
@@ -238,7 +238,7 @@ static int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr) | |||
238 | IP6CB(skb)->iif); | 238 | IP6CB(skb)->iif); |
239 | } | 239 | } |
240 | out: | 240 | out: |
241 | read_unlock(&raw_v6_lock); | 241 | read_unlock(&raw_v6_hashinfo.lock); |
242 | return delivered; | 242 | return delivered; |
243 | } | 243 | } |
244 | 244 | ||
@@ -246,7 +246,7 @@ int raw6_local_deliver(struct sk_buff *skb, int nexthdr) | |||
246 | { | 246 | { |
247 | struct sock *raw_sk; | 247 | struct sock *raw_sk; |
248 | 248 | ||
249 | raw_sk = sk_head(&raw_v6_htable[nexthdr & (MAX_INET_PROTOS - 1)]); | 249 | raw_sk = sk_head(&raw_v6_hashinfo.ht[nexthdr & (MAX_INET_PROTOS - 1)]); |
250 | if (raw_sk && !ipv6_raw_deliver(skb, nexthdr)) | 250 | if (raw_sk && !ipv6_raw_deliver(skb, nexthdr)) |
251 | raw_sk = NULL; | 251 | raw_sk = NULL; |
252 | 252 | ||
@@ -368,10 +368,10 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr, | |||
368 | int hash; | 368 | int hash; |
369 | struct in6_addr *saddr, *daddr; | 369 | struct in6_addr *saddr, *daddr; |
370 | 370 | ||
371 | hash = nexthdr & (RAWV6_HTABLE_SIZE - 1); | 371 | hash = nexthdr & (RAW_HTABLE_SIZE - 1); |
372 | 372 | ||
373 | read_lock(&raw_v6_lock); | 373 | read_lock(&raw_v6_hashinfo.lock); |
374 | sk = sk_head(&raw_v6_htable[hash]); | 374 | sk = sk_head(&raw_v6_hashinfo.ht[hash]); |
375 | if (sk != NULL) { | 375 | if (sk != NULL) { |
376 | saddr = &ipv6_hdr(skb)->saddr; | 376 | saddr = &ipv6_hdr(skb)->saddr; |
377 | daddr = &ipv6_hdr(skb)->daddr; | 377 | daddr = &ipv6_hdr(skb)->daddr; |
@@ -383,7 +383,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr, | |||
383 | sk = sk_next(sk); | 383 | sk = sk_next(sk); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | read_unlock(&raw_v6_lock); | 386 | read_unlock(&raw_v6_hashinfo.lock); |
387 | } | 387 | } |
388 | 388 | ||
389 | static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) | 389 | static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) |
@@ -1221,8 +1221,9 @@ static struct sock *raw6_get_first(struct seq_file *seq) | |||
1221 | struct hlist_node *node; | 1221 | struct hlist_node *node; |
1222 | struct raw6_iter_state* state = raw6_seq_private(seq); | 1222 | struct raw6_iter_state* state = raw6_seq_private(seq); |
1223 | 1223 | ||
1224 | for (state->bucket = 0; state->bucket < RAWV6_HTABLE_SIZE; ++state->bucket) | 1224 | for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE; |
1225 | sk_for_each(sk, node, &raw_v6_htable[state->bucket]) | 1225 | ++state->bucket) |
1226 | sk_for_each(sk, node, &raw_v6_hashinfo.ht[state->bucket]) | ||
1226 | if (sk->sk_family == PF_INET6) | 1227 | if (sk->sk_family == PF_INET6) |
1227 | goto out; | 1228 | goto out; |
1228 | sk = NULL; | 1229 | sk = NULL; |
@@ -1240,8 +1241,8 @@ try_again: | |||
1240 | ; | 1241 | ; |
1241 | } while (sk && sk->sk_family != PF_INET6); | 1242 | } while (sk && sk->sk_family != PF_INET6); |
1242 | 1243 | ||
1243 | if (!sk && ++state->bucket < RAWV6_HTABLE_SIZE) { | 1244 | if (!sk && ++state->bucket < RAW_HTABLE_SIZE) { |
1244 | sk = sk_head(&raw_v6_htable[state->bucket]); | 1245 | sk = sk_head(&raw_v6_hashinfo.ht[state->bucket]); |
1245 | goto try_again; | 1246 | goto try_again; |
1246 | } | 1247 | } |
1247 | return sk; | 1248 | return sk; |
@@ -1258,7 +1259,7 @@ static struct sock *raw6_get_idx(struct seq_file *seq, loff_t pos) | |||
1258 | 1259 | ||
1259 | static void *raw6_seq_start(struct seq_file *seq, loff_t *pos) | 1260 | static void *raw6_seq_start(struct seq_file *seq, loff_t *pos) |
1260 | { | 1261 | { |
1261 | read_lock(&raw_v6_lock); | 1262 | read_lock(&raw_v6_hashinfo.lock); |
1262 | return *pos ? raw6_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; | 1263 | return *pos ? raw6_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; |
1263 | } | 1264 | } |
1264 | 1265 | ||
@@ -1276,7 +1277,7 @@ static void *raw6_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
1276 | 1277 | ||
1277 | static void raw6_seq_stop(struct seq_file *seq, void *v) | 1278 | static void raw6_seq_stop(struct seq_file *seq, void *v) |
1278 | { | 1279 | { |
1279 | read_unlock(&raw_v6_lock); | 1280 | read_unlock(&raw_v6_hashinfo.lock); |
1280 | } | 1281 | } |
1281 | 1282 | ||
1282 | static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i) | 1283 | static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i) |