From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B0252C028F for ; Sun, 5 Jul 2026 12:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783254105; cv=none; b=gcYfu+876BYkB49eHLaQEY291vlwYvma8mFU8LXNyUArnH+hPIMO2YtI1NwNmZCQYt2uDVyjR9cAsbDmpll9UcbwbF9xLPS6fi4FH4p46auxUyk+dtJKh6hN0DfGt/gFPOtrXvPhaExt2GFVFYvOjTezNUsOsrIxQSPv3Gw1me8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783254105; c=relaxed/simple; bh=Pb6R4CZff4J/q9L9uSrqpdlScszoYWxWjvJ2iG3WSyo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SzluAPkh2lHBmXZIbKDNvW9GTr2XsGqmf4U98ksmS4uVm8g76gIIG11mD414msv/DLM9e4h6AfUUW7M48o4aaU9oEFgQbWtljAj7xjyIaBUNwV+gv1ui7SY5gGtMyyqp3HBobXaDewMvbsvadNiHkuR5dgI0Dt0Y59dl7//hln0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O3b3tGo3; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O3b3tGo3" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2cc61541f8cso12050455ad.0 for ; Sun, 05 Jul 2026 05:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783254104; x=1783858904; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UN3OYKeWWMdzRLyIltfQXEl4SYdRpzWxkhTOsimbNAU=; b=O3b3tGo3F79LkfLYiOZL1JyEh0GrIQzrI6CUhwtLGpPDc1lG152dhHCR6CU2T3pMca nER6daO02u1eNtGE7Tg8hg8ro9AQfPW0XSPe46Jvyl/Q1SSKK6od/HdZt6vJGYM+CQJM QBBdITrPrzXSYCsV78Dh3oh7BIHRSblh6IhyhViYuRME5mINGdsTIbqYDJ1aaz+tporL fTpCyC7G/FX90ExCGNlVMKqMwQneOf5z9BmjiTr5rRTZoHd0qfitBNWh6B01q9WXsliF Z3O7Q3eGF15L5ceDYF92DrL7gZ0RQlCpg8Vp6QoNd3OwCinsaAuCciKkOwF5ENCJsO6X pV5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783254104; x=1783858904; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UN3OYKeWWMdzRLyIltfQXEl4SYdRpzWxkhTOsimbNAU=; b=o8KCxddPJ7n1ZXcAseGa1QeFcgxYiTT0MQ+VeZaE8x6EKenjl60OTRLKg8nfhlmL89 Nzl/o72IxtWsUtkmen+QCuTUU5fjNGdYDDBYVcCLri7c9lxnFlW+SALw6p1jpBKiWzgx 9qIrEP1edK7YcDn7n2oHG0zXbt5/DUlS0aKNQThRBPlUhHru9onEgfBhufN0RlyAirw5 tJxnALaYAcAYHkcJuTmOQOLsVEwUPNWr6jbTKKDleq3ryYxjxijlVcP3Ee2TNddrQlQy N/zNyVHwAAvzrLH6PgELKh2jiZqTLKkzUqD3AzKxm5lbalnMWlrqq2NpvOjMXs9TEbui tOwA== X-Forwarded-Encrypted: i=1; AHgh+Rp+fzzrQVGOo1lEcKjiE7k3A62Cdj+rfLQeQX1NAAXijQp25J97fPWOPujl4w8704UTpxLVrlka31C4tH0=@vger.kernel.org X-Gm-Message-State: AOJu0YzSexMTOEsrmQjGiEnbU1yebeR2Zj9NFCPZ9UMzXVYp8lXrSoHn ObJ8ESTbjjtuhxRKnmhxMdKGJVnGSMQutZQNXIh0oiIXBd7qtOdfzDwa X-Gm-Gg: AfdE7ckZ83vFVV+J5bnep2q7gO+vAr0NAwTkTBsAUc1SfmOmNburPZrbVqpOmVqbA7u EdDzHbqGk1BDt5ymKKrDV6E7huG4M3ajmZ7G/9v44F3cr2aBLLp90SRX2ElzuE7Y8+TjvOzBfz8 mgnZeqN+hdBxeOd3ZZzzdnGFCS5KXAK+zhAzmUeALNLiLqOHfGUFhsVdhkzgRHLZ5hInT8zVuGU VzoEiLxWOCACXkmNY8jUG/SASCF8n61ceVR+sWpepRWWz7gJULe97TbPPuwXD6xD9TKTfNpPsPv yqd/xU6UOwT0s8FcWMJKRki5dsXDzZbNi/pSAjkkA2CXJsS+ZaRLsSRP8gxOszSPdIuOv1O1g+t muMB6KiRR0tA6tZhjIZmkVYOWiz6yqwYUmUh73FOForVQi7Gkf0ZOGImsQu4e88MUuQqe6BHpFy hseEkOHWYn6UA6FQWcZFImn14/FSZRxsdtUZAofGSRO7OLwxhIumfoMD/V1MDz2tpDnnNd8AC/M CcQF/Ki2iuu47tZ+JMytpFVSiXh X-Received: by 2002:a17:90b:3885:b0:385:3ab:fecb with SMTP id 98e67ed59e1d1-38503abff46mr1735933a91.4.1783254103623; Sun, 05 Jul 2026 05:21:43 -0700 (PDT) Received: from CP-IN-7ZMK5M3.. ([2402:e280:411f:685:c587:ed87:1606:e634]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30f38ee1333sm25795547eec.24.2026.07.05.05.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2026 05:21:42 -0700 (PDT) From: Amitesh Singh To: b.a.t.m.a.n@lists.open-mesh.org Cc: marek.lindner@mailbox.org, sw@simonwunderlich.de, antonio@mandelbit.com, sven@narfation.org, linux-kernel@vger.kernel.org, amitesh.singh@chargepoint.com Subject: [PATCH] batman-adv: fix throughput detection for VLAN interfaces Date: Sun, 5 Jul 2026 17:51:34 +0530 Message-ID: <20260705122134.62809-1-singh.amitesh@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Amitesh Singh batadv_v_elp_get_throughput() calls __ethtool_get_link_ksettings() to determine the link speed of an Ethernet interface. Virtual interfaces such as a VLAN on a bridge return success but with SPEED_UNKNOWN, so the function falls through to the hardcoded default even when the underlying physical device has a known speed. Move rtnl_unlock() into each exit branch so the lock is still held after the initial query. When the speed is unknown, walk the lower device stack with netdev_walk_all_lower_dev() to find the first real device that reports a valid speed, which covers DSA ports and physical NICs sitting below a VLAN or bridge interface. Signed-off-by: Amitesh Singh --- net/batman-adv/bat_v_elp.c | 48 +++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index 6ad6042a..3d4d82c5 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -70,6 +70,32 @@ static void batadv_v_elp_start_timer(struct batadv_hard_iface *hard_iface) msecs_to_jiffies(msecs)); } +/** + * batadv_v_elp_lower_dev_throughput() - netdev_walk_all_lower_dev callback + * to query ethtool link speed on a lower device in the stack + * @dev: current lower device being visited + * @priv: nested priv; priv->data points to a u32 to receive the throughput + * value in multiples of 100kbps + * + * Return: 1 to stop the walk once a valid speed is found, 0 to continue. + */ +static int batadv_v_elp_lower_dev_throughput(struct net_device *dev, + struct netdev_nested_priv *priv) +{ + struct ethtool_link_ksettings settings; + u32 speed; + + if (__ethtool_get_link_ksettings(dev, &settings) != 0) + return 0; + + speed = settings.base.speed; + if (!speed || speed == SPEED_UNKNOWN) + return 0; + + *(u32 *)priv->data = speed * 10; + return 1; +} + /** * batadv_v_elp_get_throughput() - get the throughput towards a neighbour * @neigh: the neighbour for which the throughput has to be obtained @@ -167,7 +193,6 @@ static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh, * ethtool (e.g. an Ethernet adapter) */ ret = __ethtool_get_link_ksettings(hard_iface->net_dev, &link_settings); - rtnl_unlock(); if (ret == 0) { /* link characteristics might change over time */ if (link_settings.base.duplex == DUPLEX_FULL) @@ -177,9 +202,30 @@ static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh, throughput = link_settings.base.speed; if (throughput && throughput != SPEED_UNKNOWN) { + rtnl_unlock(); *pthroughput = throughput * 10; return true; } + + /* Virtual interfaces (e.g. VLAN on bridge) don't report link + * speed directly. Walk the lower device stack to find a real + * device that does, such as a DSA port or physical NIC. + */ + throughput = 0; + { + struct netdev_nested_priv priv = { .data = &throughput }; + + netdev_walk_all_lower_dev(hard_iface->net_dev, + batadv_v_elp_lower_dev_throughput, + &priv); + } + rtnl_unlock(); + if (throughput) { + *pthroughput = throughput; + return true; + } + } else { + rtnl_unlock(); } default_throughput: -- 2.43.0