From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D54ED2EACEE; Fri, 27 Jun 2025 17:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046956; cv=none; b=jlZmNElxQIVb7eS85oNHJedYQE9DhoBPytVjZ92P9jFNOqIMl3SaFIOjmq5OrVFZ1qLCC4opWzUuS7HGZLlB8lSzr1oI4ROeRIo9nszjR3ayL3XSh87bZFAN0tZoUZOu8ivziQha05LFa6HOAgXlde738LdQZc4WQbvPDZA6Iiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046956; c=relaxed/simple; bh=jbCjWV/h7n2SHM7aPePgMluwf8TLq/orMZ98gJOmxn8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b1SY7MKMAUioKpRuKL6PB3D6GEUlpY9scuXDwgaoidBXfzY87LeOX5DU0AYO42uCl0NBvOmRunkuHiwixwVWjxi3EG1deNEmnV+ZlZldBHSYhOBAbvSMkgErP3k1khCd6IZDwNPsJCV3/xTlIS3Sr7+RbpSKtkN0vVnMH8cXWxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-607b59b447bso163856a12.1; Fri, 27 Jun 2025 10:55:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046953; x=1751651753; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BdAqTjFNYTelvz4grTCp7T82BdTogW49IVN7Iv0xIeg=; b=QX04v4xjtAn0oG4rdBB+F6EUklbhmdJKaUUhfZWOTzBz0N9hDrrTQd7Ef96XyWuw3d En3LNnR35GoofDitKL1M8LGtZt9PNYLwrUCd9Zt3XTVenJXglSTczPOIMom9QzDfoevW 1cdyI/xmg27CmwJlFtPQUZC4yRWCYqKNDpyRKTlyMB98RnHeY3FPuiWj8ttW0WFeH1yx Fb+3a1yWaQtyHlKD/UkPdmmdnFm0cbUGvlv5VnCNf8RORLz1y/EN2Qg+HdW4OKW2ob34 PmROalnm6fKF1Bc5P7MGibnrTSakNmFyhErqz5Zx2iT3osDiyV2m+9HXtryO+uwV0Klx JZeA== X-Forwarded-Encrypted: i=1; AJvYcCUn+LLVauE8lcpokO7hrSzaUbf8ybJ2KCp0xY/Frgca//Zr5YV3qhyP1qcfF65HAIpMKByFFWqz+o2/NZE2lIyu@vger.kernel.org, AJvYcCV23uLXcks/bX67RY3TMQF5D2jZ4jTsAVYFxxAPVMtIYQDW8B2NJDaM10NCNR+Tk/t4oYwNFqWQr3uKjbg=@vger.kernel.org X-Gm-Message-State: AOJu0YxrmYguiF9ZveGqLp/0JGcqrt8hBb5cQPFsksKkuNHRrkEn7mgX IGVKctn2X7zr+59zgjxZhloNec2CfIoadOAztOhbjG90mD0EY6ge4HfN X-Gm-Gg: ASbGnctfppDSr+invxuWyE6I3NwX/fltWiYdSb/ofgZPRqewrQb7DnFhra0ujJ3v+0p /7wx0Wu1L5DvkCxbTk6YM7X1O0x0bP8m5woDQ5MELjP41GtNxfbPKPsDROOD++JrYYwBl7J24kZ LXU0eM8l25mB8NOSkkRC7i0hlK6R4QIPpdvCbnS8cxJwz5fMZ3Bu4uyokRNufIp+zdIe02YoS1a tL08TVLhs6YmtR3JQGcTuCh4nvLnOUcENgcabAyaOecazuj9Cn7rXDVDMjWQuFWxEI9Xajt6L3m wdmvL6b3mAFx/wDUu/Gxc5e/yYHzFPSC5H4G5KfBFHRbLZL7Ulb2 X-Google-Smtp-Source: AGHT+IHscVx//xOJEJlpDsWzjwH1+b1+1wS2JE2Cjxc1bD4rSPBviqLSG885/ydsRTnSkUL0jLTryA== X-Received: by 2002:a17:906:4fc7:b0:ae3:6390:6ad3 with SMTP id a640c23a62f3a-ae363907084mr218911766b.22.1751046952999; Fri, 27 Jun 2025 10:55:52 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:1::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae353c6bcedsm165603166b.133.2025.06.27.10.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:52 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:47 -0700 Subject: [PATCH net-next 1/7] netpoll: Improve code clarity with explicit struct size calculations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-1-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=2146; i=leitao@debian.org; h=from:subject:message-id; bh=jbCjWV/h7n2SHM7aPePgMluwf8TLq/orMZ98gJOmxn8=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslurJE24JlCTTK6aAUL62RGQwEwDEUPhVPS iyLMnv+qq2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 bVOyD/0Wyr6x5W73Q58nAyfPEj+M7Vbjt9FHIfElBUu5ZUdcQZNf6e5RLqV9NCWNnBP7+C7vdKG yCWRwU7aMQe0im1dPBFmO1Dto/KpYmhx0ELyhFp4Ff7d0kC+pSWt3ZqnaDcywiYh0bz3y0ZwCBB nk8pmoOI7aodEHCIFCBTz2/4qiSBnzo0MzqCVvOtbET5RTMfta2vNgSxoT/696e9jABSArgaWT4 ZQqCNDzFG09V6PiI5jUcHOCJ0zgJIj4aOPzdiWWr03caeogFXe6evzAAiLJlqjRS/EcEyWgoR19 tJq44n1Mds9twGhRaxQuBBfVk7XQTgmsBUwqCmPvf3YigTSqOOgAFQhmPS5RQ1sIt3aHUq4OWZh 7J1C75rP7GRfbM5lTp8CQ1vE57qYplzUmnp48tOANuYVbdedr6Hq25UK/RoEgqRrj//11PzQhg6 BUtaleVHdXrpF2Y49D2qQCES83OdCP/aY9GtTNqDiziUiCEFeiNeGzRR8eBbpnO+WvhlJLb1PqI d/HK1mmNGDN1wo/D8Q3Ma02ilv7INoj9242MIAbcbJeo2rB08vU0NGDEuB/y1giC/5tK5not/3N BmKbZhVlN5d29AkHfwq1boDu4VUBPvWaAWPY1ceTPIws62NODNSwG91zz/4UEgytv+gjqJShTEZ 3o3tCPTF9iwPK6g== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Replace pointer-dereference sizeof() operations with explicit struct names for improved readability and maintainability. This change: 1. Replaces `sizeof(*udph)` with `sizeof(struct udphdr)` 2. Replaces `sizeof(*ip6h)` with `sizeof(struct ipv6hdr)` 3. Replaces `sizeof(*iph)` with `sizeof(struct iphdr)` This will make it easy to move code in the upcoming patches. No functional changes are introduced by this patch. Signed-off-by: Breno Leitao --- net/core/netpoll.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 54f9d505895f6..ac0ae9630654a 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -402,11 +402,11 @@ int netpoll_send_udp(struct netpoll *np, const char *= msg, int len) if (!IS_ENABLED(CONFIG_PREEMPT_RT)) WARN_ON_ONCE(!irqs_disabled()); =20 - udp_len =3D len + sizeof(*udph); + udp_len =3D len + sizeof(struct udphdr); if (np->ipv6) - ip_len =3D udp_len + sizeof(*ip6h); + ip_len =3D udp_len + sizeof(struct ipv6hdr); else - ip_len =3D udp_len + sizeof(*iph); + ip_len =3D udp_len + sizeof(struct iphdr); =20 total_len =3D ip_len + LL_RESERVED_SPACE(np->dev); =20 @@ -418,7 +418,7 @@ int netpoll_send_udp(struct netpoll *np, const char *ms= g, int len) skb_copy_to_linear_data(skb, msg, len); skb_put(skb, len); =20 - skb_push(skb, sizeof(*udph)); + skb_push(skb, sizeof(struct udphdr)); skb_reset_transport_header(skb); udph =3D udp_hdr(skb); udph->source =3D htons(np->local_port); @@ -434,7 +434,7 @@ int netpoll_send_udp(struct netpoll *np, const char *ms= g, int len) if (udph->check =3D=3D 0) udph->check =3D CSUM_MANGLED_0; =20 - skb_push(skb, sizeof(*ip6h)); + skb_push(skb, sizeof(struct ipv6hdr)); skb_reset_network_header(skb); ip6h =3D ipv6_hdr(skb); =20 @@ -461,7 +461,7 @@ int netpoll_send_udp(struct netpoll *np, const char *ms= g, int len) if (udph->check =3D=3D 0) udph->check =3D CSUM_MANGLED_0; =20 - skb_push(skb, sizeof(*iph)); + skb_push(skb, sizeof(struct iphdr)); skb_reset_network_header(skb); iph =3D ip_hdr(skb); =20 --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E9872EBBBC; Fri, 27 Jun 2025 17:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046958; cv=none; b=QjV2avjbGrXZhZy1kDg+JOlXdsHHOBYxQWLMLPjlT+KDbei9SKwNpjXXL48xZKrueNIpMF9A/2Hjo6LAxWN68P3K7DuKpMw+uGAQ++PoANxi5igkaHLDSBGPmh50f010djrdRddyr3eM6s9zD+qAU4ieRego1norxTo0m0wT/Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046958; c=relaxed/simple; bh=z6ZyZPgKMyV5y5bQXJoqji7LE1KbrdDAaxyolHnuv6Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SkE2N0f2VJFMt1ZvXZ7qs+AGHFFIz76f/g2mAsYMFkbAjELXSsXyY0zL8bJHS+lW1363azHiiRHtElwNgAaXHlhNZZiBWSaPfWFoeAD2H84u5BMmNTY6L6XiEjFGocQUlDWOyIB8Z+VYWOhaiPhhpxH3BVeZKfP11G7/q2SmEIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-60c93c23b08so175812a12.3; Fri, 27 Jun 2025 10:55:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046955; x=1751651755; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7qUEhiAZpONXJUUW9QytxIAnMQmTyOeLbTuh7J5BUSs=; b=PljvCDtqhGQr1FQqm6LbK+evDK/RyhwwT4j03EC87frWo654nbesi9YyvmdFA5C8ZR UY4+Xi2K5FSPLE8p/SpFwNBe+En+euVqUrynXq/DpUU5vmKVG4NBFACsmFrPjix9jUUV eKZrOa4qTvysoc+fjTNlEExyMO7aPl1/EOcogw7o1sBqiBmpZVK4u8ZLT9EsIKSN3bM5 iGFJ10ADMzjEbsI0YKrlOOQ/fUrsFkS1TbBnhsb37xxURAxmSPTXWAR6g0m3//f1Bn9V UR200Bun0gR5Djhx/NyAJudhaGbuoq4HOK0lmeHH2BXcUsZRY/KvyFyjvIw+Iotb/4+9 9K2Q== X-Forwarded-Encrypted: i=1; AJvYcCUjzKC+qskvLIonJGGYsE++NDu3UZE/xu45wA2lOSQ2N56QpXe1VFWCkzuBrfikADOhjp/KTBZIt9r0sGw69R6x@vger.kernel.org, AJvYcCXtq+Lowa8cnJ992R4xsGgRd2NQumuz4Ge90pEnUJ7zNdPPJhng24HBDV5TRni0o/21WHnUMBd27I8L5Qo=@vger.kernel.org X-Gm-Message-State: AOJu0YzAvePV85RTpZRle+3l8N2VrNfKm4qASfnrDEUd7yqGVQpU6ZfB Rd1drL196G6C38RkXQkhp5qaiAj8GmZPOQiSTN/nr4lGM7RpMmoMudgSCe4/0g== X-Gm-Gg: ASbGncv0UUQ1Kgq9fgVoAr9e+Wxh7Utti5fcfc/0qEkGiLwHB2I0/ZSXuZCR1nu19y7 lvV3vi6XqF7fw0eUrPrQvNCgrjIs/Zd3dnd1O6VDsr7oB+kCRKe0PqtvFDaWPh7kMtSP4neUdPa O/PaOeHQRq+XnfZx7BNfAdgJnb06ypwV0dLOClTInV5ZIRD7XBii5JuI4YpPNiF9RujRTGwMUZA 78GICSoPQ+ANGWHNc6YJcJQSJeqgJOyGwQlE7uE42ZVq+ajcIfFzC9argvaAzDgW7ZgkCso139+ ua3cqwF1Jg4CKBmu/hSMlY0UH/yZ+wmitqcq2s/toUn5OjVQ4HxNhVElf9IcQgfF X-Google-Smtp-Source: AGHT+IGNWtFfexKYAG6FZcn39pGTc3OLycGN6dxns+/+zG5bybQtNGUpDZWMCvpTFQRN2rJq91KImg== X-Received: by 2002:a17:907:7f14:b0:ae0:c561:b806 with SMTP id a640c23a62f3a-ae3500f276fmr398235366b.37.1751046954380; Fri, 27 Jun 2025 10:55:54 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:74::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae360e6ce54sm108646066b.37.2025.06.27.10.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:53 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:48 -0700 Subject: [PATCH net-next 2/7] netpoll: factor out UDP checksum calculation into helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-2-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=2594; i=leitao@debian.org; h=from:subject:message-id; bh=z6ZyZPgKMyV5y5bQXJoqji7LE1KbrdDAaxyolHnuv6Y=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslVEuPoOCcrE4gQ+5/idXTrnhBg2GM1tKgP nFYRVb9zaeJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 bSiAD/0ZPLuRf/HOdCFM0OqmJQ5MwsWT/X8oMNnCWSe4utM75IVmJwtzyFHZTfkS+/BKmIq/rgT LIg85XStfawMmpELEtXaBcDo/I9Ai1YVVXS6c7N5MZ9KHKuOKJB90GQ9QTC8cJLlBZjsCIf6f19 mFuStCOzD0tsX0EbzeQFEf2K7HsDUWfOiW2HEUADv2btvVKzGkcoY9MyLQUXO5AyX7UIO6gw0jh K6z/nkNYbykoH7Iv9ei01yav6JXb/n1C3upbZBbyPyn3ksHyndvg+PUpL5UV5BPV2q0STNIB/Ds weMMvzuXg+4OCjE+PEP03dQSyATvG8c5U7PRAAZ0VY126I5zjqNIjdS2hDYhf3I4083V9ZpeKDT gBLc1L3lfIELNta6yX60L6c9WowDkpfHWD+xD31z6J2xX+xkcThdZuq+Wg6nWquVsPQnyWt90DJ rSBa7rwla46hD0ss0rY8K5h3nzK8r3Qhu0O+cf/O8LwP18UO+NLPZxxSugmKmjvqagxlXmYQ+u1 mnTqDic2ql8R2NiIkSZTDL2Hn8d4wnNcDr/245wdVojMPmH9KffuN4ss/3gKmHEQrto8a7u9IjU cr9v1a5qe+pgjE5ydWbs+J5gUHdCdOY8KbVEsLtFTePuGdN8y79hTPhShYvU5mhMEoBCbjI1G6D EIphQgeXTRuL/Qg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Extract UDP checksum calculation logic from netpoll_send_udp() into a new static helper function netpoll_udp_checksum(). This reduces code duplication and improves readability for both IPv4 and IPv6 cases. No functional change intended. Signed-off-by: Breno Leitao --- net/core/netpoll.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index ac0ae9630654a..24e6ad2da8096 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -372,6 +372,31 @@ static netdev_tx_t __netpoll_send_skb(struct netpoll *= np, struct sk_buff *skb) return ret; } =20 +static void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb, + int len) +{ + struct udphdr *udph; + int udp_len; + + udp_len =3D len + sizeof(struct udphdr); + udph =3D udp_hdr(skb); + + /* check needs to be set, since it will be consumed in csum_partial */ + udph->check =3D 0; + if (np->ipv6) + udph->check =3D csum_ipv6_magic(&np->local_ip.in6, + &np->remote_ip.in6, + udp_len, IPPROTO_UDP, + csum_partial(udph, udp_len, 0)); + else + udph->check =3D csum_tcpudp_magic(np->local_ip.ip, + np->remote_ip.ip, + udp_len, IPPROTO_UDP, + csum_partial(udph, udp_len, 0)); + if (udph->check =3D=3D 0) + udph->check =3D CSUM_MANGLED_0; +} + netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) { unsigned long flags; @@ -425,15 +450,8 @@ int netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) udph->dest =3D htons(np->remote_port); udph->len =3D htons(udp_len); =20 - udph->check =3D 0; + netpoll_udp_checksum(np, skb, len); if (np->ipv6) { - udph->check =3D csum_ipv6_magic(&np->local_ip.in6, - &np->remote_ip.in6, - udp_len, IPPROTO_UDP, - csum_partial(udph, udp_len, 0)); - if (udph->check =3D=3D 0) - udph->check =3D CSUM_MANGLED_0; - skb_push(skb, sizeof(struct ipv6hdr)); skb_reset_network_header(skb); ip6h =3D ipv6_hdr(skb); @@ -454,13 +472,6 @@ int netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) skb_reset_mac_header(skb); skb->protocol =3D eth->h_proto =3D htons(ETH_P_IPV6); } else { - udph->check =3D csum_tcpudp_magic(np->local_ip.ip, - np->remote_ip.ip, - udp_len, IPPROTO_UDP, - csum_partial(udph, udp_len, 0)); - if (udph->check =3D=3D 0) - udph->check =3D CSUM_MANGLED_0; - skb_push(skb, sizeof(struct iphdr)); skb_reset_network_header(skb); iph =3D ip_hdr(skb); --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D3FF2ECD3C; Fri, 27 Jun 2025 17:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046959; cv=none; b=bGQA9cII+mQTEIJb/Sg1sKS6qgc3XBY4bs87NQrR57ynjhB4TRr6osfZ/kKgvr50sBcOK+ZzCS/bgdwvxHDqnExbNtfCNwWnxxA6Dw3D9AJwXWeqBGAN8TaG+fiQ/8XSnLbJvIrUJw6DWQD+MX4pqw/GUjPte8D2SAPybtNNt48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046959; c=relaxed/simple; bh=S45p4GYDOIgPeogkQywbhpuBDiWH/N8B6jk1HuoCwrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FhbPUtkrXKK2/0YG1zLeRhDA6wieTVuh/TWpQU9zWJCLeLKbAIOX4ExBbJxpcSGlG5xOeWCLXMPrDHBW85kEr97ZSiVgRqBIIrh5JMI44swxtfADkIPm/dE1fOUVOunfWxCYFILiNjLTOg+kbCqy6VUO0lLvVV+XNQFmN4y2IZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-60768f080d8so196099a12.1; Fri, 27 Jun 2025 10:55:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046956; x=1751651756; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qNF6KD9tDOu5iPqaXILqcxFXrB8p2Oad18HGGU/SHQ0=; b=gEEx8cID50tQeEyofdIWrVJ1ZHwrPnvsiZiDIbk7ywAeLlIUuxs595evNQd3wWN6bC CCqD9Q+9H2FPKHisYXTXAH4Z5DCWJGDRkiEDWywTJWt/Z9jSw3GhEmnsQNQVSkXWkfAO vrFgSsFBmKKJwuSRPaLIdG29kUIql6X0FWhXAKhABI1fOp3KV9Vc16Lnd+JFzQ+HEHwI ju4WHovYf0xEsvtIqJz4KI9T6wnDjhpC+VhBURjtzsJnKNFR3BCa8kaYj/LQr60oOCKl SaG8X4pu/m2G0FZpfA284rzIrj7F0OTl6cM5iBs418085ZWB+JHa/BhHg8x47ybqM55X qNIQ== X-Forwarded-Encrypted: i=1; AJvYcCUCYnhzMLSMdr/+15bV8k/3Qrw2J8GygvdPwTlBQA23MAC/9TdOAvbhWmviDWGr14cpjwPw9MNX0fSSYKE=@vger.kernel.org, AJvYcCWtwnv7ab4vLqOLeVTuBP4D22g5EFDgIZiPS0Hqz84de7WiCcjp1hS6f0DQ34mnVrShJFUvBt3053JqiyIooXSg@vger.kernel.org X-Gm-Message-State: AOJu0YyTtVNr3NMPgMV6TJawOsEycuvvq5TIhpuyzcmLHqDOy6EK3ZbB F2Mi+UgaSt1RV+YSz0YLlCuH7OlCb6hEBUbiuyOzmjnhW8AvIJINGXUc X-Gm-Gg: ASbGncsSIBOjibmAFl3LxFNspWEMNyWC8aa+2VeQ+kRqJag1l2hkWYNCbJLWqUGMt4o ccxo9dZQl+HmZvfMctLFKg1qQ2kSSafqdFO3xMtf6CcOlyGFBnIqE+HV+TpQ24miTFC1+ovX6g0 zkI0STL/ybGEPvX9eoQErbRylS3TKsWOPCwWy2I9C/VWOg8vzk5c94eTDZUe2xmSV8IwIdhxzjJ OyaH4TWmUFjl989HuOJbnli3hnMXZL6p43sn2Ay02dffI+Xb/Zu5izRjsuRWr0hbx5F0vCBXptA Nn8R/J2hiMQ5yWaS6u3FIy6ZpCEDN6cQC/3KcAYmqWPfFykyLuwV X-Google-Smtp-Source: AGHT+IH7BFosMcHC5XQWY/5DZOwgTmEHaiCP6wgFtBzyVXn9MYvGe/fJQaWszE0lHmU8P3n7sa+wFg== X-Received: by 2002:a05:6402:3591:b0:608:6189:eb59 with SMTP id 4fb4d7f45d1cf-60c88c4d6e3mr3624767a12.13.1751046955679; Fri, 27 Jun 2025 10:55:55 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:1::]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60c828e1a96sm1778572a12.19.2025.06.27.10.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:55 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:49 -0700 Subject: [PATCH net-next 3/7] netpoll: factor out IPv6 header setup into push_ipv6() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-3-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=2665; i=leitao@debian.org; h=from:subject:message-id; bh=S45p4GYDOIgPeogkQywbhpuBDiWH/N8B6jk1HuoCwrY=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslnekpDe+3IWlXZAbUCpJ4wH3Xm0gxWxsSD vq4qKkj5syJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 baOyD/9kd/tbLcnADpDL0hv1g88VCxBs3HuMJg/wPIkfSM6B8xNZg7UqcwCcslVHCf17UNpDzNK hxWnt3BoV8r5mXyHoIUQ6iaHDyB7chGMpyZFoMvfUXJQRG9uYU5HWbodUBqvCB/tlr2j2P1mE1B TLwjnXXnDR2gyngMsGI0fidZQLzDFoPLS7cepJ0dWM6VfM4/xf4T+iaGAskJejmzyko6YwcduD6 Miw7J/g7GZeWC94Di0j1QPUhFcz2nYRu16OOL/lrjhVlWlvfoeIA+tMwU4AVD8a7ul+e83wtesx 2fedaNPQ/WS6FDnWRjLXWQk3Kxec2ur4EFizS+CLNEJv5qSmyaojDnQsf71c4RWotWc3JlPiLIk ZZNkvpIAzftpiCSPI7YpF/TBjNQ0JoustQau7+cDOw3LNby3xkLSffq96ZLPw1tr6T3DIuQVL10 feYXct6GQ0Sl4z3dczFzFtdGYa94FZGfqg0AM30oJzAtFdMR15Pw7156TAi6lfzurkfIHXs2nA8 3iumy3/1yMtwWe0TAWQNNHI49RoHE4+OIsllsTRP8jlDBXgekrvK7NU0ADWfpYQkrFu2uXdV4Pp oBfVDm7Layn7JDyC//+u0KzXpdr1uMVv4mB5VKy0uiuF/89kmjnKzV+GX1vEGBd8bn6ivI88ACj ZhLCOVqpB4SI6mA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Move IPv6 header construction from netpoll_send_udp() into a new static helper function, push_ipv6(). This refactoring reduces code duplication and improves readability in netpoll_send_udp(). Signed-off-by: Breno Leitao --- net/core/netpoll.c | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 24e6ad2da8096..247a73762fc2c 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -414,6 +414,33 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struc= t sk_buff *skb) } EXPORT_SYMBOL(netpoll_send_skb); =20 +static void push_ipv6(struct netpoll *np, struct sk_buff *skb, int len) +{ + struct ipv6hdr *ip6h; + struct ethhdr *eth; + + skb_push(skb, sizeof(struct ipv6hdr)); + skb_reset_network_header(skb); + ip6h =3D ipv6_hdr(skb); + + /* ip6h->version =3D 6; ip6h->priority =3D 0; */ + *(unsigned char *)ip6h =3D 0x60; + ip6h->flow_lbl[0] =3D 0; + ip6h->flow_lbl[1] =3D 0; + ip6h->flow_lbl[2] =3D 0; + + ip6h->payload_len =3D htons(sizeof(struct udphdr) + len); + ip6h->nexthdr =3D IPPROTO_UDP; + ip6h->hop_limit =3D 32; + ip6h->saddr =3D np->local_ip.in6; + ip6h->daddr =3D np->remote_ip.in6; + + eth =3D skb_push(skb, ETH_HLEN); + skb_reset_mac_header(skb); + skb->protocol =3D htons(ETH_P_IPV6); + eth->h_proto =3D htons(ETH_P_IPV6); +} + int netpoll_send_udp(struct netpoll *np, const char *msg, int len) { int total_len, ip_len, udp_len; @@ -422,7 +449,6 @@ int netpoll_send_udp(struct netpoll *np, const char *ms= g, int len) struct iphdr *iph; struct ethhdr *eth; static atomic_t ip_ident; - struct ipv6hdr *ip6h; =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) WARN_ON_ONCE(!irqs_disabled()); @@ -452,25 +478,8 @@ int netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) =20 netpoll_udp_checksum(np, skb, len); if (np->ipv6) { - skb_push(skb, sizeof(struct ipv6hdr)); - skb_reset_network_header(skb); - ip6h =3D ipv6_hdr(skb); - - /* ip6h->version =3D 6; ip6h->priority =3D 0; */ - *(unsigned char *)ip6h =3D 0x60; - ip6h->flow_lbl[0] =3D 0; - ip6h->flow_lbl[1] =3D 0; - ip6h->flow_lbl[2] =3D 0; - - ip6h->payload_len =3D htons(sizeof(struct udphdr) + len); - ip6h->nexthdr =3D IPPROTO_UDP; - ip6h->hop_limit =3D 32; - ip6h->saddr =3D np->local_ip.in6; - ip6h->daddr =3D np->remote_ip.in6; - - eth =3D skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - skb->protocol =3D eth->h_proto =3D htons(ETH_P_IPV6); + push_ipv6(np, skb, len); + eth =3D eth_hdr(skb); } else { skb_push(skb, sizeof(struct iphdr)); skb_reset_network_header(skb); --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AE112ED175; Fri, 27 Jun 2025 17:55:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046961; cv=none; b=kOvf26BfyV6zjHXO5FXTZhl7QQ5Mlawoe+Emrz4nDhAn5nq+WFV5AcN94xe4ur4EkISS0CMnYU6zz4kGOBbbpN/iAn4av2c4Rtc4YQm7KiQSlriYBFBm/dE1Jrk680849ukCFjVkBKo/2yaq9A1/dlVY8H5eAGnHRQWlhsTuPbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046961; c=relaxed/simple; bh=pcZpkL8/Vo5GDdA9GSNr5ZwCPZLTyJlooFlI1HTfP/A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BnLe22hYq+b/Kq1ugaZvHLKQQ1GK6ufeWflaZiZ/8AB2owkBtQlgmWUt9pLB4ffnR1Qa6ecr+Y/XGOXZEQXfYFk/Rbfy4te4ZPajjr/BEiHQ+B4804QqK63Naj7kA2L7RAjFAJjRm/3q4YqbUPF+sRk6O6ddDPs2HU0MMufXReQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-60c4521ae2cso4504757a12.0; Fri, 27 Jun 2025 10:55:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046957; x=1751651757; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ClXLLoPFou/Zs3D5ISq3qOrdQw3SSzyGRonA8OwAUwc=; b=gxrvtbrXQdkFIvvWiJdeUdn4c68OPmtVlKdD+P/HSGcKswigGI4gu+tpzA4abTYVwB hpKOiTSjy0n3RfbwRdSx7tJ5u5QFj4Fyvt/IRCj5Z7XcI9cTXl6wsimzS+GZ2FVXLyjD 3KLt5xzRh8DOHaEnenq5w5UleoimYMByUR72+pLJjNWyhtmoDsnpMzNYYjuOuNp8eFba 6TzUAY+rAcIaqXuDAIHXmh06ThnGOugV1goudHa1ju0YJqWznZJGO5EdpnHqHSVnIDot pUJhtQt9Abf/lkQHWm6Umji67WWb8QXiYAH5dWeGaECgO8qcfB3hoiHpxysL9x3E44ax qt6g== X-Forwarded-Encrypted: i=1; AJvYcCWN4fi4D0as+tNnXTHCOXZtrK6ilCc2PuDcvZu7Ho0HaXvbDb4IKigWr9XPD675HggYYy4SAPv9Xi5xZKA=@vger.kernel.org, AJvYcCWylobvY8lTQGHXPboSbHMzOgUPoIxN9t9Wul49GBjJIYKnYxaWO7k+mfns/lRuhjHjyfoporXEe8/XdiFxtCso@vger.kernel.org X-Gm-Message-State: AOJu0YzfxhwnEUg+wYQGowCfKSZ+cLZNv/235KvYd6thtOCQUil4Eu3/ nae35jEfZfcnuZ5FfDFkUDhq2JkGIw1elC0Z52Jy7/jlFXOI0Lv0hD76 X-Gm-Gg: ASbGnctzyK1+t0oGyYNsvN9kYbFoXMhE9BmHchHtupVUTXjNb3NSiUwiRvYsHe5JUmf PJuJZQbV1P+xOs33umCRnnorMQTPSMMAlD3xgSfRNPfr6FKnhRqYPCmVgcKWZln91HzTO+kjOZH gv5z6rYje4pqYXkPdb+dnB5JnmkWIV4ZCLBe0yKOZonQ6x9sqpJtCgMCMkH5GNoB9DzR8ZO3WQ0 1wWC4FIH8f4kXVLUlBqBYXdAxvDg9Sjc+VXiR0cu3+a0oleBDjltQ9j+fxHUKwFHTY/Yypb+jSe WK56oTzeAroOm1qOeyNlu3m8FmRJswzHZ0AYdSAa18HqnFDI7xtm X-Google-Smtp-Source: AGHT+IGL04zs6hP3O1ukERCqbY/aQnu4iEblvY6W6NTE2uJj/3CMybdWq1mxRT2Q6XIgZB3mik06rA== X-Received: by 2002:a17:907:d16:b0:ae0:c6e5:9738 with SMTP id a640c23a62f3a-ae3501fc1edmr401143566b.55.1751046957147; Fri, 27 Jun 2025 10:55:57 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:9::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae353c6bdafsm162009566b.143.2025.06.27.10.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:56 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:50 -0700 Subject: [PATCH net-next 4/7] netpoll: factor out IPv4 header setup into push_ipv4() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-4-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=3390; i=leitao@debian.org; h=from:subject:message-id; bh=pcZpkL8/Vo5GDdA9GSNr5ZwCPZLTyJlooFlI1HTfP/A=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslgIbwZAltg6AAIY6pwiupMhATLK1D/ITh7 rvhcXszEv2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 bXh7D/9RjnmmaQLFxg0BW5FdR9GZM0U54oEEC0evGxZAPHT0ZPGp2zXkQHsU1r1oUnKDYI6IfT8 Wf7b4cIOrbteN89wLjSLt2TPQtQulwvU8FbLOQi/J21UlSR6VTiSqYaIA+ysvU06jLaIXQCBfCB V081FFKt8S3d4sd4hxM4vMDdw2364JF+SozmxxIFy6dTABJMNdtR4KnYARCiQ4GoiJfqy0xpiZS FZVuFcbhSSXcvauilQ9M0uMaQ+NEGNWXrhHc8J8x25vEzq8zBtMFP3p056t5S+J2asMAoYAtFLt nGJ9jk4IijBO6VoJBCaTy2+BbVglxRy9zBpjs5E6atkhcl98o1s0QhYde65hphZBrtAHpJDC3G+ tZwgh/zUGEY1ZrSjP5NmkCesY0SP8aZtv6w3Nyk4/LKTdTPKR1m4asr7zYMGZTfoty5oHa9jLID CrlvCoKbeVd7Rh63g+gSq2E7egb+M4kLHEwgZkT/+0tiAxkK6f7lJcdk54+XWMz8b0b+gypxQkn i09xsAaCYVuutJ8G3flhEnArK3iRhudCDVQwJMP/3N8KcxgiGAJaXBziJeyd06jOOkIfC+zoxzZ oykeuGl2IeOQk4xck0ozTGKZ7BzDQf5ufbeCsAvgBXmGLD3XNpNCvdELHGpsst6EqDwqiEWY+Rx HYvKDy7YZw8QGLA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Move IPv4 header construction from netpoll_send_udp() into a new static helper function push_ipv4(). This completes the refactoring started with IPv6 header handling, creating symmetric helper functions for both IP versions. Changes include: 1. Extracting IPv4 header setup logic into push_ipv4() 2. Replacing inline IPv4 code with helper call 3. Moving eth assignment after helper calls for consistency The refactoring reduces code duplication and improves maintainability by isolating IP version-specific logic. Signed-off-by: Breno Leitao --- net/core/netpoll.c | 62 +++++++++++++++++++++++++++++++-------------------= ---- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 247a73762fc2c..ff64e94df5351 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -441,14 +441,44 @@ static void push_ipv6(struct netpoll *np, struct sk_b= uff *skb, int len) eth->h_proto =3D htons(ETH_P_IPV6); } =20 +static void push_ipv4(struct netpoll *np, struct sk_buff *skb, int len) +{ + static atomic_t ip_ident; + struct ethhdr *eth; + struct iphdr *iph; + int ip_len; + + ip_len =3D len + sizeof(struct udphdr) + sizeof(struct iphdr); + + skb_push(skb, sizeof(struct iphdr)); + skb_reset_network_header(skb); + iph =3D ip_hdr(skb); + + /* iph->version =3D 4; iph->ihl =3D 5; */ + *(unsigned char *)iph =3D 0x45; + iph->tos =3D 0; + put_unaligned(htons(ip_len), &iph->tot_len); + iph->id =3D htons(atomic_inc_return(&ip_ident)); + iph->frag_off =3D 0; + iph->ttl =3D 64; + iph->protocol =3D IPPROTO_UDP; + iph->check =3D 0; + put_unaligned(np->local_ip.ip, &iph->saddr); + put_unaligned(np->remote_ip.ip, &iph->daddr); + iph->check =3D ip_fast_csum((unsigned char *)iph, iph->ihl); + + eth =3D skb_push(skb, ETH_HLEN); + skb_reset_mac_header(skb); + skb->protocol =3D htons(ETH_P_IP); + eth->h_proto =3D htons(ETH_P_IP); +} + int netpoll_send_udp(struct netpoll *np, const char *msg, int len) { int total_len, ip_len, udp_len; struct sk_buff *skb; struct udphdr *udph; - struct iphdr *iph; struct ethhdr *eth; - static atomic_t ip_ident; =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) WARN_ON_ONCE(!irqs_disabled()); @@ -477,32 +507,12 @@ int netpoll_send_udp(struct netpoll *np, const char *= msg, int len) udph->len =3D htons(udp_len); =20 netpoll_udp_checksum(np, skb, len); - if (np->ipv6) { + if (np->ipv6) push_ipv6(np, skb, len); - eth =3D eth_hdr(skb); - } else { - skb_push(skb, sizeof(struct iphdr)); - skb_reset_network_header(skb); - iph =3D ip_hdr(skb); - - /* iph->version =3D 4; iph->ihl =3D 5; */ - *(unsigned char *)iph =3D 0x45; - iph->tos =3D 0; - put_unaligned(htons(ip_len), &(iph->tot_len)); - iph->id =3D htons(atomic_inc_return(&ip_ident)); - iph->frag_off =3D 0; - iph->ttl =3D 64; - iph->protocol =3D IPPROTO_UDP; - iph->check =3D 0; - put_unaligned(np->local_ip.ip, &(iph->saddr)); - put_unaligned(np->remote_ip.ip, &(iph->daddr)); - iph->check =3D ip_fast_csum((unsigned char *)iph, iph->ihl); - - eth =3D skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - skb->protocol =3D eth->h_proto =3D htons(ETH_P_IP); - } + else + push_ipv4(np, skb, len); =20 + eth =3D eth_hdr(skb); ether_addr_copy(eth->h_source, np->dev->dev_addr); ether_addr_copy(eth->h_dest, np->remote_mac); =20 --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66EFA2EE27C; Fri, 27 Jun 2025 17:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046962; cv=none; b=p3uU53l7IO9xHfblxYgpQAkOqPxPOnTfLggCW0ZYWtLtKaz9Hlo8IGHCHzj/0sxOBWQzdXI6ekMjRsS02FMR2I0/1Sf4rfsKiWyfo0DaGDqu6eaBThEJiTiQRHHUMId5brasEEbWhbnuQoUOx1w3w0m61JD85AdXvAHWXhaS5P8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046962; c=relaxed/simple; bh=oMOUjvb17dkMjNgn7pjR5NW3PcafE7gyNJxjq175LMk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g1frpkS1K/ZF8QHY1pMBl7yT0dNmfBSxkZo6slWqg+7xf2OajSn3ETQ3fMDxNLaRgXHox4dDckPObjGEns3QBnbDtuAJO+hKeSx1z3Cvcc7Es+0PmgMSViFYNSIMnAKYpbUTcY7X2ifkqUsVyrQ0Llr1C01TkwZPZmhOX6ApWvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-60c4521ae2cso4504783a12.0; Fri, 27 Jun 2025 10:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046959; x=1751651759; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RYDZVXt1K3tFXA7SAWfw+XZ1JpA27F2JTM3+wG8ec70=; b=PL+/BbyNyfXPVkQLh85mKRBP6erMfxcEbBDoGEQaeYxjM3SBWk1ISBAxAldJPOW17C ebCFK0oU6V168iPhwwYqiBJTH26Ya1xSEHP43vIkOezVeFP/dZJguuf7fZ4olUboisyw akjgbJxpRF+ROC4KD+tATy2d5AXHjMQCIzast/XNhgBV2eZA36ZgTKTWf4VhPBVVgcsd dGJPLotkrO+Mjdw2SMMi+vPuakZi0FvPsa7pDlMM53jb/pYLd7Mip0FKghRC4bMnda69 6iEt+vhA+1viVRh3EpmY1ROzyqU5mVzuTELx8SFbxRFQkDJr6sN99fpcJmDInXaOyNRS IDMA== X-Forwarded-Encrypted: i=1; AJvYcCVGd8rvZdxyivEnnK4+r4QvZc3ofY7XEBpH9+UqnfnlgIzzODsPlr4pWlvQVNyzWoWruvXHq8fDNvn13qa1HDCv@vger.kernel.org, AJvYcCVwPnly0BycKjnkfsP4t8crsNtEJjJFlGsiNJ5aePZeox7Rg0LlYzRWYCvYPnKtuYrA1wMYZAOvKa62G1A=@vger.kernel.org X-Gm-Message-State: AOJu0YxN+NVAS113MPUN2WayA7W+ejo7wbI9ZUXRkQoW3vATN7AOSK7j wwzUpbSwRarEZ3Ek/CtAvvmGY2HNwzOcAkOt8/g4LJiX/htsYfzPd/X9 X-Gm-Gg: ASbGnctdWef4O3jEyNN+FBf7MmJFJAQBcA/lcF2W5mo8yN0X7OM7399I1ep2BdrbfHd LyMqrN4vjcyhFVVkV4EHy4oZPe1X2ppK/ffg71pSChqNJQMizZjgblP2cE+SwyJ+sN0wn7ReR5n w2tLwZ6SPww5LTgxA3Rqk36oq5FmfvejXmXo52E+TnRmhl2E5WqUk79GcGJYAX+07rP35wL2zyv kO5CoepwVfMVZSkz90PiWHzRcaC0avvsE43Bsfe+q1ad0Nitxb66OztzKnZqjCZLylY9a51U9Sr QPkIVCU5o2kD8A+FVuKPeFoh4oVc1rTLkJK+LeK3zsYlMKu7Xh7sSrZrj+Oa9vo= X-Google-Smtp-Source: AGHT+IGPMfxBFzdVtmU6aO7sJzDek40Zxc8CFLGTkaONoG0scZ4/v3uLaSR8KfrkjV+J42HjmwVJHQ== X-Received: by 2002:a05:6402:350c:b0:607:ea0c:65b2 with SMTP id 4fb4d7f45d1cf-60c88e64bfbmr3638601a12.31.1751046958559; Fri, 27 Jun 2025 10:55:58 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:9::]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-60c8319b333sm1774197a12.40.2025.06.27.10.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:58 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:51 -0700 Subject: [PATCH net-next 5/7] netpoll: factor out UDP header setup into push_udp() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-5-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=2123; i=leitao@debian.org; h=from:subject:message-id; bh=oMOUjvb17dkMjNgn7pjR5NW3PcafE7gyNJxjq175LMk=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslxabGqvLOoJi0qm6WxO4hE9T21yO8n1ukf faiLPw4UuOJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 beCRD/0cMNoa6KRm++iPV10N41fFdDxCu8dmG/Wf0Zt8yOGcvaPOmi23B0L7em9uZycjGGokSgO cHiwhkj8DSBW3YTrlj1w11MLdlWD4ig4LH2tLK7wxE3gf4NFGwCJ29hDd/RVx+u0ocZymZNPHdw 5N0qi5Xcin6rCDTN2dYFjf+r6cfLZSudmYRiCCHAl1eYb6QVrHDu3f0ObmJ5KzYgDgTEvxbVDHc q5xzfCi9mTI2FJUFFAEmaPjNeEUhuLGljZ7oCs1REJqfaId9xzwhqQHk8v7DZf+D5HT1cldFAvR qGtaXIVTuth7UfU6/3IveAMsHsZfCGO73cWjNGbRV29knLDE1ETv4f43AjFQGrlkfLt97QAVENy IJYtxWsayXZW3BZqViKwJ9OMEB0/mw8XuoX0/CXWB8XTyG4En9+tqKLEHfESLh77ed5/VWbk0Vq p65Kwkm8W7R6QqaX2cNZ+cvuUlKzhUx/gkQLWi5MvwvljRJ+491K79ATbhd3QpA+4TRRUDZoI0e 88P/22SOO1MjNgoz9EvrJKVyOosyxq4hKg8hQJWMyvzcTQ870zXA2cZUx0ralFL29tb+LOLj9p+ z3eF8qx6TfuQkxu5FY7FGcW82tt+VZxmrFBLk0c3L+HQQOl4krZaZDB8tafZxegk5+aLZc1ICvn D9xn5Ur1w26tqYQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Move UDP header construction from netpoll_send_udp() into a new static helper function push_udp(). This completes the protocol layer refactoring by: 1. Creating a dedicated helper for UDP header assembly 2. Removing UDP-specific logic from the main send function 3. Establishing a consistent pattern with existing IPv4/IPv6 helpers: - push_udp() - push_ipv4() - push_ipv6() The change improves code organization and maintains the encapsulation pattern established in previous refactorings. Signed-off-by: Breno Leitao --- net/core/netpoll.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index ff64e94df5351..70035e27d91cc 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -473,11 +473,28 @@ static void push_ipv4(struct netpoll *np, struct sk_b= uff *skb, int len) eth->h_proto =3D htons(ETH_P_IP); } =20 +static void push_udp(struct netpoll *np, struct sk_buff *skb, int len) +{ + struct udphdr *udph; + int udp_len; + + udp_len =3D len + sizeof(struct udphdr); + + skb_push(skb, sizeof(struct udphdr)); + skb_reset_transport_header(skb); + + udph =3D udp_hdr(skb); + udph->source =3D htons(np->local_port); + udph->dest =3D htons(np->remote_port); + udph->len =3D htons(udp_len); + + netpoll_udp_checksum(np, skb, len); +} + int netpoll_send_udp(struct netpoll *np, const char *msg, int len) { int total_len, ip_len, udp_len; struct sk_buff *skb; - struct udphdr *udph; struct ethhdr *eth; =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) @@ -499,14 +516,7 @@ int netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) skb_copy_to_linear_data(skb, msg, len); skb_put(skb, len); =20 - skb_push(skb, sizeof(struct udphdr)); - skb_reset_transport_header(skb); - udph =3D udp_hdr(skb); - udph->source =3D htons(np->local_port); - udph->dest =3D htons(np->remote_port); - udph->len =3D htons(udp_len); - - netpoll_udp_checksum(np, skb, len); + push_udp(np, skb, len); if (np->ipv6) push_ipv6(np, skb, len); else --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 048932EE5FA; Fri, 27 Jun 2025 17:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046963; cv=none; b=ctVdkuV+ZmuwCuHman35EuTtJ0SESuiAGo9+vFtC/xT9u+b8jGyaYN85jr+xyNrAEv5K0D7WcBZP0fTjQK/ePUFAtNPXvSYHRFHyU+2AwPK1jReR54v+NTthooIYJA+DmUTkqy0khraDZhYshrnh6xiJ4A8yRjlADJ5cWpUVGnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046963; c=relaxed/simple; bh=NHC97aT/kQf6DyeueUL+Np2VNwBSf75NdsGhKFItyvo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K5JsRY5GvSfhlYcj/nGgzoMdAgcOjBwwwrGQqAvh21vhCSniFY4Sm3GWSX+tzsJA4U8q+WiEREwi61rpMhHY32lW9XWktYjXSMPCRb8UlQqtJoWs1Q7tx3QmorBX0Zer0z5DKl3274Uck9BLUmLNbKgomYmdN6p6MnbsKZR/4zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-ae0ccfd5ca5so8775166b.3; Fri, 27 Jun 2025 10:56:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046960; x=1751651760; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w+LjrrAqRFuNuvBnrVE1gGfY7DUJLU7K/HkAJCFE+ck=; b=eZaYwH4s6fTtc0vQ1Tdgw5q35/+6qlieK0pi0oV0j+NgxUStBmOXc9LqmG+gYPlAO6 6cEqLyiK564mSy+2lG8p8Qo2fTJf4CiZ/8nJ+/9WAZ5KKOhMC0NsS77BJEoLJcl1aRtP A0bnO3u/aCq41RQoOq44jnKmqEjRV0YyjE/W9qQJcEn5S6mnXARL8RE9wEj1qzd8XLhi m1GTQzNq+B/3j/vvoynYNebrMoABC5ZR6XQvZhFkDMCq/5rZckSWXyzD6B2nwKeEYh7/ ZaNYSrQwKsX+4JlWZV19XRmd1VbBVhNjyWjIhvjYHnmoSgT6laNoqdFuOH/KBY0O8X2p teIg== X-Forwarded-Encrypted: i=1; AJvYcCWCj03ANWLf1HAVZO1t6+lW0swbgjCWZsFR54dTzjHk8AcI/H+ep4TbR8ZEvzM2HIMbottDfinD1yHgOfZbtanU@vger.kernel.org, AJvYcCXdFs8+5YuiQGwV/is3yY3gF3tMmyBYY1PkWYWZ4MY0fHZaWpP7KQRm/Mi1StX7Si3STsUJw5KKheCliqw=@vger.kernel.org X-Gm-Message-State: AOJu0YyXrFYaIdZZ1wPDz064PzhuhK+6S+tPWryTckLa7w1PoDcTwVEj mfL66xELeAlBL0/xEU11cPjMugR2/YiN0Zmj+5Ldo4CUcV6z6uj2BtpJ X-Gm-Gg: ASbGncv2VNSQ0zb1uI/7SHyo7PUJu7+691EbPoYg5UV9Hca+2n1KsJ6YLths02P/2Le Y9zG8oZbJYA0rRbtRMe3yQ4BsF16itstOEe0ObAjiT9CPb61ae32srUkNDCGzjaYyW/KJ03PXRP KFHNXj258bYUMPhzM5qOEQb7IxAfmFgCOQpYZNpZus/kq7UCwwvG1KO4ZeEU9v2q8LWgTpywNGO mTm4osZI3v7WbG/hHRskwzFQeMLdu4as65+qTnV4TQJDIZXqJ7DVoG9pGp/QzajdZeg0SObKyCq y30MaUToN3p3eqLJnugc3W9ixrjwc7aJXr7MrsyKKr45HTg3eAy0 X-Google-Smtp-Source: AGHT+IHoCWnbMx61F0L6qkW6UFUeCy8IsXYPNmEsz1xXZrlI/h6vcdq2MP4uhKk+Uwk4ONrBIeo4SA== X-Received: by 2002:a17:906:478f:b0:ade:c643:62ce with SMTP id a640c23a62f3a-ae35016e6d6mr424901366b.56.1751046959886; Fri, 27 Jun 2025 10:55:59 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:2::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae353c6bd2dsm165792766b.113.2025.06.27.10.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:55:59 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:52 -0700 Subject: [PATCH net-next 6/7] netpoll: move Ethernet setup to push_eth() helper Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-6-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=1495; i=leitao@debian.org; h=from:subject:message-id; bh=NHC97aT/kQf6DyeueUL+Np2VNwBSf75NdsGhKFItyvo=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslHLWQv+0lSWBA0BmmBBQgeBqfXV4vlJrIw MqcXoc0LsuJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 ba7PD/9cCOW9ZwZq7kh4XbZbxlwm5eTWdvbPKYYL6d9L17tgWVXymWgI/OVgzIzuFF+4/+THq2+ xfFDzLwwQb55C0Za3sCSlet7Fa+XPzi9RyeYW5uCuHl3vZRqAPX4qWs+ITOQ4lNGb4fBUAxipmL SQ6bO3ucFJzoV+kM9g1MOXU/yQqRqJM2MrsBAHVGFiAaBDttKcdG6WQHOkf6b6nc1nZyRsi17E5 E/8H9au0UR1Cb7BPzdcd6tLZCxFhFfEPBeEJBwDAqMADgaNdOOU7bILv0iwCvJ5HkBCaCDyh/gD Uw+yunJuW9bapleva6RPUiOObOxsbRyHhxKGVokviEG8QEvZATv/csKijEFbemhFQbVa4KOliJP hnnb9u4b6SmfropSmpiUNHELa8ohLJkKPibt25xv7JhhgOK7KxRv8yvzfy4Dzaeeev0us0fuaH7 TcBFTa6vHYPo0nClXKIF8a4Tp+rG3ogsyFyeLVBBQTWZJuc+z+BAIgS66E7cNZze762MFXzMfsz E/Z8bgpILKNeAIQy0gvRUry73Zmar2KuHhcmsMG2llajwZ598RQB3elMHT+9/cPBOFJhru/evOF bNl86nKBDxKaI+jfC98Db5/u6wnlt1XJXUDWs1Y4MxhbUVJDv9YZqWnBtgaaoMjE8uxlqZhOKhK HlaofcfFd8c+pWQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Refactor Ethernet header population into dedicated function, completing the layered abstraction with: - push_eth() for link layer - push_udp() for transport - push_ipv4()/push_ipv6() for network Signed-off-by: Breno Leitao --- net/core/netpoll.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 70035e27d91cc..9ab3cf78a393c 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -491,11 +491,19 @@ static void push_udp(struct netpoll *np, struct sk_bu= ff *skb, int len) netpoll_udp_checksum(np, skb, len); } =20 +static void push_eth(struct netpoll *np, struct sk_buff *skb) +{ + struct ethhdr *eth; + + eth =3D eth_hdr(skb); + ether_addr_copy(eth->h_source, np->dev->dev_addr); + ether_addr_copy(eth->h_dest, np->remote_mac); +} + int netpoll_send_udp(struct netpoll *np, const char *msg, int len) { int total_len, ip_len, udp_len; struct sk_buff *skb; - struct ethhdr *eth; =20 if (!IS_ENABLED(CONFIG_PREEMPT_RT)) WARN_ON_ONCE(!irqs_disabled()); @@ -521,11 +529,7 @@ int netpoll_send_udp(struct netpoll *np, const char *m= sg, int len) push_ipv6(np, skb, len); else push_ipv4(np, skb, len); - - eth =3D eth_hdr(skb); - ether_addr_copy(eth->h_source, np->dev->dev_addr); - ether_addr_copy(eth->h_dest, np->remote_mac); - + push_eth(np, skb); skb->dev =3D np->dev; =20 return (int)netpoll_send_skb(np, skb); --=20 2.47.1 From nobody Wed Oct 8 12:51:19 2025 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C9272EE293; Fri, 27 Jun 2025 17:56:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046965; cv=none; b=S6EkANBZ25QMhkHSue0/OulzS/AUDuL7mIG01g1jzzu3qE4fm20nhpwAuqLuyGo8LtusBHVbUnxfLTeZrGHfnBiyIkpkMQNhWRGLrOZqIoyNnuxBmAyqq6MT7p3j1/foN5rtOHVFLjX4WPBDPGKHiAoeb3j3EQl4jB0ncPD4huc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751046965; c=relaxed/simple; bh=D+oRPe93Nm/8lmSF6pVDNA/nCNLjVome6Fp+fkRvNWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ShhYfimZfU5EQsjd7a70dN9VlmoPZyCt7saoDVrPVgMeXEuqKyjXOdfMZZp29mSdlSDtSbd6Bv/R8EhClrVXHsRJmVpkgqGxmFEHMxZsSLOzg0y+ZYjCXGDF26V7/tw2+92MWYXbIoAMIwPIRps9jiaucwiUeb1BQ3NKeov6XBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-ae0b6532345so663435366b.1; Fri, 27 Jun 2025 10:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751046961; x=1751651761; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=omLci4L9HXaOKKQZZQ7UbJZ8uawl1hkgxO5eUGCEDLc=; b=ucBCudnZ6pFG0cLFtf8uVPP/ebq/fcX+NRWq4oVChu3TPgqBiYUPm8cXuzWJH3a3Xo zY5foxF83BD2sHs2u55RgpPnBMJJgUiowUUWVRfzSFZw5lD0uDJPqJrclsYAQ+zKzqQ4 2I3FPvcoVk2pcmyr42QQKsPjRh3luaFmY0nPK1JBPd01ORbrlq7nQnWbo4BFHy1QObzq xW7VZ63Zat019jPnAomSvfgvbictRbEKgC8ou9K6O9ehqnRu85OGpTrR5deMyFLfswOg y5m7m8Ju3mPL2pMbNHRVhJRXsjTO3D/N3FTCI8oehYCPWCi+ZfOB6uhwnRRxPIFmBHId rN0Q== X-Forwarded-Encrypted: i=1; AJvYcCVlCkk5qHNKNwFengysdvXE92oiGl40oX11GNaqzFPqgLToVSTYaA6DoVE7/8RVyVQnnhFEFYiyxZ1LtrM=@vger.kernel.org, AJvYcCWtCL0X/Dty9aIer9E24Qc9iwyTPrubQbipF6TabBGQAJMXcbVwu7sm8bpnoQlCKHN8mkhmmq0vnSCn6RwmzeWL@vger.kernel.org X-Gm-Message-State: AOJu0YwD+bBYjzu71njR2gQ9T9Y919wS+MHuFodENHEn/EFTgURfmPtD Cm49pAHlGNYSpMuuhuJ+HOGN5SOpKo8DqPIWu0SxkXJKiu1UBO272HpY X-Gm-Gg: ASbGncs/Dk/ZFrCm6wLsBRt+Q7LQptf8GmhyX7LIcvEEcjIxHjE+226kxiKFj2r4k3f lnmJbPJy3VsKmCsyMbFjJwl16XAq0mqh9Isb8WfBEVn3YkNjO4k1sMryMTH032cem219BGp64kd NwKDrTxr/RSGCT7WYSwWObGQYubY2xUaH7cK7R6ThaqB3uwv3IeNxdcLegWmsVFmtb2UaxO5LWr Z2RC5bsyBV5tuaMSJySokoAS/5ut6Gw/SZHAlyINxAmVulj96FYriJBjFob07dosys+zoeNEKCO 3mSkdFYnRO579hSq5wy/APOqP7I+q9aeHRBdFZR3eHY4IPy4AP0faw== X-Google-Smtp-Source: AGHT+IGrH0QZF2oANW/OIc+COjxvp38jMb0IoxvnRzvKqeOg3r2T0nzkH6r2PKDQkVIC0MkfI1MkYQ== X-Received: by 2002:a17:906:f414:b0:ae0:ace9:67eb with SMTP id a640c23a62f3a-ae0d27323c7mr839223166b.14.1751046961215; Fri, 27 Jun 2025 10:56:01 -0700 (PDT) Received: from localhost ([2a03:2880:30ff:74::]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae353c01237sm166279066b.98.2025.06.27.10.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jun 2025 10:56:00 -0700 (PDT) From: Breno Leitao Date: Fri, 27 Jun 2025 10:55:53 -0700 Subject: [PATCH net-next 7/7] selftests: net: Add IPv6 support to netconsole basic tests Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-netpoll_untagle_ip-v1-7-61a21692f84a@debian.org> References: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> In-Reply-To: <20250627-netpoll_untagle_ip-v1-0-61a21692f84a@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , gustavold@gmail.com X-Mailer: b4 0.15-dev-dd21f X-Developer-Signature: v=1; a=openpgp-sha256; l=7410; i=leitao@debian.org; h=from:subject:message-id; bh=D+oRPe93Nm/8lmSF6pVDNA/nCNLjVome6Fp+fkRvNWU=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBoXtslR7u/LQusdmyg8dF/OMCnOd73/s1aQ3pEe zPCpHrXc/CJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaF7bJQAKCRA1o5Of/Hh3 bbQzD/9BUUyNWYZrg9sDZmaDAQ4738+rdYp9Ze0IGbN/EFKwm1cIUvJrIyXIrXVCYr/tp0SquM5 bZW1VyuOTviy/O//9+xUhcQy1u+QmdPYe34Vfc5VvZnaNSORMuWnYrf+dr7F0KvIbJkAVlIwir1 m7m37HMw0znLggeEY4/gTDrmdCPrrzOs9uY7Kua5Kd5kOF2eYgrGCGqiTyj6H528cVbVpS0LHS6 MqThfVBmSECddrWKSQ7UcI9EDaK1Tybj84iwF2F9JPOOhxKwT8wrf4TFU6QgO2upbKGbSHj2GXv 1m5QkLw1qpAhB5+LL05WKlKwYvnGITN8fxjcCcWIJeR0nXAwOApoNU5CGpctuz1s+PKFxRDHF0+ rzhppeDoPqoCJIOoEb1jrb1EE/zpcV0zyiA0YwOPekv8BS1ZjZVDYOsQkWhbM7S30RIYC38ORFi Ev4piQmNCl5Xtln3WqPLIcVRE9R7T+P4oWIMy3JFwFGQytMnFIohXq9/oLwIQ2lCKI3NW1clCeP xVZHUnRfl7HHM+sRdlJohhtvqBqgJ7QfQwy1EvKP/gFUGKHSedYksUkRLzzdEGHt9PfWO0NyauC X8WECYWtC9MozsGb3f1LqakY+tbP7MPNbQi9rNng75vCxXMVg5//xzXuzv0IrZL1EPf3rJmCwqM rL2m/BE6Vt3sudA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add IPv6 support to the netconsole basic functionality tests by: - Introducing separate IPv4 and IPv6 address variables (SRCIP4/SRCIP6, DSTIP4/DSTIP6) to replace the single SRCIP/DSTIP variables - Adding select_ipv4_or_ipv6() function to choose protocol version - Updating socat configuration to use UDP6-LISTEN for IPv6 tests - Adding wait_for_port() wrapper to handle protocol-specific port waiting - Expanding test matrix to run both basic and extended formats against both IPv4 and IPv6 protocols - Improving cleanup to kill any remaining socat processes - Adding sleep delays for better IPv6 packet handling reliability The test now validates netconsole functionality across both IP versions, improving test coverage for dual-stack network environments. This test would avoid the regression fixed by commit f59902070269 ("net: netpoll: Initialize UDP checksum field before checksumming") Signed-off-by: Breno Leitao --- .../selftests/drivers/net/lib/sh/lib_netcons.sh | 74 ++++++++++++++++++= ++-- .../testing/selftests/drivers/net/netcons_basic.sh | 52 ++++++++------- 2 files changed, 96 insertions(+), 30 deletions(-) diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/to= ols/testing/selftests/drivers/net/lib/sh/lib_netcons.sh index 3fcf85a345969..60f968713cad7 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -11,9 +11,11 @@ set -euo pipefail LIBDIR=3D$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") =20 SRCIF=3D"" # to be populated later -SRCIP=3D192.0.2.1 +SRCIP4=3D"192.0.2.1" +SRCIP6=3D"fc00::1" DSTIF=3D"" # to be populated later -DSTIP=3D192.0.2.2 +DSTIP4=3D"192.0.2.2" +DSTIP6=3D"fc00::2" =20 PORT=3D"6666" MSG=3D"netconsole selftest" @@ -80,7 +82,23 @@ function configure_ip() { ip link set "${SRCIF}" up } =20 +function select_ipv4_or_ipv6() +{ + local VERSION=3D${1} + + if [[ "$VERSION" =3D=3D "ipv6" ]] + then + DSTIP=3D"${DSTIP6}" + SRCIP=3D"${SRCIP6}" + else + DSTIP=3D"${DSTIP4}" + SRCIP=3D"${SRCIP4}" + fi +} + function set_network() { + local IP_VERSION=3D${1:-"ipv4"} + # setup_ns function is coming from lib.sh setup_ns NAMESPACE =20 @@ -91,6 +109,7 @@ function set_network() { # Link both interfaces back to back link_ifaces =20 + select_ipv4_or_ipv6 "${IP_VERSION}" configure_ip } =20 @@ -119,6 +138,11 @@ function create_dynamic_target() { fi =20 echo 1 > "${NETCONS_PATH}"/enabled + + # This will make sure that the kernel was able to + # load the netconsole driver configuration. The console message + # gets more organized/sequential as well. + sleep 1 } =20 # Generate the command line argument for netconsole following: @@ -179,9 +203,18 @@ function set_user_data() { =20 function listen_port_and_save_to() { local OUTPUT=3D${1} + local IPVERSION=3D${2:-"ipv4"} + + if [ "${IPVERSION}" =3D=3D "ipv4" ] + then + SOCAT_MODE=3D"UDP-LISTEN" + else + SOCAT_MODE=3D"UDP6-LISTEN" + fi + # Just wait for 2 seconds timeout 2 ip netns exec "${NAMESPACE}" \ - socat UDP-LISTEN:"${PORT}",fork "${OUTPUT}" + socat "${SOCAT_MODE}":"${PORT}",fork "${OUTPUT}" } =20 # Only validate that the message arrived properly @@ -263,8 +296,13 @@ function check_for_dependencies() { exit "${ksft_skip}" fi =20 - if ip addr list | grep -E "inet.*(${SRCIP}|${DSTIP})" 2> /dev/null; then - echo "SKIP: IPs already in use. Skipping it" >&2 + if ip addr list | grep -E "inet.*(${SRCIP4}|${DSTIP4})" 2> /dev/null; then + echo "SKIP: IPv4s already in use. Skipping it" >&2 + exit "${ksft_skip}" + fi + + if ip addr list | grep -E "inet.*(${SRCIP6}|${DSTIP6})" 2> /dev/null; then + echo "SKIP: IPv6s already in use. Skipping it" >&2 exit "${ksft_skip}" fi } @@ -278,11 +316,13 @@ function check_for_taskset() { =20 # This is necessary if running multiple tests in a row function pkill_socat() { - PROCESS_NAME=3D"socat UDP-LISTEN:6666,fork ${OUTPUT_FILE}" + PROCESS_NAME4=3D"socat UDP-LISTEN:6666,fork ${OUTPUT_FILE}" + PROCESS_NAME6=3D"socat UDP6-LISTEN:6666,fork ${OUTPUT_FILE}" # socat runs under timeout(1), kill it if it is still alive # do not fail if socat doesn't exist anymore set +e - pkill -f "${PROCESS_NAME}" + pkill -f "${PROCESS_NAME4}" + pkill -f "${PROCESS_NAME6}" set -e } =20 @@ -294,3 +334,23 @@ function check_netconsole_module() { exit "${ksft_skip}" fi } + +# A wrapper to translate protocol version to udp version +function wait_for_port() { + local NAMESPACE=3D${1} + local PORT=3D${2} + IP_VERSION=3D${3} + + if [ "${IP_VERSION}" =3D=3D "ipv6" ] + then + PROTOCOL=3D"udp6" + else + PROTOCOL=3D"udp" + fi + + wait_local_port_listen "${NAMESPACE}" "${PORT}" "${PROTOCOL}" + # even after the port is open, let's wait 1 second before writing + # otherwise the packet could be missed, and the test will fail. Happens + # more frequently on IPv6 + sleep 1 +} diff --git a/tools/testing/selftests/drivers/net/netcons_basic.sh b/tools/t= esting/selftests/drivers/net/netcons_basic.sh index 40a6ac6191b8b..c627993dc8605 100755 --- a/tools/testing/selftests/drivers/net/netcons_basic.sh +++ b/tools/testing/selftests/drivers/net/netcons_basic.sh @@ -36,30 +36,36 @@ trap cleanup EXIT # Run the test twice, with different format modes for FORMAT in "basic" "extended" do - echo "Running with target mode: ${FORMAT}" - # Create one namespace and two interfaces - set_network - # Create a dynamic target for netconsole - create_dynamic_target "${FORMAT}" - # Only set userdata for extended format - if [ "$FORMAT" =3D=3D "extended" ] - then - # Set userdata "key" with the "value" value - set_user_data - fi - # Listed for netconsole port inside the namespace and destination interfa= ce - listen_port_and_save_to "${OUTPUT_FILE}" & - # Wait for socat to start and listen to the port. - wait_local_port_listen "${NAMESPACE}" "${PORT}" udp - # Send the message - echo "${MSG}: ${TARGET}" > /dev/kmsg - # Wait until socat saves the file to disk - busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}" + for IP_VERSION in "ipv6" "ipv4" + do + echo "Running with target mode: ${FORMAT} (${IP_VERSION})" + # Create one namespace and two interfaces + set_network "${IP_VERSION}" + # Create a dynamic target for netconsole + create_dynamic_target "${FORMAT}" + # Only set userdata for extended format + if [ "$FORMAT" =3D=3D "extended" ] + then + # Set userdata "key" with the "value" value + set_user_data + fi + # Listed for netconsole port inside the namespace and destination interf= ace + listen_port_and_save_to "${OUTPUT_FILE}" "${IP_VERSION}" & + # Wait for socat to start and listen to the port. + wait_for_port "${NAMESPACE}" "${PORT}" "${IP_VERSION}" + # Send the message + echo "${MSG}: ${TARGET}" > /dev/kmsg + # Wait until socat saves the file to disk + busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}" =20 - # Make sure the message was received in the dst part - # and exit - validate_result "${OUTPUT_FILE}" "${FORMAT}" - cleanup + # Make sure the message was received in the dst part + # and exit + validate_result "${OUTPUT_FILE}" "${FORMAT}" + # kill socat in case it is still running + pkill_socat + cleanup + echo "${FORMAT} : ${IP_VERSION} : Test passed" >&2 + done done =20 trap - EXIT --=20 2.47.1