From patchwork Thu Oct 9 09:21:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 2147524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4cj4D56H5Gz1y1V for ; Thu, 9 Oct 2025 20:23:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6E7D740FB1; Thu, 9 Oct 2025 09:23:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dsmqjRl6fjOd; Thu, 9 Oct 2025 09:22:59 +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 BC2FC40FA3 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id BC2FC40FA3; Thu, 9 Oct 2025 09:22:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A224CC060E; Thu, 9 Oct 2025 09:22:58 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2FB6BC060E for ; Thu, 9 Oct 2025 09:22:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 20652611BF for ; Thu, 9 Oct 2025 09:22:57 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dOCGDoeLD_y9 for ; Thu, 9 Oct 2025 09:22:56 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.65; helo=mail-wr1-f65.google.com; envelope-from=i.maximets.ovn@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org EA1F8611B8 Authentication-Results: smtp3.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EA1F8611B8 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp3.osuosl.org (Postfix) with ESMTPS id EA1F8611B8 for ; Thu, 9 Oct 2025 09:22:55 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id ffacd0b85a97d-3ee12a63af1so446581f8f.1 for ; Thu, 09 Oct 2025 02:22:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760001774; x=1760606574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4PAA7sRu7CCMCztvy9RTfPPlxWYUTvM3ZztNpfkIDc=; b=sijHXirpNhC2eIE75ShmwD9tolUVQckZz5wsWkZDSyd8qfcGmtqAR/ieRMsGbzHgNg v/FpyiR7cLq+MvW/jfz0zI752sbaNI4/+vBVRsN05r7tW9SvoYKDFFsrPp3g/EgmUiiQ 7SYKvSQ5Qebh253ZUPQnmgaevczFqB8gqQwrhGcg+FiK5Rc8MMoE5bO634gMwVjS+DQf Kn8MI2KunM9fPKTTIAZVKTMT10u5ovJv/04htoxKMKXtZUv3AB7Yrb38jRocFc4FBtlb 6F9lBUkHhEhic7dZs9vbXeueXnXX1l0YtY/k62sMYb9PEgzN4gsoYdn98sb9fAB7yuSI +NhQ== X-Gm-Message-State: AOJu0YwcrCQf+qex8qFXUVz4K+IFMGcRxetmo2H1MPcd5A+lhMOZVyeK sBViq2x4PWG0r5k1132gQTcimd+eXKsiDPJ6g169/GHb6YB/1ehk5CbNibOewhJN X-Gm-Gg: ASbGncv/tiAwWcDcfF9juglzpgv+6m03IIsHhZ/KrMGnB8e0GOJY3QbT1ichsBEeV5x F4yZqWimiN2zvt2YSSfOYCRk8Xg6d2I2UnzjQPDkOb85qz5zhrFMe6IYfWxNtnf6BMb/bu4QY4Q 6izHokDzoo7YW5iq3DrAewRn7yluRn7zWhOC6ojo6llpd78J2/mqNJn1gJOMvOOEt92exe2ARO8 bgrn1rogHFD5h8fXUY+Lj3Ri1b2bkocZLXNgDXjIk26+5+j3/WYXICl7ArfztUyah9ssEE0Oc7U zxpdYX0N9+bs3MkMJGUWln29cFKy4nKJHv3XJR53Vzxl8qBhw1kzfGCj0NGbR44zb4ui1P55tCq YL51/y0tM7S1dTIBYPdsRkKjo2MsltNxIPJf5lEv1XopbVgo0iwX4G0yuyU7XPcsVduNfyhHNAZ MHn6x8/DASW/Y= X-Google-Smtp-Source: AGHT+IFqn6+Gd1e4vCtlDxdO8CstXcn8zGLdWjYtmja976Xfa3NpV7sA/Qtp2ZKPyKww55IPkJE2pw== X-Received: by 2002:a05:6000:2c0e:b0:3ec:de3c:c56 with SMTP id ffacd0b85a97d-42667177c79mr4437759f8f.16.1760001773641; Thu, 09 Oct 2025 02:22:53 -0700 (PDT) Received: from im-t490s.redhat.com (37-48-48-237.nat.epc.tmcz.cz. [37.48.48.237]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f0392sm34313629f8f.42.2025.10.09.02.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Oct 2025 02:22:53 -0700 (PDT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Thu, 9 Oct 2025 11:21:22 +0200 Message-ID: <20251009092228.382349-3-i.maximets@ovn.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251009092228.382349-1-i.maximets@ovn.org> References: <20251009092228.382349-1-i.maximets@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH 2/6] netlink: Fix build on kernels < 4.1 due to missing RTA_VIA. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ilya Maximets Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Current code assumes that if the rtnetlink.h exists, then it must have definitions for RTA_VIA and 'struct rtvia'. This is causing build failures on older systems: lib/netlink.c: In function 'min_attr_len': lib/netlink.c:832:38: error: invalid application of 'sizeof' to incomplete type 'struct rtvia' case NL_A_RTA_VIA: return sizeof(struct rtvia) + sizeof(struct in_addr); ^ The code structure overall is not great, we should not include Linux specific headers in the common netlink.c. The only reason for the inclusion though is the structure size. We can just put a number instead, as it is already done for all other types. It should never change, as long as kernel uAPI is stable. Structure and the RTA_VIA should be defined in the Linux-specific route-table.c, in case rtnetlink.h doesn't have a definition for them. Fixes: 9d9a99d157f2 ("route-table: Support parsing RTA_VIA attribute.") Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2025-September/053800.html Reported-by: Brendan Doyle Signed-off-by: Ilya Maximets Acked-by: Kevin Traynor Acked-by: Eelco Chaudron --- acinclude.m4 | 7 +++++++ lib/netlink.c | 14 ++------------ lib/route-table.c | 9 +++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 8658bcfcb..369e37eae 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -155,6 +155,13 @@ AC_DEFUN([OVS_CHECK_LINUX_NETLINK], [ ])], [AC_DEFINE([HAVE_NLA_BITFIELD32], [1], [Define to 1 if struct nla_bitfield32 is available.])]) + + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([#include ], [ + struct rtvia x = { 0 }; + ])], + [AC_DEFINE([HAVE_RTA_VIA], [1], + [Define to 1 if struct rtvia is available.])]) ]) dnl OVS_CHECK_LINUX_TC diff --git a/lib/netlink.c b/lib/netlink.c index 446a0679e..fbfc20e7c 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -29,16 +29,6 @@ #include "openvswitch/vlog.h" #include "util.h" -#ifdef HAVE_NETLINK -#include -#else -/* RTA_VIA */ -struct rtvia { - sa_family_t rtvia_family; - uint8_t rtvia_addr[]; -}; -#endif - VLOG_DEFINE_THIS_MODULE(netlink); /* A single (bad) Netlink message can in theory dump out many, many log @@ -829,7 +819,7 @@ min_attr_len(enum nl_attr_type type) case NL_A_IPV6: return 16; case NL_A_NESTED: return 0; case NL_A_LL_ADDR: return 6; /* ETH_ALEN */ - case NL_A_RTA_VIA: return sizeof(struct rtvia) + sizeof(struct in_addr); + case NL_A_RTA_VIA: return 2 + 4; /* struct rtvia + struct in_addr. */ case N_NL_ATTR_TYPES: default: OVS_NOT_REACHED(); } } @@ -851,7 +841,7 @@ max_attr_len(enum nl_attr_type type) case NL_A_IPV6: return 16; case NL_A_NESTED: return SIZE_MAX; case NL_A_LL_ADDR: return 20; /* INFINIBAND_ALEN */ - case NL_A_RTA_VIA: return sizeof(struct rtvia) + sizeof(struct in6_addr); + case NL_A_RTA_VIA: return 2 + 16; /* struct rtvia + struct in6_addr. */ case N_NL_ATTR_TYPES: default: OVS_NOT_REACHED(); } } diff --git a/lib/route-table.c b/lib/route-table.c index 2bbb51c08..ca87ff7db 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -44,6 +44,15 @@ * old headers. (We can't test for it with #ifdef because it's an enum.) */ #define RTA_MARK 16 +/* Linux 4.1 added RTA_VIA. */ +#ifndef HAVE_RTA_VIA +#define RTA_VIA 18 +struct rtvia { + sa_family_t rtvia_family; + uint8_t rtvia_addr[]; +}; +#endif + VLOG_DEFINE_THIS_MODULE(route_table); COVERAGE_DEFINE(route_table_dump);