Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: networking: convert udplite.txt to ReST

- add SPDX header;
- adjust titles and chapters, adding proper markups;
- mark lists as such;
- mark tables as such;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines where needed;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mauro Carvalho Chehab and committed by
David S. Miller
961fb1ff 973d55e5

+95 -81
+1
Documentation/networking/index.rst
··· 112 112 timestamping 113 113 tproxy 114 114 tuntap 115 + udplite 115 116 116 117 .. only:: subproject and html 117 118
+94 -81
Documentation/networking/udplite.txt Documentation/networking/udplite.rst
··· 1 - =========================================================================== 2 - The UDP-Lite protocol (RFC 3828) 3 - =========================================================================== 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ================================ 4 + The UDP-Lite protocol (RFC 3828) 5 + ================================ 4 6 5 7 6 8 UDP-Lite is a Standards-Track IETF transport protocol whose characteristic ··· 13 11 This file briefly describes the existing kernel support and the socket API. 14 12 For in-depth information, you can consult: 15 13 16 - o The UDP-Lite Homepage: 17 - http://web.archive.org/web/*/http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/ 18 - From here you can also download some example application source code. 14 + - The UDP-Lite Homepage: 15 + http://web.archive.org/web/%2E/http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/ 19 16 20 - o The UDP-Lite HOWTO on 21 - http://web.archive.org/web/*/http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/ 22 - files/UDP-Lite-HOWTO.txt 17 + From here you can also download some example application source code. 23 18 24 - o The Wireshark UDP-Lite WiKi (with capture files): 25 - https://wiki.wireshark.org/Lightweight_User_Datagram_Protocol 19 + - The UDP-Lite HOWTO on 20 + http://web.archive.org/web/%2E/http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/files/UDP-Lite-HOWTO.txt 26 21 27 - o The Protocol Spec, RFC 3828, http://www.ietf.org/rfc/rfc3828.txt 22 + - The Wireshark UDP-Lite WiKi (with capture files): 23 + https://wiki.wireshark.org/Lightweight_User_Datagram_Protocol 24 + 25 + - The Protocol Spec, RFC 3828, http://www.ietf.org/rfc/rfc3828.txt 28 26 29 27 30 - I) APPLICATIONS 28 + 1. Applications 29 + =============== 31 30 32 31 Several applications have been ported successfully to UDP-Lite. Ethereal 33 - (now called wireshark) has UDP-Litev4/v6 support by default. 32 + (now called wireshark) has UDP-Litev4/v6 support by default. 33 + 34 34 Porting applications to UDP-Lite is straightforward: only socket level and 35 35 IPPROTO need to be changed; senders additionally set the checksum coverage 36 36 length (default = header length = 8). Details are in the next section. 37 37 38 - 39 - II) PROGRAMMING API 38 + 2. Programming API 39 + ================== 40 40 41 41 UDP-Lite provides a connectionless, unreliable datagram service and hence 42 42 uses the same socket type as UDP. In fact, porting from UDP to UDP-Lite is 43 - very easy: simply add `IPPROTO_UDPLITE' as the last argument of the socket(2) 44 - call so that the statement looks like: 43 + very easy: simply add ``IPPROTO_UDPLITE`` as the last argument of the 44 + socket(2) call so that the statement looks like:: 45 45 46 46 s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE); 47 47 48 - or, respectively, 48 + or, respectively, 49 + 50 + :: 49 51 50 52 s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE); 51 53 ··· 62 56 63 57 * Sender checksum coverage: UDPLITE_SEND_CSCOV 64 58 65 - For example, 59 + For example:: 66 60 67 - int val = 20; 68 - setsockopt(s, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &val, sizeof(int)); 61 + int val = 20; 62 + setsockopt(s, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &val, sizeof(int)); 69 63 70 64 sets the checksum coverage length to 20 bytes (12b data + 8b header). 71 65 Of each packet only the first 20 bytes (plus the pseudo-header) will be ··· 80 74 that of a traffic filter: when enabled, it instructs the kernel to drop 81 75 all packets which have a coverage _less_ than this value. For example, if 82 76 RTP and UDP headers are to be protected, a receiver can enforce that only 83 - packets with a minimum coverage of 20 are admitted: 77 + packets with a minimum coverage of 20 are admitted:: 84 78 85 - int min = 20; 86 - setsockopt(s, SOL_UDPLITE, UDPLITE_RECV_CSCOV, &min, sizeof(int)); 79 + int min = 20; 80 + setsockopt(s, SOL_UDPLITE, UDPLITE_RECV_CSCOV, &min, sizeof(int)); 87 81 88 82 The calls to getsockopt(2) are analogous. Being an extension and not a stand- 89 83 alone protocol, all socket options known from UDP can be used in exactly the ··· 91 85 92 86 A detailed discussion of UDP-Lite checksum coverage options is in section IV. 93 87 94 - 95 - III) HEADER FILES 88 + 3. Header Files 89 + =============== 96 90 97 91 The socket API requires support through header files in /usr/include: 98 92 99 93 * /usr/include/netinet/in.h 100 - to define IPPROTO_UDPLITE 94 + to define IPPROTO_UDPLITE 101 95 102 96 * /usr/include/netinet/udplite.h 103 - for UDP-Lite header fields and protocol constants 97 + for UDP-Lite header fields and protocol constants 104 98 105 - For testing purposes, the following can serve as a `mini' header file: 99 + For testing purposes, the following can serve as a ``mini`` header file:: 106 100 107 101 #define IPPROTO_UDPLITE 136 108 102 #define SOL_UDPLITE 136 ··· 111 105 112 106 Ready-made header files for various distros are in the UDP-Lite tarball. 113 107 108 + 4. Kernel Behaviour with Regards to the Various Socket Options 109 + ============================================================== 114 110 115 - IV) KERNEL BEHAVIOUR WITH REGARD TO THE VARIOUS SOCKET OPTIONS 116 111 117 112 To enable debugging messages, the log level need to be set to 8, as most 118 113 messages use the KERN_DEBUG level (7). ··· 143 136 3) Disabling the Checksum Computation 144 137 145 138 On both sender and receiver, checksumming will always be performed 146 - and cannot be disabled using SO_NO_CHECK. Thus 139 + and cannot be disabled using SO_NO_CHECK. Thus:: 147 140 148 - setsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, ... ); 141 + setsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, ... ); 149 142 150 - will always will be ignored, while the value of 143 + will always will be ignored, while the value of:: 151 144 152 - getsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, &value, ...); 145 + getsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, &value, ...); 153 146 154 147 is meaningless (as in TCP). Packets with a zero checksum field are 155 148 illegal (cf. RFC 3828, sec. 3.1) and will be silently discarded. ··· 174 167 first one contains the L4 header. 175 168 176 169 The send buffer size has implications on the checksum coverage length. 177 - Consider the following example: 170 + Consider the following example:: 178 171 179 - Payload: 1536 bytes Send Buffer: 1024 bytes 180 - MTU: 1500 bytes Coverage Length: 856 bytes 172 + Payload: 1536 bytes Send Buffer: 1024 bytes 173 + MTU: 1500 bytes Coverage Length: 856 bytes 181 174 182 - UDP-Lite will ship the 1536 bytes in two separate packets: 175 + UDP-Lite will ship the 1536 bytes in two separate packets:: 183 176 184 - Packet 1: 1024 payload + 8 byte header + 20 byte IP header = 1052 bytes 185 - Packet 2: 512 payload + 8 byte header + 20 byte IP header = 540 bytes 177 + Packet 1: 1024 payload + 8 byte header + 20 byte IP header = 1052 bytes 178 + Packet 2: 512 payload + 8 byte header + 20 byte IP header = 540 bytes 186 179 187 180 The coverage packet covers the UDP-Lite header and 848 bytes of the 188 181 payload in the first packet, the second packet is fully covered. Note ··· 191 184 length in such cases. 192 185 193 186 As an example of what happens when one UDP-Lite packet is split into 194 - several tiny fragments, consider the following example. 187 + several tiny fragments, consider the following example:: 195 188 196 - Payload: 1024 bytes Send buffer size: 1024 bytes 197 - MTU: 300 bytes Coverage length: 575 bytes 189 + Payload: 1024 bytes Send buffer size: 1024 bytes 190 + MTU: 300 bytes Coverage length: 575 bytes 198 191 199 - +-+-----------+--------------+--------------+--------------+ 200 - |8| 272 | 280 | 280 | 280 | 201 - +-+-----------+--------------+--------------+--------------+ 202 - 280 560 840 1032 203 - ^ 204 - *****checksum coverage************* 192 + +-+-----------+--------------+--------------+--------------+ 193 + |8| 272 | 280 | 280 | 280 | 194 + +-+-----------+--------------+--------------+--------------+ 195 + 280 560 840 1032 196 + ^ 197 + *****checksum coverage************* 205 198 206 199 The UDP-Lite module generates one 1032 byte packet (1024 + 8 byte 207 200 header). According to the interface MTU, these are split into 4 IP ··· 215 208 lengths), only the first fragment needs to be considered. When using 216 209 larger checksum coverage lengths, each eligible fragment needs to be 217 210 checksummed. Suppose we have a checksum coverage of 3062. The buffer 218 - of 3356 bytes will be split into the following fragments: 211 + of 3356 bytes will be split into the following fragments:: 219 212 220 213 Fragment 1: 1280 bytes carrying 1232 bytes of UDP-Lite data 221 214 Fragment 2: 1280 bytes carrying 1232 bytes of UDP-Lite data ··· 229 222 performance over wireless (or generally noisy) links and thus smaller 230 223 coverage lengths are likely to be expected. 231 224 232 - 233 - V) UDP-LITE RUNTIME STATISTICS AND THEIR MEANING 225 + 5. UDP-Lite Runtime Statistics and their Meaning 226 + ================================================ 234 227 235 228 Exceptional and error conditions are logged to syslog at the KERN_DEBUG 236 229 level. Live statistics about UDP-Lite are available in /proc/net/snmp 237 - and can (with newer versions of netstat) be viewed using 230 + and can (with newer versions of netstat) be viewed using:: 238 231 239 - netstat -svu 232 + netstat -svu 240 233 241 234 This displays UDP-Lite statistics variables, whose meaning is as follows. 242 235 243 - InDatagrams: The total number of datagrams delivered to users. 236 + ============ ===================================================== 237 + InDatagrams The total number of datagrams delivered to users. 244 238 245 - NoPorts: Number of packets received to an unknown port. 246 - These cases are counted separately (not as InErrors). 239 + NoPorts Number of packets received to an unknown port. 240 + These cases are counted separately (not as InErrors). 247 241 248 - InErrors: Number of erroneous UDP-Lite packets. Errors include: 249 - * internal socket queue receive errors 250 - * packet too short (less than 8 bytes or stated 251 - coverage length exceeds received length) 252 - * xfrm4_policy_check() returned with error 253 - * application has specified larger min. coverage 254 - length than that of incoming packet 255 - * checksum coverage violated 256 - * bad checksum 242 + InErrors Number of erroneous UDP-Lite packets. Errors include: 257 243 258 - OutDatagrams: Total number of sent datagrams. 244 + * internal socket queue receive errors 245 + * packet too short (less than 8 bytes or stated 246 + coverage length exceeds received length) 247 + * xfrm4_policy_check() returned with error 248 + * application has specified larger min. coverage 249 + length than that of incoming packet 250 + * checksum coverage violated 251 + * bad checksum 252 + 253 + OutDatagrams Total number of sent datagrams. 254 + ============ ===================================================== 259 255 260 256 These statistics derive from the UDP MIB (RFC 2013). 261 257 262 - 263 - VI) IPTABLES 258 + 6. IPtables 259 + =========== 264 260 265 261 There is packet match support for UDP-Lite as well as support for the LOG target. 266 - If you copy and paste the following line into /etc/protocols, 262 + If you copy and paste the following line into /etc/protocols:: 267 263 268 - udplite 136 UDP-Lite # UDP-Lite [RFC 3828] 264 + udplite 136 UDP-Lite # UDP-Lite [RFC 3828] 269 265 270 - then 271 - iptables -A INPUT -p udplite -j LOG 266 + then:: 267 + 268 + iptables -A INPUT -p udplite -j LOG 272 269 273 270 will produce logging output to syslog. Dropping and rejecting packets also works. 274 271 275 - 276 - VII) MAINTAINER ADDRESS 272 + 7. Maintainer Address 273 + ===================== 277 274 278 275 The UDP-Lite patch was developed at 279 - University of Aberdeen 280 - Electronics Research Group 281 - Department of Engineering 282 - Fraser Noble Building 283 - Aberdeen AB24 3UE; UK 276 + 277 + University of Aberdeen 278 + Electronics Research Group 279 + Department of Engineering 280 + Fraser Noble Building 281 + Aberdeen AB24 3UE; UK 282 + 284 283 The current maintainer is Gerrit Renker, <gerrit@erg.abdn.ac.uk>. Initial 285 284 code was developed by William Stanislaus, <william@erg.abdn.ac.uk>.