From patchwork Mon Feb 26 09:21:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Huettner X-Patchwork-Id: 1904213 X-Patchwork-Delegate: horms@verge.net.au 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=34oce4gi; 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=34oce4gi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.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 4Tjw9f1sklz23qD for ; Mon, 26 Feb 2024 20:21:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 60E404074C; Mon, 26 Feb 2024 09:21:55 +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 P7lw-6EL_WFr; Mon, 26 Feb 2024 09:21:53 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 19F16406A7 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=34oce4gi; 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=34oce4gi Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 19F16406A7; Mon, 26 Feb 2024 09:21:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DEC7FC0077; Mon, 26 Feb 2024 09:21:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id BFE21C0037 for ; Mon, 26 Feb 2024 09:21:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A75FF409AC for ; Mon, 26 Feb 2024 09:21:51 +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 iGuDBABdA8Cx for ; Mon, 26 Feb 2024 09:21:50 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:2612::601; helo=eur05-am6-obe.outbound.protection.outlook.com; envelope-from=felix.huettner@mail.schwarz; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org EC81840993 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 EC81840993 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=34oce4gi; dkim=pass (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=34oce4gi Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2612::601]) by smtp2.osuosl.org (Postfix) with ESMTPS id EC81840993 for ; Mon, 26 Feb 2024 09:21:49 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=DAqurDkXKxL4frOkIoytHHQLp3LmWw134VOop+pdHQA9jlLaqBr2p33pC540PQ9zJs2rhqVcZiRCXXuhIRx3Mny+0oMKSEabKOepCUYrmh6gULXcOPxS4fyTjNvdki4y8/nQLx0vDCRtyvkyGxhf22E33qkk8Lflz42B6aLrgXeYRmsQDDkWczEmjhIemyxFsIG/bAAsYyke5jvwXUNgFqNLeXreldUHF0PiojDLKCi0FjWDlN7wzv7eT61JsH1O83SWWwd+kaKRR/wpgFnUAUVMNKqKuijy2HhpFdzfQFEaxmPE/1Eo9tV568SD6oupJJcFa6f73agGTe6VozZsdw== 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=kPQL02cUojC16ulXp8iL99PI4ubfsMzoa3b25d6hz0A=; b=cdIv3oDfmEisE6QAowXG2VaqyBEH/3Cg1+c7WIAQSAd96Gk4Wc29e+OA4h8G0tcxPQNhHRsI29ef2to08UnMxB2c454CQubkxKRdXWxkzcShL2wPbFDRj8Ir9mEw9zVGdKQbHTJoJ7cxkF5U8xrqVlYB6mS8BEgHm+9Oh/q9yRVbzeQe0kldFkzFQKq6ISiJwS64pWyFhDrZWc9iiSfPf/AcjB63nTk0FyYVhDqX3fXQwkHQ/1MkSOElfcb4njlCcyi6cTN4n06Ovwf5Wz3z+PtYVeLcUGux+dICXVWku1ZiWXkp+GUUFY2vqDhtCX0PYSCgC+urS4kUaEO0Ic1Kjw== 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=kPQL02cUojC16ulXp8iL99PI4ubfsMzoa3b25d6hz0A=; b=34oce4gi79IpPxfP7xcMcuS4FIieCxq+arzGG8YcWl61v5Y+zMLLnoTIs1rsF1PiJOBwiaagUrgMQINogHVzHf7NLUBybJSrCSyl30NVy8WZBsN1itcHWJpkyyhUVLAI7g9ARbS7Wm/VcOGwbSUtn6sAhLMyUJ2ryqOXkkcf2qKKsqv/WAAizS4rlmz7R+qQgnILQ8teb1yOpxNyP36irKa7pMCJowapdoi4InnJnXF2tpeQ4NweEG/bFTvfxatc7FfKfRWEPPipFF+lB+9cbjqJP9zI1syYodoElg4oEUqKs/Md0ndwPOnGr9KDKUK7XhdBdhjuNXG6yBipPff8Iw== Received: from AM5PR04CA0019.eurprd04.prod.outlook.com (2603:10a6:206:1::32) by AS2PR10MB6896.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5fb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.31; Mon, 26 Feb 2024 09:21:45 +0000 Received: from AMS0EPF000001AB.eurprd05.prod.outlook.com (2603:10a6:206:1:cafe::58) by AM5PR04CA0019.outlook.office365.com (2603:10a6:206:1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Mon, 26 Feb 2024 09:21:45 +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 AMS0EPF000001AB.mail.protection.outlook.com (10.167.16.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.7292.25 via Frontend Transport; Mon, 26 Feb 2024 09:21:44 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (104.47.14.51) 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, 26 Feb 2024 09:21:44 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 5094416 X-ExclaimerImprintLatency: 2476520 X-ExclaimerImprintAction: 0f5a3010b56949d3b75c719eefbf01b5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XZ47p/I72ly+Jx3XCAR9MkGV9NJFrORXxYeELwoPt9+UXNDX7Bh7hZ3TzFt8yqdWrrv1RBYJ2wheaPA/vcR0T2dhGuezG3eIe7WT7HorSHzFGL1B5T32rZEC5RZbueySDd2AAgfKuH7OHsJG23piOe6m7aphyppaNzUW+SgBPEzmW9ZaPbFVnthwKX76cn9wotxiu/S6UTS7+bnaQrS01/kdZ/s+JFPPcIGlFPh8F0KXTgfCfOeYOnpZDFvazlUYx0Fo6UCQfzTh6hbArSsmApnKe1iQBwSN58t6Jug4xt2/pJKxl8WAQVtgFY8ng3XYJG+CXTc6XSSRTCdI/VrV4Q== 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=kPQL02cUojC16ulXp8iL99PI4ubfsMzoa3b25d6hz0A=; b=NDMXOUOl01hC/L+rI2s+1W/XuBij6tPJFCrAQyBwdLHUyFGMn7lUx9WcAOsbhbj5ScOT1/W3n5EUfZwrRihQJlMRX0d8OhxuvTjzdX/ReLaNw9/GZOymPbY8VLhCNJhFExjRDEkUWUrT023uA0JrkNj5JWbhBt4mxNi2n4lu7Owm/HToPuvKMDcuw/2aR8Ga2pejgBc3SA1MkNgOmmFSwRuCCFro9w6kN90lqGtmdoH6LD6tEtfZC0zOjxKUF3zilqdVDDPAzPxkIm1AFZZfowpKYJTC72fDmVL7VPcI3RymNxFYr+pmEwWVde4CzQxz5l1bUh6ZnbfTKxZ0CfBt3Q== 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=kPQL02cUojC16ulXp8iL99PI4ubfsMzoa3b25d6hz0A=; b=34oce4gi79IpPxfP7xcMcuS4FIieCxq+arzGG8YcWl61v5Y+zMLLnoTIs1rsF1PiJOBwiaagUrgMQINogHVzHf7NLUBybJSrCSyl30NVy8WZBsN1itcHWJpkyyhUVLAI7g9ARbS7Wm/VcOGwbSUtn6sAhLMyUJ2ryqOXkkcf2qKKsqv/WAAizS4rlmz7R+qQgnILQ8teb1yOpxNyP36irKa7pMCJowapdoi4InnJnXF2tpeQ4NweEG/bFTvfxatc7FfKfRWEPPipFF+lB+9cbjqJP9zI1syYodoElg4oEUqKs/Md0ndwPOnGr9KDKUK7XhdBdhjuNXG6yBipPff8Iw== 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 GV1PR10MB7600.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:8b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Mon, 26 Feb 2024 09:21:42 +0000 Received: from PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::3cb1:ce2e:b6c:7798]) by PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::3cb1:ce2e:b6c:7798%4]) with mapi id 15.20.7316.023; Mon, 26 Feb 2024 09:21:42 +0000 Date: Mon, 26 Feb 2024 10:21:40 +0100 To: dev@openvswitch.org Message-ID: <8d9feafb2348fe27252a776769b45671a4df4be8.1708939063.git.felix.huettner@mail.schwarz> Mail-Followup-To: dev@openvswitch.org Content-Disposition: inline X-ClientProxiedBy: FR3P281CA0111.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::14) To PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAVPR10MB6914:EE_|GV1PR10MB7600:EE_|AMS0EPF000001AB:EE_|AS2PR10MB6896:EE_ X-MS-Office365-Filtering-Correlation-Id: 6282fd75-0c86-4c47-bcb7-08dc36ac59bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: lOB+G9Y5oCXCF8Xhg/+Hp2PBNvr2ii9TCBUWigWaGTP/NG7ebMT0jj5o3lepjL83a7g+yh9Jm1c4n74GGmlWK/wA7C0PaT/+jtE5drS7RMliSpS6PDExF9LQhzjabzrMyMvIvA0yLvTTIDk4wA4Ng29nyt2PG2cyQKSBfikR9NbeP0HchcJewQKewib6ydpLxjFa5brvL/zscroMKlvVZhh8Kj8nwzd++gprJWSa53JhiX5vWf2kVvGVJrUGxRh5jOy6qPQCYaeElbQSTnAnloz0cu2wOYWFVThCCmaYkHvJOc/5Mqx3BOx3mtkgyqZEcLzExL3X60wDzzPVkAyFU09cP5g/CKW5nwySlE8zMl3YG9dogpTXPPvxs7VOnh3SIS1ShYYV5Mg2R9eACCVTTmInJt6PPJsCoRfWDg4esO/y31pOQgAnmNqq5jJYSyFOh2mV5Wc4UtFDnTXJwOSr/Rrr6Dl3YNYgzQU0MQZ0AMM+O6vtTVAcgcKwaYKHoLc0X8P5yQ3DUWzeWgGBQMEScs8u0+8ejI61gilt2hUkjTWvIG1qeolW65S6xeTiiRMYPg4Mrdlk04OXCl+avikjH4CmpmmiI8gM+6JPgZYjYtFc/610XaHi7UoO1337Gei8P7FczuWBrQEkY181WWhjjQ== 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); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR10MB7600 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001AB.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b3ba6dac-879a-41d1-e5c6-08dc36ac5802 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hm3Gt8mQ7SsH9linKRIhIgP7NZ9VDKXXV2ooH6NdjDAO5BXb182SuZ3d4itsaWYbrMyGS/4QDbE7wq3gDSpW/zdsnXFPVOOjFscaTTQeF8iEwNAAs7eUjHHE3nCwz5gVc/vbB0dLkYQw86tSU3aFRD7S9IDOjgRs935SnNRwqvvNdZhmilPjeHocDBPgvPunPEmKzW/f5HasJenZczSHkGTGz/KssmNB/bv7213so3BRb0Ft7zlWsVNJpiGr5tzhRMxPAxmEDWlcOL22W0TK15eNGXBPasvoEfbm8jNUPiN9WcYxB+nwJRD4ZxoqcbTxgAw54rZ3Pob00EhwC7KqMCNLKShO6SJrKTMJmM5frpiVgDPI5kftuwwIRn5QPJ+57SbUzKA16lm9iyGsGi8ndQfPXoQ0L44iYRBmK295ewFhU7IpJkKGkqmU0jjuzSbvDe3g4L/JG351XhHZhn3elroICVJNnmmkUVNz/fCCZUmSRZu+zYF0qVC7r6oxczYYXXD/PNcRBiY1HuXpsUdNHI45ldp6q3FxguiSSXo4gk9KQADZsH4vdTvo3oqwPnioVcKqIq9YX3leca/lnVF8xx2deAGkmfNkyRZf8TqvnNpZJ6bHnvS5y49My1nhXklD7otqa9yu3Ib/CfsbdRBB+rrNFfG/JLkP7K6U1+sU0wq9o0xV3U36bPwGr+psPbUztxdc4PU3Q+qOWNbnUFja2wZCKagRes151SKgAGKvw+aZL4JEeyoDVmnqnFw8aeS9 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)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 09:21:44.4368 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6282fd75-0c86-4c47-bcb7-08dc36ac59bd 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: AMS0EPF000001AB.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR10MB6896 Subject: [ovs-dev] [PATCH v5 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. Signed-off-by: Felix Huettner --- 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 | 14 +++----------- lib/util.c | 27 +++++++++++++++++++++++++++ lib/util.h | 4 ++++ 3 files changed, 34 insertions(+), 11 deletions(-) base-commit: 166ee41d282c506d100bc2185d60af277121b55b diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index bf91ef462..51bd71ae3 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -6427,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..f5b2da095 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 */