From patchwork Mon Mar 11 13:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Huettner X-Patchwork-Id: 1910453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TtcjH6zy2z1yWn for ; Tue, 12 Mar 2024 00:16:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B847940605; Mon, 11 Mar 2024 13:16:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NEmhRuXSZhKS; Mon, 11 Mar 2024 13:16:00 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 241A7405BA Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 241A7405BA; Mon, 11 Mar 2024 13:16:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 00E1CC0077; Mon, 11 Mar 2024 13:16:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 83B68C0037 for ; Mon, 11 Mar 2024 13:15:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 66391404D3 for ; Mon, 11 Mar 2024 13:15:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I6UwL0Jdzy_N for ; Mon, 11 Mar 2024 13:15:57 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:2611::600; helo=eur04-vi1-obe.outbound.protection.outlook.com; envelope-from=felix.huettner@mail.schwarz; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 52E3D4042D Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=mail.schwarz DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 52E3D4042D Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q; dkim=pass (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=Xu05dj+q Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:2611::600]) by smtp2.osuosl.org (Postfix) with ESMTPS id 52E3D4042D for ; Mon, 11 Mar 2024 13:15:57 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=PsOZy90+iMAmqG091ONHitvatu6nVauDlKoPkHNctyFlUd7/XL6aVHlt6OaVd/Ha4hMCiGQFVNZwuajs+0j1+PblsC1Ido+eOP6SHY3r6l7ho2X1s7AW2JAllW/lQxpwaLuRXbeyUW6PQph44KXDHwfgtfllqvhW2EVuLoQxM0oDpntAbetyUlJ0MT+kZbn8WyV+v/62W2axURb7rVh0ia7tyroBYifQuciyWTKUZJO4gtukfum+bXhZRYS6WCx1YoCcjARBFux9EaYBGLzCImlJOudg0q75TOW9Ju2v3L7JK3DK/Lkv+t7TzAKNNVpnrem1B0XUhuTUcauD8oeOdw== ARC-Message-Signature: i=2; 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=NUCGmVQOlQspclkXZ2REiXDdRlW2O3VRXjNMHxqyz64=; b=lp58qRqI/XC3TC7hAMc3I9MQAE/jajpv+rIBlNJITC4RpjPIFD/upHifnZbZ3xhQHRUnQKxWqOLT9QOKqDRn0Z1DffnCDefZPdNq6Hc71krcMg3+YyDvv+T9Iu2EbjfZxemvtADSjhdgOE4zLCakPEc4DQ1CQRB+HGloDkm6DCwhN9zomFaN7ULRTpta2TJRiJXMLXwyOrmt+XjbboDfTK//I/QHEVwsAVb7OHeRPNJPXDerSubD6WLii6qrQRkq4ilLWSTYeAlrhiJj4W5AR21Y/inW1QQjQM+L7gKZCad2n7/bMubzqDyfH3DTUtMpGZsCQJhxITb2jaBXeJPZwg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 104.40.229.156) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=mail.schwarz; dmarc=pass (p=reject sp=none pct=100) action=none header.from=mail.schwarz; dkim=pass (signature was verified) header.d=mail.schwarz; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=mail.schwarz] dkim=[1,1,header.d=mail.schwarz] dmarc=[1,1,header.from=mail.schwarz]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.schwarz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NUCGmVQOlQspclkXZ2REiXDdRlW2O3VRXjNMHxqyz64=; b=Xu05dj+qjujcigJNXtJCTKQF9zE9fHCzUGtK49DoV/THRHMU1k0nkEczFOkqh1VBFB4ee1gJNA+b6+GQjTJvx9pDaN3mIm0aghzRzcyWXVs27PNK9ijgYvtcb5ACQWdpZVfReNdLhQuHJ7rzzTC7/2BOkFqDQRH56fILX9wxB0d6Jd70ekA1EvulUsHyYKrjIIXd1vceIWEmB5YPHy1BAjj3GIKm7vbtDmE5iV3r1WsPIZsYLUiU/HBYJHD1ibACw78ALLjIm6M5+jDrQRf5Xh/cxD/AoeYBYM6Tzg1BkzS0tgcRDxh+u2l1vul+T9vnL7yIhDBzi1fbxSBLtBYlqA== Received: from AM8P190CA0029.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::34) by DB8PR10MB3814.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:16c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 13:15:53 +0000 Received: from AMS1EPF00000047.eurprd04.prod.outlook.com (2603:10a6:20b:219:cafe::f8) by AM8P190CA0029.outlook.office365.com (2603:10a6:20b:219::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35 via Frontend Transport; Mon, 11 Mar 2024 13:15:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 104.40.229.156) smtp.mailfrom=mail.schwarz; dkim=pass (signature was verified) header.d=mail.schwarz;dmarc=pass action=none header.from=mail.schwarz; Received-SPF: Pass (protection.outlook.com: domain of mail.schwarz designates 104.40.229.156 as permitted sender) receiver=protection.outlook.com; client-ip=104.40.229.156; helo=eu1.smtp.exclaimer.net; pr=C Received: from eu1.smtp.exclaimer.net (104.40.229.156) by AMS1EPF00000047.mail.protection.outlook.com (10.167.16.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.7386.12 via Frontend Transport; Mon, 11 Mar 2024 13:15:51 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (104.47.51.232) by eu1.smtp.exclaimer.net (104.40.229.156) with Exclaimer Signature Manager ESMTP Proxy eu1.smtp.exclaimer.net (tlsversion=TLS12, tlscipher=TLS_ECDHE_WITH_AES256_SHA384); Mon, 11 Mar 2024 13:15:51 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 4588606 X-ExclaimerImprintLatency: 2471221 X-ExclaimerImprintAction: d6b5ef60d6ad4427b37bcde5dc1775c3 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gGMHeEOrjoKsTo7glXw6zV6psod9WYanc98LOHyiLGOGrDbgiqoE/cHoAV8wsxDSPZWByS9rkNY81Dra1V0xfz4J/zf+Ay+V+Z6ZnkHLZPXGipdHmlLO/aLS//GE7eVZpJraHb9Zi0OknW6EuOigTp5Sq/JDLrMImD9mfGzV4OY3vRg+PvNXowmm/Q9A+qrnQsrupz5iyB9MHM7RHnTWEho5A3Tg58JG/dOBbLgAF+kxiwLBkME+velXdeL5RrexMGHbthRNoPe+yx9gTVSObI+G2WHogI2wfc64wERRXepMKtvE/WefeH1iX9k3FgXfz01CYyFg6KeJ1jXZSwGGAA== 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=NUCGmVQOlQspclkXZ2REiXDdRlW2O3VRXjNMHxqyz64=; b=by4BIksHmH+ow0qZbzexIUr+A7ja2mUuA5nkv5uAaEDmkAxfeFTTy7LPFtJzcazUDyyrW3nsdxVf3fFQ14Eb2Ya46uGCTidgNzBSL+Vzs4EAKgmle9/lKEWxUrff6uU9L4IayaPwq+7DPOnfVg10iNAigIgdK749V4jMB6hhoQj/oxW6So57PuAHiHXelCGXQitJIYJOjvV8cnIVne3fpFPNbNnC8ftejMpwEXaq1JU7F36EuZ7+2y1x78kZmiDQpzgVLuTZiGXekPbZGhdOABvsU8+lElq7I3abrIa/1P9g7Cp0w/knwUHyyRo/Ilh0vWzD1ee+K6G30QDF+0f2Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mail.schwarz; dmarc=pass action=none header.from=mail.schwarz; dkim=pass header.d=mail.schwarz; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.schwarz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NUCGmVQOlQspclkXZ2REiXDdRlW2O3VRXjNMHxqyz64=; b=Xu05dj+qjujcigJNXtJCTKQF9zE9fHCzUGtK49DoV/THRHMU1k0nkEczFOkqh1VBFB4ee1gJNA+b6+GQjTJvx9pDaN3mIm0aghzRzcyWXVs27PNK9ijgYvtcb5ACQWdpZVfReNdLhQuHJ7rzzTC7/2BOkFqDQRH56fILX9wxB0d6Jd70ekA1EvulUsHyYKrjIIXd1vceIWEmB5YPHy1BAjj3GIKm7vbtDmE5iV3r1WsPIZsYLUiU/HBYJHD1ibACw78ALLjIm6M5+jDrQRf5Xh/cxD/AoeYBYM6Tzg1BkzS0tgcRDxh+u2l1vul+T9vnL7yIhDBzi1fbxSBLtBYlqA== Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mail.schwarz; Received: from PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) by DB8PR10MB3322.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:11e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35; Mon, 11 Mar 2024 13:15:50 +0000 Received: from PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c69:4f96:2e5d:8aae]) by PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c69:4f96:2e5d:8aae%4]) with mapi id 15.20.7362.035; Mon, 11 Mar 2024 13:15:50 +0000 Date: Mon, 11 Mar 2024 14:15:47 +0100 To: dev@openvswitch.org Message-ID: Mail-Followup-To: dev@openvswitch.org Content-Disposition: inline X-ClientProxiedBy: FR3P281CA0108.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::11) To PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAVPR10MB6914:EE_|DB8PR10MB3322:EE_|AMS1EPF00000047:EE_|DB8PR10MB3814:EE_ X-MS-Office365-Filtering-Correlation-Id: 59eb362d-c17b-4818-e048-08dc41cd605e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7ZpeCOovI94V0X5tgoOnrThA5/5mLrlLiI2My7TwkMFpBVfBapOOrytJ1JWpIL22GCMjricXF8zrEIPYEo9pB3tCMH0OBoqjfZ02229IPv2WBAtTV7VfyWQaRgJxy0BWhvp90n2xxanwK0q4nytFZzE8hAJ0Ntik3LfzUyT4Bo3FpC4SAl6uXNzso2dtzcbqypJVHDQegEybEH1bkNvlmsruOq1+GvAmI13HmVviqu8RKXIrdzk40UP6x2loJmc9qdStx8+BO6hZJwEUbFyLBTDTJCyRtLMmuXBBKTaB4FCsB6JpF1BWPrHP2bIRRkBQptvcE5bcMpeHmHtHa9jXaa4m+tMYPp1v3DAMsv1rawPE+eWD2V5RDv8P1LYJ6CwYIWbrnTaVpa77OKkNlICNYa4tM1wZqPTK4tbyhsPUKdNY8ezU/QmmR2dLi9CILL8e2rJkr/xvp7Cu+Esz927n1W4YXaPNXhZm6iFRJrxUxcbQS30L/Bk0JarCSA4k67A4cU+8V6Dv+3uXp2MTrDw8qUnMSsymveIFyWVRhQ9BHJq1AupxxULjRQi5MgWNe235IcR+AEvQihPPWzTnVSXSDd0yUL5VCYGW78aRqwm3Ogd2Fjm7gaKzWlYrZNzq0dUECL4zz1PJRHV2hK8lv1v+n71zUTu3P5lxiuhnpt3bsnQ= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR10MB3322 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF00000047.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 35e57883-a4dd-4105-c1fb-08dc41cd5f1d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qGgNqR31toY2Rx1HcFwPVC/gAv23rzdvU4vXNE3EiL1BFJBnX5pvLbkkirOtdezsWC3L6oMcav0Z3+48OfpM28ZaYuLY2wxlRHkiIGt9bkFKdyY9AVr3+Z0ToYiyIeR21mKPmPU96jbks99Ljv8NA2RpQF1zDfHpar6VeMNSg542eMTRMk3DmOHPCYt6bYgaoXaNY+zSj74GX+74lKcLTZ6qcp4YOY4pBYsqiI+oXAw6tsXd06uAqu8TJJEuIEEwjgTv9CT6XVbmC1PIuFMxZ/d8+O87jo9Hn+IACq/FB6qCdAE4pfxgEqnjMp5pcmxP+T3IOIs94Ct6aJzcya4pfRMxiBiXYvSSs6fCuS/7B1mP8kZKeQWhjgkq8JrGAHxQwoTmyoUHdGncfJwti8vEowLvrel5EFvHc3fgDXf2JUMgytKw0quoicvZ5xC8GH+GYUk0DJVcouxYT4NnhUIsjoR0IkN47EFH7xeVop9KictRMjZ7w0/8Rq4RJ8+88y+79VFAJTCJUOfQZGSWNVH8bPVFYvV/6DKy4zjpS4RbckPHd75hWqyI25Y8I90aD+gSnyRz7HRVe+QsYpPp7m0RsTlaNqIgg58kjlFzyyuz7KWT9/0dP5IggNTg6fM719BStB6L8vzA12Q+L4uQH1ckOGevVOf0qACwX7VExrsXC00CfUBCndASQnsYJWha8sAzq4iF7u5z3BENkJdZrO0HtV/jchMlGE2lnYNwVLXhZOkhwob6hq5zFyYzrH9Yhe+z X-Forefront-Antispam-Report: CIP:104.40.229.156; CTRY:NL; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:eu1.smtp.exclaimer.net; PTR:eu1.smtp.exclaimer.net; CAT:NONE; SFS:(13230031)(376005)(36860700004)(1800799015)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 13:15:51.7730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59eb362d-c17b-4818-e048-08dc41cd605e X-MS-Exchange-CrossTenant-Id: d04f4717-5a6e-4b98-b3f9-6918e0385f4c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d04f4717-5a6e-4b98-b3f9-6918e0385f4c; Ip=[104.40.229.156]; Helo=[eu1.smtp.exclaimer.net] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF00000047.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR10MB3814 Subject: [ovs-dev] [PATCH v7 1/2] util: Support checking for kernel versions. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Felix Huettner via dev From: Felix Huettner Reply-To: Felix Huettner Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Extract checking for a given kernel version to a separate function. It will be used also in the next patch. Acked-by: Mike Pattrick Acked-by: Eelco Chaudron Signed-off-by: Felix Huettner Acked-by: Aaron Conole --- v6->v7: none v5->v6: - fix ovs_kernel_is_version_or_newer returning false if major and minor are equal (thanks Mike) v4->v5: - fix wrong ifdef that broke on macos - fix ovs_kernel_is_version_or_newer working in reverse than desired - ovs_kernel_is_version_or_newer now always returns false if uname errors (Thanks Eelco) v4: - extract function to check kernel version lib/netdev-linux.c | 15 +++------------ lib/util.c | 27 +++++++++++++++++++++++++++ lib/util.h | 4 ++++ 3 files changed, 34 insertions(+), 12 deletions(-) base-commit: 33f45ded67a2d524ccf54cf4bb79a38d8140f14b diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 1e904d8e6..25349c605 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -6428,18 +6427,10 @@ getqdisc_is_safe(void) static bool safe = false; if (ovsthread_once_start(&once)) { - struct utsname utsname; - int major, minor; - - if (uname(&utsname) == -1) { - VLOG_WARN("uname failed (%s)", ovs_strerror(errno)); - } else if (!ovs_scan(utsname.release, "%d.%d", &major, &minor)) { - VLOG_WARN("uname reported bad OS release (%s)", utsname.release); - } else if (major < 2 || (major == 2 && minor < 35)) { - VLOG_INFO("disabling unsafe RTM_GETQDISC in Linux kernel %s", - utsname.release); - } else { + if (ovs_kernel_is_version_or_newer(2, 35)) { safe = true; + } else { + VLOG_INFO("disabling unsafe RTM_GETQDISC in Linux kernel"); } ovsthread_once_done(&once); } diff --git a/lib/util.c b/lib/util.c index 3fb3a4b40..5c31d983a 100644 --- a/lib/util.c +++ b/lib/util.c @@ -27,6 +27,7 @@ #include #ifdef __linux__ #include +#include #endif #include #include @@ -2500,3 +2501,29 @@ OVS_CONSTRUCTOR(winsock_start) { } } #endif + +#ifdef __linux__ +bool +ovs_kernel_is_version_or_newer(int target_major, int target_minor) +{ + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + static int current_major, current_minor = -1; + + if (ovsthread_once_start(&once)) { + struct utsname utsname; + + if (uname(&utsname) == -1) { + VLOG_WARN("uname failed (%s)", ovs_strerror(errno)); + } else if (!ovs_scan(utsname.release, "%d.%d", + ¤t_major, ¤t_minor)) { + VLOG_WARN("uname reported bad OS release (%s)", utsname.release); + } + ovsthread_once_done(&once); + } + if (current_major == -1 || current_minor == -1) { + return false; + } + return current_major > target_major || ( + current_major == target_major && current_minor >= target_minor); +} +#endif diff --git a/lib/util.h b/lib/util.h index f2d45bcac..55718fd87 100644 --- a/lib/util.h +++ b/lib/util.h @@ -611,4 +611,8 @@ int ftruncate(int fd, off_t length); } #endif +#ifdef __linux__ +bool ovs_kernel_is_version_or_newer(int target_major, int target_minor); +#endif + #endif /* util.h */