Skip to content

Commit 4cf91f8

Browse files
dsaherndavem330
authored andcommitted
ipv6: Add reasons for skb drops to __udp6_lib_rcv
Add reasons to __udp6_lib_rcv for skb drops. The only twist is that the NO_SOCKET takes precedence over the CSUM or other counters for that path (motivation behind this patch - csum counter was misleading). Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a1b86c5 commit 4cf91f8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

net/ipv6/udp.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb,
912912
int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
913913
int proto)
914914
{
915+
enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
915916
const struct in6_addr *saddr, *daddr;
916917
struct net *net = dev_net(skb->dev);
917918
struct udphdr *uh;
@@ -988,6 +989,8 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
988989
return udp6_unicast_rcv_skb(sk, skb, uh);
989990
}
990991

992+
reason = SKB_DROP_REASON_NO_SOCKET;
993+
991994
if (!uh->check)
992995
goto report_csum_error;
993996

@@ -1000,10 +1003,12 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10001003
__UDP6_INC_STATS(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
10011004
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
10021005

1003-
kfree_skb(skb);
1006+
kfree_skb_reason(skb, reason);
10041007
return 0;
10051008

10061009
short_packet:
1010+
if (reason == SKB_DROP_REASON_NOT_SPECIFIED)
1011+
reason = SKB_DROP_REASON_PKT_TOO_SMALL;
10071012
net_dbg_ratelimited("UDP%sv6: short packet: From [%pI6c]:%u %d/%d to [%pI6c]:%u\n",
10081013
proto == IPPROTO_UDPLITE ? "-Lite" : "",
10091014
saddr, ntohs(uh->source),
@@ -1014,10 +1019,12 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
10141019
report_csum_error:
10151020
udp6_csum_zero_error(skb);
10161021
csum_error:
1022+
if (reason == SKB_DROP_REASON_NOT_SPECIFIED)
1023+
reason = SKB_DROP_REASON_UDP_CSUM;
10171024
__UDP6_INC_STATS(net, UDP_MIB_CSUMERRORS, proto == IPPROTO_UDPLITE);
10181025
discard:
10191026
__UDP6_INC_STATS(net, UDP_MIB_INERRORS, proto == IPPROTO_UDPLITE);
1020-
kfree_skb(skb);
1027+
kfree_skb_reason(skb, reason);
10211028
return 0;
10221029
}
10231030

0 commit comments

Comments
 (0)