From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796185935; b=Tj1aUt5geJcPvf49boS5+1WPp56t9de1NXMhpxwJMGzX4JpVneH4TTpal4tpnoxXk3uU ggIlnUI5pwjLXypZUmwPbliyO7xRKeeqz+DPLOBo13VO5j9rwNaDtX5vc8xqHzHVqLX1Q Awo9NHq45sXcG6LZsm9Y8IwXPkz9M4P5lxoGZnDKNLb/bi0lFriOErCfKjEP1sEUVelQl uHfJ+zRZugxaupflrV6ZWV0kjWAkxJSJhhJVaZVatdJ+RMo0FvWcZ9BKrd5c0igGdhzJo aYZLzshqGg6fdxe8RdVDozUjwcIT0J9jLwTCIjIMMCFshFfAq5SdzMD8Li/ooPEtakg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796185935; 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=j5i/BMxhlecA1VCT0bRYYgaPKFMuQB5ZNQQlGxm9at4=; b=YJsPwkH+nAmxnhVcRaGJoD/QAsl1L0S6wb1M7KWCJbXl37Em23+awbKkH6UcTlnS845A LT/YmyFUiTCyUInRmzgeR1xvXjz/yjZOsCXb+xBIrNaFZ6h1qOB9eN0opkHg8UpgD2rlX GPQfltwOr7AeSg08nCy2nUfah1SfbuiufSERKZfoYf/z7sqqlQ+/khxQhyKUf7YhYBpKV mY+EpL2SCgyZ11YGXBMNVi3g5DKprTf1mLFEbcbEVzUk2jPEHVORAoDYrAnfIVY+2gecs sus2JoX63T2u/7E88P7FOdpI8vbUYcWFg3IQM2E01kVc2SiYaVO0qPETGEdfdl95s9g== 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="XvCw/WQX"; arc=none smtp.remote-ip=74.125.82.178 Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178]) (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 81B32606A6A3 for ; Wed, 2 Dec 2026 04:32:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81B32606A6A3 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=XvCw/WQX Received: by mail-dy1-f178.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso8021439eec.0 for ; Tue, 01 Dec 2026 20:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blockcast.net; s=google; t=1796185934; x=1796790734; 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=j5i/BMxhlecA1VCT0bRYYgaPKFMuQB5ZNQQlGxm9at4=; b=XvCw/WQXTTu/TFmMMyhyTgVkMgwp8EUtNY06n/peEmAreoP63vLGIXI4r6BENg/Ass RieNQJoFUEAyE3dJaKwQVDKcYEUy5kwzOpoqMws1Bw6KoYufwDTpH79Z8gpL1OH4P4jE xCtHiAL2ZLCvvzR6OZj2AOPfLmSzhYe8H1WBUOBnhOE18pTVrJLBmJftZBb40kLeqn+t +9AjrxdAuGqPltNjc7PxK1Xb8ruyzskyEpkzQVZNeFAs6qz+eHbXWHRoWsPP1d/3RJ6W fJf2RzjfW1BYtgc7KdCM6Ecny0JrGujW0eR7rYr7l9oWZXUeCzO1/XX3cuhd2UPb++LJ cabQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796185934; x=1796790734; 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=j5i/BMxhlecA1VCT0bRYYgaPKFMuQB5ZNQQlGxm9at4=; b=l65+hcF7TzYfoArVc/mNTApbk7VCC9uKsrTCyOtdRcqXQNyMKTZ7Qn2PNHM3w6s2vZ KOOxiWjpbDTHyEmwjXsURaXefCqDIOmqMlp5w7IEdGYerqpgLW5hZnZEYuaXqqYwGgg9 Q7G5OqJ0A6HshOsofBKPDLJB7lpj3wHZnVaNTHVCfEsEDJ+chzZfB8mSIlKvBpuGvX8u HNzZtmvEgM77/DA5wNG1++7KN70AhhnobhmfTPG/mb4Ww2Y3dykpsvLarcYQTudxKMkz hZ0bRhOt6bodH+m+IMukEhR8AE93lm5ZdZq5icemIWp0EjZl/vu8nY23FbdAPYGLkHTd 4mdw== X-Forwarded-Encrypted: i=1; AL+hErGz9vZRqHrYfj2Pe+2I4YpNO+xbcSjtB6waLHls4vANrgSdSdp8lXxVfmzqo9+j/Oj6XEQkN38=@vger.kernel.org X-Gm-Message-State: APuU4Z9NTY7gEnMD3F2FKs+5MUauWKfZXWj9yWW70q5LHrFF8uR19mk4 cVGnxNUP9LRwmsxQACgxdF8tSEpaG/FPHG6rrZmVL0PceBNVFc//ZS41H+3I5SVYBCE= X-Gm-Gg: AZFdTZesjkWhLA5R5TIf2/mVOH9pVQs1pJwd2AzLiJHtdTKCu1xXt8Ol7NprhhQHzac V2XcANBEbTUyLwqX8gtFw/vZEST9zX7z2sMrc7CoyLDzDsV/+9aXJYb9bE30gtlfksI79ez0gap R3nOKuVsMPYqHqRySHWT8sCjdYiSJJIqaGcqAY2+9RjVM4Pw1YvQEoCvDG6OweuUFQxDI2nxOj4 Hky6eeVKy+W37ngIoFZIWvHlyTyw8OYdECCDVS6r1Rv8/JSW9WVnoCSWh3S+YLylX0VXmUz4nQn VZY6+6iA9W+WrXL9tpDQwTZUcbnbT1YoxcZ2wznhz4QY9f8u48qH+OAVZPg0Yfu5VRLBStqYQuo 74Syt2mrFNuqYXOn2/5OnuNlo1vQ9hAmw7jD48D8++u8K1v6H0PU8G8sFypmGMnW8pSnUXXVFlf dqKl4tfaQgZ4nTCbkLBDqxeHkzsxPm7gjiasHGtRKoynzomLhsi0WUwtKNRyrwVQpP4Zr9uT3BE cI1jTpOh5QzF5KvUgkM//becghokY/9PNLgyDt+/zxJXX9Ban5u8hlkHHdn/Vl0Tlvy7Ge0GjzP hOtgUr0/jBzklKetflEZyRouTpN0l6ZoW97h54h/nzMn/vcJ7BlEdoeWVcLs6ZoGKpXwA3GN1nX x/V4R/6SbugmzP3ZjaurA7e7h4/0= X-Received: by 2002:a05:7300:5994:b0:386:a915:8b97 with SMTP id 5a478bee46e88-386a9158dcamr38121567eec.27.1796185933672; Tue, 01 Dec 2026 20:32:13 -0800 (PST) Received: from devbox.ts.blockcast.net ([2602:f74d:1::32]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-386d605c894sm54632028eec.2.2026.12.01.20.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 20:32:12 -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 , David Ahern , Ido Schimmel Subject: [PATCH net-next v6 06/12] amt: size the encapsulation headroom by the outer IP version Date: Wed, 2 Dec 2026 04:31:54 +0000 Message-ID: <20261202043200.286260-7-omar@blockcast.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202043200.286260-1-omar@blockcast.net> References: <20261202043200.286260-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 AMT_RELAY_HLEN and AMT_GW_HLEN, which size the device's headroom and its MTU below the stream device's, assume a 20-byte IPv4 outer header, 20 bytes short of an IPv6 one. A payload near the device MTU would then exceed the tunnel MTU that amt_send_multicast_data() computes from the route and be dropped there. Add AMT_RELAY_HLEN6 and AMT_GW_HLEN6, pick between them in amt_hlen(), and use amt_hlen() at newlink and on NETDEV_CHANGEMTU of the stream device, so that the stack refuses such a payload first. 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 | 25 ++++++++++++++----------- include/net/amt.h | 6 ++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/net/amt.c b/drivers/net/amt.c index 1780d3dca..79702b002 100644 --- a/drivers/net/amt.c +++ b/drivers/net/amt.c @@ -101,6 +101,13 @@ static unsigned int amt_ip_hlen(const struct amt_dev *amt) return amt_v6(amt) ? sizeof(struct ipv6hdr) : sizeof(struct iphdr); } +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; +} + static void amt_outer_saddr(const struct amt_dev *amt, const struct sk_buff *skb, union amt_addr *addr) { @@ -3904,10 +3911,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], @@ -3930,10 +3937,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; @@ -4054,11 +4061,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 82ab63876..726026259 100644 --- a/include/net/amt.h +++ b/include/net/amt.h @@ -429,9 +429,15 @@ struct amt_dev { #define AMT_GW_HLEN (sizeof(struct iphdr) + \ sizeof(struct udphdr) + \ sizeof(struct amt_gw_headers)) +#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) {