packet: uses kfree_skb() for drop.
Subsystems (3)
PATCH 1/1 packet: uses kfree_skb() for drop.
consume_skb() isn't for drop or error cases. kfree_skb() is more proper one.
--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
@@ -2141,7 +2141,7 @@ drop_n_restore: skb->len = skb_len; } drop: -consume_skb (skb); +kfree_skb (skb);return 0 ; }
Signature · 1 line
2.1.3
Willem de Bruijn
maintainerQuoted 12 lines · Weongyo Jeong
consume_skb()isn't for drop or error cases.kfree_skb()is more proper one.Signed-off-by Weongyo Jeong <[email protected]>--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/packet/af_packet.c +0
-0
net/packet/af_packet.c drop_n_restore: · line 2144
Quoted 5 lines
net/packet/af_packet.c +1
-1@@ -2141,7 +2141,7 @@ drop_n_restore: skb->len = skb_len; } drop: -consume_skb (skb); +kfree_skb (skb);
This does show an inconsistency between packet_rcv and tpacket_rcv, which calls kfree_skb.
A comment at consume_skb mentions that kfree_skb is intended for drops that signal a failure condition, and indeed, that makes it a useful way to track errors (e.g., with perf record -a -g -e skb:kfree_skb).
This drop path is not always an error path, though. These network taps will legitimately drop references to any packets not destined to them. To be precise, only the drop_n_acct label cases are delivery errors (drops after the filter accepted the packet). Changing unconditionally to kfree_skb does pollute that useful counter with false positives. A pedantic solution is to change both functions to only call kfree_skb on drop_n_acct and consume_skb otherwise.
This shorthand change does at least makes packet_rcv and tpacket_rcv more alike.
Quoted 34 lines · Willem de Bruijn
Quoted 12 lines · Weongyo Jeong
consume_skb()isn't for drop or error cases.kfree_skb()is more proper one.Signed-off-by Weongyo Jeong <[email protected]>--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/packet/af_packet.c +0
-0net/packet/af_packet.c drop_n_restore: · line 2144
Quoted 5 lines
net/packet/af_packet.c +1
-1@@ -2141,7 +2141,7 @@ drop_n_restore: skb->len = skb_len; } drop: -consume_skb (skb); +kfree_skb (skb);This does show an inconsistency between
packet_rcvandtpacket_rcv, which callskfree_skb.A comment at
consume_skbmentions thatkfree_skbis intended for drops that signal a failure condition, and indeed, that makes it a useful way to track errors (e.g., with perf record -a -g -e skb:kfree_skb).This drop path is not always an error path, though. These network taps will legitimately drop references to any packets not destined to them. To be precise, only the
drop_n_acctlabel cases are delivery errors (drops after the filter accepted the packet). Changing unconditionally tokfree_skbdoes pollute that useful counter with false positives. A pedantic solution is to change both functions to only callkfree_skbondrop_n_acctandconsume_skbotherwise.
Quoted 1 line
This shorthand change does at least makes
packet_rcvandtpacket_rcvmore alike.
Thank you for comments. I'll try to submit patch v2 for this case.
Regards,
Weongyo Jeong