mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
udp: secondary hash on (local port, local address)
Extends udp_table to contain a secondary hash table. socket anchor for this second hash is free, because UDP doesnt use skc_bind_node : We define an union to hold both skc_bind_node & a new hlist_nulls_node udp_portaddr_node udp_lib_get_port() inserts sockets into second hash chain (additional cost of one atomic op) udp_lib_unhash() deletes socket from second hash chain (additional cost of one atomic op) Note : No spinlock lockdep annotation is needed, because lock for the secondary hash chain is always get after lock for primary hash chain. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d4cada4ae1
commit
512615b6b8
4 changed files with 53 additions and 9 deletions
|
@ -63,10 +63,19 @@ struct udp_hslot {
|
|||
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 *);
|
||||
|
@ -75,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue