From patchwork Mon May 27 18:59:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13675712 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (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 640E2DDA9; Mon, 27 May 2024 19:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.153.30 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716836460; cv=none; b=eqvzIcwDiJz0xtlVOQa93kiyPIrsST8ukI0XGjW/+S/xzdAWRPImSsQojKidZ5ehvgYy7Z9p6c1gOe7lxZEQCZmxM4dO1+pRtxw2stywG0FID/YgCL92AsvTSYZT48fantUkEadqGJzWGPLvlhDXg7FiUEGFbIgImUcRojyT4eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716836460; c=relaxed/simple; bh=c0wTFKp9XQXRgUFgtFgR9AuRbrYxnV5EJTEpQx/c25k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tXY+bOM+fcbmjSZ+nTpcjKxwxNsCdfUeujQKNbIqGGcnWYJ0AvO+UNd4McGNwmkI8EHwhUhdjwzPUha4Q/EXnPYUMU8wO7h1KudVILUvwd9fH6+KSL5hHfrMqLoC1hmgK5+BYIwBDe0DiAfnQ8ACndFY7mbriX5wjWoqfKmj/QA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; arc=none smtp.client-ip=67.231.153.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44RIQb8T007199; Mon, 27 May 2024 12:00:24 -0700 DKIM-Signature: =?utf-8?q?v=3D1=3B_a=3Drsa-sha256=3B_c=3Drelaxed/relaxed=3B_?= =?utf-8?q?d=3Dmeta=2Ecom=3B_h=3Dcc=3Acontent-transfer-encoding=3Acontent-ty?= =?utf-8?q?pe=3Adate=3Afrom=3Ain-reply-to=3Amessage-id=3Amime-version=3Arefe?= =?utf-8?q?rences=3Asubject=3Ato=3B_s=3Ds2048-2021-q4=3B_bh=3D7geuP4fh0kfWIQ?= =?utf-8?q?EG10bAFf8y5oNk1kPaQirayNWOM44=3D=3B_b=3DPP/8OkqGURhdvgDRtEzPLuATN?= =?utf-8?q?DLoKjQCiuN0jBlXEOkW2gdyt1fh2C6yjcssjnADwn1H_IULvEAgv4H8H/gOzJjc1X?= =?utf-8?q?GyEr9t+zt9k1YSbjIbEfOHLD7z8t6cFNJ2rARa2ozVfw+kd_w2iuOFxmx0TPVQD9X?= =?utf-8?q?gNtCjYhesqxx7fcGLmuZ4hhAdh2EWxNHKm1tyLJRpMSfosGhiu1_6mTZkq+JZ6rCa?= =?utf-8?q?Mny0LGiNWLK0pqc/gzL+HibYTH5MDi4GrHpcw0CDMNPmW8npEdIy6nL_zi4+Owe8E?= =?utf-8?q?T9xd6qAp93vmxGq7Zoo5gu6IWkQf3ASYkxdziDv6dJg5OdI4AZJ3VQwEOlA_uA=3D?= =?utf-8?q?=3D_?= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3ybdr3234w-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 27 May 2024 12:00:24 -0700 Received: from devvm4158.cln0.facebook.com (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server id 15.2.1544.11; Mon, 27 May 2024 19:00:22 +0000 From: Vadim Fedorenko To: Vadim Fedorenko , Martin KaFai Lau , Andrii Nakryiko , "Alexei Starovoitov" , Mykola Lysenko , Jakub Kicinski CC: Vadim Fedorenko , , Subject: [PATCH bpf-next v3 2/2] selftests: bpf: validate CHECKSUM_COMPLETE option Date: Mon, 27 May 2024 11:59:28 -0700 Message-ID: <20240527185928.1871649-2-vadfed@meta.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527185928.1871649-1-vadfed@meta.com> References: <20240527185928.1871649-1-vadfed@meta.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: N8rjF6Oi7ZTwtRAAQkoqWuYf5bPMlzjO X-Proofpoint-ORIG-GUID: N8rjF6Oi7ZTwtRAAQkoqWuYf5bPMlzjO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-27_04,2024-05-27_01,2024-05-17_01 X-Patchwork-Delegate: bpf@iogearbox.net Adjust skb program test to run with checksum validation. Signed-off-by: Vadim Fedorenko --- .../selftests/bpf/prog_tests/test_skb_pkt_end.c | 1 + tools/testing/selftests/bpf/progs/skb_pkt_end.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_skb_pkt_end.c b/tools/testing/selftests/bpf/prog_tests/test_skb_pkt_end.c index ae93411fd582..09ca13bdf6ca 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_skb_pkt_end.c +++ b/tools/testing/selftests/bpf/prog_tests/test_skb_pkt_end.c @@ -11,6 +11,7 @@ static int sanity_run(struct bpf_program *prog) .data_in = &pkt_v4, .data_size_in = sizeof(pkt_v4), .repeat = 1, + .flags = BPF_F_TEST_SKB_CHECKSUM_COMPLETE, ); prog_fd = bpf_program__fd(prog); diff --git a/tools/testing/selftests/bpf/progs/skb_pkt_end.c b/tools/testing/selftests/bpf/progs/skb_pkt_end.c index db4abd2682fc..3bb4451524a1 100644 --- a/tools/testing/selftests/bpf/progs/skb_pkt_end.c +++ b/tools/testing/selftests/bpf/progs/skb_pkt_end.c @@ -33,6 +33,8 @@ int main_prog(struct __sk_buff *skb) struct iphdr *ip = NULL; struct tcphdr *tcp; __u8 proto = 0; + int urg_ptr; + u32 offset; if (!(ip = get_iphdr(skb))) goto out; @@ -48,7 +50,14 @@ int main_prog(struct __sk_buff *skb) if (!tcp) goto out; - return tcp->urg_ptr; + urg_ptr = tcp->urg_ptr; + + /* Checksum validation part */ + proto++; + offset = sizeof(struct ethhdr) + offsetof(struct iphdr, protocol); + bpf_skb_store_bytes(skb, offset, &proto, sizeof(proto), BPF_F_RECOMPUTE_CSUM); + + return urg_ptr; out: return -1; }