aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/udp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/udp.h')
-rw-r--r--include/net/udp.h42
1 files changed, 38 insertions, 4 deletions
diff --git a/include/net/udp.h b/include/net/udp.h
index f98abd2ce709..5348d80b25bb 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -50,16 +50,49 @@ struct udp_skb_cb {
50}; 50};
51#define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb)) 51#define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
52 52
53/**
54 * struct udp_hslot - UDP hash slot
55 *
56 * @head: head of list of sockets
57 * @count: number of sockets in 'head' list
58 * @lock: spinlock protecting changes to head/count
59 */
53struct udp_hslot { 60struct udp_hslot {
54 struct hlist_nulls_head head; 61 struct hlist_nulls_head head;
62 int count;
55 spinlock_t lock; 63 spinlock_t lock;
56} __attribute__((aligned(2 * sizeof(long)))); 64} __attribute__((aligned(2 * sizeof(long))));
65
66/**
67 * struct udp_table - UDP table
68 *
69 * @hash: hash table, sockets are hashed on (local port)
70 * @hash2: hash table, sockets are hashed on (local port, local address)
71 * @mask: number of slots in hash tables, minus 1
72 * @log: log2(number of slots in hash table)
73 */
57struct udp_table { 74struct udp_table {
58 struct udp_hslot hash[UDP_HTABLE_SIZE]; 75 struct udp_hslot *hash;
76 struct udp_hslot *hash2;
77 unsigned int mask;
78 unsigned int log;
59}; 79};
60extern struct udp_table udp_table; 80extern struct udp_table udp_table;
61extern void udp_table_init(struct udp_table *); 81extern void udp_table_init(struct udp_table *, const char *);
62 82static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
83 struct net *net, unsigned num)
84{
85 return &table->hash[udp_hashfn(net, num, table->mask)];
86}
87/*
88 * For secondary hash, net_hash_mix() is performed before calling
89 * udp_hashslot2(), this explains difference with udp_hashslot()
90 */
91static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
92 unsigned int hash)
93{
94 return &table->hash2[hash & table->mask];
95}
63 96
64/* Note: this must match 'valbool' in sock_setsockopt */ 97/* Note: this must match 'valbool' in sock_setsockopt */
65#define UDP_CSUM_NOXMIT 1 98#define UDP_CSUM_NOXMIT 1
@@ -125,7 +158,8 @@ static inline void udp_lib_close(struct sock *sk, long timeout)
125} 158}
126 159
127extern int udp_lib_get_port(struct sock *sk, unsigned short snum, 160extern int udp_lib_get_port(struct sock *sk, unsigned short snum,
128 int (*)(const struct sock*,const struct sock*)); 161 int (*)(const struct sock *,const struct sock *),
162 unsigned int hash2_nulladdr);
129 163
130/* net/ipv4/udp.c */ 164/* net/ipv4/udp.c */
131extern int udp_get_port(struct sock *sk, unsigned short snum, 165extern int udp_get_port(struct sock *sk, unsigned short snum,