]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netconsole: move netpoll_udp_checksum() from netpoll
authorBreno Leitao <leitao@debian.org>
Tue, 12 May 2026 10:46:40 +0000 (03:46 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 May 2026 01:09:13 +0000 (18:09 -0700)
netpoll_udp_checksum() computes the UDP checksum for netconsole's
packets. Move it into drivers/net/netconsole.c as a file-static
helper; drop its EXPORT_SYMBOL_GPL and remove the prototype from
include/linux/netpoll.h.

This was the last csum_ipv6_magic() consumer in net/core/netpoll.c,
so drop the now-stale <net/ip6_checksum.h> include there. Pull it
into netconsole.c so the moved code keeps building.

It was also the last udp_hdr() consumer in net/core/netpoll.c. The
file no longer needs anything from <net/udp.h> (the UDP socket-layer
helpers); MAX_SKB_SIZE only needs struct udphdr, which is provided
by the lighter <linux/udp.h>. Swap the include accordingly.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260512-netconsole_split-v2-7-1191d14ad66d@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c
include/linux/netpoll.h
net/core/netpoll.c

index e8d96e482fe0572f40b75b70229cd42282a1ea5a..48d2670bbdef5e6348aaadcdffd0f8f1cf450eaf 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/netpoll.h>
 #include <linux/inet.h>
 #include <linux/unaligned.h>
+#include <net/ip6_checksum.h>
 #include <linux/configfs.h>
 #include <linux/etherdevice.h>
 #include <linux/hex.h>
@@ -1652,6 +1653,31 @@ static struct notifier_block netconsole_netdev_notifier = {
        .notifier_call  = netconsole_netdev_event,
 };
 
+static void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb,
+                                int len)
+{
+       struct udphdr *udph;
+       int udp_len;
+
+       udp_len = len + sizeof(struct udphdr);
+       udph = udp_hdr(skb);
+
+       /* check needs to be set, since it will be consumed in csum_partial */
+       udph->check = 0;
+       if (np->ipv6)
+               udph->check = csum_ipv6_magic(&np->local_ip.in6,
+                                             &np->remote_ip.in6,
+                                             udp_len, IPPROTO_UDP,
+                                             csum_partial(udph, udp_len, 0));
+       else
+               udph->check = csum_tcpudp_magic(np->local_ip.ip,
+                                               np->remote_ip.ip,
+                                               udp_len, IPPROTO_UDP,
+                                               csum_partial(udph, udp_len, 0));
+       if (udph->check == 0)
+               udph->check = CSUM_MANGLED_0;
+}
+
 static void push_udp(struct netpoll *np, struct sk_buff *skb, int len)
 {
        struct udphdr *udph;
index 03a49953a3d8ac88fce5cb571289f6b79b671933..1877d42ccbccf1f8afd33cb18836f69ca484810c 100644 (file)
@@ -74,7 +74,6 @@ void netpoll_cleanup(struct netpoll *np);
 void do_netpoll_cleanup(struct netpoll *np);
 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
 struct sk_buff *find_skb(struct netpoll *np, int len, int reserve);
-void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb, int len);
 
 #ifdef CONFIG_NETPOLL
 static inline void *netpoll_poll_lock(struct napi_struct *napi)
index 96c65625f4cbb8862eafcb5b9d84118eab14ce82..c148b3b68cec9fa5095445d3c7cca27e29a15cf8 100644 (file)
 #include <linux/slab.h>
 #include <linux/export.h>
 #include <linux/if_vlan.h>
+#include <linux/udp.h>
 #include <net/tcp.h>
-#include <net/udp.h>
 #include <net/addrconf.h>
 #include <net/ndisc.h>
-#include <net/ip6_checksum.h>
 #include <trace/events/napi.h>
 #include <linux/kconfig.h>
 
@@ -369,32 +368,6 @@ out:
        return ret;
 }
 
-void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb,
-                         int len)
-{
-       struct udphdr *udph;
-       int udp_len;
-
-       udp_len = len + sizeof(struct udphdr);
-       udph = udp_hdr(skb);
-
-       /* check needs to be set, since it will be consumed in csum_partial */
-       udph->check = 0;
-       if (np->ipv6)
-               udph->check = csum_ipv6_magic(&np->local_ip.in6,
-                                             &np->remote_ip.in6,
-                                             udp_len, IPPROTO_UDP,
-                                             csum_partial(udph, udp_len, 0));
-       else
-               udph->check = csum_tcpudp_magic(np->local_ip.ip,
-                                               np->remote_ip.ip,
-                                               udp_len, IPPROTO_UDP,
-                                               csum_partial(udph, udp_len, 0));
-       if (udph->check == 0)
-               udph->check = CSUM_MANGLED_0;
-}
-EXPORT_SYMBOL_GPL(netpoll_udp_checksum);
-
 netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
        unsigned long flags;