Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 103592
b: refs/heads/master
c: 8f0f222
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Jul 18, 2008
1 parent bd1aa73 commit 585527d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 51cb6db0f5654f08a4a6bfa3888dc36a51c2df3e
refs/heads/master: 8f0f2223cc08a5ae9a77f40edfe02e8a9f1abd77
52 changes: 52 additions & 0 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
#include <linux/ctype.h>
#include <linux/if_arp.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/in.h>

#include "net-sysfs.h"

Expand Down Expand Up @@ -1665,13 +1668,62 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
* --BLG
*/

static u16 simple_tx_hash(struct net_device *dev, struct sk_buff *skb)
{
u32 *addr, *ports, hash, ihl;
u8 ip_proto;
int alen;

switch (skb->protocol) {
case __constant_htons(ETH_P_IP):
ip_proto = ip_hdr(skb)->protocol;
addr = &ip_hdr(skb)->saddr;
ihl = ip_hdr(skb)->ihl;
alen = 2;
break;
case __constant_htons(ETH_P_IPV6):
ip_proto = ipv6_hdr(skb)->nexthdr;
addr = &ipv6_hdr(skb)->saddr.s6_addr32[0];
ihl = (40 >> 2);
alen = 8;
break;
default:
return 0;
}

ports = (u32 *) (skb_network_header(skb) + (ihl * 4));

hash = 0;
while (alen--)
hash ^= *addr++;

switch (ip_proto) {
case IPPROTO_TCP:
case IPPROTO_UDP:
case IPPROTO_DCCP:
case IPPROTO_ESP:
case IPPROTO_AH:
case IPPROTO_SCTP:
case IPPROTO_UDPLITE:
hash ^= *ports;
break;

default:
break;
}

return hash % dev->real_num_tx_queues;
}

static struct netdev_queue *dev_pick_tx(struct net_device *dev,
struct sk_buff *skb)
{
u16 queue_index = 0;

if (dev->select_queue)
queue_index = dev->select_queue(dev, skb);
else if (dev->real_num_tx_queues > 1)
queue_index = simple_tx_hash(dev, skb);

skb_set_queue_mapping(skb, queue_index);
return netdev_get_tx_queue(dev, queue_index);
Expand Down

0 comments on commit 585527d

Please sign in to comment.