Skip to content

Commit 0e00161

Browse files
Tom Herbertdavem330
authored andcommitted
net: Call skb_get_hash in get_xps_queue and __skb_tx_hash
Call standard function to get a packet hash instead of taking this from skb->sk->sk_hash or only using skb->protocol. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b73c3d0 commit 0e00161

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ static inline int netif_set_xps_queue(struct net_device *dev,
24862486
* as a distribution range limit for the returned value.
24872487
*/
24882488
static inline u16 skb_tx_hash(const struct net_device *dev,
2489-
const struct sk_buff *skb)
2489+
struct sk_buff *skb)
24902490
{
24912491
return __skb_tx_hash(dev, skb, dev->real_num_tx_queues);
24922492
}

include/linux/skbuff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,7 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb)
30053005
return skb->queue_mapping != 0;
30063006
}
30073007

3008-
u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
3008+
u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
30093009
unsigned int num_tx_queues);
30103010

30113011
static inline struct sec_path *skb_sec_path(struct sk_buff *skb)

net/core/flow_dissector.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,6 @@ static __always_inline u32 __flow_hash_3words(u32 a, u32 b, u32 c)
196196
return jhash_3words(a, b, c, hashrnd);
197197
}
198198

199-
static __always_inline u32 __flow_hash_1word(u32 a)
200-
{
201-
__flow_hash_secret_init();
202-
return jhash_1word(a, hashrnd);
203-
}
204-
205199
static inline u32 __flow_hash_from_keys(struct flow_keys *keys)
206200
{
207201
u32 hash;
@@ -253,7 +247,7 @@ EXPORT_SYMBOL(__skb_get_hash);
253247
* Returns a Tx hash based on the given packet descriptor a Tx queues' number
254248
* to be used as a distribution range.
255249
*/
256-
u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
250+
u16 __skb_tx_hash(const struct net_device *dev, struct sk_buff *skb,
257251
unsigned int num_tx_queues)
258252
{
259253
u32 hash;
@@ -273,13 +267,7 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,
273267
qcount = dev->tc_to_txq[tc].count;
274268
}
275269

276-
if (skb->sk && skb->sk->sk_hash)
277-
hash = skb->sk->sk_hash;
278-
else
279-
hash = (__force u16) skb->protocol;
280-
hash = __flow_hash_1word(hash);
281-
282-
return (u16) (((u64) hash * qcount) >> 32) + qoffset;
270+
return (u16) (((u64)skb_get_hash(skb) * qcount) >> 32) + qoffset;
283271
}
284272
EXPORT_SYMBOL(__skb_tx_hash);
285273

@@ -351,17 +339,10 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
351339
if (map) {
352340
if (map->len == 1)
353341
queue_index = map->queues[0];
354-
else {
355-
u32 hash;
356-
if (skb->sk && skb->sk->sk_hash)
357-
hash = skb->sk->sk_hash;
358-
else
359-
hash = (__force u16) skb->protocol ^
360-
skb->hash;
361-
hash = __flow_hash_1word(hash);
342+
else
362343
queue_index = map->queues[
363-
((u64)hash * map->len) >> 32];
364-
}
344+
((u64)skb_get_hash(skb) * map->len) >> 32];
345+
365346
if (unlikely(queue_index >= dev->real_num_tx_queues))
366347
queue_index = -1;
367348
}

0 commit comments

Comments
 (0)