aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-25 21:04:18 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:31 -0400
commit9c70220b73908f64792422a2c39c593c4792f2c5 (patch)
tree2090ea10aaa2714a5e095bae8cc02e743c378a3a /net/ipv4
parenta27ef749e7be3b06fb58df53d94eb97a21f18707 (diff)
[SK_BUFF]: Introduce skb_transport_header(skb)
For the places where we need a pointer to the transport header, it is still legal to touch skb->h.raw directly if just adding to, subtracting from or setting it to another layer header. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/ipconfig.c4
-rw-r--r--net/ipv4/ipmr.c8
-rw-r--r--net/ipv4/tcp.c12
-rw-r--r--net/ipv4/tcp_input.c13
-rw-r--r--net/ipv4/xfrm4_mode_beet.c2
-rw-r--r--net/ipv4/xfrm4_mode_transport.c5
9 files changed, 31 insertions, 23 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 292516bb1eca..8f0df7b4dfe7 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -348,7 +348,7 @@ static int igmpv3_sendpack(struct sk_buff *skb)
348 struct iphdr *pip = ip_hdr(skb); 348 struct iphdr *pip = ip_hdr(skb);
349 struct igmphdr *pig = igmp_hdr(skb); 349 struct igmphdr *pig = igmp_hdr(skb);
350 const int iplen = skb->tail - skb->nh.raw; 350 const int iplen = skb->tail - skb->nh.raw;
351 const int igmplen = skb->tail - skb->h.raw; 351 const int igmplen = skb->tail - skb_transport_header(skb);
352 352
353 pip->tot_len = htons(iplen); 353 pip->tot_len = htons(iplen);
354 ip_send_check(pip); 354 ip_send_check(pip);
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 39216e6a59ed..e6a9e452fd61 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -619,7 +619,7 @@ static int ipgre_rcv(struct sk_buff *skb)
619 skb_reset_mac_header(skb); 619 skb_reset_mac_header(skb);
620 __pskb_pull(skb, offset); 620 __pskb_pull(skb, offset);
621 skb_reset_network_header(skb); 621 skb_reset_network_header(skb);
622 skb_postpull_rcsum(skb, skb->h.raw, offset); 622 skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
623 skb->pkt_type = PACKET_HOST; 623 skb->pkt_type = PACKET_HOST;
624#ifdef CONFIG_NET_IPGRE_BROADCAST 624#ifdef CONFIG_NET_IPGRE_BROADCAST
625 if (MULTICAST(iph->daddr)) { 625 if (MULTICAST(iph->daddr)) {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 602268661eb3..11029b9d4cf7 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1128,7 +1128,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
1128 if (fraggap) { 1128 if (fraggap) {
1129 skb->csum = skb_copy_and_csum_bits(skb_prev, 1129 skb->csum = skb_copy_and_csum_bits(skb_prev,
1130 maxfraglen, 1130 maxfraglen,
1131 skb->h.raw, 1131 skb_transport_header(skb),
1132 fraggap, 0); 1132 fraggap, 0);
1133 skb_prev->csum = csum_sub(skb_prev->csum, 1133 skb_prev->csum = csum_sub(skb_prev->csum,
1134 skb->csum); 1134 skb->csum);
@@ -1374,7 +1374,9 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
1374 &ipc, rt, MSG_DONTWAIT); 1374 &ipc, rt, MSG_DONTWAIT);
1375 if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { 1375 if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
1376 if (arg->csumoffset >= 0) 1376 if (arg->csumoffset >= 0)
1377 *((__sum16 *)skb->h.raw + arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum)); 1377 *((__sum16 *)skb_transport_header(skb) +
1378 arg->csumoffset) = csum_fold(csum_add(skb->csum,
1379 arg->csum));
1378 skb->ip_summed = CHECKSUM_NONE; 1380 skb->ip_summed = CHECKSUM_NONE;
1379 ip_push_pending_frames(sk); 1381 ip_push_pending_frames(sk);
1380 } 1382 }
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 6b91c9f5d57a..4e19ee0e0102 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -432,7 +432,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
432 goto drop; 432 goto drop;
433 433
434 /* Basic sanity checks can be done without the lock. */ 434 /* Basic sanity checks can be done without the lock. */
435 rarp = (struct arphdr *)skb->h.raw; 435 rarp = (struct arphdr *)skb_transport_header(skb);
436 436
437 /* If this test doesn't pass, it's not IP, or we should 437 /* If this test doesn't pass, it's not IP, or we should
438 * ignore it anyway. 438 * ignore it anyway.
@@ -455,7 +455,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
455 goto drop; 455 goto drop;
456 456
457 /* OK, it is all there and looks valid, process... */ 457 /* OK, it is all there and looks valid, process... */
458 rarp = (struct arphdr *)skb->h.raw; 458 rarp = (struct arphdr *)skb_transport_header(skb);
459 rarp_ptr = (unsigned char *) (rarp + 1); 459 rarp_ptr = (unsigned char *) (rarp + 1);
460 460
461 /* One reply at a time, please. */ 461 /* One reply at a time, please. */
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 05bc27002def..8f45c95db451 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1437,7 +1437,8 @@ int pim_rcv_v1(struct sk_buff * skb)
1437 pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER) 1437 pim->group != PIM_V1_VERSION || pim->code != PIM_V1_REGISTER)
1438 goto drop; 1438 goto drop;
1439 1439
1440 encap = (struct iphdr*)(skb->h.raw + sizeof(struct igmphdr)); 1440 encap = (struct iphdr *)(skb_transport_header(skb) +
1441 sizeof(struct igmphdr));
1441 /* 1442 /*
1442 Check that: 1443 Check that:
1443 a. packet is really destinted to a multicast group 1444 a. packet is really destinted to a multicast group
@@ -1490,7 +1491,7 @@ static int pim_rcv(struct sk_buff * skb)
1490 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap))) 1491 if (!pskb_may_pull(skb, sizeof(*pim) + sizeof(*encap)))
1491 goto drop; 1492 goto drop;
1492 1493
1493 pim = (struct pimreghdr*)skb->h.raw; 1494 pim = (struct pimreghdr *)skb_transport_header(skb);
1494 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) || 1495 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
1495 (pim->flags&PIM_NULL_REGISTER) || 1496 (pim->flags&PIM_NULL_REGISTER) ||
1496 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && 1497 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
@@ -1498,7 +1499,8 @@ static int pim_rcv(struct sk_buff * skb)
1498 goto drop; 1499 goto drop;
1499 1500
1500 /* check if the inner packet is destined to mcast group */ 1501 /* check if the inner packet is destined to mcast group */
1501 encap = (struct iphdr*)(skb->h.raw + sizeof(struct pimreghdr)); 1502 encap = (struct iphdr *)(skb_transport_header(skb) +
1503 sizeof(struct pimreghdr));
1502 if (!MULTICAST(encap->daddr) || 1504 if (!MULTICAST(encap->daddr) ||
1503 encap->tot_len == 0 || 1505 encap->tot_len == 0 ||
1504 ntohs(encap->tot_len) + sizeof(*pim) > skb->len) 1506 ntohs(encap->tot_len) + sizeof(*pim) > skb->len)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index f832f3c33ab1..2b214cc3724c 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2219,8 +2219,9 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2219 th->check = ~csum_fold((__force __wsum)((__force u32)th->check + 2219 th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
2220 (__force u32)delta)); 2220 (__force u32)delta));
2221 if (skb->ip_summed != CHECKSUM_PARTIAL) 2221 if (skb->ip_summed != CHECKSUM_PARTIAL)
2222 th->check = csum_fold(csum_partial(skb->h.raw, thlen, 2222 th->check =
2223 skb->csum)); 2223 csum_fold(csum_partial(skb_transport_header(skb),
2224 thlen, skb->csum));
2224 2225
2225 seq += len; 2226 seq += len;
2226 skb = skb->next; 2227 skb = skb->next;
@@ -2230,12 +2231,13 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2230 th->cwr = 0; 2231 th->cwr = 0;
2231 } while (skb->next); 2232 } while (skb->next);
2232 2233
2233 delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len); 2234 delta = htonl(oldlen + (skb->tail - skb_transport_header(skb)) +
2235 skb->data_len);
2234 th->check = ~csum_fold((__force __wsum)((__force u32)th->check + 2236 th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
2235 (__force u32)delta)); 2237 (__force u32)delta));
2236 if (skb->ip_summed != CHECKSUM_PARTIAL) 2238 if (skb->ip_summed != CHECKSUM_PARTIAL)
2237 th->check = csum_fold(csum_partial(skb->h.raw, thlen, 2239 th->check = csum_fold(csum_partial(skb_transport_header(skb),
2238 skb->csum)); 2240 thlen, skb->csum));
2239 2241
2240out: 2242out:
2241 return segs; 2243 return segs;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index c1ce36237380..9c3b4c7a50ad 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -140,7 +140,7 @@ static void tcp_measure_rcv_mss(struct sock *sk,
140 * 140 *
141 * "len" is invariant segment length, including TCP header. 141 * "len" is invariant segment length, including TCP header.
142 */ 142 */
143 len += skb->data - skb->h.raw; 143 len += skb->data - skb_transport_header(skb);
144 if (len >= TCP_MIN_RCVMSS + sizeof(struct tcphdr) || 144 if (len >= TCP_MIN_RCVMSS + sizeof(struct tcphdr) ||
145 /* If PSH is not set, packet should be 145 /* If PSH is not set, packet should be
146 * full sized, provided peer TCP is not badly broken. 146 * full sized, provided peer TCP is not badly broken.
@@ -940,7 +940,8 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
940{ 940{
941 const struct inet_connection_sock *icsk = inet_csk(sk); 941 const struct inet_connection_sock *icsk = inet_csk(sk);
942 struct tcp_sock *tp = tcp_sk(sk); 942 struct tcp_sock *tp = tcp_sk(sk);
943 unsigned char *ptr = ack_skb->h.raw + TCP_SKB_CB(ack_skb)->sacked; 943 unsigned char *ptr = (skb_transport_header(ack_skb) +
944 TCP_SKB_CB(ack_skb)->sacked);
944 struct tcp_sack_block_wire *sp = (struct tcp_sack_block_wire *)(ptr+2); 945 struct tcp_sack_block_wire *sp = (struct tcp_sack_block_wire *)(ptr+2);
945 struct sk_buff *cached_skb; 946 struct sk_buff *cached_skb;
946 int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3; 947 int num_sacks = (ptr[1] - TCPOLEN_SACK_BASE)>>3;
@@ -3634,10 +3635,10 @@ tcp_collapse(struct sock *sk, struct sk_buff_head *list,
3634 return; 3635 return;
3635 3636
3636 skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head); 3637 skb_set_mac_header(nskb, skb_mac_header(skb) - skb->head);
3637 skb_set_network_header(nskb, 3638 skb_set_network_header(nskb, (skb_network_header(skb) -
3638 skb_network_header(skb) - skb->head); 3639 skb->head));
3639 skb_set_transport_header(nskb, skb->h.raw - skb->head); 3640 skb_set_transport_header(nskb, (skb_transport_header(skb) -
3640 3641 skb->head));
3641 skb_reserve(nskb, header); 3642 skb_reserve(nskb, header);
3642 memcpy(nskb->head, skb->head, header); 3643 memcpy(nskb->head, skb->head, header);
3643 memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); 3644 memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c
index 32fcfc0b5c8c..591f0f1ef87f 100644
--- a/net/ipv4/xfrm4_mode_beet.c
+++ b/net/ipv4/xfrm4_mode_beet.c
@@ -51,7 +51,7 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb)
51 51
52 BUG_ON(optlen < 0); 52 BUG_ON(optlen < 0);
53 53
54 ph = (struct ip_beet_phdr *)skb->h.raw; 54 ph = (struct ip_beet_phdr *)skb_transport_header(skb);
55 ph->padlen = 4 - (optlen & 4); 55 ph->padlen = 4 - (optlen & 4);
56 ph->hdrlen = optlen / 8; 56 ph->hdrlen = optlen / 8;
57 ph->nexthdr = top_iph->protocol; 57 ph->nexthdr = top_iph->protocol;
diff --git a/net/ipv4/xfrm4_mode_transport.c b/net/ipv4/xfrm4_mode_transport.c
index 2c46cbb3bbb5..dc8834ea3754 100644
--- a/net/ipv4/xfrm4_mode_transport.c
+++ b/net/ipv4/xfrm4_mode_transport.c
@@ -45,10 +45,11 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
45 */ 45 */
46static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb) 46static int xfrm4_transport_input(struct xfrm_state *x, struct sk_buff *skb)
47{ 47{
48 int ihl = skb->data - skb->h.raw; 48 int ihl = skb->data - skb_transport_header(skb);
49 49
50 if (skb->h.raw != skb->nh.raw) { 50 if (skb->h.raw != skb->nh.raw) {
51 memmove(skb->h.raw, skb_network_header(skb), ihl); 51 memmove(skb_transport_header(skb),
52 skb_network_header(skb), ihl);
52 skb->nh.raw = skb->h.raw; 53 skb->nh.raw = skb->h.raw;
53 } 54 }
54 ip_hdr(skb)->tot_len = htons(skb->len + ihl); 55 ip_hdr(skb)->tot_len = htons(skb->len + ihl);