net: lwip: support syslog
PATCH v2 1/1 net: lwip: support syslog
LOG_SYSLOG depends on NET, but the raw Ethernet and UDP header builders it uses are only available with the legacy network stack. This makes LOG_SYSLOG fail to build with NET_LWIP.
Provide lwIP implementations using the selected Ethernet device and its indexed IP address from the environment. Move the shared declarations to net-common.h and extend the syslog test to check the source MAC address and IPv4 header checksum.
---
Changes v1 -> v2:
- Guard the lwIP raw-header helpers with LOG_SYSLOG (suggested by Peter Robinson)
- Link to v1: https://patch.msgid.link/[email protected]
--- include/net-common.h | 7 ++++++ include/net-legacy.h | 4 ---- net/lwip/net-lwip.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/log/syslog_test.c | 2 ++ test/log/syslog_test.h | 4 ++-- 5 files changed, 71 insertions(+), 6 deletions(-)
include/net-common.h +7 -0
@@ -362,6 +362,13 @@ struct ethernet_hdr {/* Ethernet header size */ #define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr)) +/* Set Ethernet header; returns the size of the header */ +int net_set_ether (uchar *xet,const uchar *dest_ethaddr,uint prot); + +/* Set IPv4 and UDP headers */ +void net_set_udp_header (uchar *pkt,struct in_addr dest,int dport, +int sport,int len); +/** * net_random_ethaddr - Generate software assigned random Ethernet address * @addr: Pointer to a six-byte array containing the Ethernet address
include/net-legacy.h +0 -4
@@ -344,15 +344,11 @@ int net_loop(enum proto_t);/* Get size of the ethernet header when we send */ int net_eth_hdr_size (void ); -/* Set ethernet header; returns the size of the header */ -int net_set_ether (uchar *xet,const uchar *dest_ethaddr,uint prot);int net_update_ether (struct ethernet_hdr *et,uchar *addr,uint prot);/* Set IP header */ void net_set_ip_header (uchar *pkt,struct in_addr dest,struct in_addr source,u16 pkt_len,u8 proto); -void net_set_udp_header (uchar *pkt,struct in_addr dest,int dport, -int sport,int len);/* Callbacks */ rxhand_f *net_get_udp_handler (void );/* Get UDP RX packet handler */
net/lwip/net-lwip.c +60 -0
66 lines not on this page · raw message
test/log/syslog_test.c +2 -0
@@ -34,11 +34,13 @@ int sb_log_tx_handler(struct udevice *dev, void *packet, unsigned int len)/* Check Ethernet header */ ut_asserteq_mem (ð_hdr->et_dest, net_bcast_ethaddr,ARP_HLEN ); +ut_asserteq_mem (ð_hdr->et_src,eth_get_ethaddr (),ARP_HLEN );ut_asserteq (ntohs (eth_hdr->et_protlen),PROT_IP );/* Check IP header */ buf +=sizeof (struct ethernet_hdr ); ip_udp_hdr = (struct ip_udp_hdr *)buf; +ut_assert (ip_checksum_ok (ip_udp_hdr,IP_HDR_SIZE ));ut_asserteq (ip_udp_hdr->ip_p,IPPROTO_UDP );ut_asserteq (ip_udp_hdr->ip_dst.s_addr,0xffffffff );ut_asserteq (ntohs (ip_udp_hdr->udp_dst),514 );
test/log/syslog_test.h +2 -2
@@ -31,8 +31,8 @@ struct sb_log_env {* * The following checks are executed: * -* * the Ethernet packet indicates a IP broadcast message -* * the IP header is for a local UDP broadcast message to port 514 +* * the Ethernet packet uses the selected interface and broadcast destination +* * the IP header checksum is valid and describes a UDP broadcast to port 514 * * the UDP payload matches the expected string * * After testing the pointer to the expected string is set to NULL to signal
---
base-commit: 964ad5b5c91b7be56e443e899d7f873e6aa8c9fc
change-id: 20260825-lwip-syslog-v1-a5625eba2ea3
Best regards,
Signature · 1 line
James Hilliard <[email protected]>
Quoted 14 lines · James Hilliard
LOG_SYSLOGdepends on NET, but the raw Ethernet and UDP header builders it uses are only available with the legacy network stack. This makesLOG_SYSLOGfail to build withNET_LWIP.Provide lwIP implementations using the selected Ethernet device and its indexed IP address from the environment. Move the shared declarations to
net-common.hand extend the syslog test to check the source MAC address and IPv4 header checksum.Signed-off-by James Hilliard <[email protected]>---
Changes v1 -> v2:
- Guard the lwIP raw-header helpers withLOG_SYSLOG(suggested by Peter Robinson)
- Link to v1: https://patch.msgid.link/[email protected]
Quoted 7 lines
--- include/net-common.h | 7 ++++++ include/net-legacy.h | 4 ---- net/lwip/net-lwip.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/log/syslog_test.c | 2 ++ test/log/syslog_test.h | 4 ++-- 5 files changed, 71 insertions(+), 6 deletions(-)
Thanks,
Signature · 1 line
Jerome
Quoted 10 lines · James Hilliard
LOG_SYSLOGdepends on NET, but the raw Ethernet and UDP header builders it uses are only available with the legacy network stack. This makesLOG_SYSLOGfail to build withNET_LWIP.Provide lwIP implementations using the selected Ethernet device and its indexed IP address from the environment. Move the shared declarations to
net-common.hand extend the syslog test to check the source MAC address and IPv4 header checksum.[...]
Applied to u-boot-net branch for-main, thanks!
[1/1] net: lwip: support syslog
commit: 6410670d25b4ca6ced6b5308d582318f7c888f9c
Best regards,
Signature · 1 line
Jerome Forissier <[email protected]>