Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 134354
b: refs/heads/master
c: aa4b9f5
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Feb 9, 2009
1 parent c2fc2f5 commit 911c70e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4ae5544f9a33e4ae306e337f96951eb3ff2df6d9
refs/heads/master: aa4b9f533ed5a22952e038b9fac2447ccc682124
21 changes: 21 additions & 0 deletions trunk/include/linux/etherdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,25 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2],
}
#endif /* __KERNEL__ */

/**
* compare_ether_header - Compare two Ethernet headers
* @a: Pointer to Ethernet header
* @b: Pointer to Ethernet header
*
* Compare two ethernet headers, returns 0 if equal.
* This assumes that the network header (i.e., IP header) is 4-byte
* aligned OR the platform can handle unaligned access. This is the
* case for all packets coming into netif_receive_skb or similar
* entry points.
*/

static inline int compare_ether_header(const void *a, const void *b)
{
u32 *a32 = (u32 *)((u8 *)a + 2);
u32 *b32 = (u32 *)((u8 *)b + 2);

return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) |
(a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
}

#endif /* _LINUX_ETHERDEVICE_H */
7 changes: 7 additions & 0 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,13 @@ static inline void skb_gro_reset_offset(struct sk_buff *skb)
NAPI_GRO_CB(skb)->data_offset = 0;
}

static inline void *skb_gro_mac_header(struct sk_buff *skb)
{
return skb_mac_header(skb) < skb->data ? skb_mac_header(skb) :
page_address(skb_shinfo(skb)->frags[0].page) +
skb_shinfo(skb)->frags[0].page_offset;
}

static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type,
const void *daddr, const void *saddr,
Expand Down
4 changes: 3 additions & 1 deletion trunk/net/8021q/vlan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ static int vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp,
goto drop;

for (p = napi->gro_list; p; p = p->next) {
NAPI_GRO_CB(p)->same_flow = p->dev == skb->dev;
NAPI_GRO_CB(p)->same_flow =
p->dev == skb->dev && !compare_ether_header(
skb_mac_header(p), skb_gro_mac_header(skb));
NAPI_GRO_CB(p)->flush = 0;
}

Expand Down
23 changes: 2 additions & 21 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,6 @@ static inline struct hlist_head *dev_index_hash(struct net *net, int ifindex)
return &net->dev_index_head[ifindex & ((1 << NETDEV_HASHBITS) - 1)];
}

static inline void *skb_gro_mac_header(struct sk_buff *skb)
{
return skb_mac_header(skb) < skb->data ? skb_mac_header(skb) :
page_address(skb_shinfo(skb)->frags[0].page) +
skb_shinfo(skb)->frags[0].page_offset;
}

/* Device list insertion */
static int list_netdevice(struct net_device *dev)
{
Expand Down Expand Up @@ -2415,29 +2408,16 @@ int dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)

rcu_read_lock();
list_for_each_entry_rcu(ptype, head, list) {
struct sk_buff *p;
void *mac;

if (ptype->type != type || ptype->dev || !ptype->gro_receive)
continue;

skb_set_network_header(skb, skb_gro_offset(skb));
mac = skb_gro_mac_header(skb);
mac_len = skb->network_header - skb->mac_header;
skb->mac_len = mac_len;
NAPI_GRO_CB(skb)->same_flow = 0;
NAPI_GRO_CB(skb)->flush = 0;
NAPI_GRO_CB(skb)->free = 0;

for (p = napi->gro_list; p; p = p->next) {
if (!NAPI_GRO_CB(p)->same_flow)
continue;

if (p->mac_len != mac_len ||
memcmp(skb_mac_header(p), mac, mac_len))
NAPI_GRO_CB(p)->same_flow = 0;
}

pp = ptype->gro_receive(&napi->gro_list, skb);
break;
}
Expand Down Expand Up @@ -2492,7 +2472,8 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
struct sk_buff *p;

for (p = napi->gro_list; p; p = p->next) {
NAPI_GRO_CB(p)->same_flow = 1;
NAPI_GRO_CB(p)->same_flow = !compare_ether_header(
skb_mac_header(p), skb_gro_mac_header(skb));
NAPI_GRO_CB(p)->flush = 0;
}

Expand Down

0 comments on commit 911c70e

Please sign in to comment.