From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 198622F39A2 for ; Thu, 20 Nov 2025 02:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763606998; cv=none; b=T/kOAVwx9/r8OyOx3jTTlq9mPoKS24UMI93qXsFC/BSv6sWtiDLv9wvkiTLixqXn0w6Ht1MbDvKpETdKwiMYnF2L15CX98pOyejRs/L4I1hg2mVHONGjDrkOtb7XpviGT3lXwk+KsAziq+t+YhbY6cnOr4cZrNeHhHBEhcGtg+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763606998; c=relaxed/simple; bh=lcrVwZLgR5ItAg4hTqw5DCPtnAFmviQlQW6jyyCm6AQ=; h=MIME-Version:Date:Content-Type:From:Message-ID:Subject:To:Cc: In-Reply-To:References; b=qej16ZVO6s9CnYVQ6/3Y/OHllS3m/ARnteOaeoDpqyKl3XwMxr2jOLr4P/qimbaOzjlSYTIwX2CAMdk+gIWbrOjDHyBZDdMSrK89BbkVnCbPW3mmr0vfeYgMa9RPFQc2kq/XhcVOjV7YazdGdCLUF/3O5PJRH1KNMvTIHOiIVJI= 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=r6p8/rba; arc=none smtp.client-ip=95.215.58.171 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="r6p8/rba" Precedence: bulk X-Mailing-List: netdev@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=1763606993; 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=rAmlZ19Q2ySJYciDDAnJfVxjnGiyaxmJEvZmZ5AC8SI=; b=r6p8/rbaNJADRrVWiyUBHjV59EDhYdGHQ8MwKzVPpuSpMjcXvSmkRJ4hdHg56OEzMq5dc3 Do6Sp1UXC91GFdgK+4vDbM0WonDRKHr1YWnC57sSxMh2USyoD69HX5fih5kOabSc/w3rla o/vnqs2uFFH5whbmB7SP1GxXLOLzk0Q= Date: Thu, 20 Nov 2025 02:49:43 +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: <5a66955891ef8db94b7288bbb296efcc0ac357cf@linux.dev> TLS-Required: No Subject: Re: [PATCH bpf-next v1 1/3] bpf, sockmap: Fix incorrect copied_seq calculation To: "Jakub Sitnicki" Cc: bpf@vger.kernel.org, "John Fastabend" , "David S. Miller" , "Eric Dumazet" , "Jakub Kicinski" , "Paolo Abeni" , "Simon Horman" , "Neal Cardwell" , "Kuniyuki Iwashima" , "David Ahern" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Eduard Zingerman" , "Song Liu" , "Yonghong Song" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "Shuah Khan" , "Michal Luczaj" , "Stefano Garzarella" , "Cong Wang" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org In-Reply-To: <87zf8h6bpd.fsf@cloudflare.com> References: <20251117110736.293040-1-jiayuan.chen@linux.dev> <20251117110736.293040-2-jiayuan.chen@linux.dev> <87zf8h6bpd.fsf@cloudflare.com> X-Migadu-Flow: FLOW_OUT November 20, 2025 at 03:53, "Jakub Sitnicki" wrote: [...] > > +/* The BPF program sets BPF_F_INGRESS on sk_msg to indicate data ne= eds to be > > + * redirected to the ingress queue of a specified socket. Since BPF= _F_INGRESS is > > + * defined in UAPI so that we can't extend this enum for our intern= al flags. We > > + * define some internal flags here while inheriting BPF_F_INGRESS. > > + */ > > +enum { > > + SK_MSG_F_INGRESS =3D BPF_F_INGRESS, /* (1ULL << 0) */ > > + /* internal flag */ > > + SK_MSG_F_INGRESS_SELF =3D (1ULL << 1) > > +}; > > + > >=20 >=20I'm wondering if we need additional state to track this. > Can we track sk_msg's construted from skb's that were not redirected by > setting `sk_msg.sk =3D sk` to indicate that the source socket is us in > sk_psock_skb_ingress_self()? Functionally, that would work. However, in that case, we would have to ho= ld a reference to sk until the sk_msg is read, which would delay the release= of sk. One concern is that if there is a bug in the read-side application, s= k might never be released. > If not, then I'd just offset the internal flags like we do in > net/core/filter.c, BPF_F_REDIRECT_INTERNAL. I think we can try offsetting the internal flags.