Repository navigation
Commit 36ccdf8
net, xsk: Avoid taking multiple skbuff references
Commit 642e450 ("xsk: Do not discard packet when NETDEV_TX_BUSY")
addressed the problem that packets were discarded from the Tx AF_XDP
ring, when the driver returned NETDEV_TX_BUSY. Part of the fix was
bumping the skbuff reference count, so that the buffer would not be
freed by dev_direct_xmit(). A reference count larger than one means
that the skbuff is "shared", which is not the case.
If the "shared" skbuff is sent to the generic XDP receive path,
netif_receive_generic_xdp(), and pskb_expand_head() is entered the
BUG_ON(skb_shared(skb)) will trigger.
This patch adds a variant to dev_direct_xmit(), __dev_direct_xmit(),
where a user can select the skbuff free policy. This allows AF_XDP to
avoid bumping the reference count, but still keep the NETDEV_TX_BUSY
behavior.
Fixes: 642e450 ("xsk: Do not discard packet when NETDEV_TX_BUSY")
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20201123175600.146255-1-bjorn.topel@gmail.com1 parent 1786489 commit 36ccdf8
3 files changed
Lines changed: 16 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2813 | 2813 | | |
2814 | 2814 | | |
2815 | 2815 | | |
| 2816 | + | |
2816 | 2817 | | |
2817 | 2818 | | |
2818 | | - | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
2819 | 2831 | | |
2820 | 2832 | | |
2821 | 2833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4180 | 4180 | | |
4181 | 4181 | | |
4182 | 4182 | | |
4183 | | - | |
| 4183 | + | |
4184 | 4184 | | |
4185 | 4185 | | |
4186 | 4186 | | |
| |||
4210 | 4210 | | |
4211 | 4211 | | |
4212 | 4212 | | |
4213 | | - | |
4214 | | - | |
4215 | | - | |
4216 | | - | |
4217 | 4213 | | |
4218 | 4214 | | |
4219 | 4215 | | |
4220 | 4216 | | |
4221 | 4217 | | |
4222 | 4218 | | |
4223 | | - | |
| 4219 | + | |
4224 | 4220 | | |
4225 | 4221 | | |
4226 | 4222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
| 414 | + | |
419 | 415 | | |
420 | 416 | | |
421 | 417 | | |
| |||
429 | 425 | | |
430 | 426 | | |
431 | 427 | | |
432 | | - | |
433 | 428 | | |
434 | 429 | | |
435 | 430 | | |
436 | 431 | | |
437 | | - | |
438 | 432 | | |
439 | 433 | | |
440 | 434 | | |
| |||
0 commit comments