Commit ddc7b8e3 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller

[SK_BUFF]: Some more layer header conversions

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a6114d9
...@@ -2357,8 +2357,12 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, ...@@ -2357,8 +2357,12 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
*vlan_encapsulated_proto = htons(ETH_P_IP); *vlan_encapsulated_proto = htons(ETH_P_IP);
} }
iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)); skb_set_network_header(skb, skb->tail - skb->data);
udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); skb->h.raw = skb->nh.raw + sizeof(struct iphdr);
skb_put(skb, sizeof(struct iphdr) + sizeof(struct udphdr));
iph = ip_hdr(skb);
udph = udp_hdr(skb);
memcpy(eth, pkt_dev->hh, 12); memcpy(eth, pkt_dev->hh, 12);
*(__be16 *) & eth[12] = protocol; *(__be16 *) & eth[12] = protocol;
...@@ -2387,12 +2391,11 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, ...@@ -2387,12 +2391,11 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
iph->check = 0; iph->check = 0;
iph->check = ip_fast_csum((void *)iph, iph->ihl); iph->check = ip_fast_csum((void *)iph, iph->ihl);
skb->protocol = protocol; skb->protocol = protocol;
skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32) - skb->mac.raw = (skb->nh.raw - ETH_HLEN -
VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev); pkt_dev->nr_labels * sizeof(u32) -
VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev));
skb->dev = odev; skb->dev = odev;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
skb->nh.raw = (unsigned char *)iph;
skb->h.raw = (unsigned char *)udph;
if (pkt_dev->nfrags <= 0) if (pkt_dev->nfrags <= 0)
pgh = (struct pktgen_hdr *)skb_put(skb, datalen); pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
...@@ -2693,8 +2696,12 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, ...@@ -2693,8 +2696,12 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
*vlan_encapsulated_proto = htons(ETH_P_IPV6); *vlan_encapsulated_proto = htons(ETH_P_IPV6);
} }
iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr)); skb_set_network_header(skb, skb->tail - skb->data);
udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); skb->h.raw = skb->nh.raw + sizeof(struct ipv6hdr);
skb_put(skb, sizeof(struct ipv6hdr) + sizeof(struct udphdr));
iph = ipv6_hdr(skb);
udph = udp_hdr(skb);
memcpy(eth, pkt_dev->hh, 12); memcpy(eth, pkt_dev->hh, 12);
*(__be16 *) & eth[12] = protocol; *(__be16 *) & eth[12] = protocol;
...@@ -2731,13 +2738,12 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, ...@@ -2731,13 +2738,12 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr); ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr);
ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr); ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr);
skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32) - skb->mac.raw = (skb->nh.raw - ETH_HLEN -
VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev); pkt_dev->nr_labels * sizeof(u32) -
VLAN_TAG_SIZE(pkt_dev) - SVLAN_TAG_SIZE(pkt_dev));
skb->protocol = protocol; skb->protocol = protocol;
skb->dev = odev; skb->dev = odev;
skb->pkt_type = PACKET_HOST; skb->pkt_type = PACKET_HOST;
skb->nh.raw = (unsigned char *)iph;
skb->h.raw = (unsigned char *)udph;
if (pkt_dev->nfrags <= 0) if (pkt_dev->nfrags <= 0)
pgh = (struct pktgen_hdr *)skb_put(skb, datalen); pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
......
...@@ -1905,7 +1905,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) ...@@ -1905,7 +1905,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
skb_reserve(nskb, headroom); skb_reserve(nskb, headroom);
skb_reset_mac_header(nskb); skb_reset_mac_header(nskb);
nskb->nh.raw = nskb->data + skb->mac_len; skb_set_network_header(nskb, skb->mac_len);
nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw); nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw);
memcpy(skb_put(nskb, doffset), skb->data, doffset); memcpy(skb_put(nskb, doffset), skb->data, doffset);
......
...@@ -580,7 +580,8 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) ...@@ -580,7 +580,8 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
* Copy the IP header * Copy the IP header
*/ */
skb->nh.raw = skb_put(skb, ihl); skb_set_network_header(skb, skb->tail - skb->data);
skb_put(skb, ihl);
memcpy(skb->data,pkt->data,ihl); memcpy(skb->data,pkt->data,ihl);
ip_hdr(skb)->protocol = 0; /* Flag to the kernel this is a route add */ ip_hdr(skb)->protocol = 0; /* Flag to the kernel this is a route add */
msg = (struct igmpmsg *)skb_network_header(skb); msg = (struct igmpmsg *)skb_network_header(skb);
......
...@@ -41,7 +41,8 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -41,7 +41,8 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
iph = ipv6_hdr(skb); iph = ipv6_hdr(skb);
hdr_len = ip6_find_1stfragopt(skb, &prevhdr); hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb_set_network_header(skb,
(prevhdr - x->props.header_len) - skb->data);
skb_set_transport_header(skb, hdr_len); skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
......
...@@ -53,7 +53,8 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -53,7 +53,8 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
iph = ipv6_hdr(skb); iph = ipv6_hdr(skb);
hdr_len = x->type->hdr_offset(x, skb, &prevhdr); hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb_set_network_header(skb,
(prevhdr - x->props.header_len) - skb->data);
skb_set_transport_header(skb, hdr_len); skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
return 0; return 0;
......
...@@ -35,7 +35,8 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -35,7 +35,8 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
iph = ipv6_hdr(skb); iph = ipv6_hdr(skb);
hdr_len = x->type->hdr_offset(x, skb, &prevhdr); hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len; skb_set_network_header(skb,
(prevhdr - x->props.header_len) - skb->data);
skb_set_transport_header(skb, hdr_len); skb_set_transport_header(skb, hdr_len);
memmove(skb->data, iph, hdr_len); memmove(skb->data, iph, hdr_len);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment