Lines Matching refs:strp
34 struct strp_msg strp; member
45 static void strp_abort_strp(struct strparser *strp, int err) in strp_abort_strp() argument
49 cancel_delayed_work(&strp->msg_timer_work); in strp_abort_strp()
51 if (strp->stopped) in strp_abort_strp()
54 strp->stopped = 1; in strp_abort_strp()
56 if (strp->sk) { in strp_abort_strp()
57 struct sock *sk = strp->sk; in strp_abort_strp()
65 static void strp_start_timer(struct strparser *strp, long timeo) in strp_start_timer() argument
68 mod_delayed_work(strp_wq, &strp->msg_timer_work, timeo); in strp_start_timer()
72 static void strp_parser_err(struct strparser *strp, int err, in strp_parser_err() argument
76 kfree_skb(strp->skb_head); in strp_parser_err()
77 strp->skb_head = NULL; in strp_parser_err()
78 strp->cb.abort_parser(strp, err); in strp_parser_err()
81 static inline int strp_peek_len(struct strparser *strp) in strp_peek_len() argument
83 if (strp->sk) { in strp_peek_len()
84 struct socket *sock = strp->sk->sk_socket; in strp_peek_len()
101 struct strparser *strp = (struct strparser *)desc->arg.data; in __strp_recv() local
109 if (strp->paused) in __strp_recv()
112 head = strp->skb_head; in __strp_recv()
123 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
128 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
137 if (!strp->skb_nextp) { in __strp_recv()
143 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
162 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
167 strp->skb_nextp = &head->next; in __strp_recv()
168 strp->skb_head = skb; in __strp_recv()
171 strp->skb_nextp = in __strp_recv()
181 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
188 head = strp->skb_head; in __strp_recv()
191 strp->skb_head = head; in __strp_recv()
193 strp->skb_nextp = NULL; in __strp_recv()
196 stm->strp.offset = orig_offset + eaten; in __strp_recv()
204 STRP_STATS_INCR(strp->stats.mem_fail); in __strp_recv()
211 *strp->skb_nextp = skb; in __strp_recv()
212 strp->skb_nextp = &skb->next; in __strp_recv()
218 if (!stm->strp.full_len) { in __strp_recv()
221 len = (*strp->cb.parse_msg)(strp, head); in __strp_recv()
227 strp_start_timer(strp, timeo); in __strp_recv()
231 STRP_STATS_INCR(strp->stats.need_more_hdr); in __strp_recv()
237 strp->unrecov_intr = 1; in __strp_recv()
239 strp->interrupted = 1; in __strp_recv()
241 strp_parser_err(strp, len, desc); in __strp_recv()
245 STRP_STATS_INCR(strp->stats.msg_too_big); in __strp_recv()
246 strp_parser_err(strp, -EMSGSIZE, desc); in __strp_recv()
249 skb->len - stm->strp.offset) { in __strp_recv()
253 STRP_STATS_INCR(strp->stats.bad_hdr_len); in __strp_recv()
254 strp_parser_err(strp, -EPROTO, desc); in __strp_recv()
258 stm->strp.full_len = len; in __strp_recv()
262 stm->strp.full_len; in __strp_recv()
266 if (stm->strp.full_len - stm->accum_len > in __strp_recv()
267 strp_peek_len(strp)) { in __strp_recv()
277 strp_start_timer(strp, timeo); in __strp_recv()
282 strp->need_bytes = stm->strp.full_len - in __strp_recv()
284 STRP_STATS_ADD(strp->stats.bytes, cand_len); in __strp_recv()
303 cancel_delayed_work(&strp->msg_timer_work); in __strp_recv()
304 strp->skb_head = NULL; in __strp_recv()
305 strp->need_bytes = 0; in __strp_recv()
306 STRP_STATS_INCR(strp->stats.msgs); in __strp_recv()
309 strp->cb.rcv_msg(strp, head); in __strp_recv()
311 if (unlikely(strp->paused)) { in __strp_recv()
320 STRP_STATS_ADD(strp->stats.bytes, eaten); in __strp_recv()
325 int strp_process(struct strparser *strp, struct sk_buff *orig_skb, in strp_process() argument
331 desc.arg.data = strp; in strp_process()
341 struct strparser *strp = (struct strparser *)desc->arg.data; in strp_recv() local
344 strp->sk->sk_rcvbuf, strp->sk->sk_rcvtimeo); in strp_recv()
347 static int default_read_sock_done(struct strparser *strp, int err) in default_read_sock_done() argument
353 static int strp_read_sock(struct strparser *strp) in strp_read_sock() argument
355 struct socket *sock = strp->sk->sk_socket; in strp_read_sock()
361 desc.arg.data = strp; in strp_read_sock()
366 sock->ops->read_sock(strp->sk, &desc, strp_recv); in strp_read_sock()
368 desc.error = strp->cb.read_sock_done(strp, desc.error); in strp_read_sock()
374 void strp_data_ready(struct strparser *strp) in strp_data_ready() argument
376 if (unlikely(strp->stopped) || strp->paused) in strp_data_ready()
386 if (sock_owned_by_user_nocheck(strp->sk)) { in strp_data_ready()
387 queue_work(strp_wq, &strp->work); in strp_data_ready()
391 if (strp->need_bytes) { in strp_data_ready()
392 if (strp_peek_len(strp) < strp->need_bytes) in strp_data_ready()
396 if (strp_read_sock(strp) == -ENOMEM) in strp_data_ready()
397 queue_work(strp_wq, &strp->work); in strp_data_ready()
401 static void do_strp_work(struct strparser *strp) in do_strp_work() argument
406 strp->cb.lock(strp); in do_strp_work()
408 if (unlikely(strp->stopped)) in do_strp_work()
411 if (strp->paused) in do_strp_work()
414 if (strp_read_sock(strp) == -ENOMEM) in do_strp_work()
415 queue_work(strp_wq, &strp->work); in do_strp_work()
418 strp->cb.unlock(strp); in do_strp_work()
428 struct strparser *strp = container_of(w, struct strparser, in strp_msg_timeout() local
432 STRP_STATS_INCR(strp->stats.msg_timeouts); in strp_msg_timeout()
433 strp->cb.lock(strp); in strp_msg_timeout()
434 strp->cb.abort_parser(strp, -ETIMEDOUT); in strp_msg_timeout()
435 strp->cb.unlock(strp); in strp_msg_timeout()
438 static void strp_sock_lock(struct strparser *strp) in strp_sock_lock() argument
440 lock_sock(strp->sk); in strp_sock_lock()
443 static void strp_sock_unlock(struct strparser *strp) in strp_sock_unlock() argument
445 release_sock(strp->sk); in strp_sock_unlock()
448 int strp_init(struct strparser *strp, struct sock *sk, in strp_init() argument
471 memset(strp, 0, sizeof(*strp)); in strp_init()
473 strp->sk = sk; in strp_init()
475 strp->cb.lock = cb->lock ? : strp_sock_lock; in strp_init()
476 strp->cb.unlock = cb->unlock ? : strp_sock_unlock; in strp_init()
477 strp->cb.rcv_msg = cb->rcv_msg; in strp_init()
478 strp->cb.parse_msg = cb->parse_msg; in strp_init()
479 strp->cb.read_sock_done = cb->read_sock_done ? : default_read_sock_done; in strp_init()
480 strp->cb.abort_parser = cb->abort_parser ? : strp_abort_strp; in strp_init()
482 INIT_DELAYED_WORK(&strp->msg_timer_work, strp_msg_timeout); in strp_init()
483 INIT_WORK(&strp->work, strp_work); in strp_init()
490 void __strp_unpause(struct strparser *strp) in __strp_unpause() argument
492 strp->paused = 0; in __strp_unpause()
494 if (strp->need_bytes) { in __strp_unpause()
495 if (strp_peek_len(strp) < strp->need_bytes) in __strp_unpause()
498 strp_read_sock(strp); in __strp_unpause()
502 void strp_unpause(struct strparser *strp) in strp_unpause() argument
504 strp->paused = 0; in strp_unpause()
509 queue_work(strp_wq, &strp->work); in strp_unpause()
516 void strp_done(struct strparser *strp) in strp_done() argument
518 WARN_ON(!strp->stopped); in strp_done()
520 cancel_delayed_work_sync(&strp->msg_timer_work); in strp_done()
521 cancel_work_sync(&strp->work); in strp_done()
523 if (strp->skb_head) { in strp_done()
524 kfree_skb(strp->skb_head); in strp_done()
525 strp->skb_head = NULL; in strp_done()
530 void strp_stop(struct strparser *strp) in strp_stop() argument
532 strp->stopped = 1; in strp_stop()
536 void strp_check_rcv(struct strparser *strp) in strp_check_rcv() argument
538 queue_work(strp_wq, &strp->work); in strp_check_rcv()