Lines Matching full:strp
33 offsetof(struct sk_skb_cb, strp));
37 static void strp_abort_strp(struct strparser *strp, int err)
41 cancel_delayed_work(&strp->msg_timer_work);
43 if (strp->stopped)
46 strp->stopped = 1;
48 if (strp->skb_head) {
49 kfree_skb(strp->skb_head);
50 strp->skb_head = NULL;
53 strp->skb_nextp = NULL;
54 strp->need_bytes = 0;
56 if (strp->sk) {
57 struct sock *sk = strp->sk;
65 static void strp_start_timer(struct strparser *strp, long timeo)
68 mod_delayed_work(strp_wq, &strp->msg_timer_work, timeo);
72 static void strp_parser_err(struct strparser *strp, int err,
76 kfree_skb(strp->skb_head);
77 strp->skb_head = NULL;
78 strp->cb.abort_parser(strp, err);
81 static inline int strp_peek_len(struct strparser *strp)
83 if (strp->sk) {
84 struct socket *sock = strp->sk->sk_socket;
101 struct strparser *strp = (struct strparser *)desc->arg.data;
109 if (strp->paused)
112 head = strp->skb_head;
123 STRP_STATS_INCR(strp->stats.mem_fail);
128 STRP_STATS_INCR(strp->stats.mem_fail);
137 if (!strp->skb_nextp) {
143 STRP_STATS_INCR(strp->stats.mem_fail);
162 STRP_STATS_INCR(strp->stats.mem_fail);
167 strp->skb_nextp = &head->next;
168 strp->skb_head = skb;
171 strp->skb_nextp =
181 STRP_STATS_INCR(strp->stats.mem_fail);
188 head = strp->skb_head;
191 strp->skb_head = head;
193 strp->skb_nextp = NULL;
196 stm->strp.offset = orig_offset + eaten;
204 STRP_STATS_INCR(strp->stats.mem_fail);
211 *strp->skb_nextp = skb;
212 strp->skb_nextp = &skb->next;
218 if (!stm->strp.full_len) {
221 len = (*strp->cb.parse_msg)(strp, head);
227 strp_start_timer(strp, timeo);
231 STRP_STATS_INCR(strp->stats.need_more_hdr);
237 strp->unrecov_intr = 1;
239 strp->interrupted = 1;
241 strp_parser_err(strp, len, desc);
245 STRP_STATS_INCR(strp->stats.msg_too_big);
246 strp_parser_err(strp, -EMSGSIZE, desc);
249 (ssize_t)skb->len - stm->strp.offset) {
253 STRP_STATS_INCR(strp->stats.bad_hdr_len);
254 strp_parser_err(strp, -EPROTO, desc);
258 stm->strp.full_len = len;
262 stm->strp.full_len;
266 if (stm->strp.full_len - stm->accum_len >
267 strp_peek_len(strp)) {
269 * buffer. Set strp->need_bytes to wait for
277 strp_start_timer(strp, timeo);
282 strp->need_bytes = stm->strp.full_len -
284 STRP_STATS_ADD(strp->stats.bytes, cand_len);
303 cancel_delayed_work(&strp->msg_timer_work);
304 strp->skb_head = NULL;
305 strp->need_bytes = 0;
306 STRP_STATS_INCR(strp->stats.msgs);
309 strp->cb.rcv_msg(strp, head);
311 if (unlikely(strp->paused)) {
312 /* Upper layer paused strp */
320 STRP_STATS_ADD(strp->stats.bytes, eaten);
325 int strp_process(struct strparser *strp, struct sk_buff *orig_skb,
331 desc.arg.data = strp;
341 struct strparser *strp = (struct strparser *)desc->arg.data;
344 strp->sk->sk_rcvbuf, READ_ONCE(strp->sk->sk_rcvtimeo));
347 static int default_read_sock_done(struct strparser *strp, int err)
353 static int strp_read_sock(struct strparser *strp)
355 struct socket *sock = strp->sk->sk_socket;
361 if (unlikely(!strp->cb.read_sock && !sock->ops->read_sock))
364 desc.arg.data = strp;
369 if (strp->cb.read_sock)
370 strp->cb.read_sock(strp, &desc, strp_recv);
372 sock->ops->read_sock(strp->sk, &desc, strp_recv);
374 desc.error = strp->cb.read_sock_done(strp, desc.error);
380 void strp_data_ready(struct strparser *strp)
382 if (unlikely(strp->stopped) || strp->paused)
392 if (sock_owned_by_user_nocheck(strp->sk)) {
393 queue_work(strp_wq, &strp->work);
397 if (strp->need_bytes) {
398 if (strp_peek_len(strp) < strp->need_bytes)
402 if (strp_read_sock(strp) == -ENOMEM)
403 queue_work(strp_wq, &strp->work);
407 static void do_strp_work(struct strparser *strp)
412 strp->cb.lock(strp);
414 if (unlikely(strp->stopped))
417 if (strp->paused)
420 if (strp_read_sock(strp) == -ENOMEM)
421 queue_work(strp_wq, &strp->work);
424 strp->cb.unlock(strp);
434 struct strparser *strp = container_of(w, struct strparser,
438 STRP_STATS_INCR(strp->stats.msg_timeouts);
439 strp->cb.lock(strp);
440 strp->cb.abort_parser(strp, -ETIMEDOUT);
441 strp->cb.unlock(strp);
444 static void strp_sock_lock(struct strparser *strp)
446 lock_sock(strp->sk);
449 static void strp_sock_unlock(struct strparser *strp)
451 release_sock(strp->sk);
454 int strp_init(struct strparser *strp, struct sock *sk,
477 memset(strp, 0, sizeof(*strp));
479 strp->sk = sk;
481 strp->cb.lock = cb->lock ? : strp_sock_lock;
482 strp->cb.unlock = cb->unlock ? : strp_sock_unlock;
483 strp->cb.rcv_msg = cb->rcv_msg;
484 strp->cb.parse_msg = cb->parse_msg;
485 strp->cb.read_sock = cb->read_sock;
486 strp->cb.read_sock_done = cb->read_sock_done ? : default_read_sock_done;
487 strp->cb.abort_parser = cb->abort_parser ? : strp_abort_strp;
489 INIT_DELAYED_WORK(&strp->msg_timer_work, strp_msg_timeout);
490 INIT_WORK(&strp->work, strp_work);
496 void strp_unpause(struct strparser *strp)
498 strp->paused = 0;
503 queue_work(strp_wq, &strp->work);
507 /* strp must already be stopped so that strp_recv will no longer be called.
510 void strp_done(struct strparser *strp)
512 WARN_ON(!strp->stopped);
514 cancel_delayed_work_sync(&strp->msg_timer_work);
515 cancel_work_sync(&strp->work);
517 if (strp->skb_head) {
518 kfree_skb(strp->skb_head);
519 strp->skb_head = NULL;
524 void strp_stop(struct strparser *strp)
526 strp->stopped = 1;
530 void strp_check_rcv(struct strparser *strp)
532 queue_work(strp_wq, &strp->work);