From nobody Mon May 6 04:00:16 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6402:358d:0:0:0:0 with SMTP id y13csp182123edc; Sat, 5 Mar 2022 17:02:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRpFT4qhRXVoMY0x+IvRqknCW6cxfAsYQloaY6m04bgZe2Guy1jhRinyBOaaGCEI6kWXVh X-Received: by 2002:a63:8843:0:b0:37c:926d:3fc7 with SMTP id l64-20020a638843000000b0037c926d3fc7mr4373000pgd.112.1646528526474; Sat, 05 Mar 2022 17:02:06 -0800 (PST) Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [2604:1380:1000:8100::1]) by mx.google.com with ESMTPS id w9-20020a170902d70900b00151e05c5b9asi312248ply.620.2022.03.05.17.02.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2022 17:02:06 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-4112-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) client-ip=2604:1380:1000:8100::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=TafdHwGu; arc=fail (body hash mismatch); spf=pass (google.com: domain of mptcp+bounces-4112-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 2604:1380:1000:8100::1 as permitted sender) smtp.mailfrom="mptcp+bounces-4112-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 sjc.edge.kernel.org (Postfix) with ESMTPS id D17A93E0F4B for ; Sun, 6 Mar 2022 01:02:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9C7A10F8; Sun, 6 Mar 2022 01:02:04 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) (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 C069E10EE for ; Sun, 6 Mar 2022 01:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1646528520; 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=QczyTf36WLF6RiwPjZcEUbZdKCp4RFvJhvgbWA4SnIA=; b=TafdHwGugXFAHj5RQ8nx4szewFJJPykZnBwH5AsX2F5FzB6oSe2W5gaGcrV5CFC+nFIKtR KDHA9sVHohVu6U/y8by3J//1x4le61wBIh+QeEcxGO6h3B0U7qudEZFWLEsHl/CNNxNn2K 5Gi0YhddcyJLz9oppmE+eLYQsa0OJmY= Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2054.outbound.protection.outlook.com [104.47.13.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-39-p-mNzMpHNRCFUKN-JdeviA-1; Sun, 06 Mar 2022 02:01:59 +0100 X-MC-Unique: p-mNzMpHNRCFUKN-JdeviA-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aqc+t1pffjSia2Sa/XHuCGbiqX8Og11DMRu3tJ/zQK0IdRG9MQ09OeIO1WVLptC3eW5C/SvMkztKkWdlgvMhHzsT6q1t8mxWqpFRNTN1GKqeZClHuKENlgHqSMkTg4UPX0yShYTNHXnafnWwp6zpp2JUraYQz4+UoE0ZX9Mauo+3hOkj6GG8g4aseuaO9YZiiM5lNXDGzfzltKswyPMo+cWko18PVMEoy9LI11EyhnIDmLDe4W/GSngTbStHJ91WWMMuEkYLg+Dd8+E6+ldUiZdhkTcn+14wcFAf76/qdgFmyYmh8LsIgH7wxqz/7QfpnTM5v/6XrXNVju9unWbL6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gZ0l557PIJKHti6t23iVEEtFuxpn33BRZk+pmmHRMtM=; b=L89AxTgXaNVcn8ArMUIZtyRkmmWK1CgWypvMOgHsZdsN7qby2qp1lAylzcPfKIDnQ2PumGcg8+PO4Ymlpruxs/qHqjv4Sv9zMdihuv6JaQ5/esnVg5HinsPNapBQM4GPxTWd7NfxCXzVcc0TlVUUScf99c7YCN8K6jyFkLyXkYj6vZE23KughVXF7D8z/XDoqZxuS9gLaB9JUW13CSBzFucmnfyKuanrLdQ1GXo84Znex2ZChzB80KuMXyPBx0g8JCB5nDXqx9wH4K+Y1b8YFC7HiEzp4F4Dq1odCeNGnoHmhrq3nMy22+h1fjnsPNRM+pnN0K2G0fwqaDz2RD3C1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by DB8PR04MB5724.eurprd04.prod.outlook.com (2603:10a6:10:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sun, 6 Mar 2022 01:01:58 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05%6]) with mapi id 15.20.5038.020; Sun, 6 Mar 2022 01:01:58 +0000 From: Geliang Tang To: mptcp@lists.linux.dev CC: Geliang Tang Subject: [PATCH mptcp-next v6 1/4] Revert "selftests: bpf: add bpf_mptcp_sock() verifier tests" Date: Sun, 6 Mar 2022 09:01:34 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HK2PR02CA0207.apcprd02.prod.outlook.com (2603:1096:201:20::19) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 34e38c69-a1e5-4e04-4763-08d9ff0cea13 X-MS-TrafficTypeDiagnostic: DB8PR04MB5724:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KJBloQRg3Y0aNj9X4b3A3VelHskjzg2hXL1F17YEHvPAycPAxQDACz/n9DohF6EHEfXxS2aemJv6FnIKHRVYuRi3FHvZea7AAxO0R6rBAKPqXm+8FuMwG2h6aoJLE4rJEWX9Y6OqdoG3nTidd8EiHSwFPstmqXgLx0Ain+hVWxnNOpFKAav85obdpEl23Hrv90Eu4ekkWHLtCPAhLF5heGlc4G8fmvnwJjz0rBs+k8l/Or0qolCXqEQT25s4JyEah+bZ53c0ocVeuBjf1y2+IR+AbIN8lOlPCuT4rZbE4bQY2/tdzL7GC1uCIIwTeSeFd2aPbWRGgLnxIn/zhwZN+eDDbEXQUBFnV7ZVr3gWQTk13F/YQ22cqTrn+6zJXOzJCZ77NMWCD0WwIXbRVjEZqKxvWYY1B7DYz7XsH8LSEXEVu0njI9bxfGV/pT2FNEjwFTURUylMEMCt4bE82kfOpgg21eSeNKzIv8hpWIQSOLr9KZO7jp9wb6A1+9TEcuDpxea+iEQIz2P74FALZygLpJ48iCgQ4rpZVJaaXYorhCZKnoCRxvXT/CHRAcBCQVXwZjeichhoK7DodiFHCLowmnO2aDa4dSsxRDmtadYvfUwZ8YGZ+NNDlLZi7aeLcG2ZfDu1NjKvryPDWBXm4em6eh6PhKxR8Hd42LnCZps81aG6WqIiJOJjvpuS8mfD2wbxItTCXKH+eSSPnMq3E7fQGw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(5660300002)(86362001)(8676002)(4326008)(6512007)(66556008)(66476007)(66946007)(44832011)(38100700002)(6666004)(2906002)(8936002)(6506007)(83380400001)(316002)(26005)(186003)(107886003)(6916009)(508600001)(36756003)(6486002)(2616005)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?oIWAAC6wlqWa4npRBD6aNLDl9QkQpoaZoxoWGCYKleAtg+X3tTa3RWaBxrF3?= =?us-ascii?Q?AwBIsD7axV2irX676abrr3Yh9O1ifDWe5rC51B04Bs0odJp0WPpGFrsYVIjF?= =?us-ascii?Q?OrZdCU6bQMFUiHdv1kvLjIqUz69nm2x+O2Nq+IPxtPyqVkl5V6Kvdou9zf2S?= =?us-ascii?Q?pIgF5AOEbuCCn5CTdJq94Sl6BZX7V3CHrmsnalW/LGhpx47N0G406qzJjVCe?= =?us-ascii?Q?JUztfYhnqDWiTyHyugSvUFMQgzIqoNvUkRlUFxdpbWehV0IrzZO04hDYsz7v?= =?us-ascii?Q?hwL6EwACSfRY77WSu3p1LMMTX8TqjpNlcOovavfH8RM+UkJTVgY4vy8e7g2a?= =?us-ascii?Q?POsghuwWZbdmvJrHhLd++dcib3IWWm9+3MSmzMqn9TCOQ8OxQjoymUw1T61d?= =?us-ascii?Q?UI/yhMp8IktHZc+akWRVJAwYMFndlZ+FJkiU8eD25OjFKOaqEu+ifcAbMg2X?= =?us-ascii?Q?WapAGdDwLw/mnsUoCno2cnsOk+RBVIFO52xKRcyORdVFy17alks1NTacWKVQ?= =?us-ascii?Q?gWO6HgZLBE1JNkoeyL1wrURSjapPWQPfsNLWA+CypH0bmzvXhBBUXuot7xFu?= =?us-ascii?Q?vr/J/aY3PteTLB+gS/SrmSxjY6UfdbiYvhKHbW0xpAIAT3uw2V8wjVU1hy1p?= =?us-ascii?Q?DsASMq2E+bQwhLQoWWDB3rVGzFMXLdiRDqOcSn9XUH/WBqQ2YneC6IGzUBVD?= =?us-ascii?Q?jeTIOtzfRtUp3CLpjUp+ZBkpaBJjLP4Mm/DZfOYojpOoTkmR5dw+8OwTsMwm?= =?us-ascii?Q?79cog5rfROs41aOtPByIa/aPqPbHMjrGhggJwJJT1feDVTUe/4If2tqNh3lS?= =?us-ascii?Q?xOzhKNften9NdGiVMf1Q4C8kA1b33+SOiIkKxhNAE1y7ObGCvDzQqZAyY5fO?= =?us-ascii?Q?vvaGW9yPU2EWJ5qG4vLOow5nb/3DBHKoQK0NscXjUi7mh7ixzqU8VecrBD4u?= =?us-ascii?Q?ONEHrRhSgYdRwJ8GagP02opuy6N/QX7QEyu/zTTClXmsI3322YCuAQWwZzoF?= =?us-ascii?Q?t/I85ruSmUn7rL+lwOl+vyARa5QxHuKgP0YXMNC9iLYflHM/7BZOR/tOR/jC?= =?us-ascii?Q?QPFNhWjPlvscZFfmrPa5w7Objsz20ukB7yaVbitzbbUEqjouHfR2yET9yJzI?= =?us-ascii?Q?5OgMf+O/ohQKeD5jcHXxHgGuPgMtPDcLATTwwoW9NrJMkhBf7f0KR8tYunrS?= =?us-ascii?Q?q10GwBIJL9xyTysmaT5WDXw2FmsU2gqwDtsF0VC5Bw/V2IVDIN7BofHrBg2t?= =?us-ascii?Q?1CYybZjd8+wGXSfvCxd4cnOMLYwp3l7vyvBGx/cmTPZx9d0piaxG8A6PWvge?= =?us-ascii?Q?KRsFFJ3247n/8FIEE0vhr4kbQyXl3gSKcJF2Iy+Mhn9/egaGjjQKPOq88jmE?= =?us-ascii?Q?tWIj6NL6McmLI69TfV7GoFuPSjsYN7vnYcw0cezQ14o4nQ8QYzLB1wyfAT1l?= =?us-ascii?Q?ayQM4Xwi/picivedAv9k97a21fNDkDmbWIlvbsA+yCCS56UsZK2/qyOPX+ZI?= =?us-ascii?Q?y8nS0Div4JNex85DzySA4+Gnts0BkD7IW71jH4/4MN4VMemBAQCBSAE/C/dC?= =?us-ascii?Q?F0pYc+OCiVZUFFz0QF3JvOvx3X3n26/CMdWCDXj2f2ORfOYK3AQ5e5BV8Q8I?= =?us-ascii?Q?Mzcq/EuYJ1uAl52diHEjnfE=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34e38c69-a1e5-4e04-4763-08d9ff0cea13 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2022 01:01:58.2551 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rtdAyXOI7E+Q7+3Kwac+++ku1EajlfrBOODAjCY8mCRee7lcOz0miiHaHXcbmPhFzq5tH9yl3vF8T/Adsrovfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5724 Content-Type: text/plain; charset="utf-8" This reverts commit f48f0143286db0d8dbded9542d9a2535533dd3b9. --- tools/testing/selftests/bpf/verifier/sock.c | 63 --------------------- 1 file changed, 63 deletions(-) diff --git a/tools/testing/selftests/bpf/verifier/sock.c b/tools/testing/se= lftests/bpf/verifier/sock.c index 1f85588091ab..8c224eac93df 100644 --- a/tools/testing/selftests/bpf/verifier/sock.c +++ b/tools/testing/selftests/bpf/verifier/sock.c @@ -731,66 +731,3 @@ .result_unpriv =3D REJECT, .errstr_unpriv =3D "unknown func", }, -{ - "bpf_mptcp_sock(skops->sk): no !skops->sk check", - .insns =3D { - BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct bpf_sock_ops, s= k)), - BPF_EMIT_CALL(BPF_FUNC_mptcp_sock), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }, - .prog_type =3D BPF_PROG_TYPE_SOCK_OPS, - .result =3D REJECT, - .errstr =3D "type=3Dsock_or_null expected=3Dsock_common", -}, -{ - "bpf_mptcp_sock(skops->sk): no NULL check on ret", - .insns =3D { - BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct bpf_sock_ops, s= k)), - BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 2), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - BPF_EMIT_CALL(BPF_FUNC_mptcp_sock), - BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, offsetof(struct bpf_mptcp_sock, = token)), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }, - .prog_type =3D BPF_PROG_TYPE_SOCK_OPS, - .result =3D REJECT, - .errstr =3D "invalid mem access 'mptcp_sock_or_null'", -}, -{ - "bpf_mptcp_sock(skops->sk): msk->token", - .insns =3D { - BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct bpf_sock_ops, s= k)), - BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 2), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - BPF_EMIT_CALL(BPF_FUNC_mptcp_sock), - BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), - BPF_EXIT_INSN(), - BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, offsetof(struct bpf_mptcp_sock, = token)), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }, - .prog_type =3D BPF_PROG_TYPE_SOCK_OPS, - .result =3D ACCEPT, -}, -{ - "bpf_mptcp_sock(skops->sk): msk->token cannot be modified", - .insns =3D { - BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_1, offsetof(struct bpf_sock_ops, s= k)), - BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, 2), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - BPF_EMIT_CALL(BPF_FUNC_mptcp_sock), - BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), - BPF_EXIT_INSN(), - BPF_ST_MEM(BPF_W, BPF_REG_0, offsetof(struct bpf_mptcp_sock, token), 0x2a= ), - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_EXIT_INSN(), - }, - .prog_type =3D BPF_PROG_TYPE_SOCK_OPS, - .result =3D REJECT, - .errstr =3D "cannot write into mptcp_sock", -}, --=20 2.34.1 From nobody Mon May 6 04:00:16 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6402:358d:0:0:0:0 with SMTP id y13csp182149edc; Sat, 5 Mar 2022 17:02:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxg1w6musWDJmiPe5kFjaqb8aGPaSFYlyK2UkyvijIVIxRgynTObp7QTFfIONas+fEtMxTl X-Received: by 2002:a25:d505:0:b0:627:f53a:ae02 with SMTP id r5-20020a25d505000000b00627f53aae02mr3864274ybe.256.1646528533997; Sat, 05 Mar 2022 17:02:13 -0800 (PST) Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [147.75.197.195]) by mx.google.com with ESMTPS id i189-20020a8154c6000000b002d797232db4si6106337ywb.234.2022.03.05.17.02.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2022 17:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-4113-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) client-ip=147.75.197.195; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=iON6ThC5; arc=fail (body hash mismatch); spf=pass (google.com: domain of mptcp+bounces-4113-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-4113-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 ewr.edge.kernel.org (Postfix) with ESMTPS id 7E08A1C0C62 for ; Sun, 6 Mar 2022 01:02:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28A4F10F8; Sun, 6 Mar 2022 01:02:12 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) (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 F029510EE for ; Sun, 6 Mar 2022 01:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1646528528; 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=z0MPY+WSQNwWOyp5VgV0CTw/sHdvnUiJvFilkADeg70=; b=iON6ThC5tCZrCrvWX0bEzTdBpgtZgQEJUOYrl/HXu3z0j3X2bv6RlR03Y9c+cRhNhOwn3O x2d5x2zbskVBhaoA8qMXEvFrV8W9U2nU1zdmI5AttjxAo/YROz3jXiEP30FqgkW78BRY5q Z+i97wcVORPcLOPDqePRhucKcC+1ljE= Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2059.outbound.protection.outlook.com [104.47.13.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-41-7qXHklJVN4yyubx8FHj8Qw-1; Sun, 06 Mar 2022 02:02:07 +0100 X-MC-Unique: 7qXHklJVN4yyubx8FHj8Qw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UZkykSZHbyqUClpOnxpiEWkBvkjad3x8zeN+s4T106NgltWOIgkZJfD4uGtihYDcydWylmxqJRG7XKchY8FB3vn1sNbrfyFFBx2AA/+PeDDhF07JPM/ho3Sarst6Oe6klduAdt7h7XwuBFYP5KaazBwh9W1sAy+Crs6dURzp6vatxkRHIA+T0POKKf2SQ44pqfQ8NvKMkbObRQdB+503og+kZ3pFrk5qRIretv3/2VxOkzMD1yEshO1WUPxEe30IhjlkmQb90FlvkLqwHo+agrEAxiY4ocfFrFLAR8U69Gf+A8GHF92keGh5QwGgPZfRi5UAZsvyZTE7KGr3qiGQtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3V/CJY3nSxaI4fRpLm5g7E3duE0JKWPCKp+lNt1FwUQ=; b=c9WOb1n3LUlso/FfDL20d8ZKS/PFpWgeGtO5ld7VYIaSBhhKPuYxwYohugbzz1MdW5m8M5q6TQTSiBM1IIoEheIgZBi+z6bgkQwdio7eaavXWDzdMF9G72765WEc2za1NSF7X0/IpxRcl0/L8Tm9SHufaGsHr9H4Co0oQjpMaITzwQinnCAjZL2f8b1y8j/RAAq5lqXx7PY3pfqjd0gxsjJ06Vb6hJfh7vaQXNjWkQceTiDrFJSMlkzs8Ut3OrrZoxctQuqeARPF2cFAXPrFwnReqQvgD5ndnGySf0/Nxa+9WR2Otl0ESHqHEQaGXdLUKLGuN/LVEIhdLXAcQuQJwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by DB8PR04MB5724.eurprd04.prod.outlook.com (2603:10a6:10:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sun, 6 Mar 2022 01:02:05 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05%6]) with mapi id 15.20.5038.020; Sun, 6 Mar 2022 01:02:05 +0000 From: Geliang Tang To: mptcp@lists.linux.dev CC: Geliang Tang Subject: [PATCH mptcp-next v6 2/4] Revert "bpf: add 'bpf_mptcp_sock' structure and helper" Date: Sun, 6 Mar 2022 09:01:35 +0800 Message-ID: <5d0f38a0fb220bae4f170f2debf5a8b8a031ba7e.1646528337.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HK2PR02CA0200.apcprd02.prod.outlook.com (2603:1096:201:20::12) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b66c1576-8277-4067-d822-08d9ff0cee48 X-MS-TrafficTypeDiagnostic: DB8PR04MB5724:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1c7+jvfrquNgIAdVycOX3L4tV+NNX7SQErV7esks/pN3OJ5vBBA5iIDbAIHPI74NsH9ioY2DQWiqT+K4cwAUlo6p2CMRn4oMcpZqq0WMWpOyl733a3B9+gkP7q3DLw5IxLUjVrgYcLQ4AgmTVmpoi5apZYVWNOy9CNIo392/liD1XV2sEuRrAl/NsUV3e2RQeoGgf72LchrVqrZs14RVvxkSs2AlT7pS1SE/0WYLJwGDkobxy1Mf6XGTFlfWYNDCQurNmXLtAMfy9GU6MQJ3i6jhFx+yPVB0xsUKpNwL7YUlOcLsu8K8EUT3oHrtEonJjHhKKYSzGUyf8sonpqKYhoUtDttwX5D/svHNhuI2WT/IuBzr/9uf4vWnmiOS4HJ64jMhPZbcUzlBbayN7FcadeK+Hsff+7S9RNb/qs5d/MtlrkeUNJpUBBWEyxEVgUPKqrrfSpYbg4f6YkIMagXZCdYyS+MvT05eNU/LqJk5W/m3EbCyfZmezK41TgbOE+g6/uTLJ7lKUWfWUttG6wMvNpvJUFtfupp6Aflp9gvNVoxFrhExNpZ9pqJGrSgSE+7+JfNzcU5WZ8mxCs5wAULq6inMHuQQ+Bm3tKwUeaL2bevfstyZ4bgg2h2s/y0VnT+u9XER/wm4cHZTMrNAEc+Qk8GDEC6NKtZ5l7bgEESLiCJSXhDlhMuew0gKqM90kQQaU6EDw9KnvKRdG/kb28Dy4A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(30864003)(5660300002)(86362001)(8676002)(4326008)(6512007)(66556008)(66476007)(66946007)(44832011)(38100700002)(6666004)(2906002)(8936002)(6506007)(83380400001)(316002)(26005)(186003)(107886003)(6916009)(508600001)(36756003)(6486002)(2616005)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?9NzNmfWbfuGiorCqZwS5HwefgGGuXW/DJ9jxrWVWWCb+OLgtCt3fvZ5uU9M6?= =?us-ascii?Q?WSXjIVyI44uR639qRltqKJzj6I4wHqsoVLBx/zJ5w477IwQxWZUDhuzniXZn?= =?us-ascii?Q?hPfJH7ALRA4LxQeVo+rdxwnkVyzfwWAzGh+As5LjZeqAu4ng8wYPRsv7ofKv?= =?us-ascii?Q?OTjsWmXLIndKGO3zasdtLyT8X0Hj/LymQD9Z0wtGg5m8lCjTgp03VyTpByPp?= =?us-ascii?Q?/+oyvZYDy89T4jZOWsT3X+anGedHbq2VviLsqBWiS81/FA0yuL+yx0Ol0K7t?= =?us-ascii?Q?hDXwrMvSxO46beUlsRctdT4jkLcbFl/KmVnHIupGOuF/0asp1xatDvimgy0O?= =?us-ascii?Q?C6hz6lVKwzJSVVGXd2bId0fp4FxnUN27LVcfu4q1IE8Bo8Vwy5RX3biObsG1?= =?us-ascii?Q?+bYOHC3S5ftHdai8DeF+kS0UFgZWkPPMCvNeHuWzY01N4yDFm0IYibK8A/xe?= =?us-ascii?Q?0DoCBkoiHjtUAXcg1Dgwbf2A0PHCzfcNp1PJLDtpbdp5DySDpWF1g5FNqrf/?= =?us-ascii?Q?T0KSXFaeEUsDPtyVZ8ptlTFWmYdidy7Lxe6ropNi8T0nmFD1vj5o0xDbr+dW?= =?us-ascii?Q?R3gX0czOoKY55E1zubnjndac1ln4c6G4NiJd/Liw++xRK2Yf5PYjghq2doGP?= =?us-ascii?Q?ML6rby0oJn5KD0ZLpcMZ7PFUXZqhEiHHe1OV98mLsZaYykSl5wqWSgI/+dxY?= =?us-ascii?Q?tJRflBTy/a0in2ECS+u3LQmBV2z1bh+4ZT4cKh4c3gB7ByCGONy/Ljzgj/JX?= =?us-ascii?Q?Ph9UuYIVhFfHyl1rab2WDuZFGaC5OhjpGho6VQxSmgETpwbv2RFUseTlNXoG?= =?us-ascii?Q?z1aICdCNvgdnDPun8DXoriX1uFnkfSMSUK8GFKkj8LHOAvJm5GjH4H9fSKea?= =?us-ascii?Q?/vs4w64tM+gCcIHQ8m2ZhKoo6xQ/IZeEBsOdgkNnFK8DGLuWcrR5hmZmxYnT?= =?us-ascii?Q?7okYt5okB+WcgJ6/Cd2Y57mnAl33xELwavQnWEi9nY67SGAksgOf6aeJCdmI?= =?us-ascii?Q?hqz/JvRbY9NZcN8GWtqmNidoHWiJBnPVoTIp6B1OEmY4quxm9zlzO9fJ0Jta?= =?us-ascii?Q?ap334Fidrpyv4LQQj5SZ+Hq+JgPEXh9FSeKXZ2x/I80qglS05k9tYaoaomUD?= =?us-ascii?Q?gqQkLxhaWNk6pgrIlQKYYefWOhEziPRViHQa1xHI7C/AbrRVkeLRRqSMmPUt?= =?us-ascii?Q?2Rh0FlBd3EXSV54jkN6/c5N8nYPFkhbilTG7J3Ua2FJptbSX0DifBrO643DU?= =?us-ascii?Q?3NgdLpN65VWQ/yNnijzu6KXaO8ahMGKhW99iRmN++DOTRAuBahY6PebOWxP4?= =?us-ascii?Q?ol/Z6j1q1Olfn5D0ywKZ4dZxRce/LQ5AUoosIJ9ushk4yiz2xGNvgHuUpN+J?= =?us-ascii?Q?kBl+oF5IZtrFNQZcP/1TcRVNr46EApTC8EKR7UIROE0QoxHoL170v6BeUdYc?= =?us-ascii?Q?NUPjBffolsmpl7FP9wkWB4CuBBggs0ciJUXeQYzhRr7ULluWgmkRgz8m2S2g?= =?us-ascii?Q?0zzWug0JvGxdFT3rNIbEnJaLd3AKImcFcb8xaveb7Mp+pvtWCIqMCnFTYChF?= =?us-ascii?Q?5IHfXjNy3PvZv0wVNPBxnxsQ19BP67bYy3MZlDxjDMK0Efm/sGhI0G9dz6kM?= =?us-ascii?Q?wCH8spliDBF6IYFnu2iBgqc=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: b66c1576-8277-4067-d822-08d9ff0cee48 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2022 01:02:05.3327 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AWLcTjXsf29qbnELUh33j0s4Yez8TKtUuqvENXjSiJp1UkeZQpEF+jIPqw24KGWL6vrGirxBK7hQ52EjNKW1Rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5724 Content-Type: text/plain; charset="utf-8" This reverts commit 2ee22ce38ed4c7a416ce887eb6379aaf157634f9. --- include/linux/bpf.h | 34 ---------------- include/uapi/linux/bpf.h | 13 ------ kernel/bpf/verifier.c | 20 ---------- net/core/filter.c | 4 -- net/mptcp/Makefile | 2 - net/mptcp/bpf.c | 72 ---------------------------------- scripts/bpf_doc.py | 2 - tools/include/uapi/linux/bpf.h | 13 ------ 8 files changed, 160 deletions(-) delete mode 100644 net/mptcp/bpf.c diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 5a17c1e3a6bc..f19abc59b6cd 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -407,7 +407,6 @@ enum bpf_return_type { RET_PTR_TO_MAP_VALUE, /* returns a pointer to map elem value */ RET_PTR_TO_SOCKET, /* returns a pointer to a socket */ RET_PTR_TO_TCP_SOCK, /* returns a pointer to a tcp_sock */ - RET_PTR_TO_MPTCP_SOCK, /* returns a pointer to mptcp_sock */ RET_PTR_TO_SOCK_COMMON, /* returns a pointer to a sock_common */ RET_PTR_TO_ALLOC_MEM, /* returns a pointer to dynamically allocated memo= ry */ RET_PTR_TO_MEM_OR_BTF_ID, /* returns a pointer to a valid memory or a btf= _id */ @@ -418,7 +417,6 @@ enum bpf_return_type { RET_PTR_TO_MAP_VALUE_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_MAP_VALUE, RET_PTR_TO_SOCKET_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_SOCKET, RET_PTR_TO_TCP_SOCK_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_TCP_SOCK, - RET_PTR_TO_MPTCP_SOCK_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_MPTCP_SOCK, RET_PTR_TO_SOCK_COMMON_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_SOCK_COMMO= N, RET_PTR_TO_ALLOC_MEM_OR_NULL =3D PTR_MAYBE_NULL | MEM_ALLOC | RET_PTR_TO_= ALLOC_MEM, RET_PTR_TO_BTF_ID_OR_NULL =3D PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID, @@ -499,7 +497,6 @@ enum bpf_reg_type { PTR_TO_SOCKET, /* reg points to struct bpf_sock */ PTR_TO_SOCK_COMMON, /* reg points to sock_common */ PTR_TO_TCP_SOCK, /* reg points to struct tcp_sock */ - PTR_TO_MPTCP_SOCK, /* reg points to struct mptcp_sock */ PTR_TO_TP_BUFFER, /* reg points to a writable raw tp's buffer */ PTR_TO_XDP_SOCK, /* reg points to struct xdp_sock */ /* PTR_TO_BTF_ID points to a kernel struct that does not need @@ -528,7 +525,6 @@ enum bpf_reg_type { PTR_TO_SOCKET_OR_NULL =3D PTR_MAYBE_NULL | PTR_TO_SOCKET, PTR_TO_SOCK_COMMON_OR_NULL =3D PTR_MAYBE_NULL | PTR_TO_SOCK_COMMON, PTR_TO_TCP_SOCK_OR_NULL =3D PTR_MAYBE_NULL | PTR_TO_TCP_SOCK, - PTR_TO_MPTCP_SOCK_OR_NULL =3D PTR_MAYBE_NULL | PTR_TO_MPTCP_SOCK, PTR_TO_BTF_ID_OR_NULL =3D PTR_MAYBE_NULL | PTR_TO_BTF_ID, =20 /* This must be the last entry. Its purpose is to ensure the enum is @@ -2221,7 +2217,6 @@ extern const struct bpf_func_proto bpf_get_local_stor= age_proto; extern const struct bpf_func_proto bpf_strtol_proto; extern const struct bpf_func_proto bpf_strtoul_proto; extern const struct bpf_func_proto bpf_tcp_sock_proto; -extern const struct bpf_func_proto bpf_mptcp_sock_proto; extern const struct bpf_func_proto bpf_jiffies64_proto; extern const struct bpf_func_proto bpf_get_ns_current_pid_tgid_proto; extern const struct bpf_func_proto bpf_event_output_data_proto; @@ -2309,7 +2304,6 @@ struct sk_reuseport_kern { u32 reuseport_id; bool bind_inany; }; - bool bpf_tcp_sock_is_valid_access(int off, int size, enum bpf_access_type = type, struct bpf_insn_access_aux *info); =20 @@ -2360,34 +2354,6 @@ static inline u32 bpf_xdp_sock_convert_ctx_access(en= um bpf_access_type type, } #endif /* CONFIG_INET */ =20 -#ifdef CONFIG_MPTCP -bool bpf_mptcp_sock_is_valid_access(int off, int size, - enum bpf_access_type type, - struct bpf_insn_access_aux *info); - -u32 bpf_mptcp_sock_convert_ctx_access(enum bpf_access_type type, - const struct bpf_insn *si, - struct bpf_insn *insn_buf, - struct bpf_prog *prog, - u32 *target_size); -#else /* CONFIG_MPTCP */ -static inline bool bpf_mptcp_sock_is_valid_access(int off, int size, - enum bpf_access_type type, - struct bpf_insn_access_aux *info) -{ - return false; -} - -static inline u32 bpf_mptcp_sock_convert_ctx_access(enum bpf_access_type t= ype, - const struct bpf_insn *si, - struct bpf_insn *insn_buf, - struct bpf_prog *prog, - u32 *target_size) -{ - return 0; -} -#endif /* CONFIG_MPTCP */ - enum bpf_text_poke_type { BPF_MOD_CALL, BPF_MOD_JUMP, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index f2e5c7bd4f10..3f6dcdf4b915 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5086,14 +5086,6 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. On error * *dst* buffer is zeroed out. - * - * struct bpf_mptcp_sock *bpf_mptcp_sock(struct bpf_sock *sk) - * Description - * This helper gets a **struct bpf_mptcp_sock** pointer from a - * **struct bpf_sock** pointer. - * Return - * A **struct bpf_mptcp_sock** pointer on success, or **NULL** in - * case of failure. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -5288,7 +5280,6 @@ union bpf_attr { FN(xdp_load_bytes), \ FN(xdp_store_bytes), \ FN(copy_from_user_task), \ - FN(mptcp_sock), \ /* */ =20 /* integer value in 'imm' field of BPF_CALL instruction selects which help= er @@ -5637,10 +5628,6 @@ struct bpf_tcp_sock { __u32 is_mptcp; /* Is MPTCP subflow? */ }; =20 -struct bpf_mptcp_sock { - __u32 token; /* msk token */ -}; - struct bpf_sock_tuple { union { struct { diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 1bb1b5d0419d..d7473fee247c 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -430,7 +430,6 @@ static bool type_is_sk_pointer(enum bpf_reg_type type) return type =3D=3D PTR_TO_SOCKET || type =3D=3D PTR_TO_SOCK_COMMON || type =3D=3D PTR_TO_TCP_SOCK || - type =3D=3D PTR_TO_MPTCP_SOCK || type =3D=3D PTR_TO_XDP_SOCK; } =20 @@ -438,7 +437,6 @@ static bool reg_type_not_null(enum bpf_reg_type type) { return type =3D=3D PTR_TO_SOCKET || type =3D=3D PTR_TO_TCP_SOCK || - type =3D=3D PTR_TO_MPTCP_SOCK || type =3D=3D PTR_TO_MAP_VALUE || type =3D=3D PTR_TO_MAP_KEY || type =3D=3D PTR_TO_SOCK_COMMON; @@ -454,7 +452,6 @@ static bool reg_type_may_be_refcounted_or_null(enum bpf= _reg_type type) { return base_type(type) =3D=3D PTR_TO_SOCKET || base_type(type) =3D=3D PTR_TO_TCP_SOCK || - base_type(type) =3D=3D PTR_TO_MPTCP_SOCK || base_type(type) =3D=3D PTR_TO_MEM || base_type(type) =3D=3D PTR_TO_BTF_ID; } @@ -554,7 +551,6 @@ static const char *reg_type_str(struct bpf_verifier_env= *env, [PTR_TO_SOCKET] =3D "sock", [PTR_TO_SOCK_COMMON] =3D "sock_common", [PTR_TO_TCP_SOCK] =3D "tcp_sock", - [PTR_TO_MPTCP_SOCK] =3D "mptcp_sock", [PTR_TO_TP_BUFFER] =3D "tp_buffer", [PTR_TO_XDP_SOCK] =3D "xdp_sock", [PTR_TO_BTF_ID] =3D "ptr_", @@ -2778,7 +2774,6 @@ static bool is_spillable_regtype(enum bpf_reg_type ty= pe) case PTR_TO_SOCKET: case PTR_TO_SOCK_COMMON: case PTR_TO_TCP_SOCK: - case PTR_TO_MPTCP_SOCK: case PTR_TO_XDP_SOCK: case PTR_TO_BTF_ID: case PTR_TO_BUF: @@ -3671,9 +3666,6 @@ static int check_sock_access(struct bpf_verifier_env = *env, int insn_idx, case PTR_TO_TCP_SOCK: valid =3D bpf_tcp_sock_is_valid_access(off, size, t, &info); break; - case PTR_TO_MPTCP_SOCK: - valid =3D bpf_mptcp_sock_is_valid_access(off, size, t, &info); - break; case PTR_TO_XDP_SOCK: valid =3D bpf_xdp_sock_is_valid_access(off, size, t, &info); break; @@ -3830,9 +3822,6 @@ static int check_ptr_alignment(struct bpf_verifier_en= v *env, case PTR_TO_TCP_SOCK: pointer_desc =3D "tcp_sock "; break; - case PTR_TO_MPTCP_SOCK: - pointer_desc =3D "mptcp_sock "; - break; case PTR_TO_XDP_SOCK: pointer_desc =3D "xdp_sock "; break; @@ -6762,9 +6751,6 @@ static int check_helper_call(struct bpf_verifier_env = *env, struct bpf_insn *insn } else if (base_type(ret_type) =3D=3D RET_PTR_TO_TCP_SOCK) { mark_reg_known_zero(env, regs, BPF_REG_0); regs[BPF_REG_0].type =3D PTR_TO_TCP_SOCK | ret_flag; - } else if (base_type(ret_type) =3D=3D RET_PTR_TO_MPTCP_SOCK) { - mark_reg_known_zero(env, regs, BPF_REG_0); - regs[BPF_REG_0].type =3D PTR_TO_MPTCP_SOCK | ret_flag; } else if (base_type(ret_type) =3D=3D RET_PTR_TO_ALLOC_MEM) { mark_reg_known_zero(env, regs, BPF_REG_0); regs[BPF_REG_0].type =3D PTR_TO_MEM | ret_flag; @@ -7479,7 +7465,6 @@ static int adjust_ptr_min_max_vals(struct bpf_verifie= r_env *env, case PTR_TO_SOCKET: case PTR_TO_SOCK_COMMON: case PTR_TO_TCP_SOCK: - case PTR_TO_MPTCP_SOCK: case PTR_TO_XDP_SOCK: verbose(env, "R%d pointer arithmetic on %s prohibited\n", dst, reg_type_str(env, ptr_reg->type)); @@ -10854,7 +10839,6 @@ static bool regsafe(struct bpf_verifier_env *env, s= truct bpf_reg_state *rold, case PTR_TO_SOCKET: case PTR_TO_SOCK_COMMON: case PTR_TO_TCP_SOCK: - case PTR_TO_MPTCP_SOCK: case PTR_TO_XDP_SOCK: /* Only valid matches are exact, which memcmp() above * would have accepted @@ -11385,7 +11369,6 @@ static bool reg_type_mismatch_ok(enum bpf_reg_type = type) case PTR_TO_SOCKET: case PTR_TO_SOCK_COMMON: case PTR_TO_TCP_SOCK: - case PTR_TO_MPTCP_SOCK: case PTR_TO_XDP_SOCK: case PTR_TO_BTF_ID: return false; @@ -12810,9 +12793,6 @@ static int convert_ctx_accesses(struct bpf_verifier= _env *env) case PTR_TO_TCP_SOCK: convert_ctx_access =3D bpf_tcp_sock_convert_ctx_access; break; - case PTR_TO_MPTCP_SOCK: - convert_ctx_access =3D bpf_mptcp_sock_convert_ctx_access; - break; case PTR_TO_XDP_SOCK: convert_ctx_access =3D bpf_xdp_sock_convert_ctx_access; break; diff --git a/net/core/filter.c b/net/core/filter.c index a07b28997ad3..f64454722a7e 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -7850,10 +7850,6 @@ sock_ops_func_proto(enum bpf_func_id func_id, const = struct bpf_prog *prog) case BPF_FUNC_tcp_sock: return &bpf_tcp_sock_proto; #endif /* CONFIG_INET */ -#ifdef CONFIG_MPTCP - case BPF_FUNC_mptcp_sock: - return &bpf_mptcp_sock_proto; -#endif /* CONFIG_MPTCP */ default: return bpf_sk_base_func_proto(func_id); } diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 0a0608b6b4b4..48a9d978aaeb 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -11,5 +11,3 @@ obj-$(CONFIG_INET_MPTCP_DIAG) +=3D mptcp_diag.o mptcp_crypto_test-objs :=3D crypto_test.o mptcp_token_test-objs :=3D token_test.o obj-$(CONFIG_MPTCP_KUNIT_TEST) +=3D mptcp_crypto_test.o mptcp_token_test.o - -obj-$(CONFIG_BPF) +=3D bpf.o diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c deleted file mode 100644 index 5332469fbb28..000000000000 --- a/net/mptcp/bpf.c +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Multipath TCP - * - * Copyright (c) 2020, Tessares SA. - * - * Author: Nicolas Rybowski - * - */ - -#include - -#include "protocol.h" - -bool bpf_mptcp_sock_is_valid_access(int off, int size, enum bpf_access_typ= e type, - struct bpf_insn_access_aux *info) -{ - if (off < 0 || off >=3D offsetofend(struct bpf_mptcp_sock, token)) - return false; - - if (off % size !=3D 0) - return false; - - switch (off) { - default: - return size =3D=3D sizeof(__u32); - } -} - -u32 bpf_mptcp_sock_convert_ctx_access(enum bpf_access_type type, - const struct bpf_insn *si, - struct bpf_insn *insn_buf, - struct bpf_prog *prog, u32 *target_size) -{ - struct bpf_insn *insn =3D insn_buf; - -#define BPF_MPTCP_SOCK_GET_COMMON(FIELD) \ - do { \ - BUILD_BUG_ON(sizeof_field(struct mptcp_sock, FIELD) > \ - sizeof_field(struct bpf_mptcp_sock, FIELD)); \ - *insn++ =3D BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct mptcp_sock, FIELD), \ - si->dst_reg, si->src_reg, \ - offsetof(struct mptcp_sock, FIELD)); \ - } while (0) - - if (insn > insn_buf) - return insn - insn_buf; - - switch (si->off) { - case offsetof(struct bpf_mptcp_sock, token): - BPF_MPTCP_SOCK_GET_COMMON(token); - break; - } - - return insn - insn_buf; -} - -BPF_CALL_1(bpf_mptcp_sock, struct sock *, sk) -{ - if (sk_fullsock(sk) && sk->sk_protocol =3D=3D IPPROTO_TCP && sk_is_mptcp(= sk)) { - struct mptcp_subflow_context *mptcp_sfc =3D mptcp_subflow_ctx(sk); - - return (unsigned long)mptcp_sfc->conn; - } - return (unsigned long)NULL; -} - -const struct bpf_func_proto bpf_mptcp_sock_proto =3D { - .func =3D bpf_mptcp_sock, - .gpl_only =3D false, - .ret_type =3D RET_PTR_TO_MPTCP_SOCK_OR_NULL, - .arg1_type =3D ARG_PTR_TO_SOCK_COMMON, -}; diff --git a/scripts/bpf_doc.py b/scripts/bpf_doc.py index 6ef5c44a2a9e..096625242475 100755 --- a/scripts/bpf_doc.py +++ b/scripts/bpf_doc.py @@ -623,7 +623,6 @@ class PrinterHelpers(Printer): 'struct udp6_sock', 'struct unix_sock', 'struct task_struct', - 'struct bpf_mptcp_sock', =20 'struct __sk_buff', 'struct sk_msg_md', @@ -683,7 +682,6 @@ class PrinterHelpers(Printer): 'struct socket', 'struct file', 'struct bpf_timer', - 'struct bpf_mptcp_sock', } mapped_types =3D { 'u8': '__u8', diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index f2e5c7bd4f10..3f6dcdf4b915 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -5086,14 +5086,6 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. On error * *dst* buffer is zeroed out. - * - * struct bpf_mptcp_sock *bpf_mptcp_sock(struct bpf_sock *sk) - * Description - * This helper gets a **struct bpf_mptcp_sock** pointer from a - * **struct bpf_sock** pointer. - * Return - * A **struct bpf_mptcp_sock** pointer on success, or **NULL** in - * case of failure. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -5288,7 +5280,6 @@ union bpf_attr { FN(xdp_load_bytes), \ FN(xdp_store_bytes), \ FN(copy_from_user_task), \ - FN(mptcp_sock), \ /* */ =20 /* integer value in 'imm' field of BPF_CALL instruction selects which help= er @@ -5637,10 +5628,6 @@ struct bpf_tcp_sock { __u32 is_mptcp; /* Is MPTCP subflow? */ }; =20 -struct bpf_mptcp_sock { - __u32 token; /* msk token */ -}; - struct bpf_sock_tuple { union { struct { --=20 2.34.1 From nobody Mon May 6 04:00:16 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6402:358d:0:0:0:0 with SMTP id y13csp182191edc; Sat, 5 Mar 2022 17:02:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN4NqzY/Ltq9Qkn4hL4xEMhM+0LpHopbToIp+G9+xhKhxVGFD9W8FNOdWZyaAhfqWrbAMO X-Received: by 2002:a81:3695:0:b0:2d7:ffc0:b6b0 with SMTP id d143-20020a813695000000b002d7ffc0b6b0mr4116823ywa.38.1646528541186; Sat, 05 Mar 2022 17:02:21 -0800 (PST) Return-Path: Received: from ewr.edge.kernel.org (ewr.edge.kernel.org. [147.75.197.195]) by mx.google.com with ESMTPS id k20-20020a25b294000000b006288026b200si7171674ybj.706.2022.03.05.17.02.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2022 17:02:21 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-4114-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) client-ip=147.75.197.195; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=WCl2AX3l; arc=fail (body hash mismatch); spf=pass (google.com: domain of mptcp+bounces-4114-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.197.195 as permitted sender) smtp.mailfrom="mptcp+bounces-4114-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 ewr.edge.kernel.org (Postfix) with ESMTPS id 8F0E41C0E10 for ; Sun, 6 Mar 2022 01:02:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0373810F8; Sun, 6 Mar 2022 01:02:19 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) (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 EF69C10EE for ; Sun, 6 Mar 2022 01:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1646528535; 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=DIRFswwjsk7XTkrix4FmPXHWCL2XoOBpsQLXRVgQCI0=; b=WCl2AX3lvf7KmoVmCqM90zv+czIoEqKj86rOZROyVw60UY80LWfLeTOJe7juF2D1shqgq2 6bt5uKzAVWDzJVxML+CQYb4HIACZNlDG9BpRsd1tKCHnXRC70RsmhwAPYyro/+GGFyjKpb srcLQvFrdsfrnkEzOZm9A2M1pyM2JSk= Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2059.outbound.protection.outlook.com [104.47.13.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-28-RxTiuvCHM1mv_vEou57S2Q-1; Sun, 06 Mar 2022 02:02:13 +0100 X-MC-Unique: RxTiuvCHM1mv_vEou57S2Q-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0+PHf1LYB6HnPnv8o0XJs7pxL3Z0RhzVqynyR7wh7nevvMBDOIKvrsY9KeGnFRgvUANveTh2ayv1Ax5jFTwxaz6iEij6N/5D9ZPR17Wc5vpqmONWiOL8nCq/Se8L7ykK1VOfeoBHKKyLDP4laG+l370HtPBiylB46/RArPOg6UbISeQWAEgdLK4zMBww8E1OhGqYOpYjXm7BTPpJ0bfC/p3bc8JGtGYFI8ohk83f88HbviiGnM+Xl0dtZzxd0kojhFQZaxJ+ha7jWQHWAYlSGnMXMidG/ko4ti37WE6MQOILfWiVGJhdv4TdEmrPghD2+PoLRtGOwdzhZOHtLesXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B+IqIzCOygSIQmLBey3D5KWkDPlGv7EsKNSEgncru1k=; b=bH+oFI23wS8O3wEp2CJbzugn0XtTztsv+oVD1v/QcGJlUAejnGm3O9cKvU3B3DxyUaYnZZvtKUnQBXgzzhllINUNmtp3wZVLX0tbq41u7CGM4cS3RdWqXM3N/QEyEWrEpOvFR0U2G1dVeqDV0MP+ZhanFU2JX1mAti4SZPwf/CgoVPzMnyD+rg8TdNTOAfX4ukUmE2Jw9je1xKk15YecoElpN2KufEmJPio8mkZNuJC5W8l8YjJ/CD9P9R189RVgor89h6CjdTnWP/XpJFP7F1RWWWLA5j/+hJJKf8ArDDY3+b9zc5bgn2TLRrAxRx0rQ2umx542291clRD37KgplQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by DB8PR04MB5724.eurprd04.prod.outlook.com (2603:10a6:10:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sun, 6 Mar 2022 01:02:12 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05%6]) with mapi id 15.20.5038.020; Sun, 6 Mar 2022 01:02:12 +0000 From: Geliang Tang To: mptcp@lists.linux.dev CC: Geliang Tang Subject: [PATCH mptcp-next v6 3/4] bpf: add skc_to_mptcp_sock helper Date: Sun, 6 Mar 2022 09:01:36 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HK2PR02CA0206.apcprd02.prod.outlook.com (2603:1096:201:20::18) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c1d02340-33ea-4b47-1f37-08d9ff0cf232 X-MS-TrafficTypeDiagnostic: DB8PR04MB5724:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qc7k/LsKXba9ZFo6D354JbGJ86lsfLleC6UJUC+xYV226yhAXW9im8YPaEdcCoSPZOeeR4aIo5Jo6ZFxtTiIT2Bh/MFni6Rl+fQgJHeVOnRUE0P8ClSXVST1N8i1BiaAvuEluGdJc9YKTHRULwauhSJd3pjlnGyRGzTrd6T1wJoq0uXe7SSgmlcYcWPrYVrTCeltykEgU80nCgkv6k/iq5vX9t+nxxseCIClnAAXsA+prmNj+4sHta0YH0QSo/+IfpXHJ3PyWdq59cQ5RkA2I8YgfJ9laWkCksDKueEJAHDcSPwUw6y5O2NiJocvWy6gNbRiShCLxixJSOw6x+XClpxRBIPEU8PHp3HYYwUazBS1PrIZqPMehsNPegxVOokw6CXxzOw6mcH2UE/+3DgkIVRCc38mV9v4Q/X513WECmUV18Q7v/rsr2qrPBkXhXhVTNr1Lhlv6cD2Ag2bwNTBuW90qehW97aX+aqd+LGb6BS18c1mtCasGOGwb1uG0r7Dc66dpnt5I2Qo0nJdJ3fqntNKe7j4N8Mfe/AHnmeHV4E0qONCEC8KzkB3LAwQ2FluejWObOzuMkc/JofuoTUvrlWladCnGf3a0If70QglavQ68hkAwhkwlaFGs1hCWlgSv83cvaDn/DT6QNWHl9X2imvj7vuGwdvzPGk/IteXtnGy64j+GXpOHgTHHawKj81vZfH33Ce4wLfMGdewOCHFeA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(5660300002)(86362001)(8676002)(4326008)(6512007)(66556008)(66476007)(66946007)(44832011)(38100700002)(6666004)(2906002)(8936002)(6506007)(83380400001)(316002)(26005)(186003)(107886003)(6916009)(508600001)(36756003)(6486002)(2616005)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lRNHPdtxhP0eAPzXlfdJEqzdtdQKUmYTqy8FT4En+wuye2KjGRyRv0OhL1cE?= =?us-ascii?Q?bG/Q3YcT+k1OT9hI8b5/tMvsb7igZg1ZeenL49N0J1FoxyJ/RTbnug9aipqY?= =?us-ascii?Q?X7fUwaA86ha4xfXp39nCbu1qzCt4ygMWsDmEaNfY3wwpvTK0kWp60a+SyeG9?= =?us-ascii?Q?+4LuqFT6p/7QXfXtZ8CoZJoII5YHdNiBAdLnGj+bQYnBGxVlxZEg/TWVUeW3?= =?us-ascii?Q?pieWpAfyPQ3KcYvrpPek1j7tkhCsOXIGke2psUvw+mXfKjt0eHyskiUh2/wQ?= =?us-ascii?Q?VWoMIt0KQFdNv3EBYYIoSCNiEsGDqxC99y6LOVQlV8eei1saSr+sw5N51w34?= =?us-ascii?Q?/VU16yCWBxpLyGBZzIeEkPMoaRaWZvkwqt57TQ0mXJ0fLQYfpPzVZpgrocc9?= =?us-ascii?Q?cRtzNuRb+6VSL8SrT/F06PCjtP398jcPt4+gWg/7lmzNmfZNZHbHc4N/hKzQ?= =?us-ascii?Q?2ZllhGwr2v2PTPCEHXwBsalMmdDfy5a+zIb855ZZbKpkG0Wv0V3jlP/WuURj?= =?us-ascii?Q?b2SDCRIY8RG1tYiYXJovyPyNUGSw+tNawPTbCQlJ3C9roBeJXbHIxr3nXOp6?= =?us-ascii?Q?CycOPWh+fD/LtKfEVUr8emJwhbcs+GPpfsAT+lctr02Bnr5052KrraMcZY+D?= =?us-ascii?Q?tu+OSq3LExWFJX5YM9NDcavScxFL/9WS9UODNkisl/o8o5d1j+xdMp9wYAUS?= =?us-ascii?Q?N8T1cyRryertOKnoX+qRjzjx23jEN8ir9Hi1kABihAPUcVez+ywwLR/n8ba3?= =?us-ascii?Q?6qxsG15PRxWcV0eKT1X7jv9943ZhUXpoK88UKLVVpS0j1NZtzAUhjIjD2kf3?= =?us-ascii?Q?v4sT9+euXNcfjLaYcBl+omEG4jfNntDVjBnIYRhkFF5o9cGDPkzAGSIbN6FA?= =?us-ascii?Q?oixI7GO/noPS1osOgstrDVW06rqBJPZqkeL6H+1a/Wh40vKOsZHlQGIOsbFt?= =?us-ascii?Q?iTJTyxyoBP1BRDHaYN9s5rWs086KzctQRxBfmCaNBB6w7/gAfBhLTNREPbiR?= =?us-ascii?Q?geT0WzRHUV4PBFMVYw+qPnzfC4OBdgxj3P2UiGmBGinFOlFAtRxPNM21/VIW?= =?us-ascii?Q?qXHHpMgODAV8fGqd+Qnua+KRq7rmauBfjk4gAD3iT/fwMaJkFSUCKwzL2MyB?= =?us-ascii?Q?hZa+ZylCOMngapiIScsu4FDB7z+tjRNuqPgpvmKp5ZJEc+THkLR0/TiS7DNb?= =?us-ascii?Q?FkFihe1tZPnQyp5KNDecwX3qU4v/V0jLssMH2M/8c8zjftjG54U1e/H4NqQs?= =?us-ascii?Q?a//xCGYaKzIN0GS6NKA5sxc5vpLJkFLk+vAVawZfOJq7gz+kSduLUKHlJhMv?= =?us-ascii?Q?Sf5bp49jiN/DdtRJvlZ56rW0sAUaGhupUCqFg5uD8XYsrzGG2oPuxaNXLAlE?= =?us-ascii?Q?f2ga/lnpQ2qjzwj8xvyGd9XmS0HBem97ck1aILJ+mtYZTvnsTrMLCjEcaVlJ?= =?us-ascii?Q?rYKlbAgQgVPRtOfhK0GoHrfe2bixBidkCqjfgPvsnos8ovdlgVCMM8QQdvIn?= =?us-ascii?Q?LS+kzxJF8aS45KxA9yPtCX1FHl4pwUlTp6b/fpMso4aBlrhnNAlHUpmzIs1N?= =?us-ascii?Q?wC/Ql3cMZ483+tcU82lPDsbzxizVoE+0wV26HSKfar9WLqQuXUgSN+HQ3qsI?= =?us-ascii?Q?kQi0L2KXDHt6rCP6OqULFkM=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1d02340-33ea-4b47-1f37-08d9ff0cf232 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2022 01:02:12.0353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8VyfQcE8myihP7q9vveUT7azHmfHqDvX9RBXBlmYM48H8FRzmdsys2Beiu1+phMa80UMI+Jxcgm8NKDkaTt+PA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5724 Content-Type: text/plain; charset="utf-8" This patch implemented bpf_skc_to_mptcp_sock helper. Defined a new bpf_id BTF_SOCK_TYPE_MPTCP, and added a new helper bpf_mptcp_sock_from_subflow() to get struct bpf_mptcp_sock from a given subflow socket. Signed-off-by: Geliang Tang --- include/linux/bpf.h | 9 +++++++++ include/linux/btf_ids.h | 3 ++- include/uapi/linux/bpf.h | 7 +++++++ net/core/filter.c | 17 +++++++++++++++++ net/mptcp/Makefile | 2 ++ net/mptcp/bpf.c | 17 +++++++++++++++++ scripts/bpf_doc.py | 2 ++ tools/include/uapi/linux/bpf.h | 7 +++++++ 8 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 net/mptcp/bpf.c diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f19abc59b6cd..b28b3d8c3df2 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -2354,6 +2354,15 @@ static inline u32 bpf_xdp_sock_convert_ctx_access(en= um bpf_access_type type, } #endif /* CONFIG_INET */ =20 +#ifdef CONFIG_MPTCP +struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk); +#else /* CONFIG_MPTCP */ +static inline struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *= sk) +{ + return NULL; +} +#endif /* CONFIG_MPTCP */ + enum bpf_text_poke_type { BPF_MOD_CALL, BPF_MOD_JUMP, diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h index bc5d9cc34e4c..335a19092368 100644 --- a/include/linux/btf_ids.h +++ b/include/linux/btf_ids.h @@ -178,7 +178,8 @@ extern struct btf_id_set name; BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) \ - BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock) + BTF_SOCK_TYPE(BTF_SOCK_TYPE_UNIX, unix_sock) \ + BTF_SOCK_TYPE(BTF_SOCK_TYPE_MPTCP, mptcp_sock) =20 enum { #define BTF_SOCK_TYPE(name, str) name, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 3f6dcdf4b915..a88aac4457a9 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -5086,6 +5086,12 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. On error * *dst* buffer is zeroed out. + * + * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *mptcp_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -5280,6 +5286,7 @@ union bpf_attr { FN(xdp_load_bytes), \ FN(xdp_store_bytes), \ FN(copy_from_user_task), \ + FN(skc_to_mptcp_sock), \ /* */ =20 /* integer value in 'imm' field of BPF_CALL instruction selects which help= er diff --git a/net/core/filter.c b/net/core/filter.c index f64454722a7e..538b6db4fd76 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -11121,6 +11121,19 @@ const struct bpf_func_proto bpf_skc_to_unix_sock_p= roto =3D { .ret_btf_id =3D &btf_sock_ids[BTF_SOCK_TYPE_UNIX], }; =20 +BPF_CALL_1(bpf_skc_to_mptcp_sock, struct sock *, sk) +{ + return (unsigned long)bpf_mptcp_sock_from_subflow(sk); +} + +static const struct bpf_func_proto bpf_skc_to_mptcp_sock_proto =3D { + .func =3D bpf_skc_to_mptcp_sock, + .gpl_only =3D false, + .ret_type =3D RET_PTR_TO_BTF_ID_OR_NULL, + .arg1_type =3D ARG_PTR_TO_SOCK_COMMON, + .ret_btf_id =3D &btf_sock_ids[BTF_SOCK_TYPE_MPTCP], +}; + BPF_CALL_1(bpf_sock_from_file, struct file *, file) { return (unsigned long)sock_from_file(file); @@ -11163,6 +11176,10 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id) case BPF_FUNC_skc_to_unix_sock: func =3D &bpf_skc_to_unix_sock_proto; break; +#ifdef CONFIG_MPTCP + case BPF_FUNC_skc_to_mptcp_sock: + return &bpf_skc_to_mptcp_sock_proto; +#endif /* CONFIG_MPTCP */ case BPF_FUNC_ktime_get_coarse_ns: return &bpf_ktime_get_coarse_ns_proto; default: diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 48a9d978aaeb..0a0608b6b4b4 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -11,3 +11,5 @@ obj-$(CONFIG_INET_MPTCP_DIAG) +=3D mptcp_diag.o mptcp_crypto_test-objs :=3D crypto_test.o mptcp_token_test-objs :=3D token_test.o obj-$(CONFIG_MPTCP_KUNIT_TEST) +=3D mptcp_crypto_test.o mptcp_token_test.o + +obj-$(CONFIG_BPF) +=3D bpf.o diff --git a/net/mptcp/bpf.c b/net/mptcp/bpf.c new file mode 100644 index 000000000000..d140979181f9 --- /dev/null +++ b/net/mptcp/bpf.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Multipath TCP + * + * Copyright (c) 2022, SUSE. + */ + +#include +#include "protocol.h" + +struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk) +{ + if (sk && sk_fullsock(sk) && sk->sk_protocol =3D=3D IPPROTO_TCP && sk_is_= mptcp(sk)) + return mptcp_sk(mptcp_subflow_ctx(sk)->conn); + + return NULL; +} +EXPORT_SYMBOL(bpf_mptcp_sock_from_subflow); diff --git a/scripts/bpf_doc.py b/scripts/bpf_doc.py index 096625242475..0e5a9e69ae59 100755 --- a/scripts/bpf_doc.py +++ b/scripts/bpf_doc.py @@ -623,6 +623,7 @@ class PrinterHelpers(Printer): 'struct udp6_sock', 'struct unix_sock', 'struct task_struct', + 'struct mptcp_sock', =20 'struct __sk_buff', 'struct sk_msg_md', @@ -682,6 +683,7 @@ class PrinterHelpers(Printer): 'struct socket', 'struct file', 'struct bpf_timer', + 'struct mptcp_sock', } mapped_types =3D { 'u8': '__u8', diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 3f6dcdf4b915..a88aac4457a9 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -5086,6 +5086,12 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. On error * *dst* buffer is zeroed out. + * + * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk) + * Description + * Dynamically cast a *sk* pointer to a *mptcp_sock* pointer. + * Return + * *sk* if casting is valid, or **NULL** otherwise. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -5280,6 +5286,7 @@ union bpf_attr { FN(xdp_load_bytes), \ FN(xdp_store_bytes), \ FN(copy_from_user_task), \ + FN(skc_to_mptcp_sock), \ /* */ =20 /* integer value in 'imm' field of BPF_CALL instruction selects which help= er --=20 2.34.1 From nobody Mon May 6 04:00:16 2024 Delivered-To: wpasupplicant.patchew@gmail.com Received: by 2002:a05:6402:358d:0:0:0:0 with SMTP id y13csp182222edc; Sat, 5 Mar 2022 17:02:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyU9xyoSB6iMt9BzH6kOkmmKOt4mglQM0xG07BKg1bF2e17dYgzsrr0JO+5r0TOWKo9BLI9 X-Received: by 2002:a63:f25:0:b0:374:6b38:c6b3 with SMTP id e37-20020a630f25000000b003746b38c6b3mr4476719pgl.195.1646528546672; Sat, 05 Mar 2022 17:02:26 -0800 (PST) Return-Path: Received: from sjc.edge.kernel.org (sjc.edge.kernel.org. [147.75.69.165]) by mx.google.com with ESMTPS id p12-20020a634f4c000000b0034eb5da7d67si8680108pgl.549.2022.03.05.17.02.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2022 17:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of mptcp+bounces-4115-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) client-ip=147.75.69.165; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b=eSctqTUC; arc=fail (body hash mismatch); spf=pass (google.com: domain of mptcp+bounces-4115-wpasupplicant.patchew=gmail.com@lists.linux.dev designates 147.75.69.165 as permitted sender) smtp.mailfrom="mptcp+bounces-4115-wpasupplicant.patchew=gmail.com@lists.linux.dev"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 sjc.edge.kernel.org (Postfix) with ESMTPS id DD4ED3E0F16 for ; Sun, 6 Mar 2022 01:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F417C10F8; Sun, 6 Mar 2022 01:02:24 +0000 (UTC) X-Original-To: mptcp@lists.linux.dev Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) (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 4DE2B10EE for ; Sun, 6 Mar 2022 01:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1646528541; 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=KMFG0cyu2D4b32mHfVhpf/0t9RCwhMwt/4tIm7uVxtk=; b=eSctqTUCc1wzX/WPQUXW8WUlqJjAPDPIq0FBjB0cfBPLvI8mmcM7U46+B4oZ3U/kDnhdRu Z6K511X2SYhabdwm5Cfi6O18dgVZ5ZWM1GHexNxmdYSmJATnd5qinXC/P4pRSa4YUSby/v QuseyHc7vXcZDosW73h8dU71XpAp6h8= Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2057.outbound.protection.outlook.com [104.47.13.57]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-5-KP_mOJwJNuGMg-ee66mpyQ-1; Sun, 06 Mar 2022 02:02:20 +0100 X-MC-Unique: KP_mOJwJNuGMg-ee66mpyQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbq9q8eOZ4M/NvB5FSpaDZSmz1KLwKB3jryQwe4ukNbR1gZXXKSyUGhg09rv2C+4jPGUw0+THuUNRb5baPhFkzT4GjWVHv6/zbQFsES7f024ZujC/Ody5bdftuzniYTLWQAmvdmeIc0VSz9Rq5BQujD9xoPbx2ngudjMXoqvZHXH/7CnVu8zcq5WcrRYQo3Bo6+DBIwcx9V2D8f7Ru3rKW6a/EQjyNj0dhf1Bdgw1L2VkuiaWaxfmWDvsgadXAy6IAiprmZW7/yT/jQP2HnYYz3/hMuHMsEaM0uRRepiDgudhTauXxOdUf33i3rns1R071tn8dHIk/0J1rBi4d2AqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FA40s9gFb6FU62Q8yhMglXZBRb2+YrdeWGqgjORLntY=; b=ca95Em2aGlTtUxhIpCjVl8Ew9kOYG2L6yoO1jIylQKWg0O3/rLWEl51scvPNjDDz6dNXH/VxtoA3g0u/o2ePU+dgyXDeT9MDz4OW50VNDnSYrl2smC+Oiw6YHGzPhnF6vTORex9Z31a3fRG1K+5YEbTtKzE2+RGlfA5g4b3sSQFuukhhDxjTQT+GtY4A5r7t1o3hhp0JPD3fZJWHQ6eyxBNoodhvQhYQu9M9aylbZT7p35dmfLi2VpN7tH+rXJoxSifldjMCbnrPjR+xQ2fLBClmKujsLRNiW0kRcfHOspyw4xxsfl1YIb1NrglJ0rrulDW+n48s3oJWWj1OdB9OaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by DB8PR04MB5724.eurprd04.prod.outlook.com (2603:10a6:10:a4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Sun, 6 Mar 2022 01:02:18 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::b110:cb51:e09f:bb05%6]) with mapi id 15.20.5038.020; Sun, 6 Mar 2022 01:02:18 +0000 From: Geliang Tang To: mptcp@lists.linux.dev CC: Geliang Tang Subject: [PATCH mptcp-next v6 4/4] selftests: bpf: add skc_to_mptcp_sock test Date: Sun, 6 Mar 2022 09:01:37 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: HK0PR01CA0050.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::14) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 824ce59c-e306-4ec8-0204-08d9ff0cf638 X-MS-TrafficTypeDiagnostic: DB8PR04MB5724:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 35q2qs6HX131NhXi1pe1Isx9V+vZf+0aaCZ+e1LW0bD//Q676mGhC0VAMHqZ9OW5QY5J5wQ97Pmp+Zng1pwzxt7XUp2tyElrb/RbTgf/C1mPIeUJ4BUMn23Hqeenhr50BQasjM7wqTusrvr+tP2a8A9kx9Hwuvrq1sRiFANM7xcyBxIg13OtAJleiZ+3djtkT9WkNwPPH5oXyesCeBvtrgiK+0PsGHoWxpFdzNPbdv7f2SwU6XWezYZj7mk1OeVNdNG3yVQQiO8cDil/fkfrMbVeHPbuKO5ZBi201AzTHPljk7x+0ZjPceIpJkd+mF40k5KUBSFpsrOP96mgePkOnuyf0HDNJjsi31Ilc3mgJdgbYH3F+HJBIa/GMW45avq6WGc/xSlqy2NKwN6qm8dTqJolNW/ayTYH/FQxg0vBwUJc5s4gfssuAZBTpFAnKWvqWQt1wDlWRC/97jHgONuq5DE6FjpfNCm7i52ShHfpfQAd8ak+d6Ld5c4NTQ3nYwnXsTjflzNQSvPLueWY0safr0B7EJ6WBEfMzTuM3zmUlLBC6bmdPs8Z9RmqF4VJV4tLfshucaxa0yM/2PRa776+4u8PPjzjRsNt5E/tAbfmHETMWWLce1HcqvPLRwJcax+2DHBghWntUJrRtE23ba4SFDBfWU5iimRtc+0AylwM/rj09V0+U0iCKl92YzCrBpIs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(5660300002)(86362001)(8676002)(4326008)(6512007)(66556008)(66476007)(66946007)(44832011)(38100700002)(6666004)(2906002)(8936002)(6506007)(83380400001)(316002)(26005)(186003)(107886003)(6916009)(508600001)(36756003)(6486002)(2616005)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iz9fwzeGfbnV3u4pjDl6PHT3pTookDTEjZkT4U3LODgk9vv6+BesHf8djMmN?= =?us-ascii?Q?XNLNSBtZJlv3E+WdCfmM11dsh+VJ1R7rKW4o/AWuUMMEyU7gnJ91UnzLkx6E?= =?us-ascii?Q?DcLkhnyLOeob0YCML5Q8MXZFq8JIgVMWNIGBFBgPa+VyFs6kbDTPZg+HkBIJ?= =?us-ascii?Q?iKXpWBzU7SuyfgRB9Cv04A9bQusSWvjaiZR/Dqpe8NX9LeC+uiw2r3Wim0r2?= =?us-ascii?Q?yE1N/duSwI8zuKh3I7cWvEky5gfMIim8eoVzjBF5kd3nWi12Y9oQixElYDxJ?= =?us-ascii?Q?VIg+z8suW85jaSjCdfVND5tSTYaVo/J3GFNmKkkLnfbleT+0vZzpvzg6iZfH?= =?us-ascii?Q?1Ppypn1MD9K7vMAkUyIAEeW0MHcoKqi7j9G9KzAnlTrow2yO2Ii6PJTYK0RZ?= =?us-ascii?Q?tNwQNumhTLM5fqr6GHPxCUM4Ze58OFwc5+sZrpA1Nw1LwUxmZfkrMd+BzGut?= =?us-ascii?Q?DIL65FqYhgLZ/aLlzmfhW1jvXRkDmg1jb0ZvIElN0SoygvyehrFn23qnYdW0?= =?us-ascii?Q?CBnBqNw3tJj2kmTHqcvOFAqcuRWX1rJYKgo8FDvi9V8UgqBlN2tqWMMT2GQ2?= =?us-ascii?Q?yuEy2AGj1654yOzdZQ4krRJa1gWXY48tf/P18Z7jQe5fGeB522FHJMNo/tN3?= =?us-ascii?Q?vXlGOVv6ehijDr1/0IqgWMfK/e532RhpeESvs5DmvXhr7/KUboAmo9OPDGm8?= =?us-ascii?Q?SpBLYIse9DIfK2tPOrEV3jLG6bVm12pVoYcy/ISQjsUTKn0anyqCK0ST94l3?= =?us-ascii?Q?8z3DIBpFIse8sDCIPuLGdbmiVmLnPSJMt0IqvPaImnFggl4ASi16Wj/rfN3Z?= =?us-ascii?Q?aSl9OUj8akVGm1HC3aE8lwb8n5MrZBV2gdJpMzKECnD1BLcDvVvVSbSQO665?= =?us-ascii?Q?nMwnrQMOXBymQYDDZQwDpLRbS76IcUIc46vNOAspQUZsXo9NFVs784Vf4kcK?= =?us-ascii?Q?oxlrgVK7Vsbt8InAJd8/wEQ/YG5BP07c0LZJTd+sC7GVSa9qjgHJ3Yx8SKaV?= =?us-ascii?Q?vvouvITKSYO5DaasgFObNpudfJnQAfOZaBN1hTwR9VywfL95IIkQ3FKH/mQw?= =?us-ascii?Q?FavVGXG0Tw9kmEcm+Mp0sdqqOFaK0X2vaDKA0WlhXitJ5oLRRbAbSCiP69/T?= =?us-ascii?Q?swDBR0FRVXDgom5ixWyotMJrv2mh1HndX7hgdiUU25Ils5ULEg6pIrZH+7tu?= =?us-ascii?Q?3gI40xHI5FtumSQW3UaZ1SDMhgIZZZIZsVOfcHUM/XD+MX/BQ41wowA+MN71?= =?us-ascii?Q?gHP7d5qv6oAWnJFfTegmFor9VU2+g2QPra6VC5vn/xHc2b1/LFxpND3p2jKm?= =?us-ascii?Q?TLJcXx2Rtu3iRZZNnpcbJ/tyxys27FDrTlj1PjKesI5rPsYUdm/4iqaORdHP?= =?us-ascii?Q?OHmGt9/nFE548LzuAJTXZOSlfkVmE971G1gacs2Az8JiS+yvHzdnmTZ3VNt6?= =?us-ascii?Q?ljUjg22MX9NkOYJVyLSE5LRQtknf5PXGXuRT4PcHlZlOaQzmbsNEX5suRKbc?= =?us-ascii?Q?EO3nA2a0ZF2/f9AXEnInxvfi34IgWANKCqw941moNKuBoKpv0F4yGl1ZSYzx?= =?us-ascii?Q?eCxxkw223+pxRutRJDNeWf+eOAiRmi5+vydhXFNjFtrK7D5Q4Qc9bhNfNlWI?= =?us-ascii?Q?/kEkasHIZ3BTbDYv5Xi7OPg=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 824ce59c-e306-4ec8-0204-08d9ff0cf638 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2022 01:02:18.8004 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7SUE2kmTu6ZACweglhGYqc7noKYsLJnTlWzCIKruzm3EMVaQnbi8rLDnaGzsK8e1AtCjApUnuI4wwNR/iRq3BA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB5724 Content-Type: text/plain; charset="utf-8" This patch extended the MPTCP test base, to exercise bpf_skc_to_mptcp_sock() from C test as Alexei suggested in v3. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 6 +++++ .../testing/selftests/bpf/prog_tests/mptcp.c | 27 +++++++++++++++---- tools/testing/selftests/bpf/progs/mptcp.c | 23 ++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_tcp_helpers.h b/tools/testing/= selftests/bpf/bpf_tcp_helpers.h index b1ede6f0b821..05f62f81cc4d 100644 --- a/tools/testing/selftests/bpf/bpf_tcp_helpers.h +++ b/tools/testing/selftests/bpf/bpf_tcp_helpers.h @@ -83,6 +83,12 @@ struct tcp_sock { __u64 tcp_mstamp; /* most recent packet received/sent */ } __attribute__((preserve_access_index)); =20 +struct mptcp_sock { + struct inet_connection_sock sk; + + __u32 token; +} __attribute__((preserve_access_index)); + static __always_inline struct inet_connection_sock *inet_csk(const struct = sock *sk) { return (struct inet_connection_sock *)sk; diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index 04aef0f147dc..ba856956f9c3 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -6,9 +6,11 @@ struct mptcp_storage { __u32 invoked; __u32 is_mptcp; + __u32 token; }; =20 -static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 is_= mptcp) +static int verify_sk(int map_fd, int client_fd, const char *msg, + __u32 is_mptcp, __u32 token) { int err =3D 0, cfd =3D client_fd; struct mptcp_storage val; @@ -19,8 +21,23 @@ static int verify_sk(int map_fd, int client_fd, const ch= ar *msg, __u32 is_mptcp) * does not trigger sockops events. * We silently pass this situation at the moment. */ - if (is_mptcp =3D=3D 1) - return 0; + if (is_mptcp =3D=3D 1) { + if (token <=3D 0) + return 0; + + if (CHECK_FAIL(bpf_map_lookup_elem(map_fd, &cfd, &val) < 0)) { + perror("Failed to read socket storage"); + return -1; + } + + if (val.token <=3D 0) { + log_err("%s: unexpected bpf_mptcp_sock.token %d %d", + msg, val.token, token); + err++; + } + + return err; + } =20 if (CHECK_FAIL(bpf_map_lookup_elem(map_fd, &cfd, &val) < 0)) { perror("Failed to read socket storage"); @@ -76,8 +93,8 @@ static int run_test(int cgroup_fd, int server_fd, bool is= _mptcp) goto close_client_fd; } =20 - err +=3D is_mptcp ? verify_sk(map_fd, client_fd, "MPTCP subflow socket", = 1) : - verify_sk(map_fd, client_fd, "plain TCP socket", 0); + err +=3D is_mptcp ? verify_sk(map_fd, client_fd, "MPTCP subflow socket", = 1, 1) : + verify_sk(map_fd, client_fd, "plain TCP socket", 0, 0); =20 close_client_fd: close(client_fd); diff --git a/tools/testing/selftests/bpf/progs/mptcp.c b/tools/testing/self= tests/bpf/progs/mptcp.c index be5ee8dac2b3..212e9341b877 100644 --- a/tools/testing/selftests/bpf/progs/mptcp.c +++ b/tools/testing/selftests/bpf/progs/mptcp.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include "bpf_tcp_helpers.h" =20 char _license[] SEC("license") =3D "GPL"; __u32 _version SEC("version") =3D 1; @@ -8,6 +9,7 @@ __u32 _version SEC("version") =3D 1; struct mptcp_storage { __u32 invoked; __u32 is_mptcp; + __u32 token; }; =20 struct { @@ -20,6 +22,7 @@ struct { SEC("sockops") int _sockops(struct bpf_sock_ops *ctx) { + char fmt[] =3D "invoked=3D%u is_mptcp=3D%u token=3D%u\n"; struct mptcp_storage *storage; struct bpf_tcp_sock *tcp_sk; int op =3D (int)ctx->op; @@ -43,6 +46,26 @@ int _sockops(struct bpf_sock_ops *ctx) =20 storage->invoked++; storage->is_mptcp =3D tcp_sk->is_mptcp; + storage->token =3D 0; + + if (tcp_sk->is_mptcp) { + struct mptcp_sock *msk; + + msk =3D bpf_skc_to_mptcp_sock(sk); + if (!msk) + return 1; + storage =3D bpf_sk_storage_get(&socket_storage_map, msk, 0, + BPF_SK_STORAGE_GET_F_CREATE); + if (!storage) + return 1; + + storage->invoked++; + storage->token =3D msk->token; + storage->is_mptcp =3D 1; + } + + bpf_trace_printk(fmt, sizeof(fmt), + storage->invoked, storage->is_mptcp, storage->token); =20 return 1; } --=20 2.34.1