diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-06-23 04:52:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-23 04:52:59 -0400 |
commit | a60b33cf59d1c9e0e363287fce799cb23d45660c (patch) | |
tree | 85eb8feea5717cf472a2549e53f59183a95617c5 /net/core/dev.c | |
parent | 0f476b6d91a1395bda6464e653ce66ea9bea7167 (diff) | |
parent | 481c5346d0981940ee63037eb53e4e37b0735c10 (diff) |
Merge branch 'linus' into core/softirq
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index cf0e16731dc..48f1e041313 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -119,6 +119,7 @@ | |||
119 | #include <linux/err.h> | 119 | #include <linux/err.h> |
120 | #include <linux/ctype.h> | 120 | #include <linux/ctype.h> |
121 | #include <linux/if_arp.h> | 121 | #include <linux/if_arp.h> |
122 | #include <linux/if_vlan.h> | ||
122 | 123 | ||
123 | #include "net-sysfs.h" | 124 | #include "net-sysfs.h" |
124 | 125 | ||
@@ -1362,6 +1363,29 @@ void netif_device_attach(struct net_device *dev) | |||
1362 | } | 1363 | } |
1363 | EXPORT_SYMBOL(netif_device_attach); | 1364 | EXPORT_SYMBOL(netif_device_attach); |
1364 | 1365 | ||
1366 | static bool can_checksum_protocol(unsigned long features, __be16 protocol) | ||
1367 | { | ||
1368 | return ((features & NETIF_F_GEN_CSUM) || | ||
1369 | ((features & NETIF_F_IP_CSUM) && | ||
1370 | protocol == htons(ETH_P_IP)) || | ||
1371 | ((features & NETIF_F_IPV6_CSUM) && | ||
1372 | protocol == htons(ETH_P_IPV6))); | ||
1373 | } | ||
1374 | |||
1375 | static bool dev_can_checksum(struct net_device *dev, struct sk_buff *skb) | ||
1376 | { | ||
1377 | if (can_checksum_protocol(dev->features, skb->protocol)) | ||
1378 | return true; | ||
1379 | |||
1380 | if (skb->protocol == htons(ETH_P_8021Q)) { | ||
1381 | struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; | ||
1382 | if (can_checksum_protocol(dev->features & dev->vlan_features, | ||
1383 | veh->h_vlan_encapsulated_proto)) | ||
1384 | return true; | ||
1385 | } | ||
1386 | |||
1387 | return false; | ||
1388 | } | ||
1365 | 1389 | ||
1366 | /* | 1390 | /* |
1367 | * Invalidate hardware checksum when packet is to be mangled, and | 1391 | * Invalidate hardware checksum when packet is to be mangled, and |
@@ -1640,14 +1664,8 @@ int dev_queue_xmit(struct sk_buff *skb) | |||
1640 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | 1664 | if (skb->ip_summed == CHECKSUM_PARTIAL) { |
1641 | skb_set_transport_header(skb, skb->csum_start - | 1665 | skb_set_transport_header(skb, skb->csum_start - |
1642 | skb_headroom(skb)); | 1666 | skb_headroom(skb)); |
1643 | 1667 | if (!dev_can_checksum(dev, skb) && skb_checksum_help(skb)) | |
1644 | if (!(dev->features & NETIF_F_GEN_CSUM) && | 1668 | goto out_kfree_skb; |
1645 | !((dev->features & NETIF_F_IP_CSUM) && | ||
1646 | skb->protocol == htons(ETH_P_IP)) && | ||
1647 | !((dev->features & NETIF_F_IPV6_CSUM) && | ||
1648 | skb->protocol == htons(ETH_P_IPV6))) | ||
1649 | if (skb_checksum_help(skb)) | ||
1650 | goto out_kfree_skb; | ||
1651 | } | 1669 | } |
1652 | 1670 | ||
1653 | gso: | 1671 | gso: |
@@ -2059,6 +2077,10 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2059 | 2077 | ||
2060 | rcu_read_lock(); | 2078 | rcu_read_lock(); |
2061 | 2079 | ||
2080 | /* Don't receive packets in an exiting network namespace */ | ||
2081 | if (!net_alive(dev_net(skb->dev))) | ||
2082 | goto out; | ||
2083 | |||
2062 | #ifdef CONFIG_NET_CLS_ACT | 2084 | #ifdef CONFIG_NET_CLS_ACT |
2063 | if (skb->tc_verd & TC_NCLS) { | 2085 | if (skb->tc_verd & TC_NCLS) { |
2064 | skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); | 2086 | skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); |