From nobody Tue Sep 29 13:18:52 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 2F88D2877DA for ; Fri, 7 Aug 2026 14:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111679; cv=none; b=JAZpdx4l+mj678VBWZbjfw/+DVFm0NfBQ0+qrO81nYV0WQexjnfxIkf12YK5lvdqVDSfC4z48SpYQDF96a3XuWnBITxc4XHBIfHP9tdK1MEg7BZFDx53H2Kl8ybSm0NLg2PvOFb4r9mvW6yoXO13NPZqcRA/u8rMrZ/cGLRCgjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111679; c=relaxed/simple; bh=3bCtOifuFc7J3Rr7UUrsOND5iV/KohhwCXR0G0U50ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FRBhBsg1mWOnIlKWbQFVQ2c1GOqHvmEBwf6XPEOF4T/STLzMugmiXuKSKXglpkM5v9U1YPQPF+7C6XFS087c7FkG91lhnKMaRRu+FHjUIecpVBjtVyx/SmidZPdaar/6z55J+Xkx4zsVd3g1OzlHtbYDzwX6LgOPyGtIGoJlPiY= 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=HUav/tCV; arc=none smtp.client-ip=209.85.221.47 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="HUav/tCV" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4731f5ffa74so284151f8f.1 for ; Fri, 07 Aug 2026 07:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786111675; x=1786716475; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VdpvcqvwrdqUs5sE0SeDLQ9ugUxBd1IjKy13SBkkSv8=; b=HUav/tCV7ilSX34LG5upW1qkX86YqLA3UUCSLMkpafEFwO0pkqcccScP6jl993A806 teYcaYzOhSC5wuQdMpXmvLpNBCGOIEiZnZzn9yQOog4Wqf46c8X+sTjsG6DigAPOoSMS oLfVBFafg1uia5m8t7sod8l7yVsJuJtIMgxtasYidQpUyZ4inQdnfXXJmy08XQC4Cl5W lUud1bh4vy1cOY4GTBFcp9LPH2vO155CkYTa+wfDO0alFrGNWtaVwARnpd09zNbpwDcS H8zbaQBUSy5YlWnKNBR2dNAGURqO2eR5BN6sjGNKwhpj1h3U6bgNxLs3R+IcU6corNAM GTxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786111675; x=1786716475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=VdpvcqvwrdqUs5sE0SeDLQ9ugUxBd1IjKy13SBkkSv8=; b=PA+SghH+QPFxnMu8OoK6dvjgvUkZ9l400cTm7YHDfQQmAAcu/5X7dNC5YHPuo/c62U EWfR8VooNsOLN5URjez8wsEpQe+rFzYNswSsp4eIpMqylpsMunMs634WUNYKz0XQPoff vFZNt1ZH2U2uBOf6byTgF4D3Cp8ns+w+s2htGDQR/xuUe+6CUczIZAQkwBIUSxG5bNqR aSZ+xhgSyIcjEp8WvjvadbtV2uUVHnz713YkuP94CY6anOqmJHJcxIUSMtrfdpm0AaPQ M9V38Ej79QFm5z6Z5UOB2e7Ra51YsAyH7n3nPyPto4HSnJsZFi/QSIHEN0Gd3DFDoukM n5Fg== X-Forwarded-Encrypted: i=1; AHgh+RpIHNi8Sa3u/KwRJOYoTjXbj5/nnHX/wFMfYHOEtBIL/HbdE3E1m82Ardw22IpxY4NcRPu28Q9CY8LxWxM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywc+VtURima2SuO9beg1fOsJ70wyigxBlymfsyDSnRVLKunkf5x 8LVnZOT84zYwBdYc9V9k122ysYVHHSLSQHwbqnBc0HxwB3Dzq9IJy2a9 X-Gm-Gg: AR+sD115EG7CNSGeb7Cxg0e8ZIbJWHKKFp8Wl4+nF8PZpA9ovW/OCQYFqXotjGplAzy 17Kuz4OvrIGiRM7LHEhHFKahvFXjg7+VuZSgDb56iV+YhA4+VKeacNj/QhXdAbZyIfk5xyU4o5d /XqruAdApKKdXeMarwIOCgAG3QWPgoFbz7onqEIdRmkIcILEzuyHjyuKsLqwey0sKqRd437KBrb RccrOg3vp4DKIEJ/15jC7hjoWHSjrEOFa9HclwNEuv119Sc98QUpOBN5lMtTfC7ZDRzcJhjXF8F TgOeo49Qcn6bB0qlq1R8o1iVXrS6cxdHM5i44JWbwSD8J1eJrkba1148eUzDXws/LbYD2iYmFqE YE3tqR+0Mk4xhRRdUhHSyjWp9OODiegk7uA/86sIbcHSwGIOf8wvvBBfBZ0RMnmFB7Y/dceVdRS P5JtL9jMkgxx07xZho1yKMULm9R7GiSu+/8nnYUHW5aIbjQ0kmh197yCCnD7qcQZylP62D+nx4+ EE8FV3I7C7iyL1/5aKv5vnoc7O7heZPGNRwvaOfbccL3oBSFKJuU2vFU7FbybE6+YBBWf5vcDPg sLi3f/rNScfT/XLeFcENrzHYPmbL/B7CDQ== X-Received: by 2002:a5d:5f83:0:b0:47f:80e0:53bf with SMTP id ffacd0b85a97d-47fec5322c9mr17563757f8f.3.1786111675024; Fri, 07 Aug 2026 07:07:55 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-201-133.77.179.pool.telefonica.de. [77.179.201.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021506c0sm5980064f8f.11.2026.08.07.07.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 07:07:54 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, shuah@kernel.org, kees@kernel.org, petr.wozniak@gmail.com, qingfang.deng@linux.dev, fmaurer@redhat.com, luka.gejak@linux.dev, bigeasy@linutronix.de, xiaoliang.yang_1@nxp.com, skhawaja@google.com, stable@vger.kernel.org, sdf.kernel@gmail.com, Xin Xie Subject: [PATCH net v5 1/4] net: hsr: fix packet drops caused by GRO superpackets Date: Fri, 7 Aug 2026 16:07:47 +0200 Message-ID: <20260807140751.1351-2-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260807140751.1351-1-xiexinet@gmail.com> References: <20260807140751.1351-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" HSR/PRP process each wire frame separately for tagging and duplicate discard. GRO on a lower device hides multiple frames in one skb, which cannot be forwarded with valid per-frame metadata. Disable GRO and GRO_HW when a lower device is enslaved, matching the existing LRO handling. This is best effort because GRO may be re-enabled and some devices cannot disable GRO_HW. The forward-entry segmentation fix handles plain, trailer-free GSO skbs that still arrive; device-specific fixed-on GRO_HW output is outside this guarantee. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamle= ss Redundancy protocol (HSRv0)") Cc: stable@vger.kernel.org Signed-off-by: Xin Xie --- include/linux/netdevice.h | 2 ++ net/core/dev.c | 15 +++++++++++++++ net/core/dev_api.c | 21 +++++++++++++++++++++ net/hsr/hsr_slave.c | 5 +++++ 4 files changed, 43 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9981d637f8b5..eba2c26a49ba 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3434,6 +3434,8 @@ void dev_close(struct net_device *dev); void netif_close_many(struct list_head *head, bool unlink); void netif_disable_lro(struct net_device *dev); void dev_disable_lro(struct net_device *dev); +void netif_disable_gro(struct net_device *dev); +void dev_disable_gro(struct net_device *dev); int dev_loopback_xmit(struct net *net, struct sock *sk, struct sk_buff *ne= wskb); u16 dev_pick_tx_zero(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev); diff --git a/net/core/dev.c b/net/core/dev.c index 5933c5dab09e..f20d5ab0cf72 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1840,6 +1840,21 @@ void netif_disable_lro(struct net_device *dev) } } =20 +void netif_disable_gro(struct net_device *dev) +{ + struct net_device *lower_dev; + struct list_head *iter; + + dev->wanted_features &=3D ~(NETIF_F_GRO | NETIF_F_GRO_HW); + netdev_update_features(dev); + + netdev_for_each_lower_dev(dev, lower_dev, iter) { + netdev_lock_ops(lower_dev); + netif_disable_gro(lower_dev); + netdev_unlock_ops(lower_dev); + } +} + /** * dev_disable_gro_hw - disable HW Generic Receive Offload on a device * @dev: device diff --git a/net/core/dev_api.c b/net/core/dev_api.c index 437947dd08ed..3ca2515ad048 100644 --- a/net/core/dev_api.c +++ b/net/core/dev_api.c @@ -269,6 +269,27 @@ void dev_disable_lro(struct net_device *dev) } EXPORT_SYMBOL(dev_disable_lro); =20 +/** + * dev_disable_gro() - disable Generic Receive Offload on a device + * @dev: device + * + * Best-effort disable of Generic Receive Offload (GRO) on a net + * device. Must be called under RTNL. This is needed if received + * packets may be forwarded to another interface. + * + * The disable is best-effort: a device with a fixed-on feature (for + * example GRO_HW on a virtio-net device negotiated without + * VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) keeps it enabled. Callers that + * need a hard guarantee must inspect the resulting feature state. + */ +void dev_disable_gro(struct net_device *dev) +{ + netdev_lock_ops(dev); + netif_disable_gro(dev); + netdev_unlock_ops(dev); +} +EXPORT_SYMBOL(dev_disable_gro); + /** * dev_set_promiscuity() - update promiscuity count on a device * @dev: device diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c index 01c73b4b50dd..3cae70754bc4 100644 --- a/net/hsr/hsr_slave.c +++ b/net/hsr/hsr_slave.c @@ -171,6 +171,11 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, str= uct net_device *dev, goto fail_rx_handler; dev_disable_lro(dev); =20 + /* GRO disabling is best-effort: devices with fixed-on + * GRO/GRO_HW cannot be forced off. + */ + dev_disable_gro(dev); + return 0; =20 fail_rx_handler: --=20 2.43.0 From nobody Tue Sep 29 13:18:52 2026 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 7C435318ECD for ; Fri, 7 Aug 2026 14:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111680; cv=none; b=sqHBn1LNBD4Q1dnhHVhtbQ4jKB8Piq3EeFemPeXYuQ+MaXUDKOwAlUOrGyDdvxR0FwSl1YFaS04wD7vzPmHoV9JiEpEp7CipIeJ8AIkzU/ZLfiAapg2IqZ3k6VXK12oOCJCarTQ+NA70yilGvI0Pe5NsBvonO0ZH+NvXdsVmBYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111680; c=relaxed/simple; bh=Xwc5a3uxw4lEHg3LmvnXWJWltn7d5B6P3cO8C3Bm6u8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FuXE6ktd4yRdFAQOvKFES93anOC+XYKhTL4vG9DzMp2XQB6lgQaTfnIGjnwXF5Pjf6wrV7FoP29l6wcTVcsiH5tXuf9Sj8yuh0tPpTuD+Ir5Y2i8JR07J6mznFa8re9xnIOny0muTFXVi4VabQKdbp1e6tkBgA9XbrbrSAoEDJc= 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=b6MrMDqI; arc=none smtp.client-ip=209.85.221.41 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="b6MrMDqI" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47f611b3af9so453379f8f.3 for ; Fri, 07 Aug 2026 07:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786111677; x=1786716477; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gP1cElbhb3V3p02Nhz1yRliDsY/OwAxBtgzUnHt+zho=; b=b6MrMDqIpJeAYDgnXQ1M7zqmUaPQJiwU8tOvN6dOsIKh64PLEh1Zc4L60VHzHZmjbU 6At3+lmNqyTT+GbumRT8kZhKBN2ycCb+r17aQkNNw4i0cnKKAjglmjrn00Yb7h8eZT95 r1IuZm62/peoayDX4AWc0lfchJz9wgKCCzANrSUHKCoql3d2hc4kTVOlDI7QrFYoOurv CNpK8gKyFf6Lh5oTi6FsfA5+NpGidPKi73L9TlLzoLL0g9lHdZ//awgcYQB/p4gQDc5r jm5+Ttwvxhn/WFIAmhFKoIH2UR3Xol0sKfSiSTXVt8DWATbR1L2EUx2TKOTMDiCrpTDB hhwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786111677; x=1786716477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gP1cElbhb3V3p02Nhz1yRliDsY/OwAxBtgzUnHt+zho=; b=NG2BxQjXoyF7gcNLijWxahFHmKQsZoTqgw9CMsPhVP28lR8EEkDIRB6Z2zN0eVVby8 8otpzXSvgumpKjvaIQFmYRHZBb87x3SfXBbYlR4ly8xieBJdMpb6JgEko6+Vf3sWokvJ kgJwj9VkOqiWnlI1uWO+zbRn5fhfmkhpOr6ilvVIdNSGoDXQdTIV4a8a5E/q9U4nurrg kebJInFlMDymcSEg0Kom0XuaUpWfjc3z8XDA3MweEsUZALbjNA6IbTxm9EUAXojAthxy FXxcxqxgPmzqNes6lXVmpCYzPMhQYtvPJiZviJdatShbS1LI2Z0QlbCpvbuEHNW3tX4m v5zg== X-Forwarded-Encrypted: i=1; AHgh+RpPMoyTEXx+tpDMPly+4R7I/KYNolQtcMGXNdh4f/vE5Pu8RgbC6nhoHNoMFfsgvXqZJGu5Ilc8aND5F6o=@vger.kernel.org X-Gm-Message-State: AOJu0Ywoji9zzgIp+ttZkdrQwnP8hyD4QaACSBeK4fvL+gbIN7QhRfwX G6j0RiV6OobVahMqgVjNEkceGuumms+0y1zpMJv4i7iGKW6vzI+0E9wd X-Gm-Gg: AR+sD12Tit4Uo2x8rnqTAXwxo0CgfE7d5COlV7HsD65dQIgmQ+lQ9FftOSFAP63Hduy Sr5FK7Jd6Zrkt+wUh94IuWhoH73QP+YrmvJTbgezYsqH5Q6oK3Hjhmh6VHKiwcsB554oAKfBm3s 5wF68LerMdJ3yg29Gl6o54M59cz8qteUfmNos/ph2FUvmGwXD/+FNjZqS5e+VwCq2zic439w4gQ ePWXMw260KC2f8sWfAu5+wxN3ofUiAxYkbY6Fvw952cl+FyzVdUVO7eXUjkXxR9c3atc9ZfWryK 3bWgRrd9FD9CehXGSLctbawaDuYUFHyL7Z0LiLeSK0Hs+5ZiPZJS+Ja5IfxsVAZifVZmieW8AkL RWZ35qWNmI1mhgF+6qQIHL5ODAqO+tMMMoIQGxM9TrUkY8S9AM0Got7hbMm8/S1KwnUFbu2JiKN CqMfKbC8TsigyoV7LxoY6oxRmYxRpSUgdm9bywCYHTO6cqoa5JsjIQL7T90Uh9Fy7yF2lJNSsCs Zufa0++MCiT4+AviDz5WGL45t6GSauAIG8zTRGRAem0/3y5B2Wn1BsyxS/F4ek7JcsndJ3+QV5I +KnifiUgDk23QQVF/7Iu6Ts= X-Received: by 2002:a05:6000:1842:b0:47f:9256:52c0 with SMTP id ffacd0b85a97d-47fec634ce1mr17647347f8f.3.1786111676467; Fri, 07 Aug 2026 07:07:56 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-201-133.77.179.pool.telefonica.de. [77.179.201.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021506c0sm5980064f8f.11.2026.08.07.07.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 07:07:55 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, shuah@kernel.org, kees@kernel.org, petr.wozniak@gmail.com, qingfang.deng@linux.dev, fmaurer@redhat.com, luka.gejak@linux.dev, bigeasy@linutronix.de, xiaoliang.yang_1@nxp.com, skhawaja@google.com, stable@vger.kernel.org, sdf.kernel@gmail.com, Xin Xie Subject: [PATCH net v5 2/4] net: hsr: shrink seqnr_lock to sequence counter updates Date: Fri, 7 Aug 2026 16:07:48 +0200 Message-ID: <20260807140751.1351-3-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260807140751.1351-1-xiexinet@gmail.com> References: <20260807140751.1351-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" seqnr_lock currently covers the whole forwarding path although only the sequence counters need serialization. Limit it to the counter updates. The old lock also serialized the tx statistics; use DEV_STATS_INC() and DEV_STATS_ADD() for their now-concurrent updates. Concurrently forwarded frames may be emitted out of allocation order, which sparse-bitmap duplicate discard tolerates. The GSO segmentation patch depends on this shorter critical section. Apply both only to 7.0 and newer, where sparse-bitmap duplicate discard is present; older trees require an adapted backport. Cc: # 7.0.x Signed-off-by: Xin Xie --- net/hsr/hsr_device.c | 15 ++++----------- net/hsr/hsr_forward.c | 9 +++++---- net/hsr/hsr_slave.c | 11 +---------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5555b71ab19b..3fd1762d8916 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -232,9 +232,7 @@ static netdev_tx_t hsr_dev_xmit(struct sk_buff *skb, st= ruct net_device *dev) skb->dev =3D master->dev; skb_reset_mac_header(skb); skb_reset_mac_len(skb); - spin_lock_bh(&hsr->seqnr_lock); hsr_forward_skb(skb, master); - spin_unlock_bh(&hsr->seqnr_lock); } else { dev_core_stats_tx_dropped_inc(dev); dev_kfree_skb_any(skb); @@ -335,6 +333,7 @@ static void send_hsr_supervision_frame(struct hsr_port = *port, hsr_stag->sequence_nr =3D htons(hsr->sequence_nr); hsr->sequence_nr++; } + spin_unlock_bh(&hsr->seqnr_lock); =20 hsr_stag->tlv.HSR_TLV_type =3D type; /* HSRv0 has 6 unused bytes after the MAC */ @@ -356,14 +355,10 @@ static void send_hsr_supervision_frame(struct hsr_por= t *port, ether_addr_copy(hsr_sp->macaddress_A, hsr->macaddress_redbox); } =20 - if (skb_put_padto(skb, ETH_ZLEN)) { - spin_unlock_bh(&hsr->seqnr_lock); + if (skb_put_padto(skb, ETH_ZLEN)) return; - } =20 hsr_forward_skb(skb, port); - spin_unlock_bh(&hsr->seqnr_lock); - return; } =20 static void send_prp_supervision_frame(struct hsr_port *master, @@ -390,6 +385,7 @@ static void send_prp_supervision_frame(struct hsr_port = *master, spin_lock_bh(&hsr->seqnr_lock); hsr_stag->sequence_nr =3D htons(hsr->sup_sequence_nr); hsr->sup_sequence_nr++; + spin_unlock_bh(&hsr->seqnr_lock); hsr_stag->tlv.HSR_TLV_type =3D PRP_TLV_LIFE_CHECK_DD; hsr_stag->tlv.HSR_TLV_length =3D sizeof(struct hsr_sup_payload); =20 @@ -397,13 +393,10 @@ static void send_prp_supervision_frame(struct hsr_por= t *master, hsr_sp =3D skb_put(skb, sizeof(struct hsr_sup_payload)); ether_addr_copy(hsr_sp->macaddress_A, master->dev->dev_addr); =20 - if (skb_put_padto(skb, ETH_ZLEN)) { - spin_unlock_bh(&hsr->seqnr_lock); + if (skb_put_padto(skb, ETH_ZLEN)) return; - } =20 hsr_forward_skb(skb, master); - spin_unlock_bh(&hsr->seqnr_lock); } =20 /* Announce (supervision frame) timer function diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index 0774981a65c1..87cd72a1dc65 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -621,9 +621,10 @@ static void handle_std_frame(struct sk_buff *skb, if (port->type =3D=3D HSR_PT_MASTER || port->type =3D=3D HSR_PT_INTERLINK) { /* Sequence nr for the master/interlink node */ - lockdep_assert_held(&hsr->seqnr_lock); + spin_lock_bh(&hsr->seqnr_lock); frame->sequence_nr =3D hsr->sequence_nr; hsr->sequence_nr++; + spin_unlock_bh(&hsr->seqnr_lock); } } =20 @@ -746,8 +747,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_po= rt *port) * So check and increment stats for master port only here. */ if (port->type =3D=3D HSR_PT_MASTER || port->type =3D=3D HSR_PT_INTERLINK= ) { - port->dev->stats.tx_packets++; - port->dev->stats.tx_bytes +=3D skb->len; + DEV_STATS_INC(port->dev, tx_packets); + DEV_STATS_ADD(port->dev, tx_bytes, skb->len); } =20 kfree_skb(frame.skb_hsr); @@ -757,6 +758,6 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_po= rt *port) =20 out_drop: rcu_read_unlock(); - port->dev->stats.tx_dropped++; + DEV_STATS_INC(port->dev, tx_dropped); kfree_skb(skb); } diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c index 3cae70754bc4..aa2154b19c0b 100644 --- a/net/hsr/hsr_slave.c +++ b/net/hsr/hsr_slave.c @@ -73,16 +73,7 @@ static rx_handler_result_t hsr_handle_frame(struct sk_bu= ff **pskb) } skb_reset_mac_len(skb); =20 - /* Only the frames received over the interlink port will assign a - * sequence number and require synchronisation vs other sender. - */ - if (port->type =3D=3D HSR_PT_INTERLINK) { - spin_lock_bh(&hsr->seqnr_lock); - hsr_forward_skb(skb, port); - spin_unlock_bh(&hsr->seqnr_lock); - } else { - hsr_forward_skb(skb, port); - } + hsr_forward_skb(skb, port); =20 finish_consume: return RX_HANDLER_CONSUMED; --=20 2.43.0 From nobody Tue Sep 29 13:18:52 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 B9F9C2EC56E for ; Fri, 7 Aug 2026 14:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111681; cv=none; b=N6vYTCrquhFcJQVepuL5yebI9EkMf1MNdi9EcEKSFebGCbJXk0xBc9bej8QEObNy0sToqhFVfopK6zTrQOCl6eX9SQLXxTn2/sn/b7ZKSOuIDt9BwnF+xp5KRvuvMfHocXF5OmpZzXczVnn8EcSTJqQr3TpYQ0/HBlo58EIW2O0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111681; c=relaxed/simple; bh=6ck7GW7JTZkGApm0lDedydnZ+9IMBNxhLrjVRuo1dq4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UaDHDp+gNSaAogi4cDonXUxlvTx0eQe4A6ahKlLfKi5cuk8sqNS0bj4T/G47uASPTZH1n6V4AE1voU18j0tEDvGHwYAviVNE3pkZpJd5Fb157mUI+02mbyhYDbZz3GOIqSuSu/2EOZRTaXSi1oY0N/0rduOtXmcs5INNeiD4ILk= 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=XBtWHMqi; arc=none smtp.client-ip=209.85.221.47 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="XBtWHMqi" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-47df6a5655aso446902f8f.1 for ; Fri, 07 Aug 2026 07:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786111678; x=1786716478; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oE7F4Cq3TaG660Axwa91NtG4j0CcMsIY14xd/BazRYE=; b=XBtWHMqiTUSwLEC0zn94yBwoAb1Gr+xZCg9+43CiaRKXAuTBvRYcp7eMSQ4qA6Xx2P Hc986h43/hiyhP7PLM9u+n836zIi9D3ehZK07Qxx3NLldEwcUGFXXcg6S2DIsu1Qt3n9 au3oqWvEazQFu613CnLTlDmtYs2owoDVXJo2U1VVfeZXifXuUxuOERZo0vDeMkD/jhea 8EaG4a1scjW2yMK5xpLi+N7qwDl/1mLZMW059FkBCtRCOGoXFz50rcZox9ch0U8fIA5h NS18xbK02Bh+wjRRW2ZpL0S5eCIZkU8yAT16hz1CAsCrM6iFGWGCJaDUgQD4l7ehAJET GpPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786111678; x=1786716478; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oE7F4Cq3TaG660Axwa91NtG4j0CcMsIY14xd/BazRYE=; b=QibscsUJeD8is3iDymtt711qKW5PageEhxrI2KBaca7XTT+9XvpWYhFJd+XeqXAF5+ 1ixkZPA0mv/Y7l5/kM0pD5PQGUHNt5d94C1Lds/u4k56PFZPr9QDShisWzl0Je7kZjGg s2mYJgC24DjB5+bwEo7A64Nj8BTtsS4B7jpwFztp9SgYcQxpVxdRVH6rltG9pgscqG+8 N3K8fpovkyaZ2RF885eNH6gDlQmLPyx1jAZXT/OZznlBN3auY+4QLGOYbC7GUYa9tSPY CASD8ADnvNUUumqWQR1QYhwdcC5o53VAdIvUGdx3/Q0sRayVGR3gLJ06AV3fRZCMxvVp 1m3g== X-Forwarded-Encrypted: i=1; AHgh+RrIOW9jXt7dHMUTDkOeesFCl1OQft6eu6gHFzTJQdMoyq21jzHCB25+JZmMFRwMajxAvn9PkTboppYOF+c=@vger.kernel.org X-Gm-Message-State: AOJu0YwwiZ1QL1BQdWV21GhBZXQ+dykuEdI3lkYb/WxL6/Z8F4xRXJhr 7cMnHVzB1d27dUm3KtUsyvaSX4wGxDORshUonF72+JWLzWwno2QJJjDd X-Gm-Gg: AR+sD11LqaR8Tjc1CD5dwyZK8b4ZEJ+Kw63MEsT6+GOBw8FAp2BoQ0GwcIaTGzYFAcz u2wqNzmcgd2jLScdQ0+3TF+KoU9Bo08b23HmeLbMenGymst8KGGh2Jb6ykO4LP3ZC11PBcfKAPa U+xmUyyoyT6nmjS9ztudrU3VmXy8fK8fL6L7L/x11yGnztP3UKovTLWzyyvYruUWff02OntU5HJ e2N39MesreOmoFw3AgjTTx1oj3p6hY1+5EgNCqIgwRhV0LzxkOuQBbwriu/QnmZn+h9DTYiDCnN fi0dPlRnQ4yoa+e51vbQgSdWUq/dOpiFxjTHW9j2Zpc3Q753qmJBptsf6jN5Fz2eEvytrkcvTeD UT4hJDf5b/3huDf5HdN0MdmkqMwuR/qZObBjOZyo3esr/E3d262NHn7rsewOkumo7d+wdINnbUB ptb8TLp7BKwbg8p+7Hl1L6JTo/9XEyyrEVI0ZUWaQYs4QFuHjA62r3N+tgThtulYDG7dhB1/GfM 5wZpkKMdH82C6I9/MccQN48jbCOIAzCL+dj78MdZHk4oEwHOAY6rS0uCXAA81o+B5IaqKmwVq90 /igr43k6+25KeOd9MahspTg= X-Received: by 2002:a05:6000:401f:b0:47f:7e91:3d55 with SMTP id ffacd0b85a97d-47fec520b24mr18027535f8f.2.1786111677830; Fri, 07 Aug 2026 07:07:57 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-201-133.77.179.pool.telefonica.de. [77.179.201.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021506c0sm5980064f8f.11.2026.08.07.07.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 07:07:57 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, shuah@kernel.org, kees@kernel.org, petr.wozniak@gmail.com, qingfang.deng@linux.dev, fmaurer@redhat.com, luka.gejak@linux.dev, bigeasy@linutronix.de, xiaoliang.yang_1@nxp.com, skhawaja@google.com, stable@vger.kernel.org, sdf.kernel@gmail.com, Xin Xie Subject: [PATCH net v5 3/4] net: hsr: unfold GSO super-packets at the forward entry Date: Fri, 7 Aug 2026 16:07:49 +0200 Message-ID: <20260807140751.1351-4-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260807140751.1351-1-xiexinet@gmail.com> References: <20260807140751.1351-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" HSR/PRP require per-wire-frame tags and sequence numbers. Treating a GSO skb as one frame breaks those semantics. Classify GSO skbs at the forward entry by effective protocol rather than ingress port. Segment plain aggregates and process every segment normally, preserving local delivery and forwarding. Drop ETH_P_HSR, ETH_P_PRP and unreadable aggregates because their per-frame metadata cannot be rebuilt. HSR supports one 802.1Q C-tag, so unsupported stacked or S-tag GSO input is rejected before segmentation. In-tree software GRO does not merge PRP RCT frames because its IPv4 and IPv6 length checks reject trailing bytes. This guarantee does not cover device-specific fixed-on GRO_HW output. Also remove GSO features from the HSR master's hw_features when possible. This patch depends on patch 2 and the sparse-bitmap duplicate discard in 7.0 and newer; older trees require an adapted backport. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamle= ss Redundancy protocol (HSRv0)") Cc: # 7.0.x Signed-off-by: Xin Xie --- net/hsr/hsr_device.c | 2 +- net/hsr/hsr_forward.c | 102 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 3fd1762d8916..248cbb142e21 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -652,7 +652,7 @@ void hsr_dev_setup(struct net_device *dev) dev->needs_free_netdev =3D true; =20 dev->hw_features =3D NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | - NETIF_F_GSO_MASK | NETIF_F_HW_CSUM | + NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_FILTER; =20 diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index 87cd72a1dc65..f42694cf4309 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "hsr_main.h" #include "hsr_framereg.h" =20 @@ -732,7 +733,7 @@ static int fill_frame_info(struct hsr_frame_info *frame, } =20 /* Must be called holding rcu read lock (because of the port parameter) */ -void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) +static void hsr_forward_skb_one(struct sk_buff *skb, struct hsr_port *port) { struct hsr_frame_info frame; =20 @@ -761,3 +762,102 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_= port *port) DEV_STATS_INC(port->dev, tx_dropped); kfree_skb(skb); } + +/* GSO fan-out funnel: unfold super-packets before per-frame processing so + * each wire frame gets its own HSR/PRP tag and sequence number. + */ +/* Effective frame protocol of a (possibly VLAN-tagged) skb, or 0 when + * it cannot be determined or the tagging exceeds what HSR supports. + * HSR supports one 802.1Q C-tag only, matching fill_frame_info(): an + * accelerated tag must be a C-tag with a non-VLAN inner protocol; an + * in-band tag is unwrapped exactly once and a residual VLAN EtherType + * is rejected. Read-only; no state is kept beyond the immediate + * protocol value. + */ +static __be16 hsr_gso_effective_proto(const struct sk_buff *skb) +{ + struct ethhdr eh; + struct vlan_hdr vh; + const struct ethhdr *eth; + const struct vlan_hdr *vhdr; + __be16 proto; + + if (skb_vlan_tag_present(skb)) { + /* HSR supports one 802.1Q C-tag only. */ + if (skb->vlan_proto !=3D htons(ETH_P_8021Q)) + return 0; + if (eth_type_vlan(skb->protocol)) + return 0; + return skb->protocol; + } + + eth =3D skb_header_pointer(skb, 0, sizeof(eh), &eh); + if (!eth) + return 0; + + proto =3D eth->h_proto; + if (!eth_type_vlan(proto)) + return proto; + if (proto !=3D htons(ETH_P_8021Q)) + return 0; + + vhdr =3D skb_header_pointer(skb, ETH_HLEN, sizeof(vh), &vh); + if (!vhdr) + return 0; + + proto =3D vhdr->h_vlan_encapsulated_proto; + if (eth_type_vlan(proto)) + return 0; + + return proto; +} + +void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port) +{ + struct sk_buff *segs, *next; + __be16 proto; + + if (likely(!skb_is_gso(skb))) { + hsr_forward_skb_one(skb, port); + return; + } + + /* Conforming plain-protocol GSO super-packets carry trailer-free + * sender payload and are segmented here: each segment is delivered + * or forwarded as its own wire frame, on any ingress role. + * + * The gate is content-based, not port-based. An aggregate whose + * effective protocol is ETH_P_HSR or ETH_P_PRP cannot be safely + * segmented and is dropped, as is any skb whose header cannot be + * read or whose tagging exceeds the single 802.1Q C-tag HSR + * supports. With NETIF_F_HW_HSR_TAG_RM the lower has already + * stripped the tag, so such aggregates arrive plain and are + * segmented. + */ + proto =3D hsr_gso_effective_proto(skb); + if (!proto) + goto drop_gso; /* classification failure, fail-safe */ + if (proto =3D=3D htons(ETH_P_HSR) || proto =3D=3D htons(ETH_P_PRP)) + goto drop_gso; + + /* features =3D 0: request full software segmentation. tx_path is true + * only for locally generated traffic on the master; ingress from + * the interlink follows RX checksum semantics. + */ + segs =3D __skb_gso_segment(skb, 0, port->type =3D=3D HSR_PT_MASTER); + if (IS_ERR(segs) || unlikely(!segs)) + goto drop_gso; + + consume_skb(skb); + while (segs) { + next =3D segs->next; + segs->next =3D NULL; + hsr_forward_skb_one(segs, port); + segs =3D next; + } + return; + +drop_gso: + DEV_STATS_INC(port->dev, tx_dropped); + kfree_skb(skb); +} --=20 2.43.0 From nobody Tue Sep 29 13:18:52 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 892FE372EF3 for ; Fri, 7 Aug 2026 14:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111684; cv=none; b=Y1UQWsf/muDRp3WWxGeuldtjruJ6Jewdp9mW+Dv3i6kGD/Bl1I8GoYspNKDdHFPChHX08Cmgh7RdtWspwdztUVaNNvchNigd2gXEE1eKX3nKQP7lk0fRcv+xQub/NpVoxNv4m79pkJIAYtnK8VRLmS1f8b6FLQoYkncirN4Ab9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786111684; c=relaxed/simple; bh=6rMezGZAT/1DzOb4Y3EKXCAHfujt1Zo3rGda2dxGorU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FJocsPUhUstKqd5o380T5+uhJQcvgcKR+qPnGmf0cBUiqpQpb4tUILQpCByODdKCXzWO9r5+D1cMvCsK8rEb9TxLbbxbtPwmPCw2YTtKIuAlddYutOa4xP68PI6ZcGkCEJ4g4+FQ2Z38uwUIqrFgtRW7gkea8dvxXRj/YVwCzMc= 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=g1VBvpXe; arc=none smtp.client-ip=209.85.221.44 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="g1VBvpXe" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-47f502ff678so413931f8f.0 for ; Fri, 07 Aug 2026 07:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786111680; x=1786716480; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9iibtAF/E02RhjAbXHr1nvy835Zrtj3KSFTKn1i2JtU=; b=g1VBvpXevGL4ZPSFopr20QW/7NQBglBJxgjUtjbDvRBmUTEbAcKDordpklxmzw4ff8 yn6T/odPNfz1XSE94Z7oNAY9x7XMhFMT9/k5VG8dkWbAY+BrcJA3jEeH43dmuHTO5ZlP 1XZm9Xavyw8IbPPkrjk4T6V2hx2G7gKFWN4cw9QdoBqWgW8yxr206fSmCsgLzrzK5IHW AVeuOGybvTf+1Eb3vBLvaCDlSnp6RhubKE26mjfZD2rJjiA1M3XZSJun8eer4q0Tj/WP 0XGcTbuXMASPT5mSWtuMjDVsvv0NNXd9OMaXcZjmkUhULPR33F8Rp1S/7ah4a5LUDIH0 KpqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786111680; x=1786716480; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9iibtAF/E02RhjAbXHr1nvy835Zrtj3KSFTKn1i2JtU=; b=Wa8ksxfS6wtaRBGduNHXxtW2rmZQJUJHDVZiaq5JpLgXgv8vfzKXpPMK5VCQewRMi7 MbTCHrPgR4VJSLYyU7CN4VvF+0zVYNCPyP5fpAbKmkiIgNUBpZGKK+2GGwebsv6mKjdk 6FiH/GGPjuznBcZ85ki0+G+PKp7c76VoiR1IMB7vHPwiesdDywu1BLxiAMIBAfSmDEZS b15ztGZkpEhTgX9jhOtmQBeCpIeYrApgKsLPzMQSfedIoYz1htefZULA2Eh5AQzvf7cP gDyMWlKK9tQvwLX/GVWSCyxkVqzGNwnO4QjPNFF+dW0sMG1rPfne43KOP5vKDuz6FySz rFRQ== X-Forwarded-Encrypted: i=1; AHgh+RoZ1gIHxgxvEKtXyuLsGKc8wS0vgXTZbbfxnDFPbxERNaKjIgnQ25pmpdej4jQjVis6ml9a2k/VhPA9lLo=@vger.kernel.org X-Gm-Message-State: AOJu0YwocfhmYY/GadueKv3n8Pm+V6qeknx9SvaN4Nq46gJZFaQLqaM4 NNOMIM7+Yg9AQYLokEmIGu1OtaIs2qbX9OwCMNAjsHuJkkd+Bg7hb8f8 X-Gm-Gg: AR+sD10d5ogzHiLj96VAZy4v2JczCAQYgO4wa6utYHIu0OsKm68Gz17TjIGMrFQ4PWL 6euGoavnRAqLX4UJCvhPa32i5ezviDAmz+8l86LKamyng10iFGmw49GICxDmtPxRfuEfFhDYReR mw2iLZhkkYj/kBwM5+Zti0x6MJ3ycFsQMvsG6906IY/pi4h8giNuFthFdGQAuDj0nHqbKRxA4ug bbH7ZeNtU+4OxzjX27meRyY3hbp9/zlsaxb6umealEVJQp1JyMIMPnx9M5CXCjoEkC/vdgUiV26 oY/mVFAbPhiXKm99JtTG5zJOcBZM1V1bZN/TRIMueEbNPiU3pxH7eN1lc/dDPV9dazbtbicKLUA Vl4dWggLwH1NNTcGvbFG0Rd/JBFyAjyEdt3NfUTfFd3IiBId/2TOsCr8Q/9ErRd1+eTJjUCsGBD OOIusqqmyM43iFeA6LL9vOyaNvkaoIAiRtCY1R+dgXDnmRUL2g8EpXwMgbsW2jP2ZuUs6HhV2j0 MKoQiCI9HoWHU46zlr2pFGgKbpHFmTTT9nAUSesF7k+pavhbucJX7j/s35NXhNcnx8eWADzksYp r08wllykuI8/uNFbEIc/se4= X-Received: by 2002:a5d:584c:0:b0:47f:959f:d5e with SMTP id ffacd0b85a97d-47fec487b60mr18228988f8f.0.1786111679215; Fri, 07 Aug 2026 07:07:59 -0700 (PDT) Received: from L-022584.energy.envision.com (dynamic-077-179-201-133.77.179.pool.telefonica.de. [77.179.201.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021506c0sm5980064f8f.11.2026.08.07.07.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 07:07:58 -0700 (PDT) From: Xin Xie To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, andrew+netdev@lunn.ch, shuah@kernel.org, kees@kernel.org, petr.wozniak@gmail.com, qingfang.deng@linux.dev, fmaurer@redhat.com, luka.gejak@linux.dev, bigeasy@linutronix.de, xiaoliang.yang_1@nxp.com, skhawaja@google.com, stable@vger.kernel.org, sdf.kernel@gmail.com, Xin Xie Subject: [PATCH net v5 4/4] selftests: net: hsr: cover GSO super-packets on PRP slave ingress Date: Fri, 7 Aug 2026 16:07:50 +0200 Message-ID: <20260807140751.1351-5-xiexinet@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260807140751.1351-1-xiexinet@gmail.com> References: <20260807140751.1351-1-xiexinet@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a PRP LAN-slave GSO case which verifies that plain aggregates are segmented and delivered locally to the master. Also bound the iperf3 server readiness wait. Signed-off-by: Xin Xie --- tools/testing/selftests/net/hsr/Makefile | 1 + .../selftests/net/hsr/hsr_gro_superpacket.sh | 631 ++++++++++++++++++ 2 files changed, 632 insertions(+) create mode 100755 tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh diff --git a/tools/testing/selftests/net/hsr/Makefile b/tools/testing/selft= ests/net/hsr/Makefile index 31fb9326cf53..0d105476e7c5 100644 --- a/tools/testing/selftests/net/hsr/Makefile +++ b/tools/testing/selftests/net/hsr/Makefile @@ -3,6 +3,7 @@ top_srcdir =3D ../../../../.. =20 TEST_PROGS :=3D \ + hsr_gro_superpacket.sh \ hsr_ping.sh \ hsr_redbox.sh \ link_faults.sh \ diff --git a/tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh b/tools= /testing/selftests/net/hsr/hsr_gro_superpacket.sh new file mode 100755 index 000000000000..ebcbd9fc41ec --- /dev/null +++ b/tools/testing/selftests/net/hsr/hsr_gro_superpacket.sh @@ -0,0 +1,631 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test HSR handling of GRO/GSO super-packets: +# +# 1. Enslaving a device to an HSR master disables GRO on it +# (dev_disable_gro()). +# 2. The HSR master does not advertise GSO/TSO features. +# 3. A TCP stream from a TSO-enabled SAN (which therefore emits GSO +# super-packets) is unfolded at the HSR forward entry. Evidence: +# interface-counter deltas show super-packet-sized frames leaving +# the SAN and per-frame-sized traffic leaving the DUT's LAN ports. +# +# Topology (100.64.0.0/24): +# +# ns_san ns_dut ns_peer +# +-----------+ interlink +---------------+ LAN A/B +-----------+ +# | s0 [0.1] |-------------| d_il hsr0 |-----------| hsr1 [0.3]| +# +-----------+ | d_a / d_b | | p_a / p_b | +# +---------------+ +-----------+ +# +# SAN traffic reaches ns_peer only through hsr0's forward path +# (interlink RX -> LAN A/B TX), so every SAN frame is tagged and +# forwarded by the DUT. + +source ./hsr_common.sh + +san_ip=3D"100.64.0.1" +peer_ip=3D"100.64.0.3" + +# Aggregate counter thresholds for the stream test (bytes/packets): +# SAN_AVG_MIN proves GSO super-packets left the SAN; LAN_AVG_MAX is a +# guard with margin, not the protocol maximum (see do_tso_stream_test). +SAN_AVG_MIN=3D2048 +LAN_AVG_MAX=3D1514 + +iperf_pid=3D"" +server_wrapper=3D"" +active_srv_ns=3D"" +workdir=3D"" +pidfile=3D"" +ns_dut=3D"" +ns_san=3D"" +ns_peer=3D"" +ns_ls=3D"" +rcfile=3D"" + +# Delete the per-server private work directory and reset its +# variables. Called after a successful reap and from the EXIT +# trap, which owns all failure paths. +cleanup_workdir() +{ + # remove only the known non-empty private directory + if [ -n "${workdir}" ] && [ -d "${workdir}" ]; then + rm -rf "${workdir}" + fi + workdir=3D"" + pidfile=3D"" + rcfile=3D"" +} + +cleanup() +{ + # Server cleanup targets only the namespace of the currently + # active server (recorded by start_iperf_server); after a + # successful reap nothing is active. + if [ -n "${active_srv_ns}" ]; then + # exact-PID kill only after RE-validating identity (guards + # against PID reuse between publication and cleanup) + if [ -n "${iperf_pid}" ] && valid_server_pid "${active_srv_ns}" "${iperf= _pid}"; then + kill "${iperf_pid}" 2>/dev/null + fi + iperf_pid=3D"" + if [ -n "${server_wrapper}" ]; then + # the wrapper waits on the server; reap it with a 5s + # bound so a live-but-unpublished server can never + # hang cleanup + for _ in $(seq 1 50); do + kill -0 "${server_wrapper}" 2>/dev/null || break + sleep 0.1 + done + kill "${server_wrapper}" 2>/dev/null + wait "${server_wrapper}" 2>/dev/null + server_wrapper=3D"" + fi + # last resort, namespace-scoped only: TERM the iperf3 + # processes that actually live in the active server netns, + # poll for bounded exit, then SIGKILL any survivor before + # touching the namespace name. A blind pkill would scan + # the host PID space and hit unrelated tests. + local _p _still + for _p in $(ip netns pids "${active_srv_ns}" 2>/dev/null); do + if is_iperf3_pid "$_p"; then + kill "$_p" 2>/dev/null + fi + done + for _ in $(seq 1 50); do + _still=3D0 + for _p in $(ip netns pids "${active_srv_ns}" 2>/dev/null); do + if is_iperf3_pid "$_p"; then + _still=3D1 + break + fi + done + [ "$_still" -eq 0 ] && break + sleep 0.1 + done + for _p in $(ip netns pids "${active_srv_ns}" 2>/dev/null); do + if is_iperf3_pid "$_p"; then + kill -9 "$_p" 2>/dev/null + fi + done + fi + active_srv_ns=3D"" + cleanup_workdir + cleanup_all_ns +} + +trap cleanup EXIT + +check_tool() +{ + if ! command -v "$1" > /dev/null 2>&1; then + echo "SKIP: Could not run test without $1" + exit $ksft_skip + fi +} + +nsx() +{ + ip netns exec "$1" bash -c "$2" +} + +is_iperf3_pid() +{ + [ "$(cat /proc/"$1"/comm 2>/dev/null)" =3D "iperf3" ] +} + +# Bounded reap of the one-shot server: wait at most 5s for it to +# exit, then reap the wrapper and REQUIRE the rcfile with its real +# status. A stuck server can never hang the script. +reap_iperf_server() +{ + local server_rc + + for _ in $(seq 1 50); do + kill -0 "${iperf_pid}" 2>/dev/null || break + sleep 0.1 + done + if kill -0 "${iperf_pid}" 2>/dev/null; then + echo "FAIL: iperf3 server did not exit within 5s" 1>&2 + ret=3D1 + return 1 + fi + wait "${server_wrapper}" + server_wrapper=3D"" + if [ ! -s "${rcfile}" ]; then + echo "FAIL: iperf3 server status file missing (${rcfile})" 1>&2 + ret=3D1 + return 1 + fi + server_rc=3D$(cat "${rcfile}") + if ! [[ "$server_rc" =3D~ ^[0-9]+$ ]] || [ "$server_rc" -ne 0 ]; then + echo "FAIL: iperf3 server exited with rc=3D'${server_rc}'" 1>&2 + ret=3D1 + return 1 + fi + iperf_pid=3D"" + cleanup_workdir + active_srv_ns=3D"" + return 0 +} + +# Decimal-counter validation for the snapshot blocks: every value must +# be a plain decimal number. A parse failure in read_tx_counters yields +# empty/garbled fields, which this check turns into an immediate FAIL. +valid_decimals() +{ + local v + + for v in "$@"; do + [[ "$v" =3D~ ^[0-9]+$ ]] || return 1 + done + return 0 +} + +setup_topo() +{ + setup_ns ns_dut ns_san ns_peer || exit $? + + ip link add d_a netns "$ns_dut" type veth peer name p_a netns "$ns_peer" + ip link add d_b netns "$ns_dut" type veth peer name p_b netns "$ns_peer" + ip link add d_il netns "$ns_dut" type veth peer name s0 netns "$ns_san" + + # HSR tags add 6 bytes per frame; give the LAN legs headroom. + for iface in d_a d_b; do + nsx "$ns_dut" "ip link set $iface mtu 1600; \ + ip link set $iface up" + done + for iface in p_a p_b; do + nsx "$ns_peer" "ip link set $iface mtu 1600; \ + ip link set $iface up" + done + + nsx "$ns_dut" "ip link set d_il up" + nsx "$ns_san" "ip link set s0 up; ip addr add $san_ip/24 dev s0" + + nsx "$ns_dut" "ip link add hsr0 type hsr \ + slave1 d_a slave2 d_b interlink d_il proto 0; \ + ip link set hsr0 up" + nsx "$ns_peer" "ip link add hsr1 type hsr \ + slave1 p_a slave2 p_b proto 0; \ + ip link set hsr1 up; ip addr add $peer_ip/24 dev hsr1" + + # Let the nodes see each other's supervision frames. + sleep 2 +} + +check_feature() +{ + local ns=3D"$1" + local iface=3D"$2" + local feature=3D"$3" + local want=3D"$4" + + if nsx "$ns" "ethtool -k $iface" | grep -q "^$feature: $want"; then + echo "INFO: $ns/$iface $feature is $want [ OK ]" + else + echo "FAIL: $ns/$iface $feature is not $want" 1>&2 + ret=3D1 + fi +} + +# Off-or-absent variant: fails only when the feature is present AND on, +# so devices that simply do not list the feature do not fail it. +check_feature_not_on() +{ + local ns=3D"$1" + local iface=3D"$2" + local feature=3D"$3" + + if nsx "$ns" "ethtool -k $iface" | grep -q "^$feature: on"; then + echo "FAIL: $ns/$iface $feature is on" 1>&2 + ret=3D1 + else + echo "INFO: $ns/$iface $feature not on [ OK ]" + fi +} + +do_gro_feature_checks() +{ + echo "INFO: Checking that enslavement disabled GRO." + check_feature "$ns_dut" d_a generic-receive-offload off + check_feature "$ns_dut" d_b generic-receive-offload off + check_feature "$ns_dut" d_il generic-receive-offload off + stop_if_error "GRO not disabled on enslaved devices." + + echo "INFO: Checking that enslavement disabled HW-GRO." + check_feature "$ns_dut" d_a rx-gro-hw off + check_feature "$ns_dut" d_b rx-gro-hw off + check_feature "$ns_dut" d_il rx-gro-hw off + stop_if_error "HW-GRO not disabled on enslaved devices." + + echo "INFO: Checking that the HSR master does not advertise GSO/TSO." + check_feature "$ns_dut" hsr0 generic-segmentation-offload off + check_feature "$ns_dut" hsr0 tcp-segmentation-offload off + check_feature_not_on "$ns_dut" hsr0 tx-udp-segmentation + check_feature_not_on "$ns_dut" hsr0 tx-gso-list + stop_if_error "HSR master still advertises GSO-family features." +} + +alloc_workdir() +{ + # Allocated only here, long after the initial topology cleanup, so + # cleanup() at setup_topo() time can never remove it. mktemp failure + # is a hard test failure. + workdir=3D$(mktemp -d /tmp/hsr_gro_test.XXXXXX) || { + echo "FAIL: mktemp -d failed" 1>&2 + exit 1 + } + chmod 700 "${workdir}" + pidfile=3D"${workdir}/iperf.pid" + rcfile=3D"${workdir}/iperf.rc" +} + +# Numeric, alive, comm =3D=3D iperf3, and really owned by the given netns. +valid_server_pid() +{ + local pns=3D"$1" p=3D"$2" + + [[ "$p" =3D~ ^[0-9]+$ ]] || return 1 + kill -0 "$p" 2>/dev/null || return 1 + [ "$(cat /proc/"$p"/comm 2>/dev/null)" =3D "iperf3" ] || return 1 + ip netns pids "$pns" 2>/dev/null | grep -qx "$p" +} + +start_iperf_server() +{ + local srv_ns=3D"$1" + local srv_ip=3D"${2:-}" + local candidate_pid + + # One-shot server, no -D: the wrapper records its exact PID and its + # real exit status (netns shares the PID namespace and the host fs). + alloc_workdir + # record the server namespace for cleanup() before + # anything can fail with the server running + active_srv_ns=3D"$srv_ns" + ( nsx "$srv_ns" "iperf3 -s -1 ${srv_ip:+-B $srv_ip} > /dev/null 2>&1 & \ + echo \$! > ${pidfile}; \ + wait \$!; \ + echo \$? > ${rcfile}" ) & + server_wrapper=3D$! + # the wrapper writes the pidfile asynchronously; wait for it to + # appear instead of racing the read + for _ in $(seq 1 50); do + [ -s "${pidfile}" ] && break + sleep 0.1 + done + if [ ! -s "${pidfile}" ]; then + echo "FAIL: iperf3 server did not publish a pid" \ + "(no pidfile)" 1>&2 + ret=3D1 + return 1 + fi + candidate_pid=3D$(<"${pidfile}") + if ! valid_server_pid "$srv_ns" "${candidate_pid}"; then + echo "FAIL: iperf3 server pid '${candidate_pid}'" \ + "failed validation" 1>&2 + ret=3D1 + return 1 + fi + # publish only after full validation + iperf_pid=3D"${candidate_pid}" + sleep 1 + return 0 +} + +# Print " " for exactly one TX record of ns/dev; anything +# else (missing, duplicated, non-numeric) is a hard FAIL. +read_tx_counters() +{ + local ns=3D"$1" dev=3D"$2" + local out cnt + + out=3D$(nsx "$ns" "ip -s link show $dev" | \ + awk '/^ +TX:/{getline; print $1, $2}') + cnt=3D$(echo "$out" | grep -c '^[0-9]* [0-9]*$') + if [ "$cnt" -ne 1 ]; then + echo "FAIL: cannot parse TX counters of $ns/$dev" \ + "(records=3D$cnt)" 1>&2 + return 1 + fi + echo "$out" + return 0 +} + +# Print " " for exactly one RX record of ns/dev; the +# same single-record discipline as read_tx_counters. +read_rx_counters() +{ + local ns=3D"$1" dev=3D"$2" + local out cnt + + out=3D$(nsx "$ns" "ip -s link show $dev" | \ + awk '/^ +RX:/{getline; print $1, $2}') + cnt=3D$(echo "$out" | grep -c '^[0-9]* [0-9]*$') + if [ "$cnt" -ne 1 ]; then + echo "FAIL: cannot parse RX counters of $ns/$dev" \ + "(records=3D$cnt)" 1>&2 + return 1 + fi + echo "$out" + return 0 +} + +eval_counter_delta() +{ + local name=3D"$1" b0=3D"$2" p0=3D"$3" b1=3D"$4" p1=3D"$5" op=3D"$6" limit= =3D"$7" + local bd pd + + if ! [[ "$b0" =3D~ ^[0-9]+$ && "$b1" =3D~ ^[0-9]+$ && \ + "$p0" =3D~ ^[0-9]+$ && "$p1" =3D~ ^[0-9]+$ ]]; then + echo "FAIL: non-numeric counter input for $name" 1>&2 + ret=3D1 + return 1 + fi + bd=3D$((b1 - b0)) + pd=3D$((p1 - p0)) + if [ "$bd" -lt 0 ] || [ "$pd" -le 0 ]; then + echo "FAIL: counter delta invalid for $name" \ + "(bytes=3D$bd pkts=3D$pd)" 1>&2 + ret=3D1 + return 1 + fi + if [ "$op" =3D "gt" ]; then + if [ "$bd" -le $((pd * limit)) ]; then + echo "FAIL: $name bytes/packets $bd/$pd <=3D $limit" 1>&2 + ret=3D1 + return 1 + fi + else + if [ "$bd" -gt $((pd * limit)) ]; then + echo "FAIL: $name bytes/packets $bd/$pd > $limit" 1>&2 + ret=3D1 + return 1 + fi + fi + echo "INFO: $name counter delta bytes=3D$bd packets=3D$pd" \ + "(op $op limit $limit) [ OK ]" + return 0 +} + +# LAN-slave plain-GSO regression: a plain SAN aggregate entering a PRP +# LAN slave must be segmented at the forward entry, not dropped. PRP +# drops slave-to-slave forwarding by design (prp_drop_frame), so the +# consumer of LAN-slave SAN traffic is local delivery to the master. +# Two independent oracles: the SAN-side proof that aggregates really +# arrived at the DUT, and the volume + per-frame shape of the local +# delivery. On the broken gate the aggregates are dropped and TCP +# crawls on retransmitted single segments, separating the kernels by +# an order of magnitude in delivered bytes. +do_lansan_gso_test() +{ + local prp_ip=3D"10.99.1.1" ls_ip=3D"10.99.1.10" + local out san_b0 san_p0 san_b1 san_p1 + local a_b0 a_p0 a_b1 a_p1 r_b0 r_p0 r_b1 r_p1 + + setup_ns ns_ls || exit $? + + ip link add d_pa netns "$ns_dut" type veth peer name ls_a netns "$ns_ls" + ip link add d_pb netns "$ns_dut" type veth peer name ls_p netns "$ns_ls" + + nsx "$ns_dut" "ip link set d_pa mtu 1600 up" + nsx "$ns_dut" "ip link set d_pb mtu 1600 up" + nsx "$ns_ls" "ip link set ls_a mtu 1600 up; \ + ip link set ls_p mtu 1600 up; ip addr add $ls_ip/24 dev ls_a" + + # PRP DUT with the SAN on a LAN slave: plain SAN aggregates are + # valid traffic on a PRP LAN and must not be dropped. + nsx "$ns_dut" "ip link add prp0 type hsr \ + slave1 d_pa slave2 d_pb proto 1; \ + ip link set prp0 up; ip addr add $prp_ip/24 dev prp0" + + # Let supervision frames converge. + sleep 2 + + echo "INFO: Enabling TSO/GSO on the LAN-side SAN interface." + nsx "$ns_ls" "ethtool -K ls_a tso on gso on" + check_feature "$ns_ls" ls_a tcp-segmentation-offload on + stop_if_error "Could not enable TSO on the LAN-side SAN interface." + + start_iperf_server "$ns_dut" "$prp_ip" || return + + read -r r_b0 r_p0 <&2 + ret=3D1 + return 1 + fi + + if ! out=3D$(nsx "$ns_ls" "timeout 60 iperf3 -c $prp_ip -M 1446 \ + -b 2G -t 10" 2>&1); then + echo "FAIL: LAN-slave GSO local-delivery stream failed:" 1>&2 + echo "$out" 1>&2 + ret=3D1 + return + fi + + read -r r_b1 r_p1 <&2 + ret=3D1 + return 1 + fi + + # Oracle 1 - aggregates really arrived: the SAN emitted + # super-packets toward the DUT. + eval_counter_delta "SAN ls_a TX" "$san_b0" "$san_p0" \ + "$san_b1" "$san_p1" gt "$SAN_AVG_MIN" + [ "${ret:-0}" -eq 0 ] || return + + # Oracle 2 - local delivery of those aggregates: volume and + # per-frame shape on the PRP master. The volume gate separates + # full delivery from the retransmit crawl the broken gate leaves; + # the average gate proves the bytes arrived per-frame. + if [ $((r_b1 - r_b0)) -lt 100000000 ]; then + echo "FAIL: LAN-slave local delivery degraded" \ + "(prp0 RX delta $((r_b1 - r_b0)) bytes < 100000000)" 1>&2 + ret=3D1 + return + fi + if [ $((r_b1 - r_b0)) -gt $(( (r_p1 - r_p0) * LAN_AVG_MAX )) ]; then + echo "FAIL: local delivery not per-frame" \ + "(avg $(( (r_b1 - r_b0) / (r_p1 - r_p0) )) > $LAN_AVG_MAX)" 1>&2 + ret=3D1 + return + fi + echo "INFO: LAN-slave local delivery prp0 RX delta" \ + "$((r_b1 - r_b0)) bytes / $((r_p1 - r_p0)) pkts [ OK ]" + reap_iperf_server || return + echo "INFO: LAN-slave plain-GSO regression [ OK ]" +} + +do_tso_stream_test() +{ + local out sender_retr + local san_b0 san_p0 san_b1 san_p1 + local a_b0 a_p0 a_b1 a_p1 b_b0 b_p0 b_b1 b_p1 + + echo "INFO: Enabling TSO/GSO on the SAN interface." + nsx "$ns_san" "ethtool -K s0 tso on gso on" + check_feature "$ns_san" s0 tcp-segmentation-offload on + stop_if_error "Could not enable TSO on the SAN interface." + + echo "INFO: Running 10s TCP stream SAN -> peer through the HSR DUT." + start_iperf_server "$ns_peer" || return + + # Counter snapshots around the stream window. The SAN-side average + # must exceed SAN_AVG_MIN (aggregate proof that GSO super-packets + # really left the SAN); each DUT LAN leg must stay under LAN_AVG_MAX + # (aggregate proof that bulk output was segmented per-frame). These + # are aggregate discriminators, not a per-frame maximum proof. + san_b0=3D0; san_p0=3D0; a_b0=3D0; a_p0=3D0; b_b0=3D0; b_p0=3D0 + read -r san_b0 san_p0 <&2 + ret=3D1 + return 1 + fi + + # rate-capped: the PRIMARY discriminator is the counter inequality + # above, not max throughput; retransmits are informational only. + # Uncapped runs flap at VM/CI edge rates without indicating a + # functional problem. + if ! out=3D$(nsx "$ns_san" "timeout 60 iperf3 -c $peer_ip -M 1446 \ + -b 2G -t 10" 2>&1); then + echo "FAIL: iperf3 client failed:" 1>&2 + echo "$out" 1>&2 + ret=3D1 + return + fi + + read -r san_b1 san_p1 <&2 + ret=3D1 + return 1 + fi + + eval_counter_delta "SAN s0 TX" "$san_b0" "$san_p0" "$san_b1" "$san_p1" \ + gt "$SAN_AVG_MIN" + eval_counter_delta "DUT d_a TX" "$a_b0" "$a_p0" "$a_b1" "$a_p1" \ + le "$LAN_AVG_MAX" + eval_counter_delta "DUT d_b TX" "$b_b0" "$b_p0" "$b_b1" "$b_p1" \ + le "$LAN_AVG_MAX" + [ "${ret:-0}" -eq 0 ] || return + + # success path: bounded reap with the server's real status + reap_iperf_server || return + + # secondary health signal only: anchored, single-match, numeric =E2=80=94 + # any parse anomaly is a loud FAIL, but the value itself no longer + # gates (the counter inequalities above are the primary evidence). + sender_retr=3D$(echo "$out" | awk '/sec .* sender$/ {print $(NF-1)}') + if [ "$(echo "$sender_retr" | grep -Ec '^[0-9]+$')" -ne 1 ]; then + echo "FAIL: cannot parse sender retransmits reliably" 1>&2 + echo "$out" 1>&2 + ret=3D1 + return + fi + echo "INFO: TCP stream done;" \ + "sender retransmits=3D$sender_retr (secondary signal)" + echo "$out" | grep -E "sender|receiver" +} + +check_prerequisites +check_tool ethtool +check_tool iperf3 +check_tool timeout + +# iproute2 must know the HSR interlink syntax. +if ! ip link help hsr 2>&1 | grep -qi interlink; then + echo "SKIP: iproute2 has no HSR interlink support" + exit $ksft_skip +fi + +setup_topo + +echo "INFO: Initial validation ping (SAN -> peer through the DUT)." +do_ping "$ns_san" "$peer_ip" +stop_if_error "Initial validation failed." + +do_gro_feature_checks +do_tso_stream_test +stop_if_error "GSO super-packet stream test failed." + +do_lansan_gso_test +stop_if_error "LAN-slave plain-GSO regression failed." + +echo "INFO: All good." +cleanup +exit $ret --=20 2.43.0