Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp226938lqh; Mon, 6 May 2024 17:55:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUjdEGjlCHnFiv1HuYnO+1xpM6bxDfK8rNd/t0N6otiP+fyGUwS0XdKA/UH/T+B51NpNGVd1kh886ulQDa7EvbrS6QodbDlL0f6szlRnQ== X-Google-Smtp-Source: AGHT+IFJ0wvwoKn33tSx5pXRFU41zq1/tQR5Yv/1JZuZiqMR7zMp21o5mjljF7cWk00Z1c+OlO9/ X-Received: by 2002:a17:902:ce8c:b0:1eb:7285:d6fe with SMTP id f12-20020a170902ce8c00b001eb7285d6femr17643875plg.23.1715043315504; Mon, 06 May 2024 17:55:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715043315; cv=pass; d=google.com; s=arc-20160816; b=xIeiE/3SITQwMGASE2kKNXuz5JcrFGsvMS63j38VmRBQtZuOSXVI272s8WGPLH5FoY QL7bj80FdXg7R6mpqCHxvVhNhXOAMFJkvs8fHxe/KVj1MsVs8IJ5wqBYb3fIBpBC6n7j E27yf8WKA8jqpiN+MB3fH3BnQZlvHUzLdSm6btPEdS5UEOoJMAce6SuBdxiqvmGMUg7S vdnGxP/xEBAwUU+nRwDSgGB9ZX4+UDIYIXsTFzFCSttQ+mC+n7LzdKIBXIiv3wYvS3DZ zQWTYEiiggXTrhJlZogoHx//Xo55Aewzpk6FVQsqzOTNoHGat7YDUvzHAH5wR4AcvuXF kcvw== 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:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=EkN5x92xDG37kTOdUdSnJWPAN51eOIj86lnHKaDFNr0=; fh=KPX7UKuV9wOE6J/tV9pgu+N4YnhiaDKaR4efX4V8Fb4=; b=LmAshf641+M9Xm6tL9wQAIpg6uFWvVvb4K1JLaLxkR7orIKNSzJezVQk83Wct2ZYLn jWMWkRySBUu1qyBaNqfyaC7yP9GD4jP4LCE6BzKNhkqBWTpQX5LgWq1L+AhZGP/v0EwJ sKuCbXWTsfbt2USQvJGs+l67eiqCKIVKxz4oXBU/AliovTZ6BkpErbRUN6I3YxJ2sg3X v5ampT1GE52ZnZFTbszxLWdLIKm4coFAxx1eBCrZizGqx3hx+imoOAFRFl5TI8Pmk89P Lq6vx7QxGRRQPu/3fONK3n+HoK4ukL+ys4NLfGDBfIwy/D8p6hUpZdCXADCYeuSeFTJz 2woQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LkK5+wzm; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-170530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n16-20020a170902f61000b001eb0f19ab6asi9618427plg.514.2024.05.06.17.55.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 17:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LkK5+wzm; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-170530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 210B1B2441E for ; Tue, 7 May 2024 00:54:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 940171C3D; Tue, 7 May 2024 00:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="LkK5+wzm" Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) (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 BBB0F10F2 for ; Tue, 7 May 2024 00:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715043263; cv=none; b=sO/HrZywD9hI7azWqJApMAwD/zq8AbihjI7VoL4KwczMZ0r/DIy27Ldt9p8Zh/5lo7comy0aJwStWVeahre+FADT1GMwpzm/g6w+V8LVwCZ+zEjM3R2IFuRtj0eTNTa1PnsMFptqekPlcYjOKsPTLlObz7YgRNTH3tZQtUfCGn8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715043263; c=relaxed/simple; bh=o8Bc5Ez/6YqYURlwwo5HZX/zfkTVwJuvYFnD3wNE9ys=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Zkjb8g1hdoxnVYSrgs1WTnn9ICXieXFqHjb90b7fHASfr9a7hxhGmn9ex+WyPSBbExYftgW2Wi8KoxyIMPePny+xxEtXdSgzawxHIPc6PS42R68rs9uK1J55MIKwpABxWnwCHe8nbpy4b0OFlDmetFWq76qMGa/e4OSPCoG541w= 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=LkK5+wzm; arc=none smtp.client-ip=95.215.58.185 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 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715043258; 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=EkN5x92xDG37kTOdUdSnJWPAN51eOIj86lnHKaDFNr0=; b=LkK5+wzmXqo5sFsIhsMoTy0VapcDfqDuxZ3bfxSNryi85yj7zKlSdh+mFCFFcQCLYMRSJj TcSTdH1wcZC4ssayEtP5BM1mvNQEMHg029Xyq2bFVaS8lOF544saj0ciaq1yvd1nR/v0JP OZAckBjKAHxAuJT5NGL77nQS9sWwcN0= Date: Mon, 6 May 2024 17:54:13 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH bpf-next v6 3/3] selftests/bpf: Handle forwarding of UDP CLOCK_TAI packets To: "Abhishek Chauhan (ABC)" Cc: Willem de Bruijn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Martin KaFai Lau , Daniel Borkmann , bpf , kernel@quicinc.com References: <20240504031331.2737365-1-quic_abchauha@quicinc.com> <20240504031331.2737365-4-quic_abchauha@quicinc.com> <663929b249143_516de2945@willemb.c.googlers.com.notmuch> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 5/6/24 1:50 PM, Abhishek Chauhan (ABC) wrote: > > > On 5/6/2024 12:04 PM, Willem de Bruijn wrote: >> Abhishek Chauhan wrote: >>> With changes in the design to forward CLOCK_TAI in the skbuff >>> framework, existing selftest framework needs modification >>> to handle forwarding of UDP packets with CLOCK_TAI as clockid. >>> >>> Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/ >>> Signed-off-by: Abhishek Chauhan >>> --- >>> tools/include/uapi/linux/bpf.h | 15 ++++--- >>> .../selftests/bpf/prog_tests/ctx_rewrite.c | 10 +++-- >>> .../selftests/bpf/prog_tests/tc_redirect.c | 3 -- >>> .../selftests/bpf/progs/test_tc_dtime.c | 39 +++++++++---------- >>> 4 files changed, 34 insertions(+), 33 deletions(-) >>> >>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h >>> index 90706a47f6ff..25ea393cf084 100644 >>> --- a/tools/include/uapi/linux/bpf.h >>> +++ b/tools/include/uapi/linux/bpf.h >>> @@ -6207,12 +6207,17 @@ union { \ >>> __u64 :64; \ >>> } __attribute__((aligned(8))) >>> >>> +/* The enum used in skb->tstamp_type. It specifies the clock type >>> + * of the time stored in the skb->tstamp. >>> + */ >>> enum { >>> - BPF_SKB_TSTAMP_UNSPEC, >>> - BPF_SKB_TSTAMP_DELIVERY_MONO, /* tstamp has mono delivery time */ >>> - /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle, >>> - * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC >>> - * and try to deduce it by ingress, egress or skb->sk->sk_clockid. >>> + BPF_SKB_TSTAMP_UNSPEC = 0, /* DEPRECATED */ >>> + BPF_SKB_TSTAMP_DELIVERY_MONO = 1, /* DEPRECATED */ >>> + BPF_SKB_CLOCK_REALTIME = 0, >>> + BPF_SKB_CLOCK_MONOTONIC = 1, >>> + BPF_SKB_CLOCK_TAI = 2, >>> + /* For any future BPF_SKB_CLOCK_* that the bpf prog cannot handle, >>> + * the bpf prog can try to deduce it by ingress/egress/skb->sk->sk_clockid. >>> */ >>> }; >>> >>> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c >>> index 3b7c57fe55a5..71940f4ef0fb 100644 >>> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c >>> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c >>> @@ -69,15 +69,17 @@ static struct test_case test_cases[] = { >>> { >>> N(SCHED_CLS, struct __sk_buff, tstamp), >>> .read = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);" >>> - "w11 &= 3;" >>> - "if w11 != 0x3 goto pc+2;" >>> + "if w11 == 0x4 goto pc+1;" >>> + "goto pc+4;" >>> + "if w11 == 0x3 goto pc+1;" >>> + "goto pc+2;" >> >> Not an expert on this code, and I see that the existing code already >> has this below, but: isn't it odd and unnecessary to jump to an >> unconditional jump statement? >> > I am closely looking into your comment and i will evalute it(Martin can correct me > if the jumps are correct or not as i am new to BPF as well) but i found out that > JSET = "&" and not "==". So the above two ins has to change from - Yes, this should be bitwise "&" instead of "==". The bpf CI did report this: https://github.com/kernel-patches/bpf/actions/runs/8947652196/job/24579927178 Please monitor the bpf CI test result. Do you have issue running the test locally? > > "if w11 == 0x4 goto pc+1;" ==>(needs to be corrected to) "if w11 & 0x4 goto pc+1;" > "if w11 == 0x3 goto pc+1;" ==> (needs to be correct to) "if w11 & 0x3 goto pc+1;" > > >>> "$dst = 0;" >>> "goto pc+1;" >>> "$dst = *(u64 *)($ctx + sk_buff::tstamp);", >>> .write = "r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset);" >>> - "if w11 & 0x2 goto pc+1;" >>> + "if w11 & 0x4 goto pc+1;" >>> "goto pc+2;" >>> - "w11 &= -2;" >>> + "w11 &= -3;" > Martin, > Also i am not sure why the the dissembly complains because the value of SKB_TSTAMP_TYPE_MASK = 3 and we are > negating it ~3 = -3. > > Can't match disassembly(left) with pattern(right): > r11 = *(u8 *)(r1 +129) ; r11 = *(u8 *)($ctx + sk_buff::__mono_tc_offset) > if w11 & 0x4 goto pc+1 ; if w11 & 0x4 goto pc+1 > goto pc+2 ; goto pc+2 > w11 &= -4 ; w11 &= -3 > >>> "*(u8 *)($ctx + sk_buff::__mono_tc_offset) = r11;" >>> "*(u64 *)($ctx + sk_buff::tstamp) = $src;", >>> },