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=1796020983; b=WnKKyO04sxCVuuyMHyM3fCQem0f1aaH7M4wO2FpyypMcM6xhlwLu2ozXELZBGJxR8jUQ PAv4PYqKOkU5bK3+76mu1EYglN0dlLxOvv3ys4aR1YW8l63wtmqsTttA9UiwWb3DFWNbX phxOKOY7YUR728Tfq8PUFq0EA0svkPNxpaOAgflCztLay0HE6LXx+bnxbt6o6glcBxsC/ 65hwnNrTf6AtTkO5/uDCCQK6zl77XLS3/0O95NBesJKTCGBnO568tl4+jDBSvbME8vGMp oygOW+W0IXTiSriTPaLxOLMoayG8vBGbqBvJ4yuzwsv2bz6ltJ01UY3cGV7TF3cMpTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020983; 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=MRIBiiYIM3EGd/MyuT638adb0jbT/J1VuwPy1vaq2hTuSDuwdtwSdJkZJ4O5baZ1T8h3 Zpzqom2JDc1bgjYI4J5oxFx0JAXFf8ioBWruH+9qk2GRksAWY0HnQCtT1RjuYsAvI0tHi JDcUVZSTanjE92nd1lXvsVl8WXomC6D4mEzUAqX79fzofgjGfnB1QVUQA7lKQmmKGCjnR LozX1l3Up0DISYahRPAzJQX9VXgs3yk2BMeaT2RMxUXCxBFS1qaPuGoQih0owyDFgZDVn JsGgES0qbzaAmbxpI40Tr3uHGClRE2GwJcOa0liydGpEL9GJnrehCLaaNLuKrXgLW5g== 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.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 8D920606A6A6 for ; Mon, 30 Nov 2026 06:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D920606A6A6 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-f178.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso2843961eec.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=kzURRgK8FeRJZ80Z/FDZYv6cRdpeYVoE2nLUEiWZBHGjDeygk1KF4Vw/9UC/rwQzJ2 g27OvZBLNczz3rO0PJ5SICMNYhzBzORcE0wlcztdacuEQ1JRMxwbk34HOwQPnByWac+K o54N5P8zYOiqDwsJT41/wG1qdtp0mjv5mlQsjg4yOIs0+bbDwh6a1u23uiu++Vf54qAU PcIew0rbsIZfnsQuBz5vU1Jc2GpCd4oma5luIBYJ0b+jcUTq9aLGaqmpoJQ/Tvg+b+jp ZunaMsqpaWX36KltxfvPQDDqcMBIgmKzEfMJ/XgymGiWKHXU6pxTIbJ7E8N+XRTEYb6q oSDQ== X-Forwarded-Encrypted: i=1; AL+hErHc3R4NPl3bveGDiALyDvMwfn8G1O9CYh3QBSDnpsvlj8vPCUi0e7CRxBZtOrgMxhHXhdHB0r0=@vger.kernel.org X-Gm-Message-State: APuU4Z/6HBfxhFVfO7ZSwNsDzfNv0raM/JpBOJgsD64lAUhwh+7oAquA +SssdTgK49Y+dfEQ9X+DAu9TUSypnBH0o3MaJcoetrmbzzlw2PkSDFpB6XY6CGXYloc= X-Gm-Gg: AZFdTZcw75gtrHOUP4gRFVwkdkZC1aq4J02IBEvPXHS0M1F2MITNr6G9AhWQdhdU11B zdTeMkpGBM1P61fO/+YUmjDqz5B9fdv2FacTGYKsvZv3Phj/U2br/gjc67c+FOlxR7WiVmY3NQM KVYr60zS7bkF13j2ErhFE9BxD3YVsi8Ur6yMrVzFJM1OktmocQEeUbCgILaSmT3CXoYH0fasvyp CujIF0PuZ7JoWAeqBF9uOV6MQDJE1n+BGMlxnOfR1YrZ7TUGqE2Ygw1OUUtzb2/z37GFV+ca3fS 3G9jDtl8He2TJJpXeiuHaQ5l098AP/OBgoBfCyL7s+70CgcvobIMHHCXUyzrXCRO3P0m40zZCTG 85x9Rjj2F15U4aDJDrFzYl2ycZZ1LZLoO0hGqRY0FyEgT8rtsUjLENJLKWG/kCJnCV2tv4pXu2f j+XK7EKE06vEsZQ+MMq1JhSnTDgDCtDtfzO0O7pO0lcuMmH7xbI3hq/zM9Ca5B+5eldOhEZwK3D UTC37Gq+bAWroJVPjCjx3nFNaypVG3xGcUsQ4PCKsCHjmwyHuPhdX+3sS2TR8sSnTUYZnG0UXDY EJ8YnHJlrvjbEg3SY2NfzCgjDyfGRdG5qzGArYuTRdRsxMjMb//nYOkULJ0pN4ziiAJM7KAWTBZ dvbV+6VL+QWKBdHLK5UtG5abd0Uk= 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: 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 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) {