Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.33-rc8 137 lines 3.3 kB view raw
1#include <linux/skbuff.h> 2#include <linux/netdevice.h> 3#include <linux/if_vlan.h> 4#include <linux/netpoll.h> 5#include "vlan.h" 6 7/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */ 8int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 9 u16 vlan_tci, int polling) 10{ 11 if (netpoll_rx(skb)) 12 return NET_RX_DROP; 13 14 if (skb_bond_should_drop(skb)) 15 goto drop; 16 17 __vlan_hwaccel_put_tag(skb, vlan_tci); 18 skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); 19 20 if (!skb->dev) 21 goto drop; 22 23 return (polling ? netif_receive_skb(skb) : netif_rx(skb)); 24 25drop: 26 dev_kfree_skb_any(skb); 27 return NET_RX_DROP; 28} 29EXPORT_SYMBOL(__vlan_hwaccel_rx); 30 31int vlan_hwaccel_do_receive(struct sk_buff *skb) 32{ 33 struct net_device *dev = skb->dev; 34 struct vlan_rx_stats *rx_stats; 35 36 skb->dev = vlan_dev_info(dev)->real_dev; 37 netif_nit_deliver(skb); 38 39 skb->dev = dev; 40 skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci); 41 skb->vlan_tci = 0; 42 43 rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, 44 smp_processor_id()); 45 46 rx_stats->rx_packets++; 47 rx_stats->rx_bytes += skb->len; 48 49 switch (skb->pkt_type) { 50 case PACKET_BROADCAST: 51 break; 52 case PACKET_MULTICAST: 53 rx_stats->multicast++; 54 break; 55 case PACKET_OTHERHOST: 56 /* Our lower layer thinks this is not local, let's make sure. 57 * This allows the VLAN to have a different MAC than the 58 * underlying device, and still route correctly. */ 59 if (!compare_ether_addr(eth_hdr(skb)->h_dest, 60 dev->dev_addr)) 61 skb->pkt_type = PACKET_HOST; 62 break; 63 }; 64 return 0; 65} 66 67struct net_device *vlan_dev_real_dev(const struct net_device *dev) 68{ 69 return vlan_dev_info(dev)->real_dev; 70} 71EXPORT_SYMBOL(vlan_dev_real_dev); 72 73u16 vlan_dev_vlan_id(const struct net_device *dev) 74{ 75 return vlan_dev_info(dev)->vlan_id; 76} 77EXPORT_SYMBOL(vlan_dev_vlan_id); 78 79static gro_result_t 80vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp, 81 unsigned int vlan_tci, struct sk_buff *skb) 82{ 83 struct sk_buff *p; 84 85 if (skb_bond_should_drop(skb)) 86 goto drop; 87 88 __vlan_hwaccel_put_tag(skb, vlan_tci); 89 skb->dev = vlan_group_get_device(grp, vlan_tci & VLAN_VID_MASK); 90 91 if (!skb->dev) 92 goto drop; 93 94 for (p = napi->gro_list; p; p = p->next) { 95 NAPI_GRO_CB(p)->same_flow = 96 p->dev == skb->dev && !compare_ether_header( 97 skb_mac_header(p), skb_gro_mac_header(skb)); 98 NAPI_GRO_CB(p)->flush = 0; 99 } 100 101 return dev_gro_receive(napi, skb); 102 103drop: 104 return GRO_DROP; 105} 106 107gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, 108 unsigned int vlan_tci, struct sk_buff *skb) 109{ 110 if (netpoll_rx_on(skb)) 111 return vlan_hwaccel_receive_skb(skb, grp, vlan_tci) 112 ? GRO_DROP : GRO_NORMAL; 113 114 skb_gro_reset_offset(skb); 115 116 return napi_skb_finish(vlan_gro_common(napi, grp, vlan_tci, skb), skb); 117} 118EXPORT_SYMBOL(vlan_gro_receive); 119 120gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp, 121 unsigned int vlan_tci) 122{ 123 struct sk_buff *skb = napi_frags_skb(napi); 124 125 if (!skb) 126 return GRO_DROP; 127 128 if (netpoll_rx_on(skb)) { 129 skb->protocol = eth_type_trans(skb, skb->dev); 130 return vlan_hwaccel_receive_skb(skb, grp, vlan_tci) 131 ? GRO_DROP : GRO_NORMAL; 132 } 133 134 return napi_frags_finish(napi, skb, 135 vlan_gro_common(napi, grp, vlan_tci, skb)); 136} 137EXPORT_SYMBOL(vlan_gro_frags);