From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795924026; b=Fo5vsBkQC2UBlwoE42/x2cTP/hRDERFwL7cxF9CltpSuz4tBJTjyUn/fkh5N8XEB2aBe b2y3PrCKxAuF4MVKnremVmYyHLQgKnUZpVArANvs85dcLECbDPSq1fqS7+VQKBVteVGfz C46gZqgulCFUKjx3P9t03TxI8Zbu7o0TDhAl2uAtoN6nT+2CDBFuzDO7CxDS/3LypBkAY bUYfUuRzOOXk8RqA78p3OBXThZoDYyhjdttdF10q6Nfu8WyPA6yus8MsGcAodadc9a8iV aay5VtDbunZWkqC0syGzJb5nRPJNKmD3HlEU0QR13zkwfe0WskE/uQZaFmMaaEFtq6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795924026; 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=r8I3+P6IB+ETym06zgD6Wh9lNWe44DvYMUoQANjviqs=; b=LZq9tsYFFOb5NDJc3LAYcGkam458WWe2tibZW+IJIw+LSsXKXtaXP1iiCxrWOrjnVTma VapMA/TNX7UqUi/OtFmcS6EnA6a9NDh8zSMSpU69XTtFJaNWO3H+NA9qO5Svh9e3eTBFN MhEvkKkta5FlpvP/aZhCBeBjKcijmWC6ToNaw32k1evBrQtrbEgcUvnhYmKMIGDghKL1V bP++kboxwpfcDBEgJfoUyB24bf4LRN/XCnXfKKNqG7ZdkANQ1Yl3BliSdECtxYii/JExN Arlg+tuBMOyglv2iVOwukdlHUBV2kHbFX6csmf1bSvjoN7K77njypOA4hhS7zHFmZsw== 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=ItyXyO4G; arc=none smtp.remote-ip=74.125.82.41 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 D33CF606A6A1 for ; Sun, 29 Nov 2026 03:47:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D33CF606A6A1 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=ItyXyO4G Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-18818daa3e7so4698381c88.0 for ; Sat, 28 Nov 2026 19:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1795924025; x=1796528825; 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=r8I3+P6IB+ETym06zgD6Wh9lNWe44DvYMUoQANjviqs=; b=ItyXyO4Gah03Fw02+rYMwEUDVNIBI8J/2QTfWwh2TQWFSERVjW4hFUuO7rP0evYBbX Z8MLliL+Anss/C9UdZZmRVPuhq0ioJgX2BsCSQbEruHraz1ymCC2o/CJJis5t/dERGSm sUKeww/64gdE6cxuU8kX3ge3wXatM93uJ6z+fUNwS33KIitHUNWqLUXNdSsASueKd1VP 9eAN2lGLnyXSeHkTU7FPIRB9s6IBwhkwNxP6y7vMw6LiMoImE2UlD48WVQA/6MavyVyY NVmaJofUlaWGcRE0n4w/6lhEm/liJMI2BUTHZa4a+rfZM14xIItIuEv2L2aQ7Pzws22v 8KuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795924025; x=1796528825; 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=r8I3+P6IB+ETym06zgD6Wh9lNWe44DvYMUoQANjviqs=; b=193/yrbutRsmwKlbQXTGzWdUo82/ZFH9tpADl1kj6W/cIqlSqpujxCplnRWo6BXZIQ lVUrd+qBPuaEPuC49Yo0Rp/B9hg/14XCdDNetuqUWGyrITzDr98K2BHtSfaQU7kqMp1L e8k3onDBXONDj9RPo9IAN2vVnjw9dm8yEQjRPkf9bfyLX1OoPL327uIKYMBzLJeM7qjO VrLenpgxo6hoxSgy2lG+lF69IxB7sKT0wpy0UG4PmqnQlQwxOy9dSOhXChWJGy0/qOfm cVHZkbFplSAa50SOawsKsQZOFGu2bkKHrnTgixaX3TOzEl+SplE67Se/nOWI7a4Fe163 QFTw== X-Forwarded-Encrypted: i=1; AL+hErH+Nr7dFkispGEzO6vBpbfzBAOluQiYQd7pbKPQeFFrEJvEoqJ1d0h7hjOonPnE4odjetA1sIE=@vger.kernel.org X-Gm-Message-State: APuU4Z9f5CTV49bVUZsylJhCtvc5iHiYRxUYsBW2k9jSs/GdmCLL/2Ag NTxS6OxRz0PVlosmijowdTcpTwg137nMTQhDmiBNjDYJnWSt7lTRM6N23qPq/ZVItZE= X-Gm-Gg: AZFdTZeLLQQaXSG5hCJNtrspmhOsDrGgC+fl8r7h2f3fmvx1UffeKKwZ6YDwQbugcDa W96qlFxzYTjbcieNG4k3p9wnv/K20g+C5yAPP4M7JKBaE6cC+MBzlQuQzZeyOJmM2lljxVYUu4l BsEVJplj1SbqexSCMJ0WL0EIJwZbEoOzuGbQvXqDUyewJWlhPBtcDT6WxS5Xs70mdjyZ/DFFEZM 3fZsXGFyw759vtAh85WYI9JbNcAq14eMpfh2Nwz1Xe3TgnAeBifPIBs+Dux6jQfeTi8D65k4cky 7BA0ofOYkX1bfFXeoBfEl4OqQcwtSsEn6CdaP1hZ6app8nla0Aus0lFzxrbVHrdy+o3uBxjFqQm DhXHGz3CuNs6v1tBo5DoHZXMs6YVDsCpiR/mB/G1qhLvANNKCiRsUbJajtvemcbt/TI5R5xgJ3Q XxcOetG6zf7okb+qCCieMaN+g/mHGda0e+puKZYUEUFyQ1ICTyQJF+/ZefYqQFRAr+2msNOPdAK usrEhDXhXgKUTZC6czP/9hrpwT0WpxoiYj8b9Q4z2VSsqbP3fS8e16G3ZqY2ygIshfi5sSGWttH lmc6k3Ogy8QbjK1XBBGxQrXOAKyc0aQfGArTPcQ4uCgPnc3arb/eAqK4CSAihx0FcRpBrquJ9Zs jHHt2FfE2PQ9fvMN3XUXyfVggcYk= X-Received: by 2002:a05:701b:2706:b0:192:a481:361 with SMTP id a92af1059eb24-1b5568c12e0mr27529449c88.7.1795924025013; Sat, 28 Nov 2026 19:47:05 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b56ef9fd16sm61119077c88.4.2026.11.28.19.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 19:47:04 -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 v4 06/12] amt: size the encapsulation headroom by the outer IP version Date: Sun, 29 Nov 2026 03:46:46 +0000 Message-ID: <20261129034652.1853485-7-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261129034652.1853485-1-omar@blockcast.net> References: <20261129034652.1853485-1-omar@blockcast.net> X-Mailing-List: netdev@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 bcd88203e..a74036d33 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) @@ -3941,10 +3949,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], @@ -3967,10 +3975,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; @@ -4091,11 +4099,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) {