.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Stream Parser |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2016 Tom Herbert <tom@herbertland.com> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 |
---|
8 | | - * as published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <linux/bpf.h> |
---|
.. | .. |
---|
14 | 11 | #include <linux/file.h> |
---|
15 | 12 | #include <linux/in.h> |
---|
16 | 13 | #include <linux/kernel.h> |
---|
17 | | -#include <linux/module.h> |
---|
| 14 | +#include <linux/export.h> |
---|
| 15 | +#include <linux/init.h> |
---|
18 | 16 | #include <linux/net.h> |
---|
19 | 17 | #include <linux/netdevice.h> |
---|
20 | 18 | #include <linux/poll.h> |
---|
.. | .. |
---|
29 | 27 | |
---|
30 | 28 | static struct workqueue_struct *strp_wq; |
---|
31 | 29 | |
---|
32 | | -struct _strp_msg { |
---|
33 | | - /* Internal cb structure. struct strp_msg must be first for passing |
---|
34 | | - * to upper layer. |
---|
35 | | - */ |
---|
36 | | - struct strp_msg strp; |
---|
37 | | - int accum_len; |
---|
38 | | -}; |
---|
39 | | - |
---|
40 | 30 | static inline struct _strp_msg *_strp_msg(struct sk_buff *skb) |
---|
41 | 31 | { |
---|
42 | 32 | return (struct _strp_msg *)((void *)skb->cb + |
---|
43 | | - offsetof(struct qdisc_skb_cb, data)); |
---|
| 33 | + offsetof(struct sk_skb_cb, strp)); |
---|
44 | 34 | } |
---|
45 | 35 | |
---|
46 | 36 | /* Lower lock held */ |
---|
.. | .. |
---|
159 | 149 | return 0; |
---|
160 | 150 | } |
---|
161 | 151 | |
---|
162 | | - skb = alloc_skb(0, GFP_ATOMIC); |
---|
| 152 | + skb = alloc_skb_for_msg(head); |
---|
163 | 153 | if (!skb) { |
---|
164 | 154 | STRP_STATS_INCR(strp->stats.mem_fail); |
---|
165 | 155 | desc->error = -ENOMEM; |
---|
166 | 156 | return 0; |
---|
167 | 157 | } |
---|
168 | | - skb->len = head->len; |
---|
169 | | - skb->data_len = head->len; |
---|
170 | | - skb->truesize = head->truesize; |
---|
171 | | - *_strp_msg(skb) = *_strp_msg(head); |
---|
| 158 | + |
---|
172 | 159 | strp->skb_nextp = &head->next; |
---|
173 | | - skb_shinfo(skb)->frag_list = head; |
---|
174 | 160 | strp->skb_head = skb; |
---|
175 | 161 | head = skb; |
---|
176 | 162 | } else { |
---|
.. | .. |
---|
297 | 283 | break; |
---|
298 | 284 | } |
---|
299 | 285 | |
---|
300 | | - /* Positive extra indicates ore bytes than needed for the |
---|
| 286 | + /* Positive extra indicates more bytes than needed for the |
---|
301 | 287 | * message |
---|
302 | 288 | */ |
---|
303 | 289 | |
---|
.. | .. |
---|
545 | 531 | } |
---|
546 | 532 | EXPORT_SYMBOL_GPL(strp_check_rcv); |
---|
547 | 533 | |
---|
548 | | -static int __init strp_mod_init(void) |
---|
| 534 | +static int __init strp_dev_init(void) |
---|
549 | 535 | { |
---|
550 | 536 | strp_wq = create_singlethread_workqueue("kstrp"); |
---|
| 537 | + if (unlikely(!strp_wq)) |
---|
| 538 | + return -ENOMEM; |
---|
551 | 539 | |
---|
552 | 540 | return 0; |
---|
553 | 541 | } |
---|
554 | | - |
---|
555 | | -static void __exit strp_mod_exit(void) |
---|
556 | | -{ |
---|
557 | | - destroy_workqueue(strp_wq); |
---|
558 | | -} |
---|
559 | | -module_init(strp_mod_init); |
---|
560 | | -module_exit(strp_mod_exit); |
---|
561 | | -MODULE_LICENSE("GPL"); |
---|
| 542 | +device_initcall(strp_dev_init); |
---|