From patchwork Mon Mar 4 08:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Huettner X-Patchwork-Id: 1907415 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=VsNfBl75; 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=VsNfBl75; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4TpBWd3Dswz23fC for ; Mon, 4 Mar 2024 19:22:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C1B8881FCB; Mon, 4 Mar 2024 08:22:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fKRGrJZKs78Q; Mon, 4 Mar 2024 08:22:16 +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 smtp1.osuosl.org 4BB3E81F69 Authentication-Results: smtp1.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=VsNfBl75; 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=VsNfBl75 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4BB3E81F69; Mon, 4 Mar 2024 08:22:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28CC9C0077; Mon, 4 Mar 2024 08:22:16 +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 4CFC9C0037 for ; Mon, 4 Mar 2024 08:22:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 274B840438 for ; Mon, 4 Mar 2024 08:22:14 +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 ImTYUc_kfRWR for ; Mon, 4 Mar 2024 08:22:13 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:260f::600; helo=eur04-he1-obe.outbound.protection.outlook.com; envelope-from=felix.huettner@mail.schwarz; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org A6D0240339 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 A6D0240339 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=VsNfBl75; dkim=pass (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=VsNfBl75 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:260f::600]) by smtp2.osuosl.org (Postfix) with ESMTPS id A6D0240339 for ; Mon, 4 Mar 2024 08:22:12 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Gq7q2xsqLNPG1J9CJym/v/qcCCTvHvwCp/Q8FJVYo1gSpNN8TvYByEicLz95SnEBvsijiyNDxHRZIPXv+7wcgTvouKaMmLcWawHkBPVzOe+0FYhdPh/MMRId62izu+uSnyA9pE4miTY6MdlRHW9KyUrxCaSjEHpVpbcjlCeqxU46vFFY19Dq6e2l36oBRMso83eLsIkdphW9iFRixTqbrR3rs5B67G1zFaPIVxDnbPinepMJIyXXrZ0mXQWyRKyuaN96LUs4HKzw8SLIBQuBBWVlmfG2vYQ/ean2G7yozYCCIEZbIdHlZZrGitDKTrsEDfMxwFzv46CoRytuaJ9/WQ== 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=IEaQh36jrzyca+/c7pZV/KcdNkL2/uB054wH0fFXt70=; b=OR1MdgkGkLWwW0CG9UbYyuvpmIgZ6V8GJeWL6f/y7gvOo7ECYOkFZb2x56DEBJ6rI5N2zCC/a9QJ1jdid+lB3dfC2RFq9HJzVvwpVsPB2/H4/l2OepAhmjdZrxuVuR/my4250UJ7+Xg8JZFwYZo+qAAT+whBoNFHvrIGJcHYTjJEV3NbK6DV6Ji7MyzZpYTBBTaorIcWeiBKgpvYLZsfswJJREbee2Q6SKNaYWqJoDom7XaD7pX+fAftTNPVWEGocmo5kWHx06nrAf7wJrbN4LpHTWYd0SuEb4auXAfiFrGLhwbuSHdVkL+iAcfeFOkS1CoUA0lTTiyJ1J/JaJeGuQ== 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=IEaQh36jrzyca+/c7pZV/KcdNkL2/uB054wH0fFXt70=; b=VsNfBl759RkL1iDGOIWumZE1XHx8y+Eh/xClbqS/jm6x5syWZet7gcQw/nMP1zOko7ybzwRAwkW6ZOY9c/oIGVfI2wHkxQfwdISX0TV5y7OATArah3BMawk83ihkuqXfyo+8qMXY37hP+eGDW8t2UfpvlX1QVi5XXzLqHaxy7Uq7k6YVbKR1STI0K1iXLkIZm3n4ygBAvTkYv60ietXe5tP6EKfb4j7dCLgTJBTuAX1W9u3TzYe+zF1Kpql8z2r4nUWHqLXvo3p3KPazMeKwEhug5tJW7QBDEHwRItTMWcTe35ta+9P2kWA4erpnTnVZIy35goiS38rpGeOjyPLUEw== Received: from AM4PR07CA0013.eurprd07.prod.outlook.com (2603:10a6:205:1::26) by PR3PR10MB3961.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:4c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 08:22:08 +0000 Received: from AM3PEPF0000A79B.eurprd04.prod.outlook.com (2603:10a6:205:1:cafe::ce) by AM4PR07CA0013.outlook.office365.com (2603:10a6:205:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.22 via Frontend Transport; Mon, 4 Mar 2024 08:22:07 +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 AM3PEPF0000A79B.mail.protection.outlook.com (10.167.16.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.7362.11 via Frontend Transport; Mon, 4 Mar 2024 08:22:05 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (104.47.12.50) 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, 4 Mar 2024 08:22:05 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 4058454 X-ExclaimerImprintLatency: 1556449 X-ExclaimerImprintAction: 332aea3045e54d518210d2a2a5e6e8c4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XTMJQtSlSY4ncAVDV/qPDf0SxZQjQjh2v3x2ow+saMOufkBCuHf38DQ01N8H1/rdZIlcbpaN4wS0tz0JyULoAx40ymclf1O3720l7FZOVO5nhkwnujKb3WQ/ijTDyiiDl9kRo8wRBmah9pWru6X4In45RtxtNYLt0IJdHQNGwi2WA0mI+oNAJq07fBE569rNVRE5EZaIoZe2Rx0XuWc1BGRExOeJzjI+rF0P8u7D6yCH76TJm3soOLeLaoB71T7WfIyeVX9l/J/qZOv/NloVdrRhoThf3iuI/MHKlrmn+TUSXoWHDGb+03ghoc2XwBvicp28TtjGgFPJ2d7wxS6sRQ== 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=IEaQh36jrzyca+/c7pZV/KcdNkL2/uB054wH0fFXt70=; b=J8QOds2R0jMLIMHrsDGHXY8skB94NNq9bqymLTKv0WTpQbEw8eupjM5tJNtiQwAlTeRv/2GYiCqyA5MQZ84zn8vTSMbyfxrOcRdxaJpQ+U8PBQR1fCWQnSqW711wVcC4yYEAITK1ZPxzobWSoSHoxhxP1HteEnwwgEkra5ZF8i6aNl0IP/cqL3KE+hjdtESJ68EVfjCI+nB/pQ9K5bNikYhETOzRwRvJpvVybvq2TtcIUMPj8fsMdtHm4I8YYVddCvQVcvH9Wo1hzyLYtW6ilbUA/K6BwYw2ia8uxxW+5BONfc27Ex/INieHwLlVMJ5H3cuvZyJkmji7bs4o6XddZA== 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=IEaQh36jrzyca+/c7pZV/KcdNkL2/uB054wH0fFXt70=; b=VsNfBl759RkL1iDGOIWumZE1XHx8y+Eh/xClbqS/jm6x5syWZet7gcQw/nMP1zOko7ybzwRAwkW6ZOY9c/oIGVfI2wHkxQfwdISX0TV5y7OATArah3BMawk83ihkuqXfyo+8qMXY37hP+eGDW8t2UfpvlX1QVi5XXzLqHaxy7Uq7k6YVbKR1STI0K1iXLkIZm3n4ygBAvTkYv60ietXe5tP6EKfb4j7dCLgTJBTuAX1W9u3TzYe+zF1Kpql8z2r4nUWHqLXvo3p3KPazMeKwEhug5tJW7QBDEHwRItTMWcTe35ta+9P2kWA4erpnTnVZIy35goiS38rpGeOjyPLUEw== 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 AM7PR10MB3685.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:13d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 08:22:04 +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, 4 Mar 2024 08:22:04 +0000 Date: Mon, 4 Mar 2024 09:22:02 +0100 To: dev@openvswitch.org Message-ID: <7fc55e71ef28fc4575c0005e34599e86aefd7f51.1709537628.git.felix.huettner@mail.schwarz> Mail-Followup-To: dev@openvswitch.org Content-Disposition: inline X-ClientProxiedBy: FR3P281CA0110.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::7) To PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAVPR10MB6914:EE_|AM7PR10MB3685:EE_|AM3PEPF0000A79B:EE_|PR3PR10MB3961:EE_ X-MS-Office365-Filtering-Correlation-Id: cb65f08d-358d-4858-939a-08dc3c242d9d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: m3hsk7lE8G/ImVvQb0+S25Ev6igPaMgBoqD+z0VnWzJu50npDIcp/qwcHdLNRMi3lwitBdCGWBe9EDC+7WCuukSuNKH2/UnaMoHkW7bIgzvMuOujzycggq6IJ0w9hk2AgdwjcqtfWmgdwvuEPacFMUWkPAKApLdC0tJExJzues86+yWHbTvQgofMuTJAt4Mzkvdt09TIX93yEpd9m9UbTem2AqHpDr5NqRAmicvibbs6YmyQjTOYLW6seX7zz5v9rzNrB4oTcNxmsYAMGCiP3Cp5jfdxtahkp4Y+gKzSBiL/dLV4j9/R8xqcLGOl6YPRUBkKXJlYDOuKOK0CbeANEpvW0V6HIEaV4eeDxx6CQdOTMDQdUqyXdq3v0ZCGjBquprC75rMNVvRlhNp+eIzaVYORX+8fCn8BJFf6A0NhDyDskNq2A7Xnv2Ho9tGSHa3M6NCfzPblGB54JZVlKDCR+cQF6xrSosffvNw6SQoQV50hmOudAY3UpEjz06fUZyFGdemh8mJoLaog8nz26FpaDZj3aSIvgkcSsI9tt5lX7Tp1GNdmME2EOfsHXpDPiIOkrE+IVHkbAUyYbklUTBxFLPQnkysEvXLRYmAmLfi6zDguEkHstrrBHzdTMWuQ0+BTp6IDtPs/t3n/uTnPlv0VhfZkihuSZe0Wogcwk142acw= 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)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR10MB3685 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF0000A79B.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a4a0452f-c745-4467-5909-08dc3c242cbb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VkqlnfywdN8dSHOHoNNNO1TTHERO8Jr5v7hQj0dVp3wfTl85EKOSiBiwnuizk/oic4Sw9MQq9NUyilwDyfBJRaqfI9KakHNcpDH9q9rMqCsuzY0CEGEVadaV9o65HTZBm0fol2czTf6LqZf+J7glzUFoYBko/wkVPj3QyWrf2FIgHwY9r14Pt2rGaZS+nsN0KNT29pvWe0HOk7D2rfA4lGHZRactxfrrdU4HyWDl50n+ah1TAB+euCSjsaGAGVVZgC09tl6reHD32AYPpBSuVR5vLfYrjrSBQTNdHOdMKGBqruF1axcVHUwgIWDODvPw8eXK8Ml9hQOFw6Sl/RT539CaJOCWCUh7bIsyL5m0GcQrV/TV2eLAoolsJCbC3BS4JhFKkR0QPKpBoFDU4kC7K1/UOlYCIWtPlLI0j5vlk79NthE0pxhIO09sYppZfKpa9zEuRFK8jKphQu7JrMSs5FsU3Z8pY1EupHg31QW84HfwPVZl8dqfqYeLFeI3qfEj80M4//Ux+DXttoB8HU0JEKlfpNF9JY7AmwJWQcnRDP4/IOh4nGus6bI72QDtwy2LKT8rXuiaNYzZc3eoEReN21A77KFhnF76yozr6IK4mq6zzG1RxiN0dxG9LpOghC824MQlJF9CVU7dKGEqWh6HW41R4pAB4a7ddykiX2Lr7Ozb3oZt7FCQYgux0meGO2pY079kJ3rundb1YTn1gowWtdPG5Z9jHNWZBfLlEhR3nCzHnINMYJm78qEQG2KB7V7q 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)(82310400014)(376005)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 08:22:05.9527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb65f08d-358d-4858-939a-08dc3c242d9d 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: AM3PEPF0000A79B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR10MB3961 Subject: [ovs-dev] [PATCH v6 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 Acked-by: Mike Pattrick Acked-by: Eelco Chaudron --- 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: 436aba68d52891fb5775ec7651282ccf9d04176b diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index bf91ef462..a8424ed82 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -6427,18 +6426,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 */