From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D99132417C8 for ; Tue, 15 Apr 2025 11:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715083; cv=none; b=F/uyePClLzmj+oRN0t9/mqiEmwOJBPwirHP9foKCeUYyGVupMtB+uEf0c/aYfS7XvDT1v2OgkP7NUpJuZwbdGuuRCg2CRPX+ST5+GXzaTEZGGN3KSP/MbMBQpRNNTqFExohT5+l0CcU9/uZYTomYismtwqUt7TNhhYyKFDELUjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715083; c=relaxed/simple; bh=GSu6JHo+YSCZ8F3pdRafzygNXm1hMM/Juu0glZnvuCU=; h=MIME-Version:Date:Content-Type:From:Message-ID:Subject:To:Cc: In-Reply-To:References; b=V5iu/Y79vGVW7noRe+dtOOHzEUwfnpJwvT39XRQZdT/sa8DF0CGIs+/e57CAJGmWZGf02AoJCLKQETbSxovRTrVfraS0B5p91y0QKbdYv3x1QvdOR+XD1F2CFyhX1qXRhWO9g2aWVhRZ/99wEJCgvauxYGA/qA1Jw7GsAwxhqHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Z2liOoDp; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Z2liOoDp" Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1744715078; h=from:from:reply-to:subject:subject: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=fbbEvmW5ERCV6V3g0BQvaj+wv5+2mrjsX8ION5ZUGEQ=; b=Z2liOoDpBAthCTgDeMWcJWeim/QFw+glL9/xaSwlyqtGJyeauIlabk9niKOZMPYjfHgBzh FsYiV11/pKzTpBy0e1rofeZFzFsMBAqsDvD6JxbqiwI4ZSrLm53lP9McBeip/W8BxgW8z9 Sbj5KiXaSCi+EbSX9V8bFMtKTZiQO0Q= Date: Tue, 15 Apr 2025 11:04:36 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Jiayuan Chen" Message-ID: TLS-Required: No Subject: Re: [PATCH bpf-next v3 1/2] bpf, sockmap: Introduce tracing capability for sockmap To: "Cong Wang" Cc: bpf@vger.kernel.org, mrpre@163.com, "Jakub Sitnicki" , "Steven Rostedt" , "Alexei Starovoitov" , "Daniel Borkmann" , "John Fastabend" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Song Liu" , "Yonghong Song" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "Masami Hiramatsu" , "Mathieu Desnoyers" , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Simon Horman" , "Jesper Dangaard Brouer" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org In-Reply-To: References: <20250414161153.14990-1-jiayuan.chen@linux.dev> X-Migadu-Flow: FLOW_OUT April 15, 2025 at 05:25, "Cong Wang" wrote: >=20 >=20On Tue, Apr 15, 2025 at 12:11:45AM +0800, Jiayuan Chen wrote: >=20 >=20>=20 >=20> +#ifndef __TRACE_SOCKMAP_HELPER_ONCE_ONLY > > +#define __TRACE_SOCKMAP_HELPER_ONCE_ONLY > > + > > +enum sockmap_direct_type { > > + SOCKMAP_REDIR_NONE =3D 0, > > + SOCKMAP_REDIR_INGRESS, > > + SOCKMAP_REDIR_EGRESS, > > +}; > >=20 >=20 > I am curious why you need to define them here since you already pass > 'ingress' as a parameter? Is it possible to reuse the BPF_F_INGRESS bit= ? > Thanks! > The lowest bit of skb->_redir being 0 indicates EGRESS, so we cannot use the built-in __print_flag for output in this case, since it requires the corresponding bit to be set to 1. We could certainly do this instead: ''' if (act !=3D REDIRECT) redir =3D "none" else if (flag & BPF_F_INGRESS) redir =3D "ingress" else redir =3D "egress" ''' However, as Steven mentioned earlier, using an enum instead would be bett= er here for trace_event. Of course, we could directly print the hexadecimal value of _redir, but that would result in poor readability. Thanks~