From patchwork Thu Jul 6 07:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13303288 X-Patchwork-Delegate: bpf@iogearbox.net Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 21E4715AA for ; Thu, 6 Jul 2023 07:48:12 +0000 (UTC) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2043.outbound.protection.outlook.com [40.107.105.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFD3410B for ; Thu, 6 Jul 2023 00:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Edm40UAL0U9BcFCACF0CAyFMC1jBevk53H42ohEUICQ6YUMiZsH54W4KvK4hGpFZTb5Tyd3FZNLIL5730EWyAfMhKRSaGJfHmS+N6HAFzQQtmdkCZGCm1IG6BeO22mkXJKyjFE0ArBdWol8kpvt3iZtoQ83AVcf6nDnjliW2wjlzymKdoFtYpjO3Uiz9soQmvJm9UzQGgOBrWa+tE+bJYj6qeoh/EWd5Z3SCpNki1M0DB9L9gJhCjcfHTrjaiOK1GYIdvjZkB6Nhn5etzVDsywcE0kCmlB3qUCYfUT2ulVd10D4v+hEDGtN76JCckQiN2MzLnmWOZYOcP3ZlLbeB/A== 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=lY3Pgk1uh4FXkQ6a+2ml9sNjR4idpzfAMSUu5Wzp0tY=; b=iWguMhKIUxkIdXbyZc251EeuK5/eycH7cRHF93njur3Q7WXwrwAboO9U+Fk2Phi/sojOr3I7yfX4Px3gYWo1DBWx0D8FmjYaXbFVNyHX5iYFOoxCaG76bxrCcopZN/Gb3Jwge0Ige8PxnBEpcGR/0Q4NP30yLrTcXUKtfIqqPh40f3/PP0YY76rDgvNfCn7DRnT5KjMIVgRO33JHmqqNdbn6q7ecFDhSkjLqqLKFuU9IUTeDEPfvBpszz7644j2joVyZ3EoP42ipXsYbsfscgtn9SoDZBqvKLDbk8hxMrkYye5WC1GYpF2UnEMCK5qBL61fAkblXqOHc7dfVFABtKQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lY3Pgk1uh4FXkQ6a+2ml9sNjR4idpzfAMSUu5Wzp0tY=; b=GFiD+UCNF/p6J7jNV0X3ul+YbeMUBLhaOSEBDJ8NI3nx7/FrvZ4ygeYai0eL0Vau66bNRVqKkZwftPuwxP1Sj376kfG2FXk1nagm7MPgt5rCEjAKgkKdnbGJdO1HEGL3j6pFL16m0J/P8IhpciYi4SnCgRhPin2v9eP7ah2ZKME8en0iCsK/bDJMn1DOQe+L4JDO3nCbRcuZaDej45YWV7sZktd1Jt5kEMM8cVuCSq0C55DYaOo1iLbQ746sSoOjSVyiDDs1RlxSTLHWEMt2btiC154FjYcUXyCvD8TH96lCN7PTAoQ/wNohKOyNop3Vdcypk8L68He40Gr9vVM0EQ== 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 AM9PR04MB8437.eurprd04.prod.outlook.com (2603:10a6:20b:3dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.17; Thu, 6 Jul 2023 07:48:08 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::423a:a30f:5342:9d35]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::423a:a30f:5342:9d35%6]) with mapi id 15.20.6565.016; Thu, 6 Jul 2023 07:48:08 +0000 From: Geliang Tang To: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: Geliang Tang , bpf@vger.kernel.org, mptcp@lists.linux.dev Subject: [RFC bpf-next v2 3/8] net: socket: run sockinit hooks Date: Thu, 6 Jul 2023 15:47:27 +0800 Message-Id: <5f76da0bea3453db04bb07399b4b1c9ce4859e31.1688629124.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYAPR01CA0163.jpnprd01.prod.outlook.com (2603:1096:404:7e::31) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AM9PR04MB8437:EE_ X-MS-Office365-Filtering-Correlation-Id: 08acf7c3-d227-4430-1b77-08db7df5571d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9qzI/BVWYR10dX3h7y1I5eSHsscUASv92DSZPzKc2tFdu3M0Zz6rHmfFTua8wItuOmQgv1+puDU4rRHACp5F4/eKDVCR+XcHDzFpAPmyxqqRq5i3MQj9kzpONBXB7R0AhQqwgmrF4LSMPxA6YE877wdEqrcovLKs0M1G+Xxf2sH6fup8ixE+aqW+mFnmB2yzB4gCFpAlVisCDp15Teh3kNIRYBePXfvq8sd2pI1iCRxyhwn5ZnEeWAwJfjyuf8ypC9OOjajat8vHl9Y7uxJec4Pt8KDwRHY/zjP4d8P73BOtFN+dAr1FIQax5hhNYFAjBrWdVp/7De6L9eE1QcbSx1VbyWnCMvDzkAi7U4OuJTQ6BTeFUlQqsxC0yH3LqY2Our52TqKx1UschfXCtGwvBaQL3MDlvcDJ+GRrhvrtiAfS9OVWLVRkwKKwCy3MEJtnzOkvPx1JRTn+beBlLsY+/uf9dKJojrtNb6JrH81/YfRy5Y/MoeR47zSzWEGHzxriiVv4zlm0PJ9nQP66vQ0CAwPaMCr/wGf8YdESUJaF8utRtq4y51yJYyoug6cMkuD0u+SGKKt33naHu3EWr8DQ3LCXYEKa5/iyylC+EGVX6YXOk91oPr+eyLX+UiAa7QgY 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:(13230028)(396003)(346002)(376002)(39860400002)(366004)(136003)(451199021)(6666004)(41300700001)(7416002)(5660300002)(110136005)(36756003)(4744005)(2906002)(44832011)(8936002)(316002)(8676002)(6486002)(66476007)(66946007)(4326008)(66556008)(6512007)(478600001)(86362001)(38100700002)(186003)(2616005)(921005)(26005)(6506007)(13296009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qSb1Ja9ErQtVzwdwbwWXqMIXV18qhANxEleRUBJvGvOXLcPAQMnNrNuTnN9q2JzCSewGZPdep/atGHQmD0yTdnHRxRK4tYBvhpNE8fQN3Krk5XfE8yE//kxGgJ9CqPel0ZYe7VaO8V7Jcpzoclk6AlWzxGQLdHJ7WGuOKxBQEmxQH5mCLs3QXgIsCi6EjBVcLytaBxfx5Ft0NioKdXK9MBdzZET5xDHl5c9OVI8g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WiYDRzBTYyi2e9RCtuEE/M3ihQojWEghrBtTU8vM8MNupyxI6WM1ppUUMppM7cFr1aaB4VcSsmlyixb2t2JGTFTflfRk35jhdzfqaKRNKffsLk4+KgbttJmejkUgHRqx7AY3mKUgatTzzmYe75IlD0eAW3PhRwLhQbD8owVYxAnFXJR31EcsxuN5sXJMabwrBDMV35nxiePHRbdSsTeDF922uZs36L38lKuO5SyXxuyaVMQ0W1w0+oXeGYFuvAtKiA1qz3lAHoI5dcJuqCQyW8sXvbUStaSuWJmwx4Wtx1MU/Bdu X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08acf7c3-d227-4430-1b77-08db7df5571d X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2023 07:48:08.6540 (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: TxjYrJ79kWDYvR6fHg0oUR7krpfp1l3Cg1aBKysiLEgn7KSmlorKMM+x4Xqj3+Y7UC6ipT3z++4KVQg/1vE7Wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8437 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC The arguments of socket() need to be changed sometimes like the MPTCP case in the next commits. It's too late to add the BPF hooks in BPF_CGROUP_RUN_PROG_INET_SOCK() in inet_create(). So this patch invokes BPF_CGROUP_RUN_PROG_SOCKINIT() in __socket_create() to change the arguments. Signed-off-by: Geliang Tang --- net/socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/socket.c b/net/socket.c index 2b0e54b2405c..27b423e1800f 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1469,6 +1469,12 @@ int __sock_create(struct net *net, int family, int type, int protocol, struct socket *sock; const struct net_proto_family *pf; + if (!kern) { + err = BPF_CGROUP_RUN_PROG_SOCKINIT(&family, &type, &protocol); + if (err) + return err; + } + /* * Check protocol is in range */