netconsole: move push_ipv4() from netpoll

push_ipv4() builds the IPv4 header for netconsole's UDP 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.

put_unaligned() is no longer used in net/core/netpoll.c, so drop
the now-stale <linux/unaligned.h> include from there. Pull it into
netconsole.c so the moved code keeps building.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260512-netconsole_split-v2-4-1191d14ad66d@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Breno Leitao 2026-05-12 03:46:37 -07:00 committed by Jakub Kicinski
parent c411baa463
commit 5664c3908b
3 changed files with 28 additions and 30 deletions

View File

@ -37,6 +37,7 @@
#include <linux/udp.h>
#include <linux/netpoll.h>
#include <linux/inet.h>
#include <linux/unaligned.h>
#include <linux/configfs.h>
#include <linux/etherdevice.h>
#include <linux/hex.h>
@ -1651,6 +1652,33 @@ static struct notifier_block netconsole_netdev_notifier = {
.notifier_call = netconsole_netdev_event,
};
static void push_ipv4(struct netpoll *np, struct sk_buff *skb, int len)
{
static atomic_t ip_ident;
struct iphdr *iph;
int ip_len;
ip_len = len + sizeof(struct udphdr) + sizeof(struct iphdr);
skb_push(skb, sizeof(struct iphdr));
skb_reset_network_header(skb);
iph = ip_hdr(skb);
/* iph->version = 4; iph->ihl = 5; */
*(unsigned char *)iph = 0x45;
iph->tos = 0;
put_unaligned(htons(ip_len), &iph->tot_len);
iph->id = htons(atomic_inc_return(&ip_ident));
iph->frag_off = 0;
iph->ttl = 64;
iph->protocol = IPPROTO_UDP;
iph->check = 0;
put_unaligned(np->local_ip.ip, &iph->saddr);
put_unaligned(np->remote_ip.ip, &iph->daddr);
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
skb->protocol = htons(ETH_P_IP);
}
static void push_ipv6(struct netpoll *np, struct sk_buff *skb, int len)
{
struct ipv6hdr *ip6h;

View File

@ -75,7 +75,6 @@ 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);
void push_ipv4(struct netpoll *np, struct sk_buff *skb, int len);
void push_udp(struct netpoll *np, struct sk_buff *skb, int len);
void push_eth(struct netpoll *np, struct sk_buff *skb);

View File

@ -34,7 +34,6 @@
#include <net/addrconf.h>
#include <net/ndisc.h>
#include <net/ip6_checksum.h>
#include <linux/unaligned.h>
#include <trace/events/napi.h>
#include <linux/kconfig.h>
@ -413,34 +412,6 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
}
EXPORT_SYMBOL(netpoll_send_skb);
void push_ipv4(struct netpoll *np, struct sk_buff *skb, int len)
{
static atomic_t ip_ident;
struct iphdr *iph;
int ip_len;
ip_len = len + sizeof(struct udphdr) + sizeof(struct iphdr);
skb_push(skb, sizeof(struct iphdr));
skb_reset_network_header(skb);
iph = ip_hdr(skb);
/* iph->version = 4; iph->ihl = 5; */
*(unsigned char *)iph = 0x45;
iph->tos = 0;
put_unaligned(htons(ip_len), &iph->tot_len);
iph->id = htons(atomic_inc_return(&ip_ident));
iph->frag_off = 0;
iph->ttl = 64;
iph->protocol = IPPROTO_UDP;
iph->check = 0;
put_unaligned(np->local_ip.ip, &iph->saddr);
put_unaligned(np->remote_ip.ip, &iph->daddr);
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
skb->protocol = htons(ETH_P_IP);
}
EXPORT_SYMBOL_GPL(push_ipv4);
void push_udp(struct netpoll *np, struct sk_buff *skb, int len)
{
struct udphdr *udph;