Commit d3bc23e7 authored by Al Viro's avatar Al Viro Committed by David S. Miller

[NET]: Annotate callers of csum_fold() in net/*

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9981a0e3
...@@ -413,9 +413,9 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, ...@@ -413,9 +413,9 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
unsigned int __skb_checksum_complete(struct sk_buff *skb) unsigned int __skb_checksum_complete(struct sk_buff *skb)
{ {
unsigned int sum; __sum16 sum;
sum = (u16)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum)); sum = csum_fold(skb_checksum(skb, 0, skb->len, skb->csum));
if (likely(!sum)) { if (likely(!sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
netdev_rx_csum_fault(skb->dev); netdev_rx_csum_fault(skb->dev);
...@@ -441,7 +441,7 @@ EXPORT_SYMBOL(__skb_checksum_complete); ...@@ -441,7 +441,7 @@ EXPORT_SYMBOL(__skb_checksum_complete);
int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
int hlen, struct iovec *iov) int hlen, struct iovec *iov)
{ {
unsigned int csum; __wsum csum;
int chunk = skb->len - hlen; int chunk = skb->len - hlen;
/* Skip filled elements. /* Skip filled elements.
...@@ -460,7 +460,7 @@ int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, ...@@ -460,7 +460,7 @@ int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base, if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base,
chunk, &csum)) chunk, &csum))
goto fault; goto fault;
if ((unsigned short)csum_fold(csum)) if (csum_fold(csum))
goto csum_error; goto csum_error;
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
netdev_rx_csum_fault(skb->dev); netdev_rx_csum_fault(skb->dev);
......
...@@ -1169,7 +1169,7 @@ EXPORT_SYMBOL(netif_device_attach); ...@@ -1169,7 +1169,7 @@ EXPORT_SYMBOL(netif_device_attach);
*/ */
int skb_checksum_help(struct sk_buff *skb) int skb_checksum_help(struct sk_buff *skb)
{ {
unsigned int csum; __wsum csum;
int ret = 0, offset = skb->h.raw - skb->data; int ret = 0, offset = skb->h.raw - skb->data;
if (skb->ip_summed == CHECKSUM_COMPLETE) if (skb->ip_summed == CHECKSUM_COMPLETE)
...@@ -1193,7 +1193,7 @@ int skb_checksum_help(struct sk_buff *skb) ...@@ -1193,7 +1193,7 @@ int skb_checksum_help(struct sk_buff *skb)
BUG_ON(offset <= 0); BUG_ON(offset <= 0);
BUG_ON(skb->csum + 2 > offset); BUG_ON(skb->csum + 2 > offset);
*(u16*)(skb->h.raw + skb->csum) = csum_fold(csum); *(__sum16*)(skb->h.raw + skb->csum) = csum_fold(csum);
out_set_summed: out_set_summed:
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
......
...@@ -88,7 +88,7 @@ static int checksum_udp(struct sk_buff *skb, struct udphdr *uh, ...@@ -88,7 +88,7 @@ static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0); psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
if (skb->ip_summed == CHECKSUM_COMPLETE && if (skb->ip_summed == CHECKSUM_COMPLETE &&
!(u16)csum_fold(csum_add(psum, skb->csum))) !csum_fold(csum_add(psum, skb->csum)))
return 0; return 0;
skb->csum = psum; skb->csum = psum;
......
...@@ -1396,7 +1396,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, ...@@ -1396,7 +1396,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to) void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
{ {
unsigned int csum; __wsum csum;
long csstart; long csstart;
if (skb->ip_summed == CHECKSUM_PARTIAL) if (skb->ip_summed == CHECKSUM_PARTIAL)
...@@ -1416,7 +1416,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to) ...@@ -1416,7 +1416,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
long csstuff = csstart + skb->csum; long csstuff = csstart + skb->csum;
*((unsigned short *)(to + csstuff)) = csum_fold(csum); *((__sum16 *)(to + csstuff)) = csum_fold(csum);
} }
} }
......
...@@ -356,7 +356,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param, ...@@ -356,7 +356,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
ip_flush_pending_frames(icmp_socket->sk); ip_flush_pending_frames(icmp_socket->sk);
else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) { else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) {
struct icmphdr *icmph = skb->h.icmph; struct icmphdr *icmph = skb->h.icmph;
unsigned int csum = 0; __wsum csum = 0;
struct sk_buff *skb1; struct sk_buff *skb1;
skb_queue_walk(&icmp_socket->sk->sk_write_queue, skb1) { skb_queue_walk(&icmp_socket->sk->sk_write_queue, skb1) {
...@@ -931,7 +931,7 @@ int icmp_rcv(struct sk_buff *skb) ...@@ -931,7 +931,7 @@ int icmp_rcv(struct sk_buff *skb)
switch (skb->ip_summed) { switch (skb->ip_summed) {
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
if (!(u16)csum_fold(skb->csum)) if (!csum_fold(skb->csum))
break; break;
/* fall through */ /* fall through */
case CHECKSUM_NONE: case CHECKSUM_NONE:
......
...@@ -932,7 +932,7 @@ int igmp_rcv(struct sk_buff *skb) ...@@ -932,7 +932,7 @@ int igmp_rcv(struct sk_buff *skb)
switch (skb->ip_summed) { switch (skb->ip_summed) {
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
if (!(u16)csum_fold(skb->csum)) if (!csum_fold(skb->csum))
break; break;
/* fall through */ /* fall through */
case CHECKSUM_NONE: case CHECKSUM_NONE:
......
...@@ -557,7 +557,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -557,7 +557,7 @@ static int ipgre_rcv(struct sk_buff *skb)
struct iphdr *iph; struct iphdr *iph;
u8 *h; u8 *h;
__be16 flags; __be16 flags;
u16 csum = 0; __sum16 csum = 0;
__be32 key = 0; __be32 key = 0;
u32 seqno = 0; u32 seqno = 0;
struct ip_tunnel *tunnel; struct ip_tunnel *tunnel;
...@@ -580,7 +580,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -580,7 +580,7 @@ static int ipgre_rcv(struct sk_buff *skb)
if (flags&GRE_CSUM) { if (flags&GRE_CSUM) {
switch (skb->ip_summed) { switch (skb->ip_summed) {
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
csum = (u16)csum_fold(skb->csum); csum = csum_fold(skb->csum);
if (!csum) if (!csum)
break; break;
/* fall through */ /* fall through */
......
...@@ -1384,7 +1384,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar ...@@ -1384,7 +1384,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
&ipc, rt, MSG_DONTWAIT); &ipc, rt, MSG_DONTWAIT);
if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
if (arg->csumoffset >= 0) if (arg->csumoffset >= 0)
*((u16 *)skb->h.raw + arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum)); *((__sum16 *)skb->h.raw + arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum));
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
ip_push_pending_frames(sk); ip_push_pending_frames(sk);
} }
......
...@@ -1493,7 +1493,7 @@ static int pim_rcv(struct sk_buff * skb) ...@@ -1493,7 +1493,7 @@ static int pim_rcv(struct sk_buff * skb)
if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) || if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
(pim->flags&PIM_NULL_REGISTER) || (pim->flags&PIM_NULL_REGISTER) ||
(ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
(u16)csum_fold(skb_checksum(skb, 0, skb->len, 0)))) csum_fold(skb_checksum(skb, 0, skb->len, 0))))
goto drop; goto drop;
/* check if the inner packet is destined to mcast group */ /* check if the inner packet is destined to mcast group */
......
...@@ -538,7 +538,7 @@ static unsigned int ip_vs_post_routing(unsigned int hooknum, ...@@ -538,7 +538,7 @@ static unsigned int ip_vs_post_routing(unsigned int hooknum,
u16 ip_vs_checksum_complete(struct sk_buff *skb, int offset) u16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)
{ {
return (u16) csum_fold(skb_checksum(skb, offset, skb->len - offset, 0)); return csum_fold(skb_checksum(skb, offset, skb->len - offset, 0));
} }
static inline struct sk_buff * static inline struct sk_buff *
......
...@@ -172,7 +172,7 @@ unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook, ...@@ -172,7 +172,7 @@ unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
case CHECKSUM_COMPLETE: case CHECKSUM_COMPLETE:
if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN) if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN)
break; break;
if ((protocol == 0 && !(u16)csum_fold(skb->csum)) || if ((protocol == 0 && !csum_fold(skb->csum)) ||
!csum_tcpudp_magic(iph->saddr, iph->daddr, !csum_tcpudp_magic(iph->saddr, iph->daddr,
skb->len - dataoff, protocol, skb->len - dataoff, protocol,
skb->csum)) { skb->csum)) {
......
...@@ -2162,7 +2162,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features) ...@@ -2162,7 +2162,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
struct tcphdr *th; struct tcphdr *th;
unsigned thlen; unsigned thlen;
unsigned int seq; unsigned int seq;
unsigned int delta; __be32 delta;
unsigned int oldlen; unsigned int oldlen;
unsigned int len; unsigned int len;
...@@ -2215,7 +2215,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features) ...@@ -2215,7 +2215,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
do { do {
th->fin = th->psh = 0; th->fin = th->psh = 0;
th->check = ~csum_fold(th->check + delta); th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
(__force u32)delta));
if (skb->ip_summed != CHECKSUM_PARTIAL) if (skb->ip_summed != CHECKSUM_PARTIAL)
th->check = csum_fold(csum_partial(skb->h.raw, thlen, th->check = csum_fold(csum_partial(skb->h.raw, thlen,
skb->csum)); skb->csum));
...@@ -2229,7 +2230,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features) ...@@ -2229,7 +2230,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
} while (skb->next); } while (skb->next);
delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len); delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len);
th->check = ~csum_fold(th->check + delta); th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
(__force u32)delta));
if (skb->ip_summed != CHECKSUM_PARTIAL) if (skb->ip_summed != CHECKSUM_PARTIAL)
th->check = csum_fold(csum_partial(skb->h.raw, thlen, th->check = csum_fold(csum_partial(skb->h.raw, thlen,
skb->csum)); skb->csum));
......
...@@ -166,7 +166,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb) ...@@ -166,7 +166,7 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
} }
if (desc.count) if (desc.count)
return -1; return -1;
if ((unsigned short)csum_fold(desc.csum)) if (csum_fold(desc.csum))
return -1; return -1;
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
netdev_rx_csum_fault(skb->dev); netdev_rx_csum_fault(skb->dev);
......
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