From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796020982; b=Daxezx0V5TRQruqaQGAkzhyf6SvOxXQ0KRXQeLg9iLyDfOyrSzGpolvJ6GdGj5KoJDsC eV2DlvKsmJE2YArIDdf4/stU43afByVanGGmtRGD0U8xVW9GIe1trIAIO3NvinXl+0vV5 vbMs9azgwHl69TorIBiOwc8sH6wCZbHU02O7lIKOG9fmBSGFkhRneqe8QJRHHLwS4lfvM OqnVlW1rYGdGJ7yjcqKoaHpK6lA+v8bK6hhZAv97VxEZ0pjj9AJJw5hx4+ywlqUfJRA33 zN/puom3m1ntu3UA0UoLqLbEHQlemSpBR00s2Gr0rKfocPZIsSMsv8LNpYIZ9X4Ukjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020982; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=SkLqnrOdLl8hNqX0UlE9OZ9A2/AUJIMLpNr6Q/7UHNI=; b=ZxO/PCyB0nL2bhqYIo/Y6fbLXx0AM8k9vGVIfQ+MjH4dJMM79xqOxbfjeKVmeds/psmJ HNhRhx5YM7wpr/C5WNp44Aomx8pvlKNtu+3BY/wIcHdEgvSOyTF6f46vrSVT75uGS8kky hJvJXcgEspVbYIkKI0PF8BQphk/YUkX1VwNDiI3Ds4ifU55sPN0F9BcSCiaqVNapJitlG OqlEDAI6Fwt7HZyLZV9ud6e5t2rjV1pWTbUR4xxoQEhkjVeXt/VTG1ESTnexSVvtLww5T 3AcVvUiOEcxXd7KAE+N7WVkiM/ty0B0UNgH9lnipVlJWej+fw90BrW3WhAMSgB8JzNw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=blockcast.net; spf=pass smtp.mailfrom=blockcast.net; dkim=pass header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b=vDLryEgW; arc=none smtp.remote-ip=74.125.82.176 Received: from mail-dy1-f176.google.com (mail-dy1-f176.google.com [74.125.82.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82EE660A261B for ; Mon, 30 Nov 2026 06:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82EE660A261B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=blockcast.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=blockcast.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=blockcast.net header.i=@blockcast.net header.a=rsa-sha256 header.s=google header.b=vDLryEgW Received: by mail-dy1-f176.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso2843960eec.0 for ; Sun, 29 Nov 2026 22:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1796020982; x=1796625782; 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=SkLqnrOdLl8hNqX0UlE9OZ9A2/AUJIMLpNr6Q/7UHNI=; b=vDLryEgWyYj6yuqpprWnn1N9kVq2WEi2bTXfGpgyETLcLUOKEleD1JPOKfLkCE7S/+ Vi9A4YadzpnWVlSMHx/EMUiZzkyK8sThxK9ecw5pnP1Ls2fS2EeBwt3KHO8Ws3R9ESOA jMIlmcowhzqj6vrw+FosGBnn29tTyzpGmjI+njK4NSFZy2rXtQ77vMgXyVRHaZnXBuSN 57R4XCsZhHIM4TdNF0qNwo21rmTQdpCQmCmUf3wW+w2G1Qg3JOUzvgE99y/hodnD8qIH v9B9/33DV9BA5MQi5MBV91wJ3xmPylR6jby/6mQbIE+lTOeuK7auz1nzC/R80nmnF1fe zqFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796020982; x=1796625782; 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=SkLqnrOdLl8hNqX0UlE9OZ9A2/AUJIMLpNr6Q/7UHNI=; b=MPMjGXhIQ1biTDetOoV6kMrm145TI9of+nbUnnrgP4wueTTxCSmvWzvb+O6t4G05kZ sezu6nqMIHltN8v/wf3JSTGAvlmyRJemqTpeY1+c5Z8T3HzNXufFMuoVX0ctVn8p8Jh8 IPQRoscAECuJ256MopjEDj4AkcesRz2oWMyAileW0bU+EpB57Aou1gHjoNzsOuS+4j1c oGvjtAaHJ1sWrlW2c8+1RDlBBaj30dnlaxzKe/efpQjxJptcNPYXrA7KO6hzz1fHfSUx 817XPO9e1VDa9rp5P0Ga9IQE8FxDOoEGzZVxk35AliWoTbBqZg8ADlR5kWbRp+a/mkZr 6+NQ== X-Forwarded-Encrypted: i=1; AL+hErFpknAyqvBVvK19THio8V4b09Xvhz0QdZvje8C9v1zb/Ikaulzs3JVu3lEB8qXdChGiobwnhbTk0+AWPOQ=@vger.kernel.org X-Gm-Message-State: APuU4Z+nHLNkfpe3baB7i+bX2bIURCzCjGwUFQRyqZ4jZ2gf8VjUlvBP sy3wFYkrTAFHdFJwb0kiRSwaTfOn+PyRiDEpNhh2N/grU42EFlQlAw4WP0Q9TBJxeBk= X-Gm-Gg: AZFdTZcVnhU/glA2a/1V15w3hqUMlDLpZ+6SSC5RZa0yqDNoGcjQt9xGAa+O93BuUlR GTxN75a+fjesl/8E8iIMDzdIS/swC3J2SiHWz2htp4UBt/bzipgV6BeaKWD2kz2nM29xoQzWFcZ dWA6T3PirE+hi6MMPm/uuoD7lNdGZqacpcu1mtIHIRTeCiUiU9FC0nR8q69RZvJ6kpNP0YujGZB Mj4VDvZClbtJwFLaGx73QMGx5AA2xUKyNbyCbmHjsCGPFApUzm2R/mQUXvxLTELoGNRN20HOQGT /0x1ClfGImMuE2HUj5kG6EFk8rSyTQ8L/WWTrgj+46HwRqSk3M/w2Y3Cw+XyAOCk153bnVj3ZfB F1Og9goIrQjlSw9U8IAFlBJHMkkgjqOJjiVEZxGDlWRPH2tQgj01juubDopbKwiFoYbjBWZVwo8 Jgvih76bcAIMWyLZpHrBkaCnEXqhLQ72hWFBYXUNDVZb7PLszu7yE5OGrx+U4n0fKk+a2FHxjq7 ZGKTWzae6wCjzTPSLuO66Vx6Rr4wi0l+yCeL3q2IwnMiqb2aNgLkNSbLgf9onUNBfrM0AYGCr7H GpyZlkRyXnjIM6Ozm6PDcVocY9m4Z/3Rx37QE8gP5wWNCIF/X1n+aFdyGfOOta1NNJuLMZdzLWJ RlcaT+FUHdYRMNxQYRcbMRus8ffI= X-Received: by 2002:a05:7300:4721:b0:386:da66:671f with SMTP id 5a478bee46e88-386da66762cmr13069118eec.28.1796020981673; Sun, 29 Nov 2026 22:43:01 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672c6f31sm94744995eec.15.2026.11.29.22.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 22:43:01 -0800 (PST) From: Omar Ramadan To: Taehee Yoo , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Simon Horman , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Willem de Bruijn Subject: [PATCH net-next v5 06/12] amt: size the encapsulation headroom by the outer IP version Date: Mon, 30 Nov 2026 06:42:43 +0000 Message-ID: <20261130064249.1874523-7-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130064249.1874523-1-omar@blockcast.net> References: <20261130064249.1874523-1-omar@blockcast.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The amt device reserves AMT_RELAY_HLEN or AMT_GW_HLEN of headroom and subtracts the same amount from the stream device's MTU. Both assume a 20-byte IPv4 outer header, which is 20 bytes short of an IPv6 one. A relay's multicast payload close to the device MTU would then be larger than the tunnel MTU that amt_send_multicast_data() computes from the route, and be dropped there: an IPv6 payload with a Packet Too Big, an IPv4 payload without notice, as icmp_send() does not answer multicast. Sizing the device for the IPv6 headers makes the stack refuse such a payload first. Add AMT_RELAY_HLEN6 and AMT_GW_HLEN6, pick between the IPv4 and IPv6 sizes in amt_hlen(), and use amt_hlen() wherever the device sizes its headroom and MTU: at newlink and on NETDEV_CHANGEMTU of the stream device. amt_v6() is still false for every device, so there is no functional change. Assisted-by: LLM Signed-off-by: Omar Ramadan --- drivers/net/amt.c | 26 +++++++++++++++----------- include/net/amt.h | 7 +++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index cfd8e0277..c46d73464 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -104,6 +104,14 @@ static unsigned int amt_ip_hlen(const struct amt_dev *amt) return amt_v6(amt) ? sizeof(struct ipv6hdr) : sizeof(struct iphdr); } +/* Headroom the device reserves for its outer encapsulation. */ +static unsigned int amt_hlen(const struct amt_dev *amt) +{ + if (amt->mode == AMT_MODE_RELAY) + return amt_v6(amt) ? AMT_RELAY_HLEN6 : AMT_RELAY_HLEN; + return amt_v6(amt) ? AMT_GW_HLEN6 : AMT_GW_HLEN; +} + /* Snapshot the outer source address of a received AMT message. */ static void amt_outer_saddr(const struct amt_dev *amt, const struct sk_buff *skb, union amt_addr *addr) @@ -3942,10 +3950,10 @@ static int amt_newlink(struct net_device *dev, amt->qrv = READ_ONCE(amt->net->ipv4.sysctl_igmp_qrv); amt->qri = 10; dev->needed_headroom = amt->stream_dev->needed_headroom + - AMT_RELAY_HLEN; - dev->mtu = amt->stream_dev->mtu - AMT_RELAY_HLEN; + amt_hlen(amt); + dev->mtu = amt->stream_dev->mtu - amt_hlen(amt); dev->max_mtu = dev->mtu; - dev->min_mtu = ETH_MIN_MTU + AMT_RELAY_HLEN; + dev->min_mtu = ETH_MIN_MTU + amt_hlen(amt); } else { if (!data[IFLA_AMT_DISCOVERY_IP]) { NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_AMT_DISCOVERY_IP], @@ -3968,10 +3976,10 @@ static int amt_newlink(struct net_device *dev, } dev->needed_headroom = amt->stream_dev->needed_headroom + - AMT_GW_HLEN; - dev->mtu = amt->stream_dev->mtu - AMT_GW_HLEN; + amt_hlen(amt); + dev->mtu = amt->stream_dev->mtu - amt_hlen(amt); dev->max_mtu = dev->mtu; - dev->min_mtu = ETH_MIN_MTU + AMT_GW_HLEN; + dev->min_mtu = ETH_MIN_MTU + amt_hlen(amt); } amt->qi = AMT_INIT_QUERY_INTERVAL; @@ -4092,11 +4100,7 @@ static int amt_device_event(struct notifier_block *unused, amt_dellink(amt->dev, &list); break; case NETDEV_CHANGEMTU: - if (amt->mode == AMT_MODE_RELAY) - new_mtu = dev->mtu - AMT_RELAY_HLEN; - else - new_mtu = dev->mtu - AMT_GW_HLEN; - + new_mtu = dev->mtu - amt_hlen(amt); dev_set_mtu(amt->dev, new_mtu); break; } diff --git a/include/net/amt.h b/include/net/amt.h index 117515f67..1a8f0dbb4 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -434,9 +434,16 @@ struct amt_dev { #define AMT_GW_HLEN (sizeof(struct iphdr) + \ sizeof(struct udphdr) + \ sizeof(struct amt_gw_headers)) +/* IPv6-outer gateway headroom: the outer header is a struct ipv6hdr. */ +#define AMT_GW_HLEN6 (sizeof(struct ipv6hdr) + \ + sizeof(struct udphdr) + \ + sizeof(struct amt_gw_headers)) #define AMT_RELAY_HLEN (sizeof(struct iphdr) + \ sizeof(struct udphdr) + \ sizeof(struct amt_relay_headers)) +#define AMT_RELAY_HLEN6 (sizeof(struct ipv6hdr) + \ + sizeof(struct udphdr) + \ + sizeof(struct amt_relay_headers)) static inline bool netif_is_amt(const struct net_device *dev) {