Lines Matching +full:buffered +full:- +full:positive
1 // SPDX-License-Identifier: GPL-2.0-only
32 return (struct _strp_msg *)((void *)skb->cb + in _strp_msg()
41 cancel_delayed_work(&strp->msg_timer_work); in strp_abort_strp()
43 if (strp->stopped) in strp_abort_strp()
46 strp->stopped = 1; in strp_abort_strp()
48 if (strp->sk) { in strp_abort_strp()
49 struct sock *sk = strp->sk; in strp_abort_strp()
52 sk->sk_err = -err; in strp_abort_strp()
60 mod_delayed_work(strp_wq, &strp->msg_timer_work, timeo); in strp_start_timer()
67 desc->error = err; in strp_parser_err()
68 kfree_skb(strp->skb_head); in strp_parser_err()
69 strp->skb_head = NULL; in strp_parser_err()
70 strp->cb.abort_parser(strp, err); in strp_parser_err()
75 if (strp->sk) { in strp_peek_len()
76 struct socket *sock = strp->sk->sk_socket; in strp_peek_len()
78 return sock->ops->peek_len(sock); in strp_peek_len()
93 struct strparser *strp = (struct strparser *)desc->arg.data; in __strp_recv()
101 if (strp->paused) in __strp_recv()
104 head = strp->skb_head; in __strp_recv()
108 /* Getting data with a non-zero offset when a message is in __strp_recv()
115 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
116 desc->error = -ENOMEM; in __strp_recv()
120 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
122 desc->error = -ENOMEM; in __strp_recv()
129 if (!strp->skb_nextp) { in __strp_recv()
135 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
136 desc->error = err; in __strp_recv()
140 if (unlikely(skb_shinfo(head)->frag_list)) { in __strp_recv()
144 * then are able to use the old head->next for in __strp_recv()
147 if (WARN_ON(head->next)) { in __strp_recv()
148 desc->error = -EINVAL; in __strp_recv()
154 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
155 desc->error = -ENOMEM; in __strp_recv()
159 strp->skb_nextp = &head->next; in __strp_recv()
160 strp->skb_head = skb; in __strp_recv()
163 strp->skb_nextp = in __strp_recv()
164 &skb_shinfo(head)->frag_list; in __strp_recv()
173 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
174 desc->error = -ENOMEM; in __strp_recv()
178 cand_len = orig_len - eaten; in __strp_recv()
180 head = strp->skb_head; in __strp_recv()
183 strp->skb_head = head; in __strp_recv()
185 strp->skb_nextp = NULL; in __strp_recv()
188 stm->strp.offset = orig_offset + eaten; in __strp_recv()
196 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
197 desc->error = err; in __strp_recv()
203 *strp->skb_nextp = skb; in __strp_recv()
204 strp->skb_nextp = &skb->next; in __strp_recv()
205 head->data_len += skb->len; in __strp_recv()
206 head->len += skb->len; in __strp_recv()
207 head->truesize += skb->truesize; in __strp_recv()
210 if (!stm->strp.full_len) { in __strp_recv()
213 len = (*strp->cb.parse_msg)(strp, head); in __strp_recv()
217 if (!stm->accum_len) { in __strp_recv()
221 stm->accum_len += cand_len; in __strp_recv()
223 STRP_STATS_INCR(strp->stats.need_more_hdr); in __strp_recv()
227 if (len == -ESTRPIPE && stm->accum_len) { in __strp_recv()
228 len = -ENODATA; in __strp_recv()
229 strp->unrecov_intr = 1; in __strp_recv()
231 strp->interrupted = 1; in __strp_recv()
237 STRP_STATS_INCR(strp->stats.msg_too_big); in __strp_recv()
238 strp_parser_err(strp, -EMSGSIZE, desc); in __strp_recv()
240 } else if (len <= (ssize_t)head->len - in __strp_recv()
241 skb->len - stm->strp.offset) { in __strp_recv()
245 STRP_STATS_INCR(strp->stats.bad_hdr_len); in __strp_recv()
246 strp_parser_err(strp, -EPROTO, desc); in __strp_recv()
250 stm->strp.full_len = len; in __strp_recv()
253 extra = (ssize_t)(stm->accum_len + cand_len) - in __strp_recv()
254 stm->strp.full_len; in __strp_recv()
258 if (stm->strp.full_len - stm->accum_len > in __strp_recv()
261 * buffer. Set strp->need_bytes to wait for in __strp_recv()
263 * eaten" since we've already buffered the skb in __strp_recv()
267 if (!stm->accum_len) { in __strp_recv()
272 stm->accum_len += cand_len; in __strp_recv()
274 strp->need_bytes = stm->strp.full_len - in __strp_recv()
275 stm->accum_len; in __strp_recv()
276 STRP_STATS_ADD(strp->stats.bytes, cand_len); in __strp_recv()
277 desc->count = 0; /* Stop reading socket */ in __strp_recv()
280 stm->accum_len += cand_len; in __strp_recv()
286 /* Positive extra indicates more bytes than needed for the in __strp_recv()
292 eaten += (cand_len - extra); in __strp_recv()
295 cancel_delayed_work(&strp->msg_timer_work); in __strp_recv()
296 strp->skb_head = NULL; in __strp_recv()
297 strp->need_bytes = 0; in __strp_recv()
298 STRP_STATS_INCR(strp->stats.msgs); in __strp_recv()
301 strp->cb.rcv_msg(strp, head); in __strp_recv()
303 if (unlikely(strp->paused)) { in __strp_recv()
312 STRP_STATS_ADD(strp->stats.bytes, eaten); in __strp_recv()
333 struct strparser *strp = (struct strparser *)desc->arg.data; in strp_recv()
336 strp->sk->sk_rcvbuf, strp->sk->sk_rcvtimeo); in strp_recv()
347 struct socket *sock = strp->sk->sk_socket; in strp_read_sock()
350 if (unlikely(!sock || !sock->ops || !sock->ops->read_sock)) in strp_read_sock()
351 return -EBUSY; in strp_read_sock()
358 sock->ops->read_sock(strp->sk, &desc, strp_recv); in strp_read_sock()
360 desc.error = strp->cb.read_sock_done(strp, desc.error); in strp_read_sock()
368 if (unlikely(strp->stopped) || strp->paused) in strp_data_ready()
378 if (sock_owned_by_user_nocheck(strp->sk)) { in strp_data_ready()
379 queue_work(strp_wq, &strp->work); in strp_data_ready()
383 if (strp->need_bytes) { in strp_data_ready()
384 if (strp_peek_len(strp) < strp->need_bytes) in strp_data_ready()
388 if (strp_read_sock(strp) == -ENOMEM) in strp_data_ready()
389 queue_work(strp_wq, &strp->work); in strp_data_ready()
398 strp->cb.lock(strp); in do_strp_work()
400 if (unlikely(strp->stopped)) in do_strp_work()
403 if (strp->paused) in do_strp_work()
406 if (strp_read_sock(strp) == -ENOMEM) in do_strp_work()
407 queue_work(strp_wq, &strp->work); in do_strp_work()
410 strp->cb.unlock(strp); in do_strp_work()
424 STRP_STATS_INCR(strp->stats.msg_timeouts); in strp_msg_timeout()
425 strp->cb.lock(strp); in strp_msg_timeout()
426 strp->cb.abort_parser(strp, -ETIMEDOUT); in strp_msg_timeout()
427 strp->cb.unlock(strp); in strp_msg_timeout()
432 lock_sock(strp->sk); in strp_sock_lock()
437 release_sock(strp->sk); in strp_sock_unlock()
444 if (!cb || !cb->rcv_msg || !cb->parse_msg) in strp_init()
445 return -EINVAL; in strp_init()
459 if (!cb->lock || !cb->unlock) in strp_init()
460 return -EINVAL; in strp_init()
465 strp->sk = sk; in strp_init()
467 strp->cb.lock = cb->lock ? : strp_sock_lock; in strp_init()
468 strp->cb.unlock = cb->unlock ? : strp_sock_unlock; in strp_init()
469 strp->cb.rcv_msg = cb->rcv_msg; in strp_init()
470 strp->cb.parse_msg = cb->parse_msg; in strp_init()
471 strp->cb.read_sock_done = cb->read_sock_done ? : default_read_sock_done; in strp_init()
472 strp->cb.abort_parser = cb->abort_parser ? : strp_abort_strp; in strp_init()
474 INIT_DELAYED_WORK(&strp->msg_timer_work, strp_msg_timeout); in strp_init()
475 INIT_WORK(&strp->work, strp_work); in strp_init()
484 strp->paused = 0; in __strp_unpause()
486 if (strp->need_bytes) { in __strp_unpause()
487 if (strp_peek_len(strp) < strp->need_bytes) in __strp_unpause()
496 strp->paused = 0; in strp_unpause()
501 queue_work(strp_wq, &strp->work); in strp_unpause()
510 WARN_ON(!strp->stopped); in strp_done()
512 cancel_delayed_work_sync(&strp->msg_timer_work); in strp_done()
513 cancel_work_sync(&strp->work); in strp_done()
515 if (strp->skb_head) { in strp_done()
516 kfree_skb(strp->skb_head); in strp_done()
517 strp->skb_head = NULL; in strp_done()
524 strp->stopped = 1; in strp_stop()
530 queue_work(strp_wq, &strp->work); in strp_check_rcv()
541 return -ENOMEM; in strp_dev_init()