[PATCH 07/10] net: netconsole: use net_eth_to_udp() for packet parsing

Sascha Hauer
2026-04-02T06:37:23Z

Replace the separate net_eth_to_udp_payload() and net_eth_to_udplen()
calls with the new consolidated net_eth_to_udp() helper.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---
net/netconsole.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/netconsole.c b/net/netconsole.c
index 28fd0e98ec..859cfe8e6f 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -33,9 +33,12 @@ static struct nc_priv *g_priv;
static void nc_handler(void *ctx, char *pkt, unsigned len)
{
struct nc_priv *priv = g_priv;
- unsigned char *packet = net_eth_to_udp_payload(pkt);
+ struct net_udp_pkt udp;

- kfifo_put(priv->fifo, packet, net_eth_to_udplen(pkt));
+ if (net_eth_to_udp(pkt, len, &udp))
+ return;
+
+ kfifo_put(priv->fifo, udp.payload, udp.len);
}

static int nc_getc(struct console_device *cdev)

--
2.47.3