* [PATH net 0/2] add drop reason when do fragment @ 2025-10-24 6:23 Yonglong Li 2025-10-24 6:23 ` [PATH net 1/2] net: ip: add drop reasons when handling ip fragments Yonglong Li 2025-10-24 6:23 ` [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment Yonglong Li 0 siblings, 2 replies; 7+ messages in thread From: Yonglong Li @ 2025-10-24 6:23 UTC (permalink / raw) To: netdev; +Cc: davem, dsahern, edumazet, pabeni, kuba, horms, liyonglong Add a new drop reason FRAG_FAILED to trace do fragment failed. And use drop reasons PKT_TOO_BIG when pkt too big. Reasons show up as: perf record -e skb:kfree_skb -a; perf script swapper 0 [005] 154.086537: skb:kfree_skb: ... location=ip6_fragment reason: PKT_TOO_BIG swapper 0 [005] 154.086540: skb:kfree_skb: ... location=ip6_fragment reason: PKT_TOO_BIG swapper 0 [005] 154.086544: skb:kfree_skb: ... location=ip6_fragment reason: PKT_TOO_BIG Yonglong Li (2): net: ip: add drop reasons when handling ip fragments net: ipv6: use drop reasons in ip6_fragment include/net/dropreason-core.h | 3 +++ net/ipv4/ip_output.c | 6 +++--- net/ipv6/ip6_output.c | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATH net 1/2] net: ip: add drop reasons when handling ip fragments 2025-10-24 6:23 [PATH net 0/2] add drop reason when do fragment Yonglong Li @ 2025-10-24 6:23 ` Yonglong Li 2025-10-24 6:43 ` Eric Dumazet 2025-10-24 6:23 ` [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment Yonglong Li 1 sibling, 1 reply; 7+ messages in thread From: Yonglong Li @ 2025-10-24 6:23 UTC (permalink / raw) To: netdev; +Cc: davem, dsahern, edumazet, pabeni, kuba, horms, liyonglong 1, add new drop reason FRAG_FAILED, and use it in ip_do_fragment 2, use drop reasons PKT_TOO_BIG in ip_fragment Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn> --- include/net/dropreason-core.h | 3 +++ net/ipv4/ip_output.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 58d91cc..7da80f4 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -99,6 +99,7 @@ FN(DUP_FRAG) \ FN(FRAG_REASM_TIMEOUT) \ FN(FRAG_TOO_FAR) \ + FN(FRAG_FAILED) \ FN(TCP_MINTTL) \ FN(IPV6_BAD_EXTHDR) \ FN(IPV6_NDISC_FRAG) \ @@ -500,6 +501,8 @@ enum skb_drop_reason { * (/proc/sys/net/ipv4/ipfrag_max_dist) */ SKB_DROP_REASON_FRAG_TOO_FAR, + /* do ip/ip6 fragment failed */ + SKB_DROP_REASON_FRAG_FAILED, /** * @SKB_DROP_REASON_TCP_MINTTL: ipv4 ttl or ipv6 hoplimit below * the threshold (IP_MINTTL or IPV6_MINHOPCOUNT). diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index ff11d3a..879fe49 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -588,7 +588,7 @@ static int ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_PKT_TOO_BIG); return -EMSGSIZE; } @@ -871,7 +871,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, return 0; } - kfree_skb_list(iter.frag); + kfree_skb_list_reason(iter.frag, SKB_DROP_REASON_FRAG_FAILED); IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); return err; @@ -923,7 +923,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, return err; fail: - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_FRAG_FAILED); IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); return err; } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATH net 1/2] net: ip: add drop reasons when handling ip fragments 2025-10-24 6:23 ` [PATH net 1/2] net: ip: add drop reasons when handling ip fragments Yonglong Li @ 2025-10-24 6:43 ` Eric Dumazet 2025-10-24 9:56 ` YonglongLi 2025-10-24 15:57 ` Simon Horman 0 siblings, 2 replies; 7+ messages in thread From: Eric Dumazet @ 2025-10-24 6:43 UTC (permalink / raw) To: Yonglong Li; +Cc: netdev, davem, dsahern, pabeni, kuba, horms On Thu, Oct 23, 2025 at 11:23 PM Yonglong Li <liyonglong@chinatelecom.cn> wrote: > > 1, add new drop reason FRAG_FAILED, and use it in ip_do_fragment > 2, use drop reasons PKT_TOO_BIG in ip_fragment > > Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn> > --- > include/net/dropreason-core.h | 3 +++ > net/ipv4/ip_output.c | 6 +++--- > 2 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h > index 58d91cc..7da80f4 100644 > --- a/include/net/dropreason-core.h > +++ b/include/net/dropreason-core.h > @@ -99,6 +99,7 @@ > FN(DUP_FRAG) \ > FN(FRAG_REASM_TIMEOUT) \ > FN(FRAG_TOO_FAR) \ > + FN(FRAG_FAILED) \ > FN(TCP_MINTTL) \ > FN(IPV6_BAD_EXTHDR) \ > FN(IPV6_NDISC_FRAG) \ > @@ -500,6 +501,8 @@ enum skb_drop_reason { > * (/proc/sys/net/ipv4/ipfrag_max_dist) > */ > SKB_DROP_REASON_FRAG_TOO_FAR, > + /* do ip/ip6 fragment failed */ > + SKB_DROP_REASON_FRAG_FAILED, > /** > * @SKB_DROP_REASON_TCP_MINTTL: ipv4 ttl or ipv6 hoplimit below > * the threshold (IP_MINTTL or IPV6_MINHOPCOUNT). > diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c > index ff11d3a..879fe49 100644 > --- a/net/ipv4/ip_output.c > +++ b/net/ipv4/ip_output.c > @@ -588,7 +588,7 @@ static int ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); > icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, > htonl(mtu)); > - kfree_skb(skb); > + kfree_skb_reason(skb, SKB_DROP_REASON_PKT_TOO_BIG); This part looks fine. > return -EMSGSIZE; > } > > @@ -871,7 +871,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > return 0; > } > > - kfree_skb_list(iter.frag); > + kfree_skb_list_reason(iter.frag, SKB_DROP_REASON_FRAG_FAILED); > > IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); > return err; > @@ -923,7 +923,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > return err; > > fail: > - kfree_skb(skb); > + kfree_skb_reason(skb, SKB_DROP_REASON_FRAG_FAILED); There are many different reasons for the possible failures ? skb_checksum_help() error, ip_frag_next() error output() error. I think that having the distinction could really help, especially the output() one... ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATH net 1/2] net: ip: add drop reasons when handling ip fragments 2025-10-24 6:43 ` Eric Dumazet @ 2025-10-24 9:56 ` YonglongLi 2025-10-24 15:57 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: YonglongLi @ 2025-10-24 9:56 UTC (permalink / raw) To: Eric Dumazet; +Cc: netdev On 10/24/2025 14:43, Eric Dumazet wrote: > On Thu, Oct 23, 2025 at 11:23 PM Yonglong Li <liyonglong@chinatelecom.cn> wrote: > >> return -EMSGSIZE; >> } >> >> @@ -871,7 +871,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, >> return 0; >> } >> >> - kfree_skb_list(iter.frag); >> + kfree_skb_list_reason(iter.frag, SKB_DROP_REASON_FRAG_FAILED); >> >> IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); >> return err; >> @@ -923,7 +923,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, >> return err; >> >> fail: >> - kfree_skb(skb); >> + kfree_skb_reason(skb, SKB_DROP_REASON_FRAG_FAILED); > > There are many different reasons for the possible failures ? > skb_checksum_help() error, > ip_frag_next() error > output() error. > > I think that having the distinction could really help, especially the > output() one.. Hi Eric, Thank you for for the suggestion. I will send a v2 with these case. -- Li YongLong ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATH net 1/2] net: ip: add drop reasons when handling ip fragments 2025-10-24 6:43 ` Eric Dumazet 2025-10-24 9:56 ` YonglongLi @ 2025-10-24 15:57 ` Simon Horman 1 sibling, 0 replies; 7+ messages in thread From: Simon Horman @ 2025-10-24 15:57 UTC (permalink / raw) To: Eric Dumazet; +Cc: Yonglong Li, netdev, davem, dsahern, pabeni, kuba On Thu, Oct 23, 2025 at 11:43:25PM -0700, Eric Dumazet wrote: > On Thu, Oct 23, 2025 at 11:23 PM Yonglong Li <liyonglong@chinatelecom.cn> wrote: > > > > 1, add new drop reason FRAG_FAILED, and use it in ip_do_fragment > > 2, use drop reasons PKT_TOO_BIG in ip_fragment > > > > Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn> > > --- > > include/net/dropreason-core.h | 3 +++ > > net/ipv4/ip_output.c | 6 +++--- > > 2 files changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h > > index 58d91cc..7da80f4 100644 > > --- a/include/net/dropreason-core.h > > +++ b/include/net/dropreason-core.h > > @@ -99,6 +99,7 @@ > > FN(DUP_FRAG) \ > > FN(FRAG_REASM_TIMEOUT) \ > > FN(FRAG_TOO_FAR) \ > > + FN(FRAG_FAILED) \ > > FN(TCP_MINTTL) \ > > FN(IPV6_BAD_EXTHDR) \ > > FN(IPV6_NDISC_FRAG) \ > > @@ -500,6 +501,8 @@ enum skb_drop_reason { > > * (/proc/sys/net/ipv4/ipfrag_max_dist) > > */ > > SKB_DROP_REASON_FRAG_TOO_FAR, > > + /* do ip/ip6 fragment failed */ nit; This comment should be a Kernel doc, like the comments for other members of this enum. > > + SKB_DROP_REASON_FRAG_FAILED, > > /** > > * @SKB_DROP_REASON_TCP_MINTTL: ipv4 ttl or ipv6 hoplimit below > > * the threshold (IP_MINTTL or IPV6_MINHOPCOUNT). ... ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment 2025-10-24 6:23 [PATH net 0/2] add drop reason when do fragment Yonglong Li 2025-10-24 6:23 ` [PATH net 1/2] net: ip: add drop reasons when handling ip fragments Yonglong Li @ 2025-10-24 6:23 ` Yonglong Li 2025-10-24 6:45 ` Eric Dumazet 1 sibling, 1 reply; 7+ messages in thread From: Yonglong Li @ 2025-10-24 6:23 UTC (permalink / raw) To: netdev; +Cc: davem, dsahern, edumazet, pabeni, kuba, horms, liyonglong use drop reasons in ip6_output like ip_fragment/ip_do_fragment Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn> --- net/ipv6/ip6_output.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index f904739e..575c7d1 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -875,6 +875,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, int (*output)(struct net *, struct sock *, struct sk_buff *)) { struct sk_buff *frag; + enum skb_drop_reason reason = SKB_DROP_REASON_FRAG_FAILED; struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? inet6_sk(skb->sk) : NULL; @@ -995,7 +996,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, return 0; } - kfree_skb_list(iter.frag); + kfree_skb_list_reason(iter.frag, reason); IP6_INC_STATS(net, ip6_dst_idev(&rt->dst), IPSTATS_MIB_FRAGFAILS); @@ -1050,12 +1051,13 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, fail_toobig: icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); + reason = SKB_DROP_REASON_PKT_TOO_BIG; err = -EMSGSIZE; fail: IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_FRAGFAILS); - kfree_skb(skb); + kfree_skb_reason(skb, reason); return err; } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment 2025-10-24 6:23 ` [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment Yonglong Li @ 2025-10-24 6:45 ` Eric Dumazet 0 siblings, 0 replies; 7+ messages in thread From: Eric Dumazet @ 2025-10-24 6:45 UTC (permalink / raw) To: Yonglong Li; +Cc: netdev, davem, dsahern, pabeni, kuba, horms On Thu, Oct 23, 2025 at 11:23 PM Yonglong Li <liyonglong@chinatelecom.cn> wrote: > > use drop reasons in ip6_output like ip_fragment/ip_do_fragment > > Signed-off-by: Yonglong Li <liyonglong@chinatelecom.cn> > --- > net/ipv6/ip6_output.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c > index f904739e..575c7d1 100644 > --- a/net/ipv6/ip6_output.c > +++ b/net/ipv6/ip6_output.c > @@ -875,6 +875,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > int (*output)(struct net *, struct sock *, struct sk_buff *)) > { > struct sk_buff *frag; > + enum skb_drop_reason reason = SKB_DROP_REASON_FRAG_FAILED; Reverse Christmas .... move this one line up, or move "struct sk_buff *frag;" > struct rt6_info *rt = dst_rt6_info(skb_dst(skb)); > struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? > inet6_sk(skb->sk) : NULL; > @@ -995,7 +996,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > return 0; > } > > - kfree_skb_list(iter.frag); > + kfree_skb_list_reason(iter.frag, reason); > > IP6_INC_STATS(net, ip6_dst_idev(&rt->dst), > IPSTATS_MIB_FRAGFAILS); > @@ -1050,12 +1051,13 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, > > fail_toobig: > icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); > + reason = SKB_DROP_REASON_PKT_TOO_BIG; > err = -EMSGSIZE; > > fail: > IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), > IPSTATS_MIB_FRAGFAILS); > - kfree_skb(skb); > + kfree_skb_reason(skb, reason); Same remark as the IPv4 part. > return err; > } > > -- > 1.8.3.1 > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-10-24 15:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-10-24 6:23 [PATH net 0/2] add drop reason when do fragment Yonglong Li 2025-10-24 6:23 ` [PATH net 1/2] net: ip: add drop reasons when handling ip fragments Yonglong Li 2025-10-24 6:43 ` Eric Dumazet 2025-10-24 9:56 ` YonglongLi 2025-10-24 15:57 ` Simon Horman 2025-10-24 6:23 ` [PATH net 2/2] net: ipv6: use drop reasons in ip6_fragment Yonglong Li 2025-10-24 6:45 ` Eric Dumazet
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).