netfilter: nf_conntrack: fix a race in __nf_conntrack_confirm against nf_ct_get_next_...
[safe/jmp/linux-2.6] / include / net / udp.h
index 22aa2e7..5348d80 100644 (file)
@@ -50,15 +50,32 @@ struct udp_skb_cb {
 };
 #define UDP_SKB_CB(__skb)      ((struct udp_skb_cb *)((__skb)->cb))
 
+/**
+ *     struct udp_hslot - UDP hash slot
+ *
+ *     @head:  head of list of sockets
+ *     @count: number of sockets in 'head' list
+ *     @lock:  spinlock protecting changes to head/count
+ */
 struct udp_hslot {
        struct hlist_nulls_head head;
+       int                     count;
        spinlock_t              lock;
 } __attribute__((aligned(2 * sizeof(long))));
 
+/**
+ *     struct udp_table - UDP table
+ *
+ *     @hash:  hash table, sockets are hashed on (local port)
+ *     @hash2: hash table, sockets are hashed on (local port, local address)
+ *     @mask:  number of slots in hash tables, minus 1
+ *     @log:   log2(number of slots in hash table)
+ */
 struct udp_table {
        struct udp_hslot        *hash;
-       unsigned int mask;
-       unsigned int log;
+       struct udp_hslot        *hash2;
+       unsigned int            mask;
+       unsigned int            log;
 };
 extern struct udp_table udp_table;
 extern void udp_table_init(struct udp_table *, const char *);
@@ -67,6 +84,15 @@ static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
 {
        return &table->hash[udp_hashfn(net, num, table->mask)];
 }
+/*
+ * For secondary hash, net_hash_mix() is performed before calling
+ * udp_hashslot2(), this explains difference with udp_hashslot()
+ */
+static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
+                                             unsigned int hash)
+{
+       return &table->hash2[hash & table->mask];
+}
 
 /* Note: this must match 'valbool' in sock_setsockopt */
 #define UDP_CSUM_NOXMIT                1
@@ -132,7 +158,8 @@ static inline void udp_lib_close(struct sock *sk, long timeout)
 }
 
 extern int     udp_lib_get_port(struct sock *sk, unsigned short snum,
-               int (*)(const struct sock*,const struct sock*));
+               int (*)(const struct sock *,const struct sock *),
+               unsigned int hash2_nulladdr);
 
 /* net/ipv4/udp.c */
 extern int     udp_get_port(struct sock *sk, unsigned short snum,