aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/udplite.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-03-25 23:10:56 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:23:51 -0400
commit759e5d006462d53fb708daa8284b4ad909415da1 (patch)
treeedcc4e9d975199b3fe5e2aadc3d1e06824755e75 /include/net/udplite.h
parent1ab6eb62b02e0949a392fb19bf31ba59ae1022b1 (diff)
[UDP]: Clean up UDP-Lite receive checksum
This patch eliminates some duplicate code for the verification of receive checksums between UDP-Lite and UDP. It does this by introducing __skb_checksum_complete_head which is identical to __skb_checksum_complete_head apart from the fact that it takes a length parameter rather than computing the first skb->len bytes. As a result UDP-Lite will be able to use hardware checksum offload for packets which do not use partial coverage checksums. It also means that UDP-Lite loopback no longer does unnecessary checksum verification. If any NICs start support UDP-Lite this would also start working automatically. This patch removes the assumption that msg_flags has MSG_TRUNC clear upon entry in recvmsg. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/udplite.h')
-rw-r--r--include/net/udplite.h39
1 files changed, 6 insertions, 33 deletions
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 67ac51424307..d99df75fe54c 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -47,11 +47,10 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
47 return 1; 47 return 1;
48 } 48 }
49 49
50 UDP_SKB_CB(skb)->partial_cov = 0;
51 cscov = ntohs(uh->len); 50 cscov = ntohs(uh->len);
52 51
53 if (cscov == 0) /* Indicates that full coverage is required. */ 52 if (cscov == 0) /* Indicates that full coverage is required. */
54 cscov = skb->len; 53 ;
55 else if (cscov < 8 || cscov > skb->len) { 54 else if (cscov < 8 || cscov > skb->len) {
56 /* 55 /*
57 * Coverage length violates RFC 3828: log and discard silently. 56 * Coverage length violates RFC 3828: log and discard silently.
@@ -60,42 +59,16 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
60 cscov, skb->len); 59 cscov, skb->len);
61 return 1; 60 return 1;
62 61
63 } else if (cscov < skb->len) 62 } else if (cscov < skb->len) {
64 UDP_SKB_CB(skb)->partial_cov = 1; 63 UDP_SKB_CB(skb)->partial_cov = 1;
65 64 UDP_SKB_CB(skb)->cscov = cscov;
66 UDP_SKB_CB(skb)->cscov = cscov; 65 if (skb->ip_summed == CHECKSUM_COMPLETE)
67 66 skb->ip_summed = CHECKSUM_NONE;
68 /* 67 }
69 * There is no known NIC manufacturer supporting UDP-Lite yet,
70 * hence ip_summed is always (re-)set to CHECKSUM_NONE.
71 */
72 skb->ip_summed = CHECKSUM_NONE;
73 68
74 return 0; 69 return 0;
75} 70}
76 71
77static __inline__ int udplite4_csum_init(struct sk_buff *skb, struct udphdr *uh)
78{
79 int rc = udplite_checksum_init(skb, uh);
80
81 if (!rc)
82 skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr,
83 skb->nh.iph->daddr,
84 skb->len, IPPROTO_UDPLITE, 0);
85 return rc;
86}
87
88static __inline__ int udplite6_csum_init(struct sk_buff *skb, struct udphdr *uh)
89{
90 int rc = udplite_checksum_init(skb, uh);
91
92 if (!rc)
93 skb->csum = ~csum_unfold(csum_ipv6_magic(&skb->nh.ipv6h->saddr,
94 &skb->nh.ipv6h->daddr,
95 skb->len, IPPROTO_UDPLITE, 0));
96 return rc;
97}
98
99static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh) 72static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh)
100{ 73{
101 int cscov = up->len; 74 int cscov = up->len;