diff options
Diffstat (limited to 'drivers/net/loopback.c')
-rw-r--r-- | drivers/net/loopback.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 2b739fd584f1..6ba6ed2b480a 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -75,8 +75,9 @@ static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats); | |||
75 | #ifdef LOOPBACK_TSO | 75 | #ifdef LOOPBACK_TSO |
76 | static void emulate_large_send_offload(struct sk_buff *skb) | 76 | static void emulate_large_send_offload(struct sk_buff *skb) |
77 | { | 77 | { |
78 | struct iphdr *iph = skb->nh.iph; | 78 | struct iphdr *iph = ip_hdr(skb); |
79 | struct tcphdr *th = (struct tcphdr*)(skb->nh.raw + (iph->ihl * 4)); | 79 | struct tcphdr *th = (struct tcphdr *)(skb_network_header(skb) + |
80 | (iph->ihl * 4)); | ||
80 | unsigned int doffset = (iph->ihl + th->doff) * 4; | 81 | unsigned int doffset = (iph->ihl + th->doff) * 4; |
81 | unsigned int mtu = skb_shinfo(skb)->gso_size + doffset; | 82 | unsigned int mtu = skb_shinfo(skb)->gso_size + doffset; |
82 | unsigned int offset = 0; | 83 | unsigned int offset = 0; |
@@ -90,10 +91,11 @@ static void emulate_large_send_offload(struct sk_buff *skb) | |||
90 | if (!nskb) | 91 | if (!nskb) |
91 | break; | 92 | break; |
92 | skb_reserve(nskb, 32); | 93 | skb_reserve(nskb, 32); |
93 | nskb->mac.raw = nskb->data - 14; | 94 | skb_set_mac_header(nskb, -ETH_HLEN); |
94 | nskb->nh.raw = nskb->data; | 95 | skb_reset_network_header(nskb); |
95 | iph = nskb->nh.iph; | 96 | iph = ip_hdr(nskb); |
96 | memcpy(nskb->data, skb->nh.raw, doffset); | 97 | skb_copy_to_linear_data(nskb, skb_network_header(skb), |
98 | doffset); | ||
97 | if (skb_copy_bits(skb, | 99 | if (skb_copy_bits(skb, |
98 | doffset + offset, | 100 | doffset + offset, |
99 | nskb->data + doffset, | 101 | nskb->data + doffset, |
@@ -108,7 +110,7 @@ static void emulate_large_send_offload(struct sk_buff *skb) | |||
108 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); | 110 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); |
109 | nskb->pkt_type = skb->pkt_type; | 111 | nskb->pkt_type = skb->pkt_type; |
110 | 112 | ||
111 | th = (struct tcphdr*)(nskb->nh.raw + iph->ihl*4); | 113 | th = (struct tcphdr *)(skb_network_header(nskb) + iph->ihl * 4); |
112 | iph->tot_len = htons(frag_size + doffset); | 114 | iph->tot_len = htons(frag_size + doffset); |
113 | iph->id = htons(id); | 115 | iph->id = htons(id); |
114 | iph->check = 0; | 116 | iph->check = 0; |
@@ -137,7 +139,6 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) | |||
137 | skb_orphan(skb); | 139 | skb_orphan(skb); |
138 | 140 | ||
139 | skb->protocol = eth_type_trans(skb,dev); | 141 | skb->protocol = eth_type_trans(skb,dev); |
140 | skb->dev = dev; | ||
141 | #ifndef LOOPBACK_MUST_CHECKSUM | 142 | #ifndef LOOPBACK_MUST_CHECKSUM |
142 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 143 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
143 | #endif | 144 | #endif |
@@ -145,7 +146,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) | |||
145 | #ifdef LOOPBACK_TSO | 146 | #ifdef LOOPBACK_TSO |
146 | if (skb_is_gso(skb)) { | 147 | if (skb_is_gso(skb)) { |
147 | BUG_ON(skb->protocol != htons(ETH_P_IP)); | 148 | BUG_ON(skb->protocol != htons(ETH_P_IP)); |
148 | BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP); | 149 | BUG_ON(ip_hdr(skb)->protocol != IPPROTO_TCP); |
149 | 150 | ||
150 | emulate_large_send_offload(skb); | 151 | emulate_large_send_offload(skb); |
151 | return 0; | 152 | return 0; |
@@ -163,11 +164,9 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) | |||
163 | return 0; | 164 | return 0; |
164 | } | 165 | } |
165 | 166 | ||
166 | static struct net_device_stats loopback_stats; | ||
167 | |||
168 | static struct net_device_stats *get_stats(struct net_device *dev) | 167 | static struct net_device_stats *get_stats(struct net_device *dev) |
169 | { | 168 | { |
170 | struct net_device_stats *stats = &loopback_stats; | 169 | struct net_device_stats *stats = &dev->stats; |
171 | unsigned long bytes = 0; | 170 | unsigned long bytes = 0; |
172 | unsigned long packets = 0; | 171 | unsigned long packets = 0; |
173 | int i; | 172 | int i; |
@@ -207,7 +206,6 @@ static const struct ethtool_ops loopback_ethtool_ops = { | |||
207 | struct net_device loopback_dev = { | 206 | struct net_device loopback_dev = { |
208 | .name = "lo", | 207 | .name = "lo", |
209 | .get_stats = &get_stats, | 208 | .get_stats = &get_stats, |
210 | .priv = &loopback_stats, | ||
211 | .mtu = (16 * 1024) + 20 + 20 + 12, | 209 | .mtu = (16 * 1024) + 20 + 20 + 12, |
212 | .hard_start_xmit = loopback_xmit, | 210 | .hard_start_xmit = loopback_xmit, |
213 | .hard_header = eth_header, | 211 | .hard_header = eth_header, |