aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/skbuff.h16
-rw-r--r--include/net/tcp.h2
-rw-r--r--include/net/udp.h2
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c6
-rw-r--r--net/ipv4/tcp_input.c6
-rw-r--r--net/ipv4/tcp_ipv4.c3
-rw-r--r--net/ipv4/udp.c4
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/ipv6/tcp_ipv6.c3
-rw-r--r--net/ipv6/udp.c4
-rw-r--r--net/sctp/input.c3
-rw-r--r--net/sunrpc/socklib.c2
13 files changed, 29 insertions, 28 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 910560e85561..c413afbe0b9c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -32,10 +32,11 @@
32#define HAVE_ALLOC_SKB /* For the drivers to know */ 32#define HAVE_ALLOC_SKB /* For the drivers to know */
33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */ 33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
34 34
35/* Don't change this without changing skb_csum_unnecessary! */
35#define CHECKSUM_NONE 0 36#define CHECKSUM_NONE 0
36#define CHECKSUM_PARTIAL 1 37#define CHECKSUM_UNNECESSARY 1
37#define CHECKSUM_UNNECESSARY 2 38#define CHECKSUM_COMPLETE 2
38#define CHECKSUM_COMPLETE 3 39#define CHECKSUM_PARTIAL 3
39 40
40#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ 41#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
41 ~(SMP_CACHE_BYTES - 1)) 42 ~(SMP_CACHE_BYTES - 1))
@@ -1572,6 +1573,11 @@ static inline void __net_timestamp(struct sk_buff *skb)
1572extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 1573extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len);
1573extern __sum16 __skb_checksum_complete(struct sk_buff *skb); 1574extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1574 1575
1576static inline int skb_csum_unnecessary(const struct sk_buff *skb)
1577{
1578 return skb->ip_summed & CHECKSUM_UNNECESSARY;
1579}
1580
1575/** 1581/**
1576 * skb_checksum_complete - Calculate checksum of an entire packet 1582 * skb_checksum_complete - Calculate checksum of an entire packet
1577 * @skb: packet to process 1583 * @skb: packet to process
@@ -1590,8 +1596,8 @@ extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1590 */ 1596 */
1591static inline unsigned int skb_checksum_complete(struct sk_buff *skb) 1597static inline unsigned int skb_checksum_complete(struct sk_buff *skb)
1592{ 1598{
1593 return skb->ip_summed != CHECKSUM_UNNECESSARY && 1599 return skb_csum_unnecessary(skb) ?
1594 __skb_checksum_complete(skb); 1600 0 : __skb_checksum_complete(skb);
1595} 1601}
1596 1602
1597#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 1603#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index af9273204cfd..07f724e02f84 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -818,7 +818,7 @@ static inline __sum16 __tcp_checksum_complete(struct sk_buff *skb)
818 818
819static inline int tcp_checksum_complete(struct sk_buff *skb) 819static inline int tcp_checksum_complete(struct sk_buff *skb)
820{ 820{
821 return skb->ip_summed != CHECKSUM_UNNECESSARY && 821 return !skb_csum_unnecessary(skb) &&
822 __tcp_checksum_complete(skb); 822 __tcp_checksum_complete(skb);
823} 823}
824 824
diff --git a/include/net/udp.h b/include/net/udp.h
index 4906ed7113e7..98755ebaf163 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -77,7 +77,7 @@ static inline __sum16 __udp_lib_checksum_complete(struct sk_buff *skb)
77 77
78static inline int udp_lib_checksum_complete(struct sk_buff *skb) 78static inline int udp_lib_checksum_complete(struct sk_buff *skb)
79{ 79{
80 return skb->ip_summed != CHECKSUM_UNNECESSARY && 80 return !skb_csum_unnecessary(skb) &&
81 __udp_lib_checksum_complete(skb); 81 __udp_lib_checksum_complete(skb);
82} 82}
83 83
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 1fb30c3528bc..b316435b0e2a 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -86,7 +86,7 @@ static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh,
86{ 86{
87 __wsum psum; 87 __wsum psum;
88 88
89 if (uh->check == 0 || skb->ip_summed == CHECKSUM_UNNECESSARY) 89 if (uh->check == 0 || skb_csum_unnecessary(skb))
90 return 0; 90 return 0;
91 91
92 psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0); 92 psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 62cfbed317bf..f005a2f929f4 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -681,8 +681,7 @@ static int ip_vs_out_icmp(struct sk_buff **pskb, int *related)
681 } 681 }
682 682
683 /* Ensure the checksum is correct */ 683 /* Ensure the checksum is correct */
684 if (skb->ip_summed != CHECKSUM_UNNECESSARY && 684 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
685 ip_vs_checksum_complete(skb, ihl)) {
686 /* Failed checksum! */ 685 /* Failed checksum! */
687 IP_VS_DBG(1, "Forward ICMP: failed checksum from %d.%d.%d.%d!\n", 686 IP_VS_DBG(1, "Forward ICMP: failed checksum from %d.%d.%d.%d!\n",
688 NIPQUAD(iph->saddr)); 687 NIPQUAD(iph->saddr));
@@ -921,8 +920,7 @@ ip_vs_in_icmp(struct sk_buff **pskb, int *related, unsigned int hooknum)
921 verdict = NF_DROP; 920 verdict = NF_DROP;
922 921
923 /* Ensure the checksum is correct */ 922 /* Ensure the checksum is correct */
924 if (skb->ip_summed != CHECKSUM_UNNECESSARY && 923 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
925 ip_vs_checksum_complete(skb, ihl)) {
926 /* Failed checksum! */ 924 /* Failed checksum! */
927 IP_VS_DBG(1, "Incoming ICMP: failed checksum from %d.%d.%d.%d!\n", 925 IP_VS_DBG(1, "Incoming ICMP: failed checksum from %d.%d.%d.%d!\n",
928 NIPQUAD(iph->saddr)); 926 NIPQUAD(iph->saddr));
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 9c3b4c7a50ad..d1604f59d77e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4009,7 +4009,7 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
4009 int err; 4009 int err;
4010 4010
4011 local_bh_enable(); 4011 local_bh_enable();
4012 if (skb->ip_summed==CHECKSUM_UNNECESSARY) 4012 if (skb_csum_unnecessary(skb))
4013 err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk); 4013 err = skb_copy_datagram_iovec(skb, hlen, tp->ucopy.iov, chunk);
4014 else 4014 else
4015 err = skb_copy_and_csum_datagram_iovec(skb, hlen, 4015 err = skb_copy_and_csum_datagram_iovec(skb, hlen,
@@ -4041,7 +4041,7 @@ static __sum16 __tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb
4041 4041
4042static inline int tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb) 4042static inline int tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb)
4043{ 4043{
4044 return skb->ip_summed != CHECKSUM_UNNECESSARY && 4044 return !skb_csum_unnecessary(skb) &&
4045 __tcp_checksum_complete_user(sk, skb); 4045 __tcp_checksum_complete_user(sk, skb);
4046} 4046}
4047 4047
@@ -4059,7 +4059,7 @@ static int tcp_dma_try_early_copy(struct sock *sk, struct sk_buff *skb, int hlen
4059 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list) 4059 if (!tp->ucopy.dma_chan && tp->ucopy.pinned_list)
4060 tp->ucopy.dma_chan = get_softnet_dma(); 4060 tp->ucopy.dma_chan = get_softnet_dma();
4061 4061
4062 if (tp->ucopy.dma_chan && skb->ip_summed == CHECKSUM_UNNECESSARY) { 4062 if (tp->ucopy.dma_chan && skb_csum_unnecessary(skb)) {
4063 4063
4064 dma_cookie = dma_skb_copy_datagram_iovec(tp->ucopy.dma_chan, 4064 dma_cookie = dma_skb_copy_datagram_iovec(tp->ucopy.dma_chan,
4065 skb, hlen, tp->ucopy.iov, chunk, tp->ucopy.pinned_list); 4065 skb, hlen, tp->ucopy.iov, chunk, tp->ucopy.pinned_list);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a091a99ad263..5a3e7f839fc5 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1638,8 +1638,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
1638 * Packet length and doff are validated by header prediction, 1638 * Packet length and doff are validated by header prediction,
1639 * provided case of th->doff==0 is eliminated. 1639 * provided case of th->doff==0 is eliminated.
1640 * So, we defer the checks. */ 1640 * So, we defer the checks. */
1641 if ((skb->ip_summed != CHECKSUM_UNNECESSARY && 1641 if (!skb_csum_unnecessary(skb) && tcp_v4_checksum_init(skb))
1642 tcp_v4_checksum_init(skb)))
1643 goto bad_packet; 1642 goto bad_packet;
1644 1643
1645 th = tcp_hdr(skb); 1644 th = tcp_hdr(skb);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5ad7a26e3091..cec0f2cc49b7 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -848,7 +848,7 @@ try_again:
848 goto csum_copy_err; 848 goto csum_copy_err;
849 } 849 }
850 850
851 if (skb->ip_summed == CHECKSUM_UNNECESSARY) 851 if (skb_csum_unnecessary(skb))
852 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), 852 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
853 msg->msg_iov, copied ); 853 msg->msg_iov, copied );
854 else { 854 else {
@@ -1190,7 +1190,7 @@ static inline int udp4_csum_init(struct sk_buff *skb, struct udphdr *uh,
1190 proto, skb->csum)) 1190 proto, skb->csum))
1191 skb->ip_summed = CHECKSUM_UNNECESSARY; 1191 skb->ip_summed = CHECKSUM_UNNECESSARY;
1192 } 1192 }
1193 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 1193 if (!skb_csum_unnecessary(skb))
1194 skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr, 1194 skb->csum = csum_tcpudp_nofold(iph->saddr, iph->daddr,
1195 skb->len, proto, 0); 1195 skb->len, proto, 0);
1196 /* Probably, we should checksum udp header (it should be in cache 1196 /* Probably, we should checksum udp header (it should be in cache
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 2b3be68b70a7..f65fcd7704ca 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -368,7 +368,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
368 skb->len, inet->num, skb->csum)) 368 skb->len, inet->num, skb->csum))
369 skb->ip_summed = CHECKSUM_UNNECESSARY; 369 skb->ip_summed = CHECKSUM_UNNECESSARY;
370 } 370 }
371 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 371 if (!skb_csum_unnecessary(skb))
372 skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 372 skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
373 &ipv6_hdr(skb)->daddr, 373 &ipv6_hdr(skb)->daddr,
374 skb->len, 374 skb->len,
@@ -421,7 +421,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
421 msg->msg_flags |= MSG_TRUNC; 421 msg->msg_flags |= MSG_TRUNC;
422 } 422 }
423 423
424 if (skb->ip_summed==CHECKSUM_UNNECESSARY) { 424 if (skb_csum_unnecessary(skb)) {
425 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); 425 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
426 } else if (msg->msg_flags&MSG_TRUNC) { 426 } else if (msg->msg_flags&MSG_TRUNC) {
427 if (__skb_checksum_complete(skb)) 427 if (__skb_checksum_complete(skb))
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 7e824b97126d..2b668a6ae698 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1707,8 +1707,7 @@ static int tcp_v6_rcv(struct sk_buff **pskb)
1707 if (!pskb_may_pull(skb, th->doff*4)) 1707 if (!pskb_may_pull(skb, th->doff*4))
1708 goto discard_it; 1708 goto discard_it;
1709 1709
1710 if ((skb->ip_summed != CHECKSUM_UNNECESSARY && 1710 if (!skb_csum_unnecessary(skb) && tcp_v6_checksum_init(skb))
1711 tcp_v6_checksum_init(skb)))
1712 goto bad_packet; 1711 goto bad_packet;
1713 1712
1714 th = tcp_hdr(skb); 1713 th = tcp_hdr(skb);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 1e3dfb20b1cf..b083c09e3d2d 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -153,7 +153,7 @@ try_again:
153 goto csum_copy_err; 153 goto csum_copy_err;
154 } 154 }
155 155
156 if (skb->ip_summed == CHECKSUM_UNNECESSARY) 156 if (skb_csum_unnecessary(skb))
157 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), 157 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
158 msg->msg_iov, copied ); 158 msg->msg_iov, copied );
159 else { 159 else {
@@ -397,7 +397,7 @@ static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh,
397 skb->len, proto, skb->csum)) 397 skb->len, proto, skb->csum))
398 skb->ip_summed = CHECKSUM_UNNECESSARY; 398 skb->ip_summed = CHECKSUM_UNNECESSARY;
399 399
400 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 400 if (!skb_csum_unnecessary(skb))
401 skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr, 401 skb->csum = ~csum_unfold(csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
402 &ipv6_hdr(skb)->daddr, 402 &ipv6_hdr(skb)->daddr,
403 skb->len, proto, 0)); 403 skb->len, proto, 0));
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 18b97eedc1fa..885109fb3dda 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -140,8 +140,7 @@ int sctp_rcv(struct sk_buff *skb)
140 __skb_pull(skb, skb_transport_offset(skb)); 140 __skb_pull(skb, skb_transport_offset(skb));
141 if (skb->len < sizeof(struct sctphdr)) 141 if (skb->len < sizeof(struct sctphdr))
142 goto discard_it; 142 goto discard_it;
143 if ((skb->ip_summed != CHECKSUM_UNNECESSARY) && 143 if (!skb_csum_unnecessary(skb) && sctp_rcv_checksum(skb) < 0)
144 (sctp_rcv_checksum(skb) < 0))
145 goto discard_it; 144 goto discard_it;
146 145
147 skb_pull(skb, sizeof(struct sctphdr)); 146 skb_pull(skb, sizeof(struct sctphdr));
diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c
index 634885b0c04d..1d377d1ab7f4 100644
--- a/net/sunrpc/socklib.c
+++ b/net/sunrpc/socklib.c
@@ -154,7 +154,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
154 desc.offset = sizeof(struct udphdr); 154 desc.offset = sizeof(struct udphdr);
155 desc.count = skb->len - desc.offset; 155 desc.count = skb->len - desc.offset;
156 156
157 if (skb->ip_summed == CHECKSUM_UNNECESSARY) 157 if (skb_csum_unnecessary(skb))
158 goto no_checksum; 158 goto no_checksum;
159 159
160 desc.csum = csum_partial(skb->data, desc.offset, skb->csum); 160 desc.csum = csum_partial(skb->data, desc.offset, skb->csum);