Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp134871lqh; Mon, 6 May 2024 13:51:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhfZn4VNLonmVOsu8eAug7F9MKt1VaHhOvV+tv2ELNYCg8zyB+S8NtrElZ1eaTClwiJvhqpbBIhjHz9Bz6vXKaCiEWpfNf1RMwbjaB/A== X-Google-Smtp-Source: AGHT+IFVP8KIMOlDcap/CXXE1xI7UdaLFDbeFCx8WmXci8kVi3QA4FszzK1uWc9T7/HG3R0VWcSR X-Received: by 2002:a17:906:2e8b:b0:a59:c0a6:25cd with SMTP id o11-20020a1709062e8b00b00a59c0a625cdmr4663070eji.5.1715028687974; Mon, 06 May 2024 13:51:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715028687; cv=pass; d=google.com; s=arc-20160816; b=sEqAZ5M59XUEWPivEXFQRCXV1UUELb7dEcwPs4hQOxuijwitBlmWZbJxl1zdQB9hIw xNVY3B0svyg+aYLLWqQgbnHuP5xB7hl7kmuSq47b/TVCn/DrCJFBLfUEOa0F1MZA72vj U7JSQkUHpXlJw4bFJwdA8Omorl9mopfuMiISlbIv1qr/gjdxzLOoq/UnjhPzSZOK8qvy E4G46LumS5nVLy1gpyqIf8vZ9VT4c3Kz9sIMVjbcqknzlQF0OT31ySA076KdgOKTvQ8c lLw22YUYag+pDYTcQNSEHbQbYFmvNok3xealygF1ojaL6WFK4g96VafEzSRAoPyFPEsv Xvwg== 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; bh=a2U/iA8GNI7F5BhfZCcM97PTYyYh4OxkTr1BEFIEPxc=; fh=uhTEl8kPg6xs3Bvr46hHutHWH7IuZTkFWyRreB+zyKc=; b=y7dlx+ruUYEO/Neb+6+Kqt45XiUJVQZXxBsrA7EvjIzsYluy5kA6WXhjS5Q5rtHlGh BMqto8XxuOdFWK0qrrMdRJKvIKap3KYFQiaxHnQrYH2WIDzQ83LeiCB41j6WO3n28VcK 7BOLfHNZOnf2ArUYWcejpI/yxHE/V88uMv+fLccl+zeV/2sz9mHl0zt2Za64a2IlGEaY gR8XDu7fJGjDrqe++xMABgV5UMoAzQRk40w2wY4xZyvtwGGlycafGEevgE7jQVjkHDGp tGAkGj49C2f622kxzDxhjRS6tt1hV86QWMP7wXi2KtbJrux4RLZ2Xtoal5nQDvIbJ84v f/nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uy82Fwmy; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-170414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oz12-20020a1709077d8c00b00a59d05d086dsi1351266ejc.636.2024.05.06.13.51.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 13:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Uy82Fwmy; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-170414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 891221F21909 for ; Mon, 6 May 2024 20:51:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49B4C15B97E; Mon, 6 May 2024 20:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="Uy82Fwmy" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 CA34AEBB; Mon, 6 May 2024 20:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715028675; cv=none; b=gc9g+N+vZJ3bjGqbyQSqbEMTk7ZGaxq43/8GLJvoKo3W7PnIdg+BJniDT66Nz0jg5Up7pFkl9b4bMGGZcN8k1lFxLseHaRpqff3hd1iwYYJT8RTZXbecqv3ByiBFPed54U2C+HKauaW0lC/ZRvczZefsYUnNVaN/HELphkCbmIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715028675; c=relaxed/simple; bh=U69AYRyoyLR6XEyyf6FemIroNsRcMVXgJe9TeaSY6q0=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=gTDo6sEHl3KAjILwO93zNL68AjxqabwFM9fRM0naMSVlVznbajXO11/kWY/3xDWLZUJJnaRTEchM+TvpGjYj4ZuXKD2Cuy840R8RlKoNawxQDI3q40yJPGDze2tOxY/VoRg9+A5YWSHOyoiH0I30dbd4kSHwpu4qNrkDlUS4FJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=Uy82Fwmy; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 446KF1GJ029460; Mon, 6 May 2024 20:50:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=a2U/iA8GNI7F5BhfZCcM97PTYyYh4OxkTr1BEFIEPxc=; b=Uy 82Fwmyq0b5qB7KV1dMwUzKGuYcZ2p9i1f3o2t/jC8PhTo9VVjs8WDh55mTajY2O7 LdZ1CaAbESeYoroElrgyavvIZU7eijoZjCbJkndMtVEV2UT3QtTyHz+YBReY96mU lyu5XUZK/ovBuxsP4Pq3KTp2PZxtSxVH/HcDH+sli9YcEf23N9MYmaJcFmcCtWzA 4Wvs8UURD1w7KL0Yr+DiPcYFRTrR4ndyASLSQ5qsaJ7ID6ewh3m2DS7wElto88kZ J70MEikbhVxJcH/f/b59cTER8DUUNWEesbwRyuL56BZ5nWi6V1HwKdXYE8+J4S8h HAygYUNbC69ed/pYyOlQ== Received: from nasanppmta04.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xy15egr93-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 May 2024 20:50:53 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 446KoqC6031529 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 6 May 2024 20:50:52 GMT Received: from [10.46.19.239] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 6 May 2024 13:50:49 -0700 Message-ID: Date: Mon, 6 May 2024 13:50:48 -0700 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: [RFC PATCH bpf-next v6 3/3] selftests/bpf: Handle forwarding of UDP CLOCK_TAI packets Content-Language: en-US To: Willem de Bruijn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , Andrew Halaney , "Martin KaFai Lau" , Martin KaFai Lau , Daniel Borkmann , bpf CC: References: <20240504031331.2737365-1-quic_abchauha@quicinc.com> <20240504031331.2737365-4-quic_abchauha@quicinc.com> <663929b249143_516de2945@willemb.c.googlers.com.notmuch> From: "Abhishek Chauhan (ABC)" In-Reply-To: <663929b249143_516de2945@willemb.c.googlers.com.notmuch> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: shk_um8revS9wrBGaPQaKXWVkUZUIJYW X-Proofpoint-ORIG-GUID: shk_um8revS9wrBGaPQaKXWVkUZUIJYW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_15,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 mlxscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2405060151 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 - "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;", >> },