Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp958565lqp; Fri, 22 Mar 2024 00:42:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVO/bBhYHq/UfCK7DO7OIpcoR8AqK0v0a2E31L2nt060J0gwtQrqt2FfGwovdrCDpVq2iwibzWNxRE4ZTvU2/HHLKbXwG38jqHwoBZu5g== X-Google-Smtp-Source: AGHT+IFDy2B4XP4Pi9Y6XlP7HSUMjSDCYlXk0lwNb2WhzcLXmxMuFmzlFUf5ctf4JorApAzxL/kT X-Received: by 2002:a05:6214:405:b0:696:2134:95e5 with SMTP id z5-20020a056214040500b00696213495e5mr2069763qvx.3.1711093329470; Fri, 22 Mar 2024 00:42:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711093329; cv=pass; d=google.com; s=arc-20160816; b=zW9S2gNA/WslG6YwDzIa2SCjdQYE7zPVgY5TGijFmeb8vi9UxcinAwv/dQLYSYyKTQ x3E1tJHEdAoqLElKWo47rRLaCOrQv17kMhw1DakbPfcIfTiljQIWC1bbbYRApUxPGfbR GNSZ8Dy4TJbTJ8KTT+AOY1vkPQPgcyht8eJe7gsA4KNPHtI4vSbevlKcwxr/Gwmn3jNp cCP/F2/uDZBcLkpQZ40YP22gPT6/cyQuT4lOrJ2SBWQB6qQ+BADponH1m5JIuMP4OSb7 XUACyTyp9B3c/0H679R6X1eOfx7NHIX/BE73hJQrId8O+6qBajGAS7c5AJEaNDEcyyu2 dIXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=0Qg0aAz2t8fhysVs3lIOlEc9pSaxXny4Ew84jrO9zds=; fh=ZhBWgfIg9XofgJEvvQmOWcpxYrm/fhwJnEB6RWafthM=; b=E/1K3mgrTMCu0DJi2erk4RirKZai/kIbnFKzNiWYi9HIeM1cNf/5DAMxKXSF0RHQ+O eMxADMlPgdyaM0UJ3b2bumhFsuj0j5kfvdirpNN5fh4T/6yQYHGbamwnc4yRk4/RY4+8 SPlKos9dyajqA7Zk05JCxlIv7PnkEGR2Z82CjdiHPGMwSwG75ico+WYWsHsblf336xyn +f+j1Hp7Zd6ZtLLcq6gTttQCZ+SD0wyhkWDBYOF7eCHW6iavmRpsA4+dHhFtlNkvNxER twoOytGJee4Vex2bmanonQcmbamiQYHqbhm5a2KN091hCqVxHgr712ISPgp8sMvW8e5J M19Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q6R43q+9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q6R43q+9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-111073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gi8-20020a056214248800b0069616879b6esi1511376qvb.37.2024.03.22.00.42.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 00:42:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q6R43q+9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q6R43q+9; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-111073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 16B4C1C21892 for ; Fri, 22 Mar 2024 07:42:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FDD113AC4; Fri, 22 Mar 2024 07:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Q6R43q+9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T2JSS0Xs"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Q6R43q+9"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T2JSS0Xs" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 400BA10A3E; Fri, 22 Mar 2024 07:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711093318; cv=none; b=Hk4SMVnZ46u/XJy8R8zbzb9B4WbefIDh5RYZIRZOdEjRdYCdF+iJkwI97tSfZDowONDsdsWyuvOe5rF4/ZTD6SYeC7Px/ugYM5Pego50xo9wF7o+ACfTqkwUmHkV4RqWagdO5JZwiGW33TydALo+TYctTTu5qIkNjxul6DH3lIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711093318; c=relaxed/simple; bh=dKrafs6XcwNUasz4rY+rfSh1ClLebRTPfnGFP4kCwrA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KESNuuMpT5nxFxA4zJVfJEMSXuLplMhxS9cV4B3M+rl1CwMqcGuHtnuGcj1RzYuHnKBh5Zf0L37+gMOBHHDW+yqpuOVYTgF4FyvCwZC9aH01SZau+e2VxvJ5k/etZ6BCPYJSa9kpaFGwGbRs3RyHvfUis2cVj+M1jdoe3n8hE4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Q6R43q+9; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=T2JSS0Xs; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Q6R43q+9; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=T2JSS0Xs; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 330C15FAE1; Fri, 22 Mar 2024 07:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1711093314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qg0aAz2t8fhysVs3lIOlEc9pSaxXny4Ew84jrO9zds=; b=Q6R43q+9lo9fC/D7JRizMmYMGnfekrbVYSVetQxKgeaLVMACKjEei5SrPRKo+TDXPO5cFt 3nVausOo/49km9AgeU4B8zCvCutEpoBSygMB3g6lkonZ+spIc6MpoEDAKdPCQSTJXmZLyh kCU0XMUxSyBTlj2W3ywfCGTd2fX/hgk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1711093314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qg0aAz2t8fhysVs3lIOlEc9pSaxXny4Ew84jrO9zds=; b=T2JSS0Xs6L8K3uhXYGVrvzd7lmqxE3EWX+XOBbMKaVERPxT6+s9LIPK8f//p9zhI4HKsSt edFe+4QT8x3D84BA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1711093314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qg0aAz2t8fhysVs3lIOlEc9pSaxXny4Ew84jrO9zds=; b=Q6R43q+9lo9fC/D7JRizMmYMGnfekrbVYSVetQxKgeaLVMACKjEei5SrPRKo+TDXPO5cFt 3nVausOo/49km9AgeU4B8zCvCutEpoBSygMB3g6lkonZ+spIc6MpoEDAKdPCQSTJXmZLyh kCU0XMUxSyBTlj2W3ywfCGTd2fX/hgk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1711093314; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Qg0aAz2t8fhysVs3lIOlEc9pSaxXny4Ew84jrO9zds=; b=T2JSS0Xs6L8K3uhXYGVrvzd7lmqxE3EWX+XOBbMKaVERPxT6+s9LIPK8f//p9zhI4HKsSt edFe+4QT8x3D84BA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 41575136AD; Fri, 22 Mar 2024 07:41:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SW2UDEE2/WXaIQAAD6G6ig (envelope-from ); Fri, 22 Mar 2024 07:41:53 +0000 Message-ID: Date: Fri, 22 Mar 2024 10:41:52 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] net/ipv4: add tracepoint for icmp_send Content-Language: en-US To: xu.xin16@zte.com.cn, edumazet@google.com, davem@davemloft.net Cc: rostedt@goodmis.org, mhiramat@kernel.org, dsahern@kernel.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, yang.yang29@zte.com.cn, he.peilin@zte.com.cn, liu.chun2@zte.com.cn, jiang.xuexin@zte.com.cn, zhang.yunkai@zte.com.cn References: <202403211010443485000@zte.com.cn> From: Denis Kirjanov In-Reply-To: <202403211010443485000@zte.com.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Level: Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Q6R43q+9; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=T2JSS0Xs X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-6.50 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[15]; NEURAL_HAM_SHORT(-0.20)[-0.999]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Score: -6.50 X-Rspamd-Queue-Id: 330C15FAE1 X-Spam-Flag: NO On 3/21/24 05:10, xu.xin16@zte.com.cn wrote: > From: he peilin > > Introduce a tracepoint for icmp_send, which can help users to get more > detail information conveniently when icmp abnormal events happen. > > 1. Giving an usecase example: > ============================= > When an application experiences packet loss due to an unreachable UDP > destination port, the kernel will send an exception message through the > icmp_send function. By adding a trace point for icmp_send, developers or > system administrators can obtain detailed information about the UDP > packet loss, including the type, code, source address, destination address, > source port, and destination port. This facilitates the trouble-shooting > of UDP packet loss issues especially for those network-service > applications. > > 2. Operation Instructions: > ========================== > Switch to the tracing directory. > cd /sys/kernel/tracing > Filter for destination port unreachable. > echo "type==3 && code==3" > events/icmp/icmp_send/filter > Enable trace event. > echo 1 > events/icmp/icmp_send/enable > > 3. Result View: > ================ > udp_client_erro-11370 [002] ...s.12 124.728002: > icmp_send: icmp_send: type=3, code=3. > From 127.0.0.1:41895 to 127.0.0.1:6666 ulen=23 > skbaddr=00000000589b167a > > Changelog > --------- > v2->v3: > Some fixes according to > https://lore.kernel.org/all/20240319102549.7f7f6f53@gandalf.local.home/ > 1. Change the tracking directory to/sys/kernel/tracking. > 2. Adjust the layout of the TP-STRUCT_entry parameter structure. > > v1->v2: > Some fixes according to > https://lore.kernel.org/all/CANn89iL-y9e_VFpdw=sZtRnKRu_tnUwqHuFQTJvJsv-nz1xPDw@mail.gmail.com/ > 1. adjust the trace_icmp_send() to more protocols than UDP. > 2. move the calling of trace_icmp_send after sanity checks > in __icmp_send(). You should target it for net-next > > Signed-off-by: Peilin He > Reviewed-by: xu xin > Reviewed-by: Yunkai Zhang > Cc: Yang Yang > Cc: Liu Chun > Cc: Xuexin Jiang > --- > include/trace/events/icmp.h | 64 +++++++++++++++++++++++++++++++++++++ > net/ipv4/icmp.c | 4 +++ > 2 files changed, 68 insertions(+) > create mode 100644 include/trace/events/icmp.h > > diff --git a/include/trace/events/icmp.h b/include/trace/events/icmp.h > new file mode 100644 > index 000000000000..2098d4b1b12e > --- /dev/null > +++ b/include/trace/events/icmp.h > @@ -0,0 +1,64 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM icmp > + > +#if !defined(_TRACE_ICMP_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_ICMP_H > + > +#include > +#include > + > +TRACE_EVENT(icmp_send, > + > + TP_PROTO(const struct sk_buff *skb, int type, int code), > + > + TP_ARGS(skb, type, code), > + > + TP_STRUCT__entry( > + __field(const void *, skbaddr) > + __field(int, type) > + __field(int, code) > + __array(__u8, saddr, 4) > + __array(__u8, daddr, 4) > + __field(__u16, sport) > + __field(__u16, dport) > + __field(unsigned short, ulen) > + ), > + > + TP_fast_assign( > + struct iphdr *iph = ip_hdr(skb); > + int proto_4 = iph->protocol; > + __be32 *p32; > + > + __entry->skbaddr = skb; > + __entry->type = type; > + __entry->code = code; > + > + if (proto_4 == IPPROTO_UDP) { > + struct udphdr *uh = udp_hdr(skb); > + __entry->sport = ntohs(uh->source); > + __entry->dport = ntohs(uh->dest); > + __entry->ulen = ntohs(uh->len); > + } else { > + __entry->sport = 0; > + __entry->dport = 0; > + __entry->ulen = 0; > + } > + > + p32 = (__be32 *) __entry->saddr; > + *p32 = iph->saddr; > + > + p32 = (__be32 *) __entry->daddr; > + *p32 = iph->daddr; > + ), > + > + TP_printk("icmp_send: type=%d, code=%d. From %pI4:%u to %pI4:%u ulen=%d skbaddr=%p", > + __entry->type, __entry->code, > + __entry->saddr, __entry->sport, __entry->daddr, > + __entry->dport, __entry->ulen, __entry->skbaddr) > +); > + > +#endif /* _TRACE_ICMP_H */ > + > +/* This part must be outside protection */ > +#include > \ No newline at end of file > diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c > index e63a3bf99617..21fb41257fe9 100644 > --- a/net/ipv4/icmp.c > +++ b/net/ipv4/icmp.c > @@ -92,6 +92,8 @@ > #include > #include > #include > +#define CREATE_TRACE_POINTS > +#include > > /* > * Build xmit assembly blocks > @@ -672,6 +674,8 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, > } > } > > + trace_icmp_send(skb_in, type, code); > + > /* Needed by both icmp_global_allow and icmp_xmit_lock */ > local_bh_disable(); >