Hi James, On 25/08/2026 19:31, James Hilliard wrote: > The packet capture command is restricted to NET_LEGACY even though the > recorder only consumes Ethernet frames. The lwIP adapter sends and receives > directly through Ethernet drivers, bypassing the legacy capture hooks. > > Build the recorder for either network stack and add capture hooks to the > lwIP transmit and receive paths. Print the capture summary when the > outermost lwIP network operation stops, matching the legacy net_loop() > behavior. > > Signed-off-by: James Hilliard <[email protected]> > --- > cmd/Kconfig | 14 +++++++------- > net/Makefile | 2 +- > net/lwip/net-lwip.c | 8 ++++++++ > 3 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/cmd/Kconfig b/cmd/Kconfig > index ff90a87024c..7025aab4714 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -2078,13 +2078,6 @@ config BOOTP_TIMEOFFSET > bool "Request & store 'timeoffset' from BOOTP/DHCP server" > depends on CMD_BOOTP && CMD_SNTP > > -config CMD_PCAP > - bool "pcap capture" > - help > - Selecting this will allow capturing all Ethernet packets and store > - them in physical memory in a PCAP formated file, > - later to be analyzed by PCAP reader application (IE. WireShark). > - > config BOOTP_PXE > bool "Send PXE client arch to BOOTP/DHCP server" > default y > @@ -2210,6 +2203,13 @@ config CMD_WOL > > endif # if NET_LEGACY > > +config CMD_PCAP > + bool "pcap capture" > + help > + Selecting this will allow capturing all Ethernet packets and store > + them in physical memory in a PCAP formated file, > + later to be analyzed by PCAP reader application (IE. WireShark). > + > config CMD_DHCP > bool "dhcp" > select PROT_DHCP_LWIP if NET_LWIP > diff --git a/net/Makefile b/net/Makefile > index ceac6de6377..6666db519a1 100644 > --- a/net/Makefile > +++ b/net/Makefile > @@ -19,7 +19,6 @@ obj-$(CONFIG_CMD_NFS) += nfs.o > obj-$(CONFIG_CMD_PING) += ping.o > obj-$(CONFIG_CMD_PING6) += ping6.o > obj-$(CONFIG_CMD_DHCP6) += dhcpv6.o > -obj-$(CONFIG_CMD_PCAP) += pcap.o > obj-$(CONFIG_CMD_RARP) += rarp.o > obj-$(CONFIG_CMD_SNTP) += sntp.o > obj-$(CONFIG_CMD_TFTPBOOT) += tftp.o > @@ -44,6 +43,7 @@ obj-$(CONFIG_$(PHASE_)BOOTDEV_ETH) += eth_bootdev.o > obj-$(CONFIG_DM_MDIO) += mdio-uclass.o > obj-$(CONFIG_DM_MDIO_MUX) += mdio-mux-uclass.o > obj-$(CONFIG_CMD_NFS) += nfs-common.o > +obj-$(CONFIG_CMD_PCAP) += pcap.o > obj-$(CONFIG_$(PHASE_)DM_ETH) += eth_common.o > obj-y += net-common.o > endif > diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c > index 8f8f9d69020..e114d98c1c8 100644 > --- a/net/lwip/net-lwip.c > +++ b/net/lwip/net-lwip.c > @@ -19,6 +19,7 @@ > #include <lwip/prot/etharp.h> > #include <lwip/timeouts.h> > #include <net.h> > +#include <net/pcap.h> > #include <timer.h> > #include <u-boot/schedule.h> > > @@ -77,6 +78,8 @@ static err_t net_lwip_tx(struct netif *netif, struct pbuf > *p) > } > > err = eth_get_ops(udev)->send(udev, pp, plen); > + if (err >= 0 && CONFIG_IS_ENABLED(CMD_PCAP)) > + pcap_post(pp, plen, true); > > if (pp_allocated) > free(pp); > @@ -225,6 +228,8 @@ void net_lwip_eth_stop(void) > return; > > eth_halt(); > + if (CONFIG_IS_ENABLED(CMD_PCAP) && pcap_active()) > + pcap_print_status(); > } > > static struct netif *new_netif(struct udevice *udev, bool with_ip) > @@ -365,6 +370,9 @@ int net_lwip_rx(struct udevice *udev, struct netif *netif) > flags = 0; > > if (len > 0) { > + if (CONFIG_IS_ENABLED(CMD_PCAP)) > + pcap_post(packet, len, false); > + > if (CONFIG_IS_ENABLED(LWIP_DEBUG_RXTX)) { > printf("net_lwip_tx: %u bytes, udev %s \n", len, > udev->name); > > --- > base-commit: 964ad5b5c91b7be56e443e899d7f873e6aa8c9fc > change-id: 20260825-submit-lwip-pcap-v1-fd0514deb533 > > Best regards, > -- > James Hilliard <[email protected]>
Looks good, thanks! Reviewed-by: Jerome Forissier <[email protected]> Thanks, -- Jerome IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
