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

docs: networking: convert strparser.txt to ReST

- add SPDX header;
- adjust title markup;
- mark code blocks and literals as such;
- mark tables 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
060d9d3e fe3dfe41

+60 -26
+1
Documentation/networking/index.rst
··· 104 104 secid 105 105 seg6-sysctl 106 106 skfp 107 + strparser 107 108 108 109 .. only:: subproject and html 109 110
+59 -26
Documentation/networking/strparser.txt Documentation/networking/strparser.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ========================= 1 4 Stream Parser (strparser) 5 + ========================= 2 6 3 7 Introduction 4 8 ============ ··· 38 34 Functions 39 35 ========= 40 36 41 - strp_init(struct strparser *strp, struct sock *sk, 42 - const struct strp_callbacks *cb) 37 + :: 38 + 39 + strp_init(struct strparser *strp, struct sock *sk, 40 + const struct strp_callbacks *cb) 43 41 44 42 Called to initialize a stream parser. strp is a struct of type 45 43 strparser that is allocated by the upper layer. sk is the TCP ··· 49 43 callback mode; in general mode this is set to NULL. Callbacks 50 44 are called by the stream parser (the callbacks are listed below). 51 45 52 - void strp_pause(struct strparser *strp) 46 + :: 47 + 48 + void strp_pause(struct strparser *strp) 53 49 54 50 Temporarily pause a stream parser. Message parsing is suspended 55 51 and no new messages are delivered to the upper layer. 56 52 57 - void strp_unpause(struct strparser *strp) 53 + :: 54 + 55 + void strp_unpause(struct strparser *strp) 58 56 59 57 Unpause a paused stream parser. 60 58 61 - void strp_stop(struct strparser *strp); 59 + :: 60 + 61 + void strp_stop(struct strparser *strp); 62 62 63 63 strp_stop is called to completely stop stream parser operations. 64 64 This is called internally when the stream parser encounters an 65 65 error, and it is called from the upper layer to stop parsing 66 66 operations. 67 67 68 - void strp_done(struct strparser *strp); 68 + :: 69 + 70 + void strp_done(struct strparser *strp); 69 71 70 72 strp_done is called to release any resources held by the stream 71 73 parser instance. This must be called after the stream processor 72 74 has been stopped. 73 75 74 - int strp_process(struct strparser *strp, struct sk_buff *orig_skb, 75 - unsigned int orig_offset, size_t orig_len, 76 - size_t max_msg_size, long timeo) 76 + :: 77 + 78 + int strp_process(struct strparser *strp, struct sk_buff *orig_skb, 79 + unsigned int orig_offset, size_t orig_len, 80 + size_t max_msg_size, long timeo) 77 81 78 82 strp_process is called in general mode for a stream parser to 79 83 parse an sk_buff. The number of bytes processed or a negative ··· 91 75 consume the sk_buff. max_msg_size is maximum size the stream 92 76 parser will parse. timeo is timeout for completing a message. 93 77 94 - void strp_data_ready(struct strparser *strp); 78 + :: 79 + 80 + void strp_data_ready(struct strparser *strp); 95 81 96 82 The upper layer calls strp_tcp_data_ready when data is ready on 97 83 the lower socket for strparser to process. This should be called ··· 101 83 maximum messages size is the limit of the receive socket 102 84 buffer and message timeout is the receive timeout for the socket. 103 85 104 - void strp_check_rcv(struct strparser *strp); 86 + :: 87 + 88 + void strp_check_rcv(struct strparser *strp); 105 89 106 90 strp_check_rcv is called to check for new messages on the socket. 107 91 This is normally called at initialization of a stream parser ··· 114 94 115 95 There are six callbacks: 116 96 117 - int (*parse_msg)(struct strparser *strp, struct sk_buff *skb); 97 + :: 98 + 99 + int (*parse_msg)(struct strparser *strp, struct sk_buff *skb); 118 100 119 101 parse_msg is called to determine the length of the next message 120 102 in the stream. The upper layer must implement this function. It ··· 129 107 130 108 The return values of this function are: 131 109 132 - >0 : indicates length of successfully parsed message 133 - 0 : indicates more data must be received to parse the message 134 - -ESTRPIPE : current message should not be processed by the 135 - kernel, return control of the socket to userspace which 136 - can proceed to read the messages itself 137 - other < 0 : Error in parsing, give control back to userspace 138 - assuming that synchronization is lost and the stream 139 - is unrecoverable (application expected to close TCP socket) 110 + ========= =========================================================== 111 + >0 indicates length of successfully parsed message 112 + 0 indicates more data must be received to parse the message 113 + -ESTRPIPE current message should not be processed by the 114 + kernel, return control of the socket to userspace which 115 + can proceed to read the messages itself 116 + other < 0 Error in parsing, give control back to userspace 117 + assuming that synchronization is lost and the stream 118 + is unrecoverable (application expected to close TCP socket) 119 + ========= =========================================================== 140 120 141 121 In the case that an error is returned (return value is less than 142 122 zero) and the parser is in receive callback mode, then it will set ··· 147 123 the current message, then the error set on the attached socket is 148 124 ENODATA since the stream is unrecoverable in that case. 149 125 150 - void (*lock)(struct strparser *strp) 126 + :: 127 + 128 + void (*lock)(struct strparser *strp) 151 129 152 130 The lock callback is called to lock the strp structure when 153 131 the strparser is performing an asynchronous operation (such as ··· 157 131 function is to lock_sock for the associated socket. In general 158 132 mode the callback must be set appropriately. 159 133 160 - void (*unlock)(struct strparser *strp) 134 + :: 135 + 136 + void (*unlock)(struct strparser *strp) 161 137 162 138 The unlock callback is called to release the lock obtained 163 139 by the lock callback. In receive callback mode the default 164 140 function is release_sock for the associated socket. In general 165 141 mode the callback must be set appropriately. 166 142 167 - void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb); 143 + :: 144 + 145 + void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb); 168 146 169 147 rcv_msg is called when a full message has been received and 170 148 is queued. The callee must consume the sk_buff; it can ··· 182 152 the length of the message. skb->len - offset may be greater 183 153 then full_len since strparser does not trim the skb. 184 154 185 - int (*read_sock_done)(struct strparser *strp, int err); 155 + :: 156 + 157 + int (*read_sock_done)(struct strparser *strp, int err); 186 158 187 159 read_sock_done is called when the stream parser is done reading 188 160 the TCP socket in receive callback mode. The stream parser may ··· 192 160 to occur when exiting the loop. If the callback is not set (NULL 193 161 in strp_init) a default function is used. 194 162 195 - void (*abort_parser)(struct strparser *strp, int err); 163 + :: 164 + 165 + void (*abort_parser)(struct strparser *strp, int err); 196 166 197 167 This function is called when stream parser encounters an error 198 168 in parsing. The default function stops the stream parser and ··· 238 204 ====== 239 205 240 206 Tom Herbert (tom@quantonium.net) 241 -