From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 7A54280067 for ; Mon, 30 Nov 2026 18:49:58 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AUIminE031133; Mon, 30 Nov 2026 21:48:45 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AUIminE031133 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="PiHr4iTx" Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AUImXrD031070 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 30 Nov 2026 21:48:33 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AUImXrD031070 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-6b879462421so3755380a12.1 for ; Mon, 30 Nov 2026 10:48:33 -0800 (PST) X-Gm-Message-State: APuU4Z9Zh4r0uqQfkukX/z5tewMQcEUVPeiXEY+R7H8ZrDBWEGQmkhQ/ pukz+h0Kl34d3AudPc8umxkegt4Xs0BL8YESOBcWHj3coPha1i/KJkDVMOpAs4IN2c41+ztxA1Y Bkk1FhmjYBOPKAAgLLYJSnbI3oNqbf4eMJQvvTss4X/k/9k7NnJr6mw== X-Gm-Gg: AZFdTZetVYT3dWW23TQyip/ZMSgztUW8dzDUvZWgjGEGgnbrgLggeJdOM+3s1JqVptE idVNUzH4dgAgMmhaIkU7jizQSP8LHyP4gyXE+KzZhDZDp4IHuzUkh02sbxqu+9fAdmY4lKkJ4Mv qrubu+UZt9GrPi4zW6Vt/l9IlU92rs9AVqJnT3TrgDVYKEbY9WcKlqjwzAAoSemzSVJIKBLYL0U pZHElB5rfB6AQcMtkQPp0dWwJ6vcsT56pqu5Hssuatk6yP1rjVVhPXmtCsmGro2/JgWxbNnNuT4 4wYfJupnf3MKz/TmD4lmzNde5KJWuWSi8yQrIOj3nDmq0wbkEc4zR5B6sPi/ihAhLfQRC7BuNdx g9i70WzaiZV9DQKc8mXhkH64d X-Received: by 2002:a17:907:3e86:b0:c36:777f:824c with SMTP id a640c23a62f3a-c51315851d7mr3008207666b.4.1796064513172; Mon, 30 Nov 2026 10:48:33 -0800 (PST) X-Received: by 2002:a17:907:3e86:b0:c36:777f:824c with SMTP id a640c23a62f3a-c51315851d7mr3008205566b.4.1796064512666; Mon, 30 Nov 2026 10:48:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796064512; cv=none; d=google.com; s=arc-20260327; b=aEw/BIIhni4NgIfXhrZ0bn0ZjJwzdJjg9BdVxNYPaafMoVVmR1mf/V9JQtYkyFO1+o RSM4VvF13SIBTRPEwRBQD4h9iSgPv0bXjFXCoNLN8NiA3MgGpYeY4pDzqM6EhsMpj300 DXVNS1uKFV/yeJd8fkjDuf5CLYTySffSsp4KoxBO8VAMGWyMDtYWXS8mSFzBngsnblWq osjBIC0yYWeUI7OYfkWn7AP8LcSc3rZsYrT2Vfq0AmwbgkhrhXCQtT4j+mXj7e+CmMM+ lqSkx2nKofCR8qHSe0COPzj/6UEUJ3cGZXFHT5L9rH8fNwDylTHWBf1lAWOkbfilhz5R 28QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Dy3MsCHdPFywNdWmKAt3MCN3dI4RsWVMldkwX4NygGc=; fh=/QSWnKFFIPNLStgUoDwCQRaXnWcMIG7fyKJgHY+VEpU=; b=rcVN8NAHV5dNHEccfopJih3d6vIPK/L/1WdXzk9Riq7JEkNjAE7Kh7Gw2t6jU4Wiai eYAgNv4csng+DjAP12YnThcLhJh0MO6ibzNPCPinDrZ0XuqJEYMewILhUwOVJC8n67+7 NJg/66AA2azIXx7OaV9mSJy+4igx/HN2kWlSObXq+1IN7kVeTM3tbKJ2nhSiFRx51x2E 2jxUVPpSub5ThpnJYc7AKrN4apYv0qwLhCHwO/hEeuU9ICgBATEFs9UO6rJ21DUnJ3gx o13nzMccyJoRlgoI9ICM+T+9ljiNjZLwHubTRh/nyO2fScV6CN7Kw2yLA8/1ASuLtdqt No2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=PiHr4iTx; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513b0a6e54si2141389566b.293.2026.11.30.10.48.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:48:32 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=PiHr4iTx; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=Dy3MsCHdPFywNdWmKAt3MCN3dI4RsWVMldkwX4NygGc=; b=PiHr4iTxczy3 PKhUx+8/nE5sGLXWB1n+ueOX7p1B4EYcck3xAaWrWxCwdCO8lJfvAUKJAHgPfADqm/XVZaftbuXya E+UYwWKrWUk9CPRCaOD/P3sAGEDqR0DSp1e86nwAAA8I6B26tP4uisQ8DrSHdpnT3Y1QCRNxeNkFR yodgX8eiFBnNqNUP4qBLcTBg8zQAmc6qyPAuHhnd/H2dSmyPzq5WcQxXoGLarexaVZ1rH1hYHg79Q xe3EUjQgNbm8m/gfRRuTSEAgG0WpgLXUi7kcDKllVtg9R7Gb/c11qyoTC5SYer4O5SS3hd2S6BOwB Fu7ApwZBKrPCdqU2Dom7ZQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xY6Q8-001tKJ-34; Mon, 30 Nov 2026 19:48:23 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com Date: Mon, 30 Nov 2026 20:45:48 +0200 Message-ID: <20261130184822.2743885-4-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130184822.2743885-1-eva.kurchatova@virtuozzo.com> References: <20261130184822.2743885-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 3/8] ms/net/ipv6: Introduce payload_len helpers X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Alice Mikityanska [ Upstream commit b2936b4fd56294e49d6c8e9152ea6c4982757c7d ] The next commits will transition away from using the hop-by-hop extension header to encode packet length for BIG TCP. Add wrappers around ip6->payload_len that return the actual value if it's non-zero, and calculate it from skb->len if payload_len is set to zero (and a symmetrical setter). The new helpers are used wherever the surrounding code supports the hop-by-hop jumbo header for BIG TCP IPv6, or the corresponding IPv4 code uses skb_ip_totlen (e.g., in include/net/netfilter/nf_tables_ipv6.h). No behavioral change in this commit. Signed-off-by: Alice Mikityanska Acked-by: Paolo Abeni Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260205133925.526371-2-alice.kernel@fastmail.im Signed-off-by: Jakub Kicinski Stable-dep-of: 8070ed578b6b ("calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()") Signed-off-by: Sasha Levin (cherry picked from commit 7100c4a728911396569eb43e5ce14d557bdbcb08) https://virtuozzo.atlassian.net/browse/VSTOR-157577 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- include/linux/ipv6.h | 22 ++++++++++++++++++++++ include/net/ipv6.h | 2 -- include/net/netfilter/nf_tables_ipv6.h | 4 ++-- net/bridge/br_netfilter_ipv6.c | 2 +- net/bridge/netfilter/nf_conntrack_bridge.c | 4 ++-- net/ipv6/ip6_input.c | 2 +- net/ipv6/ip6_offload.c | 7 +++---- net/ipv6/output_core.c | 7 +------ net/netfilter/ipvs/ip_vs_xmit.c | 2 +- net/netfilter/nf_conntrack_ovs.c | 2 +- net/netfilter/nf_log_syslog.c | 2 +- net/sched/sch_cake.c | 2 +- 12 files changed, 36 insertions(+), 22 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index a6e2aadbb91b..d960b887469d 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -125,6 +125,28 @@ static inline unsigned int ipv6_transport_len(const struct sk_buff *skb) skb_network_header_len(skb); } +static inline unsigned int +ipv6_payload_len(const struct sk_buff *skb, const struct ipv6hdr *ip6) +{ + u32 len = ntohs(ip6->payload_len); + + return (len || !skb_is_gso(skb) || !skb_is_gso_tcp(skb)) ? + len : + skb->len - skb_network_offset(skb) - sizeof(struct ipv6hdr); +} + +static inline unsigned int skb_ipv6_payload_len(const struct sk_buff *skb) +{ + return ipv6_payload_len(skb, ipv6_hdr(skb)); +} + +#define IPV6_MAXPLEN 65535 + +static inline void ipv6_set_payload_len(struct ipv6hdr *ip6, unsigned int len) +{ + ip6->payload_len = len <= IPV6_MAXPLEN ? htons(len) : 0; +} + /* This structure contains results of exthdrs parsing as offsets from skb->nh. diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 248bfb26e2af..5d25cc46fb28 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -25,8 +25,6 @@ struct ip_tunnel_info; #define SIN6_LEN_RFC2133 24 -#define IPV6_MAXPLEN 65535 - /* * NextHeader field of IPv6 header */ diff --git a/include/net/netfilter/nf_tables_ipv6.h b/include/net/netfilter/nf_tables_ipv6.h index a0633eeaec97..c53ac00bb974 100644 --- a/include/net/netfilter/nf_tables_ipv6.h +++ b/include/net/netfilter/nf_tables_ipv6.h @@ -42,7 +42,7 @@ static inline int __nft_set_pktinfo_ipv6_validate(struct nft_pktinfo *pkt) if (ip6h->version != 6) return -1; - pkt_len = ntohs(ip6h->payload_len); + pkt_len = ipv6_payload_len(pkt->skb, ip6h); skb_len = pkt->skb->len - skb_network_offset(pkt->skb); if (pkt_len + sizeof(*ip6h) > skb_len) return -1; @@ -86,7 +86,7 @@ static inline int nft_set_pktinfo_ipv6_ingress(struct nft_pktinfo *pkt) if (ip6h->version != 6) goto inhdr_error; - pkt_len = ntohs(ip6h->payload_len); + pkt_len = ipv6_payload_len(pkt->skb, ip6h); if (pkt_len + sizeof(*ip6h) > pkt->skb->len) { idev = __in6_dev_get(nft_in(pkt)); __IP6_INC_STATS(nft_net(pkt), idev, IPSTATS_MIB_INTRUNCATEDPKTS); diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c index e0421eaa3abc..76ce70b4e7f3 100644 --- a/net/bridge/br_netfilter_ipv6.c +++ b/net/bridge/br_netfilter_ipv6.c @@ -58,7 +58,7 @@ int br_validate_ipv6(struct net *net, struct sk_buff *skb) if (hdr->version != 6) goto inhdr_error; - pkt_len = ntohs(hdr->payload_len); + pkt_len = ipv6_payload_len(skb, hdr); if (hdr->nexthdr == NEXTHDR_HOP && nf_ip6_check_hbh_len(skb, &pkt_len)) goto drop; diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c index 10127b7588ef..8ec934e5ffd2 100644 --- a/net/bridge/netfilter/nf_conntrack_bridge.c +++ b/net/bridge/netfilter/nf_conntrack_bridge.c @@ -234,7 +234,7 @@ static int nf_ct_br_ipv6_check(const struct sk_buff *skb) if (hdr->version != 6) return -1; - len = ntohs(hdr->payload_len) + sizeof(struct ipv6hdr) + nhoff; + len = ipv6_payload_len(skb, hdr) + sizeof(struct ipv6hdr) + nhoff; if (skb->len < len) return -1; @@ -274,7 +274,7 @@ static unsigned int nf_ct_bridge_pre(void *priv, struct sk_buff *skb, if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) return NF_ACCEPT; - len = sizeof(struct ipv6hdr) + ntohs(ipv6_hdr(skb)->payload_len); + len = sizeof(struct ipv6hdr) + skb_ipv6_payload_len(skb); if (pskb_trim_rcsum(skb, len)) return NF_ACCEPT; diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 0b3b81fd4a58..9c2be98b961a 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -262,7 +262,7 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev, skb->transport_header = skb->network_header + sizeof(*hdr); IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr); - pkt_len = ntohs(hdr->payload_len); + pkt_len = ipv6_payload_len(skb, hdr); /* pkt_len may be zero if Jumbo payload option is present */ if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) { diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index fce91183797a..6762ce7909c8 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -372,12 +372,11 @@ INDIRECT_CALLABLE_SCOPE int ipv6_gro_complete(struct sk_buff *skb, int nhoff) hop_jumbo->jumbo_payload_len = htonl(payload_len + hoplen); iph->nexthdr = NEXTHDR_HOP; - iph->payload_len = 0; - } else { - iph = (struct ipv6hdr *)(skb->data + nhoff); - iph->payload_len = htons(payload_len); } + iph = (struct ipv6hdr *)(skb->data + nhoff); + ipv6_set_payload_len(iph, payload_len); + nhoff += sizeof(*iph) + ipv6_exthdrs_len(iph, &ops); if (WARN_ON(!ops || !ops->callbacks.gro_complete)) goto out; diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c index 1c9b283a4132..cba1684a3f30 100644 --- a/net/ipv6/output_core.c +++ b/net/ipv6/output_core.c @@ -125,12 +125,7 @@ EXPORT_SYMBOL(ip6_dst_hoplimit); int __ip6_local_out(struct net *net, struct sock *sk, struct sk_buff *skb) { - int len; - - len = skb->len - sizeof(struct ipv6hdr); - if (len > IPV6_MAXPLEN) - len = 0; - ipv6_hdr(skb)->payload_len = htons(len); + ipv6_set_payload_len(ipv6_hdr(skb), skb->len - sizeof(struct ipv6hdr)); IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr); /* if egress device is enslaved to an L3 master device pass the diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c index e8efe75d63b2..e62365d9103a 100644 --- a/net/netfilter/ipvs/ip_vs_xmit.c +++ b/net/netfilter/ipvs/ip_vs_xmit.c @@ -948,7 +948,7 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af, *next_protocol = IPPROTO_IPV6; if (payload_len) *payload_len = - ntohs(old_ipv6h->payload_len) + + ipv6_payload_len(skb, old_ipv6h) + sizeof(*old_ipv6h); old_dsfield = ipv6_get_dsfield(old_ipv6h); *ttl = old_ipv6h->hop_limit; diff --git a/net/netfilter/nf_conntrack_ovs.c b/net/netfilter/nf_conntrack_ovs.c index 068e9489e1c2..a6988eeb1579 100644 --- a/net/netfilter/nf_conntrack_ovs.c +++ b/net/netfilter/nf_conntrack_ovs.c @@ -121,7 +121,7 @@ int nf_ct_skb_network_trim(struct sk_buff *skb, int family) len = skb_ip_totlen(skb); break; case NFPROTO_IPV6: - len = ntohs(ipv6_hdr(skb)->payload_len); + len = skb_ipv6_payload_len(skb); if (ipv6_hdr(skb)->nexthdr == NEXTHDR_HOP) { int err = nf_ip6_check_hbh_len(skb, &len); diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c index 9e1a6224d071..9e40d95dcb07 100644 --- a/net/netfilter/nf_log_syslog.c +++ b/net/netfilter/nf_log_syslog.c @@ -569,7 +569,7 @@ dump_ipv6_packet(struct net *net, struct nf_log_buf *m, /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ nf_log_buf_add(m, "LEN=%zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", - ntohs(ih->payload_len) + sizeof(struct ipv6hdr), + ipv6_payload_len(skb, ih) + sizeof(struct ipv6hdr), (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20, ih->hop_limit, (ntohl(*(__be32 *)ih) & 0x000fffff)); diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 8db48f8ec81f..4db9ffb00abd 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1266,7 +1266,7 @@ static struct sk_buff *cake_ack_filter(struct cake_sched_data *q, ipv6_addr_cmp(&ipv6h_check->daddr, &ipv6h->daddr)) continue; - seglen = ntohs(ipv6h_check->payload_len); + seglen = ipv6_payload_len(skb, ipv6h_check); } else { WARN_ON(1); /* shouldn't happen */ continue; -- 2.56.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel