aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2011-10-17 19:07:30 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-17 19:07:30 -0400
commitf36c23bb9f822904dacf83a329518d0a5fde7968 (patch)
treefc7808103cdf00bb8a42247fccf638014798dd35 /include/net
parent4c41042d1d4c29e596b31e2d14b26d2940fb24b4 (diff)
udplite: fast-path computation of checksum coverage
Commit 903ab86d195cca295379699299c5fc10beba31c7 of 1 March this year ("udp: Add lockless transmit path") introduced a new fast TX path that broke the checksum coverage computation of UDP-lite, which so far depended on up->len (only set if the socket is locked and 0 in the fast path). Fixed by providing both fast- and slow-path computation of checksum coverage. The latter can be removed when UDP(-lite)v6 also uses a lockless transmit path. Reported-by: Thomas Volkert <thomas@homer-conferencing.com> Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/udplite.h63
1 files changed, 31 insertions, 32 deletions
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 673a024c6b2..5f097ca7d5c 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -66,40 +66,34 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
66 return 0; 66 return 0;
67} 67}
68 68
69static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh) 69/* Slow-path computation of checksum. Socket is locked. */
70static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
70{ 71{
72 const struct udp_sock *up = udp_sk(skb->sk);
71 int cscov = up->len; 73 int cscov = up->len;
74 __wsum csum = 0;
72 75
73 /* 76 if (up->pcflag & UDPLITE_SEND_CC) {
74 * Sender has set `partial coverage' option on UDP-Lite socket 77 /*
75 */ 78 * Sender has set `partial coverage' option on UDP-Lite socket.
76 if (up->pcflag & UDPLITE_SEND_CC) { 79 * The special case "up->pcslen == 0" signifies full coverage.
80 */
77 if (up->pcslen < up->len) { 81 if (up->pcslen < up->len) {
78 /* up->pcslen == 0 means that full coverage is required, 82 if (0 < up->pcslen)
79 * partial coverage only if 0 < up->pcslen < up->len */ 83 cscov = up->pcslen;
80 if (0 < up->pcslen) { 84 udp_hdr(skb)->len = htons(up->pcslen);
81 cscov = up->pcslen;
82 }
83 uh->len = htons(up->pcslen);
84 } 85 }
85 /* 86 /*
86 * NOTE: Causes for the error case `up->pcslen > up->len': 87 * NOTE: Causes for the error case `up->pcslen > up->len':
87 * (i) Application error (will not be penalized). 88 * (i) Application error (will not be penalized).
88 * (ii) Payload too big for send buffer: data is split 89 * (ii) Payload too big for send buffer: data is split
89 * into several packets, each with its own header. 90 * into several packets, each with its own header.
90 * In this case (e.g. last segment), coverage may 91 * In this case (e.g. last segment), coverage may
91 * exceed packet length. 92 * exceed packet length.
92 * Since packets with coverage length > packet length are 93 * Since packets with coverage length > packet length are
93 * illegal, we fall back to the defaults here. 94 * illegal, we fall back to the defaults here.
94 */ 95 */
95 } 96 }
96 return cscov;
97}
98
99static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
100{
101 int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
102 __wsum csum = 0;
103 97
104 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */ 98 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
105 99
@@ -115,16 +109,21 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
115 return csum; 109 return csum;
116} 110}
117 111
112/* Fast-path computation of checksum. Socket may not be locked. */
118static inline __wsum udplite_csum(struct sk_buff *skb) 113static inline __wsum udplite_csum(struct sk_buff *skb)
119{ 114{
120 struct sock *sk = skb->sk; 115 const struct udp_sock *up = udp_sk(skb->sk);
121 int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb));
122 const int off = skb_transport_offset(skb); 116 const int off = skb_transport_offset(skb);
123 const int len = skb->len - off; 117 int len = skb->len - off;
124 118
119 if ((up->pcflag & UDPLITE_SEND_CC) && up->pcslen < len) {
120 if (0 < up->pcslen)
121 len = up->pcslen;
122 udp_hdr(skb)->len = htons(up->pcslen);
123 }
125 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */ 124 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
126 125
127 return skb_checksum(skb, off, min(cscov, len), 0); 126 return skb_checksum(skb, off, len, 0);
128} 127}
129 128
130extern void udplite4_register(void); 129extern void udplite4_register(void);