Lines Matching refs: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->sk) {
49 struct sock *sk = strp->sk;
57 static void strp_start_timer(struct strparser *strp, long timeo)
60 mod_delayed_work(strp_wq, &strp->msg_timer_work, timeo);
64 static void strp_parser_err(struct strparser *strp, int err,
68 kfree_skb(strp->skb_head);
69 strp->skb_head = NULL;
70 strp->cb.abort_parser(strp, err);
73 static inline int strp_peek_len(struct strparser *strp)
75 if (strp->sk) {
76 struct socket *sock = strp->sk->sk_socket;
93 struct strparser *strp = (struct strparser *)desc->arg.data;
101 if (strp->paused)
104 head = strp->skb_head;
115 STRP_STATS_INCR(strp->stats.mem_fail);
120 STRP_STATS_INCR(strp->stats.mem_fail);
129 if (!strp->skb_nextp) {
135 STRP_STATS_INCR(strp->stats.mem_fail);
154 STRP_STATS_INCR(strp->stats.mem_fail);
159 strp->skb_nextp = &head->next;
160 strp->skb_head = skb;
163 strp->skb_nextp =
173 STRP_STATS_INCR(strp->stats.mem_fail);
180 head = strp->skb_head;
183 strp->skb_head = head;
185 strp->skb_nextp = NULL;
188 stm->strp.offset = orig_offset + eaten;
196 STRP_STATS_INCR(strp->stats.mem_fail);
203 *strp->skb_nextp = skb;
204 strp->skb_nextp = &skb->next;
210 if (!stm->strp.full_len) {
213 len = (*strp->cb.parse_msg)(strp, head);
219 strp_start_timer(strp, timeo);
223 STRP_STATS_INCR(strp->stats.need_more_hdr);
229 strp->unrecov_intr = 1;
231 strp->interrupted = 1;
233 strp_parser_err(strp, len, desc);
237 STRP_STATS_INCR(strp->stats.msg_too_big);
238 strp_parser_err(strp, -EMSGSIZE, desc);
241 skb->len - stm->strp.offset) {
245 STRP_STATS_INCR(strp->stats.bad_hdr_len);
246 strp_parser_err(strp, -EPROTO, desc);
250 stm->strp.full_len = len;
254 stm->strp.full_len;
258 if (stm->strp.full_len - stm->accum_len >
259 strp_peek_len(strp)) {
261 * buffer. Set strp->need_bytes to wait for
269 strp_start_timer(strp, timeo);
274 strp->need_bytes = stm->strp.full_len -
276 STRP_STATS_ADD(strp->stats.bytes, cand_len);
295 cancel_delayed_work(&strp->msg_timer_work);
296 strp->skb_head = NULL;
297 strp->need_bytes = 0;
298 STRP_STATS_INCR(strp->stats.msgs);
301 strp->cb.rcv_msg(strp, head);
303 if (unlikely(strp->paused)) {
304 /* Upper layer paused strp */
312 STRP_STATS_ADD(strp->stats.bytes, eaten);
317 int strp_process(struct strparser *strp, struct sk_buff *orig_skb,
323 desc.arg.data = strp;
333 struct strparser *strp = (struct strparser *)desc->arg.data;
336 strp->sk->sk_rcvbuf, strp->sk->sk_rcvtimeo);
339 static int default_read_sock_done(struct strparser *strp, int err)
345 static int strp_read_sock(struct strparser *strp)
347 struct socket *sock = strp->sk->sk_socket;
353 desc.arg.data = strp;
358 sock->ops->read_sock(strp->sk, &desc, strp_recv);
360 desc.error = strp->cb.read_sock_done(strp, desc.error);
366 void strp_data_ready(struct strparser *strp)
368 if (unlikely(strp->stopped) || strp->paused)
378 if (sock_owned_by_user_nocheck(strp->sk)) {
379 queue_work(strp_wq, &strp->work);
383 if (strp->need_bytes) {
384 if (strp_peek_len(strp) < strp->need_bytes)
388 if (strp_read_sock(strp) == -ENOMEM)
389 queue_work(strp_wq, &strp->work);
393 static void do_strp_work(struct strparser *strp)
398 strp->cb.lock(strp);
400 if (unlikely(strp->stopped))
403 if (strp->paused)
406 if (strp_read_sock(strp) == -ENOMEM)
407 queue_work(strp_wq, &strp->work);
410 strp->cb.unlock(strp);
420 struct strparser *strp = container_of(w, struct strparser,
424 STRP_STATS_INCR(strp->stats.msg_timeouts);
425 strp->cb.lock(strp);
426 strp->cb.abort_parser(strp, -ETIMEDOUT);
427 strp->cb.unlock(strp);
430 static void strp_sock_lock(struct strparser *strp)
432 lock_sock(strp->sk);
435 static void strp_sock_unlock(struct strparser *strp)
437 release_sock(strp->sk);
440 int strp_init(struct strparser *strp, struct sock *sk,
463 memset(strp, 0, sizeof(*strp));
465 strp->sk = sk;
467 strp->cb.lock = cb->lock ? : strp_sock_lock;
468 strp->cb.unlock = cb->unlock ? : strp_sock_unlock;
469 strp->cb.rcv_msg = cb->rcv_msg;
470 strp->cb.parse_msg = cb->parse_msg;
471 strp->cb.read_sock_done = cb->read_sock_done ? : default_read_sock_done;
472 strp->cb.abort_parser = cb->abort_parser ? : strp_abort_strp;
474 INIT_DELAYED_WORK(&strp->msg_timer_work, strp_msg_timeout);
475 INIT_WORK(&strp->work, strp_work);
482 void __strp_unpause(struct strparser *strp)
484 strp->paused = 0;
486 if (strp->need_bytes) {
487 if (strp_peek_len(strp) < strp->need_bytes)
490 strp_read_sock(strp);
494 void strp_unpause(struct strparser *strp)
496 strp->paused = 0;
501 queue_work(strp_wq, &strp->work);
505 /* strp must already be stopped so that strp_recv will no longer be called.
508 void strp_done(struct strparser *strp)
510 WARN_ON(!strp->stopped);
512 cancel_delayed_work_sync(&strp->msg_timer_work);
513 cancel_work_sync(&strp->work);
515 if (strp->skb_head) {
516 kfree_skb(strp->skb_head);
517 strp->skb_head = NULL;
522 void strp_stop(struct strparser *strp)
524 strp->stopped = 1;
528 void strp_check_rcv(struct strparser *strp)
530 queue_work(strp_wq, &strp->work);