Add link-local addressing support
Subsystems (4)
PATCH v3 8/18 net: Refactor to protect access to the NetState variable
In reply to Joe HershbergerChanges to NetState now go through an accessor function called net_set_state()
---
Changes for v2:
- net_set_state changed to static inline
- States changed to an enum
- Eliminate CamelCase in new functions.
Changes for v3:
- Rebased onto other changed patches
- Added a blank line
- Renamed NfsDownloadState to nfs_download_state
- Put net_loop_state values on separate lines
drivers/net/netconsole.c | 6 +++--- include/net.h | 20 ++++++++++++++------ net/cdp.c | 2 +- net/dns.c | 8 ++++---- net/net.c | 21 ++++++++++++--------- net/nfs.c | 12 ++++++------ net/ping.c | 4 ++-- net/sntp.c | 4 ++-- net/tftp.c | 8 ++++---- 9 files changed, 48 insertions(+), 37 deletions(-)
drivers/net/netconsole.c +3 -3
@@ -44,19 +44,19 @@ static void nc_wait_arp_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) { - NetState =NETLOOP_SUCCESS ;/* got arp reply - quit net loop */ +net_set_state (NETLOOP_SUCCESS );/* got arp reply - quit net loop */ }static void nc_handler (uchar *pkt,unsigned dest,IPaddr_t sip,unsigned src,unsigned len) {if (input_size) - NetState =NETLOOP_SUCCESS ;/* got input - quit net loop */ +net_set_state (NETLOOP_SUCCESS );/* got input - quit net loop */ }static void nc_timeout (void ) { - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void NcStart (void )
include/net.h +14 -6
@@ -391,12 +391,6 @@ extern uchar NetEtherNullAddr[6];extern ushort NetOurVLAN;/* Our VLAN */ extern ushort NetOurNativeVLAN;/* Our Native VLAN */ -extern int NetState;/* Network loop state */ -#define NETLOOP_CONTINUE 1 -#define NETLOOP_RESTART 2 -#define NETLOOP_SUCCESS 3 -#define NETLOOP_FAIL 4 -extern int NetRestartWrap;/* Tried all network devices */ enum proto_t {
@@ -471,6 +465,20 @@ extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */extern void net_set_icmp_handler (rxhand_icmp_f *f);/* Set ICMP RX handler */ extern void NetSetTimeout (ulong ,thand_f *);/* Set timeout handler */ +/* Network loop state */ +enum net_loop_state { +NETLOOP_CONTINUE , +NETLOOP_RESTART , +NETLOOP_SUCCESS , +NETLOOP_FAIL +}; +static inline void net_set_state (enum net_loop_state state) +{ +extern enum net_loop_state net_state; + + net_state = state; +} +/* Transmit "NetTxPacket" */ static inline void NetSendPacket (uchar *pkt,int len) {
net/cdp.c +1 -1
@@ -235,7 +235,7 @@ CDPTimeout(void)if (!CDPOK )NetStartAgain ();else - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } static void
net/dns.c +4 -4
@@ -98,7 +98,7 @@ static voidDnsTimeout (void) {puts ("Timeout\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); } static void
@@ -128,7 +128,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)/* Received 0 answers */ if (header->nanswers ==0 ) {puts ("DNS: host not found\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }
@@ -141,7 +141,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)/* We sent query class 1, query type 1 */ if (&p[5 ] > e ||get_unaligned_be16 (p+1 ) !=DNS_A_RECORD ) {puts ("DNS: response was not an A record\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }
@@ -191,7 +191,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)puts ("server responded with invalid IP number\n" ); } - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void
net/net.c +12 -9
@@ -149,7 +149,7 @@ uchar NetEtherNullAddr[6];void (*push_packet)(void *,int len) =0 ;#endif /* Network loop state */ -int NetState; +enum net_loop_state net_state;/* Tried all network devices */ int NetRestartWrap;/* Network loop restarted */
@@ -212,7 +212,7 @@ void net_auto_load(void)* Just use BOOTP/RARP to configure system; * Do not use TFTP to load the bootfile. */ - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }#if defined(CONFIG_CMD_NFS )
@@ -290,7 +290,7 @@ int NetLoop(enum proto_t protocol) restart:memcpy (NetOurEther,eth_get_dev ()->enetaddr,6 ); - NetState =NETLOOP_CONTINUE ; +net_set_state (NETLOOP_CONTINUE );/* * Start the ball rolling with the given start function. From
@@ -399,7 +399,7 @@ restart:/* * Main packet reception loop. Loop receiving packets until -* someone sets `NetState' to a state that terminates. +* someone sets `net_state' to a state that terminates. */ for (;;) {WATCHDOG_RESET ();
@@ -451,7 +451,7 @@ restart: } -switch (NetState) { +switch (net_state) {case NETLOOP_RESTART : NetRestarted =1 ;
@@ -475,6 +475,9 @@ restart:case NETLOOP_FAIL : goto done; + +case NETLOOP_CONTINUE : +continue ; } }
@@ -492,7 +495,7 @@ done:static void startAgainTimeout (void ) { - NetState =NETLOOP_RESTART ; +net_set_state (NETLOOP_RESTART ); } static void
@@ -523,7 +526,7 @@ void NetStartAgain(void)if ((!retry_forever) && (NetTryCount >= retrycnt)) {eth_halt (); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; }
@@ -540,10 +543,10 @@ void NetStartAgain(void)NetSetTimeout (10000UL , startAgainTimeout);NetSetHandler (startAgainHandler); }else { - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); } }else { - NetState =NETLOOP_RESTART ; +net_set_state (NETLOOP_RESTART ); } }
net/nfs.c +6 -6
@@ -41,7 +41,7 @@ static int nfs_len;static char dirfh[NFS_FHSIZE ];/* file handle of directory */ static char filefh[NFS_FHSIZE ];/* file handle of kernel image */ -static int NfsDownloadState; +static enum net_loop_state nfs_download_state;static IPaddr_t NfsServerIP;static int NfsSrvMountPort;static int NfsSrvNfsPort;
@@ -613,10 +613,10 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)case STATE_UMOUNT_REQ :if (nfs_umountall_reply (pkt, len)) {puts ("*** ERROR: Cannot umount\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); }else {puts ("\ndone\n" ); - NetState = NfsDownloadState; +net_set_state (nfs_download_state); }break ;
@@ -660,7 +660,7 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)NfsSend (); }else {if (!rlen) - NfsDownloadState =NETLOOP_SUCCESS ; + nfs_download_state =NETLOOP_SUCCESS ; NfsState =STATE_UMOUNT_REQ ;NfsSend (); }
@@ -673,13 +673,13 @@ voidNfsStart (void) {debug ("%s\n" , __func__); - NfsDownloadState =NETLOOP_FAIL ; + nfs_download_state =NETLOOP_FAIL ; NfsServerIP = NetServerIP; nfs_path = (char *)nfs_path_buff;if (nfs_path ==NULL ) { - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );puts ("*** ERROR: Fail allocate memory\n" );return ; }
net/ping.c +2 -2
@@ -72,7 +72,7 @@ static int ping_send(void)static void ping_timeout (void ) {eth_halt (); - NetState =NETLOOP_FAIL ;/* we did not get the reply */ +net_set_state (NETLOOP_FAIL );/* we did not get the reply */ }void ping_start (void )
@@ -92,7 +92,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)case ICMP_ECHO_REPLY : src_ip =NetReadIP ((void *)&ip->ip_src);if (src_ip == NetPingIP) - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ;case ICMP_ECHO_REQUEST : debug("Got ICMP ECHO REQUEST, return "
net/sntp.c +2 -2
@@ -45,7 +45,7 @@ static voidSntpTimeout (void) {puts ("Timeout\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; }
@@ -76,7 +76,7 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void
net/tftp.c +4 -4
@@ -177,7 +177,7 @@ store_block(unsigned block, uchar *src, unsigned len) rc =flash_write ((char *)src, (ulong)(load_addr+offset), len);if (rc) {flash_perror (rc); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; } }else
@@ -300,7 +300,7 @@ static void tftp_complete(void) }#endif puts ("\ndone\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } static void
@@ -627,7 +627,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,if (MasterClient && (TftpBlock >= TftpEndingBlock)) {puts ("\nMulticast tftp done\n" );mcast_cleanup (); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } } else#endif
@@ -644,7 +644,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,case TFTP_ERR_ACCESS_DENIED :puts ("Not retrying...\n" );eth_halt (); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );break ;case TFTP_ERR_UNDEFINED :case TFTP_ERR_DISK_FULL :
Signature · 1 line
1.6.0.2
PATCH v3 9/18 net: Refactor to separate the UDP handler from the ARP handler
In reply to Joe HershbergerCall a built-in dummy if none is registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in arp.c)
Clear handlers at the end of net loop
---
Changes for v2:
- Change NULL checks into dummy functions
- Must now call net_set_*_handler(NULL); in init to set dummies
- Eliminate CamelCase for new functions
Changes for v3:
- Rebased onto other changed patches
- Fixed comment style
- Cleaned up parameters on line wrap
drivers/net/netconsole.c | 4 +- include/net.h | 7 ++- net/arp.c | 6 +- net/bootp.c | 4 +- net/cdp.c | 8 ---- net/dns.c | 2 +- net/net.c | 95 ++++++++++++++++++++++++++++++---------------- net/nfs.c | 2 +- net/sntp.c | 2 +- net/tftp.c | 4 +- 10 files changed, 79 insertions(+), 55 deletions(-)
drivers/net/netconsole.c +2 -2
@@ -63,12 +63,12 @@ void NcStart(void) {if (!output_packet_len ||memcmp (nc_ether, NetEtherNullAddr,6 )) {/* going to check for input packet */ -NetSetHandler (nc_handler); +net_set_udp_handler (nc_handler);NetSetTimeout (net_timeout, nc_timeout); }else {/* send arp request */ uchar *pkt; -NetSetHandler (nc_wait_arp_handler); +net_set_arp_handler (nc_wait_arp_handler); pkt = (uchar *)NetTxPacket +NetEthHdrSize () +IP_UDP_HDR_SIZE ;memcpy (pkt, output_packet, output_packet_len); NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
include/net.h +5 -2
@@ -460,8 +460,10 @@ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */extern uint NetCksum (uchar *,int );/* Calculate the checksum */ /* Callbacks */ -extern rxhand_f *NetGetHandler (void );/* Get RX packet handler */ -extern void NetSetHandler (rxhand_f *);/* Set RX packet handler */ +extern rxhand_f *net_get_udp_handler (void );/* Get UDP RX packet handler */ +extern void net_set_udp_handler (rxhand_f *);/* Set UDP RX packet handler */ +extern rxhand_f *net_get_arp_handler (void );/* Get ARP RX packet handler */ +extern void net_set_arp_handler (rxhand_f *);/* Set ARP RX packet handler */ extern void net_set_icmp_handler (rxhand_icmp_f *f);/* Set ICMP RX handler */ extern void NetSetTimeout (ulong ,thand_f *);/* Set timeout handler */
@@ -487,6 +489,7 @@ static inline void NetSendPacket(uchar *pkt, int len)/* * Transmit UDP packet, performing ARP request if needed +* (ether will be populated) * * @param ether Raw packet buffer * @param dest IP address to send the datagram to
net/arp.c +3 -3
@@ -192,9 +192,9 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)memcpy (NetArpWaitPacketMAC, &arp->ar_sha,ARP_HLEN ); -#ifdef CONFIG_NETCONSOLE -NetGetHandler ()(0 ,0 ,0 ,0 ,0 ); -#endif +net_get_arp_handler ()((uchar *)arp,0 , reply_ip_addr, +0 , len); +/* modify header, and transmit it */ memcpy (((struct ethernet_hdr *)NetArpWaitTxPacket)-> et_dest, NetArpWaitPacketMAC,ARP_HLEN );
net/bootp.c +2 -2
@@ -669,9 +669,9 @@ BootpRequest(void)#if defined(CONFIG_CMD_DHCP ) dhcp_state =SELECTING ; -NetSetHandler (DhcpHandler); +net_set_udp_handler (DhcpHandler);#else -NetSetHandler (BootpHandler); +net_set_udp_handler (BootpHandler);#endif NetSendPacket (NetTxPacket, pktlen); }
net/cdp.c +0 -8
@@ -238,13 +238,6 @@ CDPTimeout(void)net_set_state (NETLOOP_SUCCESS ); } -static void -CDPDummyHandler (uchar *pkt,unsigned dest,IPaddr_t sip,unsigned src, -unsigned len) -{ -/* nothing */ -} -void cdp_receive (const uchar *pkt,unsigned len) {const uchar *t;
@@ -368,7 +361,6 @@ CDPStart(void) CDPApplianceVLAN =htons (-1 );NetSetTimeout (CDP_TIMEOUT , CDPTimeout); -NetSetHandler (CDPDummyHandler);CDPSendTrigger (); }
net/dns.c +1 -1
@@ -200,7 +200,7 @@ DnsStart(void)debug ("%s\n" , __func__);NetSetTimeout (DNS_TIMEOUT , DnsTimeout); -NetSetHandler (DnsHandler); +net_set_udp_handler (DnsHandler);DnsSend (); }
net/net.c +62 -33
174 lines not on this page · raw message
net/nfs.c +1 -1
@@ -735,7 +735,7 @@ NfsStart(void) "Loading: *\b", load_addr);NetSetTimeout (NFS_TIMEOUT , NfsTimeout); -NetSetHandler (NfsHandler); +net_set_udp_handler (NfsHandler); NfsTimeoutCount =0 ; NfsState =STATE_PRCLOOKUP_PROG_MOUNT_REQ ;
net/sntp.c +1 -1
@@ -85,7 +85,7 @@ SntpStart(void)debug ("%s\n" , __func__);NetSetTimeout (SNTP_TIMEOUT , SntpTimeout); -NetSetHandler (SntpHandler); +net_set_udp_handler (SntpHandler);memset (NetServerEther,0 ,sizeof (NetServerEther));SntpSend ();
net/tftp.c +2 -2
@@ -778,7 +778,7 @@ void TftpStart(enum proto_t protocol) TftpTimeoutCountMax = TftpRRQTimeoutCountMax;NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); -NetSetHandler (TftpHandler); +net_set_udp_handler (TftpHandler);#ifdef CONFIG_CMD_TFTPPUT net_set_icmp_handler (icmp_handler);#endif
@@ -840,7 +840,7 @@ TftpStartServer(void)#endif TftpState =STATE_RECV_WRQ ; - NetSetHandler(TftpHandler); + net_set_udp_handler(TftpHandler); }#endif /* CONFIG_CMD_TFTPSRV */
Signature · 1 line
1.6.0.2
PATCH v3 10/18 net: Add net_update_ether() to handle ARP and Ping replies
In reply to Joe HershbergerWhen the network is VLAN or SNAP, net_update_ether() will preserve the original Ethernet packet header and simply replace the src and dest MACs and the protocol
---
Changes for v2:
Changes for v3:
- Rebased onto other changed patches
include/net.h | 1 + net/arp.c | 2 +- net/net.c | 23 +++++++++++++++++++++++ net/ping.c | 10 +++++----- 4 files changed, 30 insertions(+), 6 deletions(-)
include/net.h +1 -0
@@ -449,6 +449,7 @@ extern int NetEthHdrSize(void);/* Set ethernet header; returns the size of the header */ extern int NetSetEther (uchar *,uchar *,uint ); +extern int net_update_ether (struct ethernet_hdr *et,uchar *addr,uint prot);/* Set IP header */ extern void net_set_ip_header (uchar *pkt,IPaddr_t dest,IPaddr_t source);
net/arp.c +1 -1
@@ -158,7 +158,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)/* reply with our IP address */ debug ("Got ARP REQUEST, return our IP\n" ); pkt = (uchar *)et; - eth_hdr_size =NetSetEther (pkt, et->et_src,PROT_ARP ); + eth_hdr_size =net_update_ether (et, et->et_src,PROT_ARP ); pkt += eth_hdr_size; arp->ar_op =htons (ARPOP_REPLY );memcpy (&arp->ar_tha, &arp->ar_sha,ARP_HLEN );
net/net.c +23 -0
@@ -1276,6 +1276,29 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) } } +int net_update_ether (struct ethernet_hdr *et,uchar *addr,uint prot) +{ +ushort protlen; + +memcpy (et->et_dest, addr,6 ); +memcpy (et->et_src, NetOurEther,6 ); + protlen =ntohs (et->et_protlen); +if (protlen ==PROT_VLAN ) { +struct vlan_ethernet_hdr *vet = + (struct vlan_ethernet_hdr *)et; + vet->vet_type =htons (prot); +return VLAN_ETHER_HDR_SIZE ; + }else if (protlen >1514 ) { + et->et_protlen =htons (prot); +return ETHER_HDR_SIZE ; + }else { +/* 802.2 + SNAP */ +struct e802_hdr *et802 = (struct e802_hdr *)et; + et802->et_prot =htons (prot); +return E802_HDR_SIZE ; + } +} +void net_set_ip_header (uchar *pkt,IPaddr_t dest,IPaddr_t source) {struct ip_udp_hdr *ip = (struct ip_udp_hdr *)pkt;
net/ping.c +5 -5
@@ -87,6 +87,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) {struct icmp_hdr *icmph = (struct icmp_hdr *)&ip->udp_src;IPaddr_t src_ip; +int eth_hdr_size;switch (icmph->type) {case ICMP_ECHO_REPLY :
@@ -95,11 +96,10 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)net_set_state (NETLOOP_SUCCESS );return ;case ICMP_ECHO_REQUEST : -debug ("Got ICMP ECHO REQUEST, return " -"%d bytes\n" ,ETHER_HDR_SIZE + len); + eth_hdr_size =net_update_ether (et, et->et_src,PROT_IP ); -memcpy (&et->et_dest[0 ], &et->et_src[0 ],6 ); -memcpy (&et->et_src[0 ], NetOurEther,6 ); +debug ("Got ICMP ECHO REQUEST, return " +"%d bytes\n" , eth_hdr_size + len); ip->ip_sum =0 ; ip->ip_off =0 ;
@@ -112,7 +112,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) icmph->checksum =0 ; icmph->checksum = ~NetCksum ((uchar *)icmph, (len -IP_HDR_SIZE ) >>1 ); -NetSendPacket ((uchar *)et,ETHER_HDR_SIZE + len); +NetSendPacket ((uchar *)et, eth_hdr_size + len);return ;/* default: return;*/
Signature · 1 line
1.6.0.2
PATCH v3 11/18 net: Don't write the "serverip" env var if configured not to
In reply to Joe HershbergerBefore this patch, bootp would not overwrite the value, but the value was still clobbered in the env
---
Changes for v2:
- Added a comment
Changes for v3:
- Rebased onto other changed patches
- Fixed comment style
common/cmd_net.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
common/cmd_net.c +6 -2
@@ -153,12 +153,16 @@ static void netboot_update_env (void)ip_to_string (NetOurIP, tmp);setenv ("ipaddr" , tmp); } - +#if !defined(CONFIG_BOOTP_SERVERIP ) +/* +* Only attempt to change serverip if net/bootp.c:BootpCopyNetParams() +* could have set it +*/ if (NetServerIP) {ip_to_string (NetServerIP, tmp);setenv ("serverip" , tmp); } - +#endif if (NetOurDNSIP) {ip_to_string (NetOurDNSIP, tmp);setenv ("dnsip" , tmp);
Signature · 1 line
1.6.0.2
PATCH v3 12/18 net: Fix unused variable compile warning
In reply to Joe HershbergerIf CONFIG_BOOTP_SERVERIP is not defined, unused variable warning is reported. This was fixed upstream using a compiler feature instead of a simple reorder of the statements.
---
Changes for v2:
Changes for v3:
- Rebased onto other changed patches
- Fixed commit message
net/bootp.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
net/bootp.c +3 -4
@@ -18,7 +18,6 @@#ifdef CONFIG_STATUS_LED #include <status_led.h> #endif -#include <linux/compiler.h> #define BOOTP_VENDOR_MAGIC 0x63825363/* RFC1048 Magic Cookie */
@@ -96,15 +95,15 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)*/ static void BootpCopyNetParams (struct Bootp_t *bp) { -__maybe_unused IPaddr_t tmp_ip; - -NetCopyIP (&NetOurIP, &bp->bp_yiaddr);#if !defined(CONFIG_BOOTP_SERVERIP ) +IPaddr_t tmp_ip; +NetCopyIP (&tmp_ip, &bp->bp_siaddr);if (tmp_ip !=0 )NetCopyIP (&NetServerIP, &bp->bp_siaddr);memcpy (NetServerEther, ((struct ethernet_hdr *)NetRxPacket)->et_src,6 );#endif +NetCopyIP (&NetOurIP, &bp->bp_yiaddr);if (strlen (bp->bp_file) >0 )copy_filename (BootFile, bp->bp_file,sizeof (BootFile));
Signature · 1 line
1.6.0.2
PATCH v3 13/18 net: Add option CONFIG_BOOTP_MAY_FAIL
In reply to Joe HershbergerThis is useful if you want to look for a DHCP server, but try some other settings if not available.
---
Changes for v2:
- Renamed to CONFIG_BOOTP_MAY_FAIL
Changes for v3:
- Rebased onto other changed patches
README | 7 +++++++ net/bootp.c | 5 +++++ 2 files changed, 12 insertions(+), 0 deletions(-)
README +7 -0
@@ -1592,10 +1592,17 @@ The following options need to be configured: CONFIG_BOOTP_NTPSERVER CONFIG_BOOTP_TIMEOFFSET CONFIG_BOOTP_VENDOREX + CONFIG_BOOTP_MAY_FAIL CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip environment variable, not the BOOTP server. + CONFIG_BOOTP_MAY_FAIL - If the DHCP server is not found + after the configured retry count, the call will fail + instead of starting over. This can be used to fail over + to Link-local IP address configuration if the DHCP server + is not available. + CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS serverip from a DHCP server, it is possible that more than one DNS serverip is offered to the client.
net/bootp.c +5 -0
@@ -326,8 +326,13 @@ static voidBootpTimeout (void) {if (BootpTry >=TIMEOUT_COUNT ) { +#ifdef CONFIG_BOOTP_MAY_FAIL +puts ("\nRetry count exceeded\n" ); +NetSetState (NETLOOP_FAIL ); +#else puts ("\nRetry count exceeded; starting again\n" );NetStartAgain (); +#endif }else {NetSetTimeout (TIMEOUT , BootpTimeout);BootpRequest ();
Signature · 1 line
1.6.0.2
PATCH v3 14/18 net: Remove static allocation for MAC address in PingSend()
In reply to Joe HershbergerDon't force ARP clients to return the MAC address if they don't care (such as ping)
---
Changes for v2:
Changes for v3:
- Rebased onto other changed patches
net/arp.c | 9 +++++---- net/ping.c | 10 +++------- 2 files changed, 8 insertions(+), 11 deletions(-)
net/arp.c +5 -4
@@ -170,7 +170,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)case ARPOP_REPLY :/* arp reply */ /* are we waiting for a reply */ -if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) +if (!NetArpWaitPacketIP)break ;#ifdef CONFIG_KEEP_SERVERADDR
@@ -189,15 +189,16 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len) arp->ar_data);/* save address for later use */ -memcpy (NetArpWaitPacketMAC, - &arp->ar_sha,ARP_HLEN ); +if (NetArpWaitPacketMAC !=NULL ) +memcpy (NetArpWaitPacketMAC, + &arp->ar_sha,ARP_HLEN );net_get_arp_handler ()((uchar *)arp,0 , reply_ip_addr,0 , len);/* modify header, and transmit it */ memcpy (((struct ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, NetArpWaitPacketMAC,ARP_HLEN ); + et_dest, &arp->ar_sha,ARP_HLEN );NetSendPacket (NetArpWaitTxPacket, NetArpWaitTxPacketSize);
net/ping.c +3 -7
@@ -40,22 +40,18 @@ static void set_icmp_header(uchar *pkt, IPaddr_t dest)static int ping_send (void ) { -static uchar mac[6 ];uchar *pkt;int eth_hdr_size;/* XXX always send arp request */ -memcpy (mac, NetEtherNullAddr,6 ); -debug ("sending ARP for %pI4\n" , &NetPingIP); NetArpWaitPacketIP = NetPingIP; - NetArpWaitPacketMAC = mac; - pkt = NetArpWaitTxPacket; - eth_hdr_size =NetSetEther (pkt, mac,PROT_IP ); - pkt += eth_hdr_size; + eth_hdr_size =NetSetEther (NetArpWaitTxPacket, NetEtherNullAddr, +PROT_IP ); + pkt = NetArpWaitTxPacket + eth_hdr_size;set_icmp_header (pkt, NetPingIP);
Signature · 1 line
1.6.0.2
PATCH v3 15/18 net: Remove unused parameter from NetInitLoop()
In reply to Joe HershbergerNoone uses it.
---
Changes for v2:
- Split from "Fix net buffer initialization"
Changes for v3:
- Rebased onto other changed patches
- Added a short commit message
net/net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/net.c +2 -2
@@ -231,7 +231,7 @@ void net_auto_load(void)TftpStart (TFTPGET ); } -static void NetInitLoop (enum proto_t protocol) +static void NetInitLoop (void ) {static int env_changed_id;int env_id =get_env_id ();
@@ -311,7 +311,7 @@ restart:* here on, this code is a state machine driven by received * packets and timer events. */ -NetInitLoop (protocol); +NetInitLoop ();switch (net_check_prereq (protocol)) {case 1 :
Signature · 1 line
1.6.0.2
PATCH v3 16/18 net: Fix net buffer initialization
In reply to Joe HershbergerA new non-static function net_init() will initialize buffers and read from the environment. Only update from the env on each entry to NetLoop().
---
Changes for v2:
- Unadded explicit parameter name in net.h for NetLoop
- Eliminate CamelCase from new functions
- Changed null pointer print to an assert
Changes for v3:
- Rebased onto other changed patches
- Added a blank line
- Added space around operators
include/net.h | 1 + net/net.c | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 14 deletions(-)
include/net.h +1 -0
@@ -436,6 +436,7 @@ extern IPaddr_t Mcast_addr;#endif /* Initialize the network adapter */ +extern void net_init (void );extern int NetLoop (enum proto_t );/* Shutdown adapters and cleanup */
net/net.c +31 -14
71 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH v3 17/18 net: Make sure NetLoop is initialized when using NetConsole
In reply to Joe HershbergerFix NetConsole bug that causes first packet header to claim a source IP address of 0.0.0.0
---
Changes for v2:
Changes for v3:
- Rebased onto other changed patches
- Fix comment style
drivers/net/netconsole.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +6 -0
@@ -169,6 +169,12 @@ static int nc_start(void)else memset (nc_ether,0 ,sizeof (nc_ether));/* force arp request */ +/* +* Initialize the static IP settings and buffer pointers +* incase we call NetSendUDPPacket before NetLoop +*/ +net_init (); +return 0 ; }
Signature · 1 line
1.6.0.2
PATCH v3 18/18 net: Don't copy every packet that waits for an ARP
In reply to Joe HershbergerUse the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket.
This saves a copy and makes the code easier to understand.
---
Changes for v2:
Changes for v3:
- Rebased onto other changed patches
- Fixed comment style
include/net.h | 6 +++--- net/arp.c | 24 ++++++++++++------------ net/arp.h | 2 -- net/net.c | 24 ++++++------------------ net/ping.c | 5 ++--- 5 files changed, 23 insertions(+), 38 deletions(-)
include/net.h +3 -3
@@ -483,14 +483,14 @@ static inline void net_set_state(enum net_loop_state state) net_state = state; } -/* Transmit "NetTxPacket" */ +/* Transmit a packet */ static inline void NetSendPacket (uchar *pkt,int len) { (void )eth_send (pkt, len); }/* -* Transmit UDP packet, performing ARP request if needed +* Transmit "NetTxPacket" as UDP packet, performing ARP request if needed * (ether will be populated) * * @param ether Raw packet buffer
@@ -499,7 +499,7 @@ static inline void NetSendPacket(uchar *pkt, int len)* @param sport Source UDP port * @param payload_len Length of data after the UDP header */ -extern int NetSendUDPPacket (uchar *ether,IPaddr_t dest,int dport, +extern int NetSendUDPPacket (uchar *ether,IPaddr_t dest,int dport,int sport,int payload_len);/* Processes a received packet */
net/arp.c +12 -12
@@ -30,22 +30,22 @@ IPaddr_t NetArpWaitPacketIP;IPaddr_t NetArpWaitReplyIP;/* MAC address of waiting packet's destination */ uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -uchar *NetArpWaitTxPacket;int NetArpWaitTxPacketSize; -uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN +PKTALIGN ];ulong NetArpWaitTimerStart;int NetArpWaitTry; +uchar *NetArpTxPacket;/* THE ARP transmit packet */ +uchar NetArpPacketBuf[PKTSIZE_ALIGN +PKTALIGN ]; +void ArpInit (void ) {/* XXX problem with bss workaround */ NetArpWaitPacketMAC =NULL ; NetArpWaitPacketIP =0 ; NetArpWaitReplyIP =0 ; - NetArpWaitTxPacket = &NetArpWaitPacketBuf[0 ] + (PKTALIGN -1 ); - NetArpWaitTxPacket -= (ulong )NetArpWaitTxPacket %PKTALIGN ; NetArpWaitTxPacketSize =0 ; + NetArpTxPacket = &NetArpPacketBuf[0 ] + (PKTALIGN -1 ); + NetArpTxPacket -= (ulong )NetArpTxPacket %PKTALIGN ; }void ArpRequest (void )
@@ -56,7 +56,7 @@ void ArpRequest(void)debug ("ARP broadcast %d\n" , NetArpWaitTry); - pkt = NetTxPacket; + pkt = NetArpTxPacket; eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_ARP ); pkt += eth_hdr_size;
@@ -88,7 +88,7 @@ void ArpRequest(void) }NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); -NetSendPacket (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); }void ArpTimeoutCheck (void )
@@ -196,11 +196,11 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)net_get_arp_handler ()((uchar *)arp,0 , reply_ip_addr,0 , len); -/* modify header, and transmit it */ -memcpy (((struct ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, &arp->ar_sha,ARP_HLEN ); -NetSendPacket (NetArpWaitTxPacket, - NetArpWaitTxPacketSize); +/* set the mac address in the waiting packet's header +and transmit it */ +memcpy (((struct ethernet_hdr *)NetTxPacket)->et_dest, + &arp->ar_sha,ARP_HLEN ); +NetSendPacket (NetTxPacket, NetArpWaitTxPacketSize);/* no arp request pending now */ NetArpWaitPacketIP =0 ;
net/arp.h +0 -2
@@ -16,8 +16,6 @@extern IPaddr_t NetArpWaitPacketIP;/* MAC address of waiting packet's destination */ extern uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -extern uchar *NetArpWaitTxPacket;extern int NetArpWaitTxPacketSize;extern ulong NetArpWaitTimerStart;extern int NetArpWaitTry;
net/net.c +6 -18
@@ -442,6 +442,9 @@ restart:* Abort if ctrl-c was pressed. */ if (ctrlc ()) { +/* cancel any ARP that may not have completed */ + NetArpWaitPacketIP =0 ; +net_cleanup_loop ();eth_halt ();puts ("\nAbort\n" );
@@ -632,7 +635,6 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len) {uchar *pkt; -int need_arp =0 ;int eth_hdr_size;int pkt_hdr_size;
@@ -649,35 +651,21 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,if (dest ==0xFFFFFFFF ) ether = NetBcastAddr; -/* -* if MAC address was not discovered yet, save the packet and do -* an ARP request -*/ -if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) { - need_arp =1 ; - pkt = NetArpWaitTxPacket; - }else - pkt = (uchar *)NetTxPacket; + pkt = (uchar *)NetTxPacket; eth_hdr_size =NetSetEther (pkt, ether,PROT_IP ); pkt += eth_hdr_size;net_set_udp_header (pkt, dest, dport, sport, payload_len); pkt_hdr_size = eth_hdr_size +IP_UDP_HDR_SIZE ; -if (need_arp) { +/* if MAC address was not discovered yet, do an ARP request */ +if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) {debug ("sending ARP for %pI4\n" , &dest);/* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest; NetArpWaitPacketMAC = ether; -/* -* Copy the packet data from the NetTxPacket into the -* NetArpWaitTxPacket to send after arp -*/ -memcpy (pkt +IP_UDP_HDR_SIZE , (uchar *)NetTxPacket + - pkt_hdr_size, payload_len); -/* size of the waiting packet */ NetArpWaitTxPacketSize = pkt_hdr_size + payload_len;
net/ping.c +2 -3
@@ -49,9 +49,8 @@ static int ping_send(void) NetArpWaitPacketIP = NetPingIP; - eth_hdr_size =NetSetEther (NetArpWaitTxPacket, NetEtherNullAddr, -PROT_IP ); - pkt = NetArpWaitTxPacket + eth_hdr_size; + eth_hdr_size =NetSetEther (NetTxPacket, NetEtherNullAddr,PROT_IP ); + pkt = (uchar *)NetTxPacket + eth_hdr_size;set_icmp_header (pkt, NetPingIP);
Signature · 1 line
1.6.0.2
PATCH v2 20/21 net: cosmetic: Rename tmp to reply_ip_addr in arp.c
In reply to Joe Hershberger---
Changes for v2:
- Split from "Improve variable names and code readability"
net/arp.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
net/arp.c +3 -3
@@ -116,7 +116,7 @@ void ArpTimeoutCheck(void)void ArpReceive (struct Ethernet_hdr *et,struct IP_UDP_hdr *ip,int len) {struct ARP_hdr *arp; -IPaddr_t tmp; +IPaddr_t reply_ip_addr;uchar *pkt;/*
@@ -178,10 +178,10 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) }#endif - tmp =NetReadIP (&arp->ar_data[6 ]); + reply_ip_addr =NetReadIP (&arp->ar_data[6 ]);/* matched waiting packet's address */ -if (tmp == NetArpWaitReplyIP) { +if (reply_ip_addr == NetArpWaitReplyIP) {debug ("Got ARP REPLY, set eth addr (%pM)\n" , arp->ar_data);
Signature · 1 line
1.6.0.2
PATCH v2 20/21 net: cosmetic: Rename tmp to reply_ip_addr in arp.c
Quoted 5 lines · Joe Hershberger
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Quoted 38 lines
---
Changes for v2:
- Split from "Improve variable names and code readability"net/arp.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)net/arp.c +3
-4@@ -116,7 +116,7 @@ void ArpTimeoutCheck(void)void ArpReceive (struct Ethernet_hdr *et,struct IP_UDP_hdr *ip,int len) {struct ARP_hdr *arp; -IPaddr_t tmp; +IPaddr_t reply_ip_addr;uchar *pkt;/* @@ -178,10 +178,10 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) } #endif - tmp =NetReadIP (&arp->ar_data[6 ]); + reply_ip_addr =NetReadIP (&arp->ar_data[6 ]);/* matched waiting packet's address */ -if (tmp == NetArpWaitReplyIP) { +if (reply_ip_addr == NetArpWaitReplyIP) {debug ("Got ARP REPLY, set eth addr (%pM)\n" , arp->ar_data); --1.6.0.2
PATCH v2 1/18 net: Refactor IP, UPD, and ICMP header writing functions
In reply to Joe HershbergerICMP (ping) was reimplementing IP header code... it now shares code.
---
Changes for v2:
- Eliminate CamelCase in new functions
include/net.h | 4 +++- net/bootp.c | 8 ++++---- net/net.c | 47 ++++++++++++++++++++++++++++------------------- net/ping.c | 52 +++++++++++++++++++++++----------------------------- 4 files changed, 58 insertions(+), 53 deletions(-)
include/net.h +3 -1
@@ -451,7 +451,9 @@ extern int NetEthHdrSize(void);extern int NetSetEther (uchar *,uchar *,uint );/* Set IP header */ -extern void NetSetIP (uchar *,IPaddr_t ,int ,int ,int ); +extern void net_set_ip_header (uchar *pkt,IPaddr_t dest,IPaddr_t source); +extern void net_set_udp_header (uchar *pkt,IPaddr_t dest,int dport, +int sport,int len);/* Checksum */ extern int NetCksumOk (uchar *,int );/* Return true if cksum OK */
net/bootp.c +4 -4
@@ -621,9 +621,9 @@ BootpRequest(void)* determined. * C. Hallinan, DS4.COM, Inc. */ -/* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, +/* net_set_udp_header(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (struct Bootp_t)); */ - iphdr = pkt;/* We need this later for NetSetUDPHeader() */ + iphdr = pkt;/* We need this later for net_set_udp_header() */ pkt +=IP_UDP_HDR_SIZE ; bp = (struct Bootp_t *)pkt;
@@ -665,7 +665,7 @@ BootpRequest(void) pktlen = ((int )(pkt-NetTxPacket)) +BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + ext_len; iplen =BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + ext_len; -NetSetIP (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen); +net_set_udp_header (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen);NetSetTimeout (SELECT_TIMEOUT , BootpTimeout);#if defined(CONFIG_CMD_DHCP )
@@ -846,7 +846,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) pktlen = ((int )(pkt-NetTxPacket)) +BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + extlen; iplen =BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + extlen; -NetSetIP (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen); +net_set_udp_header (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen);debug ("Transmitting DHCPREQUEST packet: len = %d\n" , pktlen);#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
net/net.c +28 -19
82 lines not on this page · raw message
net/ping.c +23 -29
67 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH v2 1/18 net: Refactor IP, UPD, and ICMP header writing functions
Quoted 6 lines · Joe Hershberger
ICMP (ping) was reimplementing IP header code... it now shares code.
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Seems like the call to NetCksum() could be tidied up later.
PATCH v2 21/21 net: cosmetic: Replace magic numbers in arp.c with constants
In reply to Joe Hershberger---
Changes for v2:
- Split from "Improve variable names and code readability"
include/net.h | 6 ++++++ net/arp.c | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-)
include/net.h +6 -0
@@ -258,7 +258,9 @@ struct ARP_hdr {# define ARP_ETHER 1/* Ethernet hardware address */ ushort ar_pro;/* Format of protocol address */ uchar ar_hln;/* Length of hardware address */ +# define ARP_HLEN 6uchar ar_pln;/* Length of protocol address */ +# define ARP_PLEN 4ushort ar_op;/* Operation */ # define ARPOP_REQUEST 1/* Request to resolve address */ # define ARPOP_REPLY 2/* Response to previous request */
@@ -272,6 +274,10 @@ struct ARP_hdr {* specific hardware/protocol combinations. */ uchar ar_data[0 ]; +#define ar_sha ar_data[0] +#define ar_spa ar_data[ARP_HLEN] +#define ar_tha ar_data[ARP_HLEN + ARP_PLEN] +#define ar_tpa ar_data[ARP_HLEN + ARP_PLEN + ARP_HLEN]#if 0 uchar ar_sha[];/* Sender hardware address */ uchar ar_spa[];/* Sender protocol address */
net/arp.c +17 -17
@@ -63,16 +63,16 @@ void ArpRequest(void) arp->ar_hrd =htons (ARP_ETHER ); arp->ar_pro =htons (PROT_IP ); - arp->ar_hln =6 ; - arp->ar_pln =4 ; + arp->ar_hln =ARP_HLEN ; + arp->ar_pln =ARP_PLEN ; arp->ar_op =htons (ARPOP_REQUEST );/* source ET addr */ -memcpy (&arp->ar_data[0 ], NetOurEther,6 ); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );/* source IP addr */ -NetWriteIP ((uchar *) &arp->ar_data[6 ], NetOurIP); +NetWriteIP (&arp->ar_spa, NetOurIP);/* dest ET addr = 0 */ -memset (&arp->ar_data[10 ],'\0' ,6 ); +memset (&arp->ar_tha,0 ,ARP_HLEN );if ((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) {if (NetOurGatewayIP ==0 ) {
@@ -85,7 +85,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } -NetWriteIP ((uchar *) &arp->ar_data[16 ], NetArpWaitReplyIP); +NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); (void )eth_send (NetTxPacket, (pkt - NetTxPacket) +ARP_HDR_SIZE ); }
@@ -139,15 +139,15 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)return ;if (ntohs (arp->ar_pro) !=PROT_IP )return ; -if (arp->ar_hln !=6 ) +if (arp->ar_hln !=ARP_HLEN )return ; -if (arp->ar_pln !=4 ) +if (arp->ar_pln !=ARP_PLEN )return ;if (NetOurIP ==0 )return ; -if (NetReadIP (&arp->ar_data[16 ]) != NetOurIP) +if (NetReadIP (&arp->ar_tpa) != NetOurIP)return ;switch (ntohs (arp->ar_op)) {
@@ -157,10 +157,10 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) pkt = (uchar *)et; pkt +=NetSetEther (pkt, et->et_src,PROT_ARP ); arp->ar_op =htons (ARPOP_REPLY ); -memcpy (&arp->ar_data[10 ], &arp->ar_data[0 ],6 ); -NetCopyIP (&arp->ar_data[16 ], &arp->ar_data[6 ]); -memcpy (&arp->ar_data[0 ], NetOurEther,6 ); -NetCopyIP (&arp->ar_data[6 ], &NetOurIP); +memcpy (&arp->ar_tha, &arp->ar_sha,ARP_HLEN ); +NetCopyIP (&arp->ar_tpa, &arp->ar_spa); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN ); +NetCopyIP (&arp->ar_spa, &NetOurIP); (void )eth_send ((uchar *)et, (pkt - (uchar *)et) +ARP_HDR_SIZE );return ;
@@ -173,12 +173,12 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)#ifdef CONFIG_KEEP_SERVERADDR if (NetServerIP == NetArpWaitPacketIP) {char buf[20 ]; -sprintf (buf,"%pM" , arp->ar_data); +sprintf (buf,"%pM" , arp->ar_sha);setenv ("serveraddr" , buf); }#endif - reply_ip_addr =NetReadIP (&arp->ar_data[6 ]); + reply_ip_addr =NetReadIP (&arp->ar_spa);/* matched waiting packet's address */ if (reply_ip_addr == NetArpWaitReplyIP) {
@@ -187,14 +187,14 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* save address for later use */ memcpy (NetArpWaitPacketMAC, - &arp->ar_data[0 ],6 ); + &arp->ar_sha,ARP_HLEN );#ifdef CONFIG_NETCONSOLE NetGetHandler ()(0 ,0 ,0 ,0 ,0 );#endif /* modify header, and transmit it */ memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, NetArpWaitPacketMAC,6 ); + et_dest, NetArpWaitPacketMAC,ARP_HLEN ); (void )eth_send (NetArpWaitTxPacket, NetArpWaitTxPacketSize);
Signature · 1 line
1.6.0.2
PATCH v2 21/21 net: cosmetic: Replace magic numbers in arp.c with constants
Hi Joe,
Quoted 51 lines · Joe Hershberger
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>---
Changes for v2:
- Split from "Improve variable names and code readability"include/net.h | 6 ++++++ net/arp.c | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-)include/net.h +6
-0@@ -258,7 +258,9 @@ struct ARP_hdr {# define ARP_ETHER 1/* Ethernet hardware address */ ushort ar_pro;/* Format of protocol address */ uchar ar_hln;/* Length of hardware address */ +# define ARP_HLEN 6uchar ar_pln;/* Length of protocol address */ +# define ARP_PLEN 4ushort ar_op;/* Operation */ # define ARPOP_REQUEST 1/* Request to resolve address */ # define ARPOP_REPLY 2/* Response to previous request */ @@ -272,6 +274,10 @@ struct ARP_hdr {* specific hardware/protocol combinations. */ uchar ar_data[0 ]; +#define ar_sha ar_data[0] +#define ar_spa ar_data[ARP_HLEN] +#define ar_tha ar_data[ARP_HLEN + ARP_PLEN] +#define ar_tpa ar_data[ARP_HLEN + ARP_PLEN + ARP_HLEN]#if 0 uchar ar_sha[];/* Sender hardware address */ uchar ar_spa[];/* Sender protocol address */ net/arp.c +2
-2@@ -63,16 +63,16 @@ void ArpRequest(void) arp->ar_hrd =htons (ARP_ETHER ); arp->ar_pro =htons (PROT_IP ); - arp->ar_hln =6 ; - arp->ar_pln =4 ; + arp->ar_hln =ARP_HLEN ; + arp->ar_pln =ARP_PLEN ; arp->ar_op =htons (ARPOP_REQUEST );
net/arp.c void ArpRequest(void) · line 76
Quoted 10 lines
net/arp.c +3
-3/* source ET addr */ -memcpy (&arp->ar_data[0 ], NetOurEther,6 ); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );/* source IP addr */ -NetWriteIP ((uchar *) &arp->ar_data[6 ], NetOurIP); +NetWriteIP (&arp->ar_spa, NetOurIP);/* dest ET addr = 0 */ -memset (&arp->ar_data[10 ],'\0' ,6 ); +memset (&arp->ar_tha,0 ,ARP_HLEN );
Did you mean to change this to 0? I prefer '\0\ but I might be the only one.
Quoted 85 lines
net/arp.c +0
-0if ((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) {if (NetOurGatewayIP == 0) {net/arp.c +4
-4@@ -85,7 +85,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } -NetWriteIP ((uchar *) &arp->ar_data[16 ], NetArpWaitReplyIP); +NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); (void )eth_send (NetTxPacket, (pkt - NetTxPacket) +ARP_HDR_SIZE ); }@@ -139,15 +139,15 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) return;if (ntohs (arp->ar_pro) !=PROT_IP )return ; -if (arp->ar_hln !=6 ) +if (arp->ar_hln !=ARP_HLEN )return ; -if (arp->ar_pln !=4 ) +if (arp->ar_pln !=ARP_PLEN )return ;if (NetOurIP ==0 )return ; -if (NetReadIP (&arp->ar_data[16 ]) != NetOurIP) +if (NetReadIP (&arp->ar_tpa) != NetOurIP)return ;switch (ntohs(arp->ar_op)) {net/arp.c +4
-4@@ -157,10 +157,10 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) pkt = (uchar *)et; pkt +=NetSetEther (pkt, et->et_src,PROT_ARP ); arp->ar_op =htons (ARPOP_REPLY ); -memcpy (&arp->ar_data[10 ], &arp->ar_data[0 ],6 ); -NetCopyIP (&arp->ar_data[16 ], &arp->ar_data[6 ]); -memcpy (&arp->ar_data[0 ], NetOurEther,6 ); -NetCopyIP (&arp->ar_data[6 ], &NetOurIP); +memcpy (&arp->ar_tha, &arp->ar_sha,ARP_HLEN ); +NetCopyIP (&arp->ar_tpa, &arp->ar_spa); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN ); +NetCopyIP (&arp->ar_spa, &NetOurIP); (void )eth_send ((uchar *)et, (pkt - (uchar *)et) +ARP_HDR_SIZE );return;net/arp.c +2
-2@@ -173,12 +173,12 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)#ifdef CONFIG_KEEP_SERVERADDR if (NetServerIP == NetArpWaitPacketIP) {char buf[20 ]; -sprintf (buf,"%pM" , arp->ar_data); +sprintf (buf,"%pM" , arp->ar_sha);setenv ("serveraddr" , buf); }#endif - reply_ip_addr =NetReadIP (&arp->ar_data[6 ]); + reply_ip_addr =NetReadIP (&arp->ar_spa);/* matched waiting packet's address */ if (reply_ip_addr == NetArpWaitReplyIP) {net/arp.c +2
-3@@ -187,14 +187,14 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* save address for later use */ memcpy (NetArpWaitPacketMAC , - &arp->ar_data[0], 6); + &arp->ar_sha, ARP_HLEN);#ifdef CONFIG_NETCONSOLE NetGetHandler ()(0 ,0 ,0 ,0 ,0 );#endif /* modify header, and transmit it */ memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, NetArpWaitPacketMAC,6 ); + et_dest, NetArpWaitPacketMAC,ARP_HLEN ); (void )eth_send (NetArpWaitTxPacket, NetArpWaitTxPacketSize); --1.6.0.2
Quoted 1 line
Regards,
Simon
PATCH v2 2/18 net: Refactor NetSendUDPPacket to share more code
In reply to Joe HershbergerShare more of the code that is common between ARP vs not.
--- net/net.c | 44 +++++++++++++++++++++++++------------------- 1 files changed, 25 insertions(+), 19 deletions(-)
net/net.c +25 -19
@@ -598,6 +598,9 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len) {uchar *pkt; +int need_arp =0 ; +int eth_hdr_size; +int pkt_hdr_size;/* convert to new style broadcast */ if (dest ==0 )
@@ -612,40 +615,43 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,* an ARP request */ if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) { + need_arp =1 ; + pkt = NetArpWaitTxPacket; + }else + pkt = (uchar *)NetTxPacket; + + eth_hdr_size =NetSetEther (pkt, ether,PROT_IP ); + pkt += eth_hdr_size; +net_set_udp_header (pkt, dest, dport, sport, payload_len); + pkt_hdr_size = eth_hdr_size +IP_UDP_HDR_SIZE ; -debug ("sending ARP for %08x\n" , dest); +if (need_arp) { +debug ("sending ARP for %pI4\n" , &dest); +/* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest; NetArpWaitPacketMAC = ether; - pkt = NetArpWaitTxPacket; - pkt +=NetSetEther (pkt, NetArpWaitPacketMAC,PROT_IP ); - -net_set_udp_header (pkt, dest, dport, sport, payload_len); +/* +* Copy the packet data from the NetTxPacket into the +* NetArpWaitTxPacket to send after arp +*/ memcpy (pkt +IP_UDP_HDR_SIZE , (uchar *)NetTxPacket + - (pkt - (uchar *)NetArpWaitTxPacket) + -IP_UDP_HDR_SIZE , payload_len); + pkt_hdr_size, payload_len);/* size of the waiting packet */ - NetArpWaitTxPacketSize = (pkt - NetArpWaitTxPacket) + -IP_UDP_HDR_SIZE + payload_len; + NetArpWaitTxPacketSize = pkt_hdr_size + payload_len;/* and do the ARP request */ NetArpWaitTry =1 ; NetArpWaitTimerStart =get_timer (0 );ArpRequest ();return 1 ;/* waiting */ + }else { +debug ("sending UDP to %pI4/%pM\n" , &dest, ether); +eth_send (NetTxPacket, pkt_hdr_size + payload_len); +return 0 ;/* transmitted */ } - -debug ("sending UDP to %08x/%pM\n" , dest, ether); - - pkt = (uchar *)NetTxPacket; - pkt +=NetSetEther (pkt, ether,PROT_IP ); -net_set_udp_header (pkt, dest, dport, sport, payload_len); -eth_send (NetTxPacket, (pkt - NetTxPacket) +IP_UDP_HDR_SIZE + - payload_len); - -return 0 ;/* transmitted */ }#ifdef CONFIG_IP_DEFRAG
Signature · 1 line
1.6.0.2
PATCH v2 2/18 net: Refactor NetSendUDPPacket to share more code
Hi Joe,
Quoted 6 lines · Joe Hershberger
Share more of the code that is common between ARP vs not.
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
It seems ok to my eye.
Regards,
Simon
PATCH v2 3/18 net: Refactor packet length computations
In reply to Joe Hershberger--- net/arp.c | 13 ++++++++----- net/ping.c | 7 ++++--- net/rarp.c | 6 ++++-- 3 files changed, 16 insertions(+), 10 deletions(-)
net/arp.c +8 -5
@@ -52,12 +52,14 @@ void ArpRequest(void) {uchar *pkt;struct ARP_hdr *arp; +int eth_hdr_size;debug ("ARP broadcast %d\n" , NetArpWaitTry); pkt = NetTxPacket; - pkt +=NetSetEther (pkt, NetBcastAddr,PROT_ARP ); + eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_ARP ); + pkt += eth_hdr_size; arp = (struct ARP_hdr *) pkt;
@@ -86,7 +88,7 @@ void ArpRequest(void) }NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); - (void )eth_send (NetTxPacket, (pkt - NetTxPacket) +ARP_HDR_SIZE ); + (void )eth_send (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE ); }void ArpTimeoutCheck (void )
@@ -118,6 +120,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)struct ARP_hdr *arp;IPaddr_t reply_ip_addr;uchar *pkt; +int eth_hdr_size;/* * We have to deal with two types of ARP packets:
@@ -155,14 +158,14 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* reply with our IP address */ debug ("Got ARP REQUEST, return our IP\n" ); pkt = (uchar *)et; - pkt +=NetSetEther (pkt, et->et_src,PROT_ARP ); + eth_hdr_size =NetSetEther (pkt, et->et_src,PROT_ARP ); + pkt += eth_hdr_size; arp->ar_op =htons (ARPOP_REPLY );memcpy (&arp->ar_tha, &arp->ar_sha,ARP_HLEN );NetCopyIP (&arp->ar_tpa, &arp->ar_spa);memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );NetCopyIP (&arp->ar_spa, &NetOurIP); - (void )eth_send ((uchar *)et, - (pkt - (uchar *)et) +ARP_HDR_SIZE ); + (void )eth_send ((uchar *)et, eth_hdr_size +ARP_HDR_SIZE );return ;case ARPOP_REPLY :/* arp reply */
net/ping.c +4 -3
@@ -42,6 +42,7 @@ static int ping_send(void) {static uchar mac[6 ];uchar *pkt; +int eth_hdr_size;/* XXX always send arp request */
@@ -53,13 +54,13 @@ static int ping_send(void) NetArpWaitPacketMAC = mac; pkt = NetArpWaitTxPacket; - pkt +=NetSetEther (pkt, mac,PROT_IP ); + eth_hdr_size =NetSetEther (pkt, mac,PROT_IP ); + pkt += eth_hdr_size;set_icmp_header (pkt, NetPingIP);/* size of the waiting packet */ - NetArpWaitTxPacketSize = - (pkt - NetArpWaitTxPacket) +IP_HDR_SIZE +8 ; + NetArpWaitTxPacketSize = eth_hdr_size +IP_ICMP_HDR_SIZE ;/* and do the ARP request */ NetArpWaitTry =1 ;
net/rarp.c +4 -2
@@ -88,11 +88,13 @@ void RarpRequest(void) {uchar *pkt;struct ARP_hdr *rarp; +int eth_hdr_size;printf ("RARP broadcast %d\n" , ++RarpTry); pkt = NetTxPacket; - pkt +=NetSetEther (pkt, NetBcastAddr,PROT_RARP ); + eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_RARP ); + pkt += eth_hdr_size; rarp = (struct ARP_hdr *)pkt;
@@ -108,7 +110,7 @@ void RarpRequest(void)/* dest IP addr set to broadcast */ memset (&rarp->ar_data[16 ],0xff ,4 ); -NetSendPacket (NetTxPacket, (pkt - NetTxPacket) +ARP_HDR_SIZE ); +NetSendPacket (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE );NetSetTimeout (TIMEOUT , RarpTimeout); }
Signature · 1 line
1.6.0.2
PATCH v2 3/18 net: Refactor packet length computations
Quoted 4 lines · Joe Hershberger
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
PATCH v2 4/18 net: Refactor bootp packet length computations
In reply to Joe HershbergerEliminate pointer subtraction that recovers values computed earlier
---
Changes for v2:
- Split debug message move to a separate commit
net/bootp.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
net/bootp.c +13 -11
@@ -583,7 +583,8 @@ BootpRequest(void) {uchar *pkt, *iphdr;struct Bootp_t *bp; -int ext_len, pktlen, iplen; +int extlen, pktlen, iplen; +int eth_hdr_size;#ifdef CONFIG_BOOTP_RANDOM_DELAY ulong i, rand_ms;#endif
@@ -612,7 +613,8 @@ BootpRequest(void) pkt = NetTxPacket;memset ((void *)pkt,0 ,PKTSIZE ); - pkt +=NetSetEther (pkt, NetBcastAddr,PROT_IP ); + eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_IP ); + pkt += eth_hdr_size;/* * Next line results in incorrect packet size being transmitted,
@@ -641,9 +643,9 @@ BootpRequest(void)/* Request additional information from the BOOTP/DHCP server */ #if defined(CONFIG_CMD_DHCP ) - ext_len =DhcpExtended ((u8 *)bp->bp_vend,DHCP_DISCOVER ,0 ,0 ); + extlen =DhcpExtended ((u8 *)bp->bp_vend,DHCP_DISCOVER ,0 ,0 );#else - ext_len =BootpExtended ((u8 *)bp->bp_vend); + extlen =BootpExtended ((u8 *)bp->bp_vend);#endif /*
@@ -662,9 +664,8 @@ BootpRequest(void)* Calculate proper packet lengths taking into account the * variable size of the options field */ - pktlen = ((int )(pkt-NetTxPacket)) +BOOTP_HDR_SIZE - -sizeof (bp->bp_vend) + ext_len; - iplen =BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + ext_len; + iplen =BOOTP_HDR_SIZE -OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size +IP_UDP_HDR_SIZE + iplen;net_set_udp_header (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen);NetSetTimeout (SELECT_TIMEOUT , BootpTimeout);
@@ -800,13 +801,15 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer)uchar *pkt, *iphdr;struct Bootp_t *bp;int pktlen, iplen, extlen; +int eth_hdr_size;IPaddr_t OfferedIP;debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n" ); pkt = NetTxPacket;memset ((void *)pkt,0 ,PKTSIZE ); - pkt +=NetSetEther (pkt, NetBcastAddr,PROT_IP ); + eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_IP ); + pkt += eth_hdr_size; iphdr = pkt;/* We'll need this later to set proper pkt size */ pkt +=IP_UDP_HDR_SIZE ;
@@ -843,9 +846,8 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) extlen =DhcpExtended ((u8 *)bp->bp_vend,DHCP_REQUEST , NetDHCPServerIP, OfferedIP); - pktlen = ((int )(pkt-NetTxPacket)) +BOOTP_HDR_SIZE - -sizeof (bp->bp_vend) + extlen; - iplen =BOOTP_HDR_SIZE -sizeof (bp->bp_vend) + extlen; + iplen =BOOTP_HDR_SIZE -OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size +IP_UDP_HDR_SIZE + iplen;net_set_udp_header (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen);debug ("Transmitting DHCPREQUEST packet: len = %d\n" , pktlen);
Signature · 1 line
1.6.0.2
PATCH v2 4/18 net: Refactor bootp packet length computations
Quoted 6 lines · Joe Hershberger
Eliminate pointer subtraction that recovers values computed earlier
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
PATCH v2 5/18 net: Move debug trace to point of action
In reply to Joe Hershberger---
Changes for v2:
- Split from "Refactor bootp packet length computations"
net/bootp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/bootp.c +1 -1
@@ -850,10 +850,10 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) pktlen = eth_hdr_size +IP_UDP_HDR_SIZE + iplen;net_set_udp_header (iphdr,0xFFFFFFFFL ,PORT_BOOTPS ,PORT_BOOTPC , iplen); -debug ("Transmitting DHCPREQUEST packet: len = %d\n" , pktlen);#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY udelay (CONFIG_BOOTP_DHCP_REQUEST_DELAY );#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */ +debug ("Transmitting DHCPREQUEST packet: len = %d\n" , pktlen);NetSendPacket (NetTxPacket, pktlen); }
Signature · 1 line
1.6.0.2
PATCH v2 5/18 net: Move debug trace to point of action
Quoted 4 lines · Joe Hershberger
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Quoted 26 lines
---
Changes for v2:
? - Split from "Refactor bootp packet length computations"?net/bootp.c | ? ?2 +-
?1 files changed, 1 insertions(+), 1 deletions(-)net/bootp.c +0
-1@@ -850,10 +850,10 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) ? ? ? ?pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; ? ? ? ?net_set_udp_header(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen); - ? ? ? debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);?#ifdef
CONFIG_BOOTP_DHCP_REQUEST_DELAY
? ? ? ?udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
?#endif /*CONFIG_BOOTP_DHCP_REQUEST_DELAY*/
+ ? ? ?debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen); ? ? ? ?NetSendPacket(NetTxPacket, pktlen);
?}--
1.6.0.2
PATCH v2 6/18 net: Refactor ping receive handler
In reply to Joe HershbergerThere is no need to call through the handler... inline it
--- net/ping.c | 18 ++---------------- 1 files changed, 2 insertions(+), 16 deletions(-)
net/ping.c +2 -16
@@ -75,20 +75,10 @@ static void ping_timeout(void) NetState =NETLOOP_FAIL ;/* we did not get the reply */ } -static void ping_handler (uchar *pkt,unsigned dest,IPaddr_t sip, -unsigned src,unsigned len) -{ -if (sip != NetPingIP) -return ; - - NetState =NETLOOP_SUCCESS ; -} -void ping_start (void ) {printf ("Using %s device\n" ,eth_get_name ());NetSetTimeout (10000UL , ping_timeout); -NetSetHandler (ping_handler);ping_send (); }
@@ -100,13 +90,9 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)switch (icmph->type) {case ICMP_ECHO_REPLY : -/* -* IP header OK. Pass the packet to the -* current handler. -*/ -/* XXX point to ip packet */ src_ip =NetReadIP ((void *)&ip->ip_src); -NetGetHandler ()((uchar *)ip,0 , src_ip,0 ,0 ); +if (src_ip == NetPingIP) + NetState =NETLOOP_SUCCESS ;return ;case ICMP_ECHO_REQUEST : debug("Got ICMP ECHO REQUEST, return "
Signature · 1 line
1.6.0.2
PATCH v2 6/18 net: Refactor ping receive handler
Quoted 6 lines · Joe Hershberger
There is no need to call through the handler... inline it
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Quoted 48 lines
---
?net/ping.c | ? 18 ++----------------
?1 files changed, 2 insertions(+), 16 deletions(-)net/ping.c +0
-0@@ -75,20 +75,10 @@ static void ping_timeout(void)? ? ? ?NetState =
NETLOOP_FAIL; ? ? ? ?/* we did not get the reply */ ?}net/ping.c +0
-9-static void ping_handler (uchar *pkt,unsigned dest,IPaddr_t sip, - ? ? ? ? ? unsigned src, unsigned len) -{ - ? ? ? if (sip != NetPingIP) - ? ? ? ? ? ? ? return; - - ? ? ? NetState = NETLOOP_SUCCESS; -} -?void
ping_start(void)
?{
? ? ? ?printf("Using %s device\n",eth_get_name()); ? ? ? ?NetSetTimeout(10000UL,ping_timeout);
- ? ? ?NetSetHandler(ping_handler);? ? ? ?ping_send();
?}net/ping.c +0
-0@@ -100,13 +90,9 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ?switch (icmph->type) {? ? ? ?case
ICMP_ECHO_REPLY:
- ? ? ? ? ? ? ? /*
- ? ? ? ? ? ? ? ?* IP header OK. ?Pass the packet to the
- ? ? ? ? ? ? ? ?* current handler.
- ? ? ? ? ? ? ? ?*/
- ? ? ? ? ? ? ? /* XXX point to ip packet */
? ? ? ? ? ? ? ?src_ip =NetReadIP((void *)&ip->ip_src);
- ? ? ? ? ? ? ? NetGetHandler()((uchar *)ip, 0,src_ip, 0, 0);
+ ? ? ? ? ? ? ? if (src_ip== NetPingIP)
+ ? ? ? ? ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS; ? ? ? ? ? ? ? ?return;
? ? ? ?caseICMP_ECHO_REQUEST:
? ? ? ? ? ? ? ?debug("Got ICMP ECHO REQUEST, return " --
1.6.0.2
PATCH v2 7/18 net: Refactor to use NetSendPacket instead of eth_send directly
In reply to Joe HershbergerUse this entry-point consistently across the net/ code Use a static inline function to preserve code size
---
Changes for v2:
- Change NetSendPacket into a static inline
include/net.h | 5 ++++- net/arp.c | 6 +++--- net/cdp.c | 2 +- net/net.c | 9 +-------- net/ping.c | 3 +-- 5 files changed, 10 insertions(+), 15 deletions(-)
include/net.h +4 -1
@@ -466,7 +466,10 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */extern void NetSetTimeout (ulong ,thand_f *);/* Set timeout handler */ /* Transmit "NetTxPacket" */ -extern void NetSendPacket (uchar *,int ); +static inline void NetSendPacket (uchar *pkt,int len) +{ + (void )eth_send (pkt, len); +}/* Transmit UDP packet, performing ARP request if needed */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport,
net/arp.c +3 -3
@@ -88,7 +88,7 @@ void ArpRequest(void) }NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); - (void )eth_send (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +NetSendPacket (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE ); }void ArpTimeoutCheck (void )
@@ -165,7 +165,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)NetCopyIP (&arp->ar_tpa, &arp->ar_spa);memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );NetCopyIP (&arp->ar_spa, &NetOurIP); - (void )eth_send ((uchar *)et, eth_hdr_size +ARP_HDR_SIZE ); +NetSendPacket ((uchar *)et, eth_hdr_size +ARP_HDR_SIZE );return ;case ARPOP_REPLY :/* arp reply */
@@ -198,7 +198,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* modify header, and transmit it */ memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> et_dest, NetArpWaitPacketMAC,ARP_HLEN ); - (void )eth_send (NetArpWaitTxPacket, +NetSendPacket (NetArpWaitTxPacket, NetArpWaitTxPacketSize);/* no arp request pending now */
net/cdp.c +1 -1
@@ -215,7 +215,7 @@ CDPSendTrigger(void) chksum =0xFFFF ; *cp =htons (chksum); - (void )eth_send (NetTxPacket, (uchar *)s - NetTxPacket); +NetSendPacket (NetTxPacket, (uchar *)s - NetTxPacket);return 0 ; }
net/net.c +1 -8
@@ -586,13 +586,6 @@ NetSetTimeout(ulong iv, thand_f *f) } } - -void -NetSendPacket (uchar *pkt,int len) -{ - (void )eth_send (pkt, len); -} -int NetSendUDPPacket (uchar *ether,IPaddr_t dest,int dport,int sport,int payload_len)
@@ -649,7 +642,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,return 1 ;/* waiting */ }else {debug ("sending UDP to %pI4/%pM\n" , &dest, ether); -eth_send (NetTxPacket, pkt_hdr_size + payload_len); +NetSendPacket (NetTxPacket, pkt_hdr_size + payload_len);return 0 ;/* transmitted */ } }
net/ping.c +1 -2
@@ -112,8 +112,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) icmph->checksum =0 ; icmph->checksum = ~NetCksum ((uchar *)icmph, (len -IP_HDR_SIZE ) >>1 ); - (void )eth_send ((uchar *)et, -ETHER_HDR_SIZE + len); +NetSendPacket ((uchar *)et,ETHER_HDR_SIZE + len);return ;/* default: return;*/
Signature · 1 line
1.6.0.2
PATCH v2 7/18 net: Refactor to use NetSendPacket instead of eth_send directly
Quoted 7 lines · Joe Hershberger
Use this entry-point consistently across the
net/code Use a static inline function to preserve code sizeSigned-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Quoted 115 lines
---
Changes for v2:
? - Change NetSendPacket into a static inline?include/net.h | ? ?5 ++++- ?net/arp.c ? ? | ? ?6 +++--- ?net/cdp.c ? ? | ? ?2 +- ?net/net.c ? ? | ? ?9 +-------- ?net/ping.c ? ?| ? ?3 +--?5 files changed, 10 insertions(+), 15 deletions(-)
include/net.h +0
-0@@ -466,7 +466,10 @@ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */?extern void ? ?NetSetTimeout(ulong,
thand_f*);/* Set timeout handler */?/* Transmit "NetTxPacket" */
include/net.h +4
-1-extern void NetSendPacket (uchar *,int ); +static inline void NetSendPacket (uchar *pkt,int len) +{ + ? ? ? (void) eth_send(pkt, len); +}?/* Transmit UDP packet, performing ARP request if needed */ ?extern int ? ? NetSendUDPPacket(uchar *ether,
IPaddr_tdest, int dport,net/arp.c +2
-2@@ -88,7 +88,7 @@ void ArpRequest(void) ? ? ? ?} ? ? ? ?NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP); - ? ? ? (void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); + ? ? ? NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); ?} ?void ArpTimeoutCheck(void)@@ -165,7 +165,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ?NetCopyIP(&arp->ar_tpa, &arp->ar_spa); ? ? ? ? ? ? ? ?memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN); ? ? ? ? ? ? ? ?NetCopyIP(&arp->ar_spa, &NetOurIP); - ? ? ? ? ? ? ? (void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); + ? ? ? ? ? ? ? NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); ? ? ? ? ? ? ? ?return;? ? ? ?case
ARPOP_REPLY: ? ? ? ? ? ? ? /* arp reply */net/arp.c +0
-0@@ -198,7 +198,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)? ? ? ? ? ? ? ? ? ? ? ?/* modify header, and transmit it */
? ? ? ? ? ? ? ? ? ? ? ?memcpy(((structEthernet_hdr*)NetArpWaitTxPacket)-> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?et_dest, NetArpWaitPacketMAC,ARP_HLEN);
- ? ? ? ? ? ? ? ? ? ? ? (void) eth_send(NetArpWaitTxPacket,
+ ? ? ? ? ? ? ? ? ? ? ? NetSendPacket(NetArpWaitTxPacket,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NetArpWaitTxPacketSize);? ? ? ? ? ? ? ? ? ? ? ?/* no arp request pending now */
net/cdp.c +1
-1@@ -215,7 +215,7 @@ CDPSendTrigger(void) ? ? ? ? ? ? ? ?chksum = 0xFFFF; ? ? ? ?*cp = htons(chksum); - ? ? ? (void) eth_send(NetTxPacket, (uchar *)s - NetTxPacket); + ? ? ? NetSendPacket(NetTxPacket, (uchar *)s - NetTxPacket); ? ? ? ?return 0; ?}net/net.c +0
-7@@ -586,13 +586,6 @@ NetSetTimeout(ulong iv, thand_f *f) ? ? ? ?} ?} - -void -NetSendPacket (uchar *pkt,int len) -{ - ? ? ? (void) eth_send(pkt, len); -} -?int
?NetSendUDPPacket(uchar *ether,IPaddr_tdest, int dport, int sport, ? ? ? ? ? ? ? ?intpayload_len)net/net.c +0
-0@@ -649,7 +642,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,? ? ? ? ? ? ? ?return 1; ? ? ? /* waiting */
? ? ? ?} else {
? ? ? ? ? ? ? ?debug("sending UDP to %pI4/%pM\n", &dest, ether);
- ? ? ? ? ? ? ?eth_send(NetTxPacket, pkt_hdr_size + payload_len);
+ ? ? ? ? ? ? ?NetSendPacket(NetTxPacket, pkt_hdr_size + payload_len); ? ? ? ? ? ? ? ?return 0; ? ? ? /* transmitted */
? ? ? ?}
?}net/ping.c +1
-2@@ -112,8 +112,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ?icmph->checksum = 0; ? ? ? ? ? ? ? ?icmph->checksum = ~NetCksum((uchar *)icmph, ? ? ? ? ? ? ? ? ? ? ? ?(len - IP_HDR_SIZE) >> 1); - ? ? ? ? ? ? ? (void) eth_send((uchar *)et, - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ETHER_HDR_SIZE + len); + ? ? ? ? ? ? ? NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len); ? ? ? ? ? ? ? ?return;?/* ? ? default:
? ? ? ? ? ? ? ?return;*/
--
1.6.0.2
PATCH v2 8/18 net: Refactor to protect access to the NetState variable
In reply to Joe HershbergerChanges to NetState now go through an accessor function called net_set_state()
---
Changes for v2:
- net_set_state changed to static inline
- States changed to an enum
- Eliminate CamelCase in new functions.
drivers/net/netconsole.c | 6 +++--- include/net.h | 16 ++++++++++------ net/cdp.c | 2 +- net/dns.c | 8 ++++---- net/net.c | 21 ++++++++++++--------- net/nfs.c | 8 ++++---- net/ping.c | 4 ++-- net/sntp.c | 4 ++-- net/tftp.c | 8 ++++---- 9 files changed, 42 insertions(+), 35 deletions(-)
drivers/net/netconsole.c +3 -3
@@ -44,19 +44,19 @@ static void nc_wait_arp_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) { - NetState =NETLOOP_SUCCESS ;/* got arp reply - quit net loop */ +net_set_state (NETLOOP_SUCCESS );/* got arp reply - quit net loop */ }static void nc_handler (uchar *pkt,unsigned dest,IPaddr_t sip,unsigned src,unsigned len) {if (input_size) - NetState =NETLOOP_SUCCESS ;/* got input - quit net loop */ +net_set_state (NETLOOP_SUCCESS );/* got input - quit net loop */ }static void nc_timeout (void ) { - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void NcStart (void )
include/net.h +10 -6
@@ -390,12 +390,6 @@ extern uchar NetEtherNullAddr[6];extern ushort NetOurVLAN;/* Our VLAN */ extern ushort NetOurNativeVLAN;/* Our Native VLAN */ -extern int NetState;/* Network loop state */ -#define NETLOOP_CONTINUE 1 -#define NETLOOP_RESTART 2 -#define NETLOOP_SUCCESS 3 -#define NETLOOP_FAIL 4 -extern int NetRestartWrap;/* Tried all network devices */ enum proto_t {
@@ -465,6 +459,16 @@ extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */extern void net_set_icmp_handler (rxhand_icmp_f *f);/* Set ICMP RX handler */ extern void NetSetTimeout (ulong ,thand_f *);/* Set timeout handler */ +/* Network loop state */ +enum net_loop_state { +NETLOOP_CONTINUE ,NETLOOP_RESTART ,NETLOOP_SUCCESS ,NETLOOP_FAIL +}; +static inline void net_set_state (enum net_loop_state state) +{ +extern enum net_loop_state net_state; + net_state = state; +} +/* Transmit "NetTxPacket" */ static inline void NetSendPacket (uchar *pkt,int len) {
net/cdp.c +1 -1
@@ -234,7 +234,7 @@ CDPTimeout(void)if (!CDPOK )NetStartAgain ();else - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } static void
net/dns.c +4 -4
@@ -98,7 +98,7 @@ static voidDnsTimeout (void) {puts ("Timeout\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); } static void
@@ -128,7 +128,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)/* Received 0 answers */ if (header->nanswers ==0 ) {puts ("DNS: host not found\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }
@@ -141,7 +141,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)/* We sent query class 1, query type 1 */ if (&p[5 ] > e ||get_unaligned_be16 (p+1 ) !=DNS_A_RECORD ) {puts ("DNS: response was not an A record\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }
@@ -191,7 +191,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)puts ("server responded with invalid IP number\n" ); } - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void
net/net.c +12 -9
@@ -149,7 +149,7 @@ uchar NetEtherNullAddr[6];void (*push_packet)(void *,int len) =0 ;#endif /* Network loop state */ -int NetState; +enum net_loop_state net_state;/* Tried all network devices */ int NetRestartWrap;/* Network loop restarted */
@@ -212,7 +212,7 @@ void net_auto_load(void)* Just use BOOTP/RARP to configure system; * Do not use TFTP to load the bootfile. */ - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ; }#if defined(CONFIG_CMD_NFS )
@@ -292,7 +292,7 @@ int NetLoop(enum proto_t protocol) restart:memcpy (NetOurEther,eth_get_dev ()->enetaddr,6 ); - NetState =NETLOOP_CONTINUE ; +net_set_state (NETLOOP_CONTINUE );/* * Start the ball rolling with the given start function. From
@@ -401,7 +401,7 @@ restart:/* * Main packet reception loop. Loop receiving packets until -* someone sets `NetState' to a state that terminates. +* someone sets `net_state' to a state that terminates. */ for (;;) {WATCHDOG_RESET ();
@@ -453,7 +453,7 @@ restart: } -switch (NetState) { +switch (net_state) {case NETLOOP_RESTART : NetRestarted =1 ;
@@ -477,6 +477,9 @@ restart:case NETLOOP_FAIL : goto done; + +case NETLOOP_CONTINUE : +continue ; } }
@@ -494,7 +497,7 @@ done:static void startAgainTimeout (void ) { - NetState =NETLOOP_RESTART ; +net_set_state (NETLOOP_RESTART ); } static void
@@ -525,7 +528,7 @@ void NetStartAgain(void)if ((!retry_forever) && (NetTryCount >= retrycnt)) {eth_halt (); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; }
@@ -542,10 +545,10 @@ void NetStartAgain(void)NetSetTimeout (10000UL , startAgainTimeout);NetSetHandler (startAgainHandler); }else { - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); } }else { - NetState =NETLOOP_RESTART ; +net_set_state (NETLOOP_RESTART ); } }
net/nfs.c +4 -4
@@ -41,7 +41,7 @@ static int nfs_len;static char dirfh[NFS_FHSIZE ];/* file handle of directory */ static char filefh[NFS_FHSIZE ];/* file handle of kernel image */ -static int NfsDownloadState; +static enum net_loop_state NfsDownloadState;static IPaddr_t NfsServerIP;static int NfsSrvMountPort;static int NfsSrvNfsPort;
@@ -613,10 +613,10 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)case STATE_UMOUNT_REQ :if (nfs_umountall_reply (pkt, len)) {puts ("*** ERROR: Cannot umount\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL ); }else {puts ("\ndone\n" ); - NetState = NfsDownloadState; +net_set_state (NfsDownloadState); }break ;
@@ -679,7 +679,7 @@ NfsStart(void) nfs_path = (char *)nfs_path_buff;if (nfs_path ==NULL ) { - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );puts ("*** ERROR: Fail allocate memory\n" );return ; }
net/ping.c +2 -2
@@ -72,7 +72,7 @@ static int ping_send(void)static void ping_timeout (void ) {eth_halt (); - NetState =NETLOOP_FAIL ;/* we did not get the reply */ +net_set_state (NETLOOP_FAIL );/* we did not get the reply */ }void ping_start (void )
@@ -92,7 +92,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)case ICMP_ECHO_REPLY : src_ip =NetReadIP ((void *)&ip->ip_src);if (src_ip == NetPingIP) - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS );return ;case ICMP_ECHO_REQUEST : debug("Got ICMP ECHO REQUEST, return "
net/sntp.c +2 -2
@@ -45,7 +45,7 @@ static voidSntpTimeout (void) {puts ("Timeout\n" ); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; }
@@ -76,7 +76,7 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); }void
net/tftp.c +4 -4
@@ -177,7 +177,7 @@ store_block(unsigned block, uchar *src, unsigned len) rc =flash_write ((char *)src, (ulong)(load_addr+offset), len);if (rc) {flash_perror (rc); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );return ; } }else
@@ -300,7 +300,7 @@ static void tftp_complete(void) }#endif puts ("\ndone\n" ); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } static void
@@ -627,7 +627,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,if (MasterClient && (TftpBlock >= TftpEndingBlock)) {puts ("\nMulticast tftp done\n" );mcast_cleanup (); - NetState =NETLOOP_SUCCESS ; +net_set_state (NETLOOP_SUCCESS ); } } else#endif
@@ -644,7 +644,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,case TFTP_ERR_ACCESS_DENIED :puts ("Not retrying...\n" );eth_halt (); - NetState =NETLOOP_FAIL ; +net_set_state (NETLOOP_FAIL );break ;case TFTP_ERR_UNDEFINED :case TFTP_ERR_DISK_FULL :
Signature · 1 line
1.6.0.2
PATCH v2 8/18 net: Refactor to protect access to the NetState variable
Hi Joe,
Quoted 72 lines · Joe Hershberger
Changes to NetState now go through an accessor function called
net_set_state()Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>---
Changes for v2:
? -net_set_statechanged to static inline
? - States changed to an enum
? - Eliminate CamelCase in new functions.?drivers/net/netconsole.c | ? ?6 +++--- ?include/net.h ? ? ? ? ? ?| ? 16 ++++++++++------ ?net/cdp.c ? ? ? ? ? ? ? ?| ? ?2 +- ?net/dns.c ? ? ? ? ? ? ? ?| ? ?8 ++++---- ?net/net.c ? ? ? ? ? ? ? ?| ? 21 ++++++++++++--------- ?net/nfs.c ? ? ? ? ? ? ? ?| ? ?8 ++++---- ?net/ping.c ? ? ? ? ? ? ? | ? ?4 ++-- ?net/sntp.c ? ? ? ? ? ? ? | ? ?4 ++-- ?net/tftp.c ? ? ? ? ? ? ? | ? ?8 ++++----?9 files changed, 42 insertions(+), 35 deletions(-)
drivers/net/netconsole.c +3
-3@@ -44,19 +44,19 @@ static void nc_wait_arp_handler(uchar *pkt, unsigned dest, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IPaddr_t sip, unsigned src, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned len) ?{ - ? ? ? NetState = NETLOOP_SUCCESS; /* got arp reply - quit net loop */ + ? ? ? net_set_state(NETLOOP_SUCCESS); /* got arp reply - quit net loop */ ?} ?static void nc_handler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, ? ? ? ? ? ? ? ? ? ? ? ?unsigned len) ?{ ? ? ? ?if (input_size) - ? ? ? ? ? ? ? NetState = NETLOOP_SUCCESS; /* got input - quit net loop */ + ? ? ? ? ? ? ? net_set_state(NETLOOP_SUCCESS); /* got input - quit net loop */ ?} ?static void nc_timeout(void) ?{ - ? ? ? NetState = NETLOOP_SUCCESS; + ? ? ? net_set_state(NETLOOP_SUCCESS); ?} ?void NcStart(void)include/net.h +0
-0@@ -390,12 +390,6 @@ extern uchar ? ? ? ? ? ? ? NetEtherNullAddr[6];?extern ushort ? ? ? ? ?NetOurVLAN; ? ? ? ? ? ? /* Our VLAN */ ?extern ushort ? ? ? ? ?NetOurNativeVLAN; ? ? ? /* Our Native VLAN */
include/net.h +0
-6-extern int ? ? ? ? ? ? NetState; ? ? ? ? ? ? ? /* Network loop state */ -#define NETLOOP_CONTINUE ? ? ? 1 -#define NETLOOP_RESTART ? ? ? ? ? ? ? ?2 -#define NETLOOP_SUCCESS ? ? ? ? ? ? ? ?3 -#define NETLOOP_FAIL ? ? ? ? ? 4 -?extern int ? ? ? ? ? ? NetRestartWrap; ? ? ? ? /* Tried all network devices */
?enum
proto_t{include/net.h +0
-0@@ -465,6 +459,16 @@ extern void ? ? ? ?NetSetHandler(rxhand_f *); ? ? ?/* Set RX packet handler */?extern void
net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ ?extern void ? ?NetSetTimeout(ulong,thand_f*);/* Set timeout handler */
include/net.h extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
Quoted 3 lines
include/net.h +3
-0+/* Network loop state */ +enum net_loop_state { + ? ? ? NETLOOP_CONTINUE, NETLOOP_RESTART, NETLOOP_SUCCESS, NETLOOP_FAIL
Do we need these all on one line?
include/net.h extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */
Quoted 4 lines
include/net.h +4
-0+}; +static inline void net_set_state (enum net_loop_state state) +{ + ? ? ? extern enum net_loop_state net_state;
blank line?
Quoted 157 lines
+ ? ? ?
net_state= state;include/net.h +2
-0+} +?/* Transmit "NetTxPacket" */
?static inline voidNetSendPacket(uchar *pkt, int len)?{net/cdp.c +0
-0@@ -234,7 +234,7 @@ CDPTimeout(void) ? ? ? ?if (!CDPOK) ? ? ? ? ? ? ? ?NetStartAgain();? ? ? ?else
- ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ?}?static void
net/dns.c +1
-1@@ -98,7 +98,7 @@ static void ?DnsTimeout(void) ?{ ? ? ? ?puts("Timeout\n"); - ? ? ? NetState = NETLOOP_FAIL; + ? ? ? net_set_state(NETLOOP_FAIL); ?}?static void
net/dns.c +0
-0@@ -128,7 +128,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)? ? ? ?/* Received 0 answers */
? ? ? ?if (header->nanswers== 0) {
? ? ? ? ? ? ? ?puts("DNS: host not found\n");
- ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ? ? ? ? ? ? ? ?return;
? ? ? ?}net/dns.c +0
-0@@ -141,7 +141,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)? ? ? ?/* We sent query class 1, query type 1 */
? ? ? ?if (&p[5] > e ||get_unaligned_be16(p+1)!=DNS_A_RECORD) { ? ? ? ? ? ? ? ?puts("DNS: response was not an A record\n");
- ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS);
? ? ? ? ? ? ? ?return;
? ? ? ?}net/dns.c +1
-1@@ -191,7 +191,7 @@ DnsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len) ? ? ? ? ? ? ? ? ? ? ? ?puts("server responded with invalid IP number\n"); ? ? ? ?} - ? ? ? NetState = NETLOOP_SUCCESS; + ? ? ? net_set_state(NETLOOP_SUCCESS); ?}?void
net/net.c +0
-0@@ -149,7 +149,7 @@ uchar ? ? ? ? ? ? ? NetEtherNullAddr[6]; ?void ? ? ? ? ? (*push_packet)(void *, int len) = 0;?#endif
?/* Network loop state */net/net.c +1
-1-int ? ? ? ? ? ?NetState; +enum net_loop_state net_state;?/* Tried all network devices */
?int ? ? ? ? ? ?NetRestartWrap;
?/* Network loop restarted */net/net.c +0
-0@@ -212,7 +212,7 @@ void net_auto_load(void) ? ? ? ? ? ? ? ? ? ? ? ? * Just use BOOTP/RARP to configure system;? ? ? ? ? ? ? ? ? ? ? ? * Do not use TFTP to load the bootfile. ? ? ? ? ? ? ? ? ? ? ? ? */
- ? ? ? ? ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ? ? ? ? ? ? ? ? ? ? ? ?return;
? ? ? ? ? ? ? ?}
?#ifdefined(CONFIG_CMD_NFS)net/net.c +0
-0@@ -292,7 +292,7 @@ int NetLoop(enum proto_t protocol)?restart:
? ? ? ?memcpy(NetOurEther, eth_get_dev()->enetaddr, 6);- ? ? ? NetState =
NETLOOP_CONTINUE;
+ ? ? ?net_set_state(NETLOOP_CONTINUE);? ? ? ?/*
? ? ? ? * ? ? ?Start the ball rolling with the given start function. ?Fromnet/net.c +0
-0@@ -401,7 +401,7 @@ restart:? ? ? ?/*
? ? ? ? * ? ? ?Main packet reception loop. ?Loop receiving packets until
- ? ? ? ?* ? ? ?someone sets `NetState' to a state that terminates.
+ ? ? ? ?* ? ? ?someone sets `net_state' to a state that terminates. ? ? ? ? */
? ? ? ?for (;;) {
? ? ? ? ? ? ? ?WATCHDOG_RESET();net/net.c +1
-1@@ -453,7 +453,7 @@ restart: ? ? ? ? ? ? ? ?} - ? ? ? ? ? ? ? switch (NetState) { + ? ? ? ? ? ? ? switch (net_state) {? ? ? ? ? ? ? ?case
NETLOOP_RESTART:
? ? ? ? ? ? ? ? ? ? ? ?NetRestarted = 1;net/net.c +0
-0@@ -477,6 +477,9 @@ restart:? ? ? ? ? ? ? ?case
NETLOOP_FAIL:
? ? ? ? ? ? ? ? ? ? ? ?goto done;
+
+ ? ? ? ? ? ? ? caseNETLOOP_CONTINUE:
+ ? ? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ?}
? ? ? ?}net/net.c +0
-0@@ -494,7 +497,7 @@ done:?static void
?startAgainTimeout(void)
?{
- ? ? ? NetState =NETLOOP_RESTART;
+ ? ? ?net_set_state(NETLOOP_RESTART);
?}?static void
net/net.c +3
-3@@ -525,7 +528,7 @@ void NetStartAgain(void) ? ? ? ?if ((!retry_forever) && (NetTryCount >= retrycnt)) { ? ? ? ? ? ? ? ?eth_halt(); - ? ? ? ? ? ? ? NetState = NETLOOP_FAIL; + ? ? ? ? ? ? ? net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ?return; ? ? ? ?}@@ -542,10 +545,10 @@ void NetStartAgain(void) ? ? ? ? ? ? ? ? ? ? ? ?NetSetTimeout(10000UL, startAgainTimeout); ? ? ? ? ? ? ? ? ? ? ? ?NetSetHandler(startAgainHandler); ? ? ? ? ? ? ? ?} else { - ? ? ? ? ? ? ? ? ? ? ? NetState = NETLOOP_FAIL; + ? ? ? ? ? ? ? ? ? ? ? net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ?} ? ? ? ?} else { - ? ? ? ? ? ? ? NetState = NETLOOP_RESTART; + ? ? ? ? ? ? ? net_set_state(NETLOOP_RESTART); ? ? ? ?} ?}net/nfs.c +0
-0@@ -41,7 +41,7 @@ static int nfs_len;?static char dirfh[NFS_FHSIZE]; /* file handle of directory */ ?static char filefh[NFS_FHSIZE]; /* file handle of kernel image */
net/nfs.c
Quoted 2 lines
net/nfs.c +1
-1-static int ? ? NfsDownloadState; +static enum net_loop_state NfsDownloadState;
Can you use nfs_download_state instead?
Quoted 103 lines
?static
IPaddr_tNfsServerIP;
?static int ? ? NfsSrvMountPort;
?static int ? ? NfsSrvNfsPort;net/nfs.c +0
-0@@ -613,10 +613,10 @@ NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)? ? ? ?case
STATE_UMOUNT_REQ:
? ? ? ? ? ? ? ?if (nfs_umountall_reply(pkt, len)) { ? ? ? ? ? ? ? ? ? ? ? ?puts("*** ERROR: Cannot umount\n");
- ? ? ? ? ? ? ? ? ? ? ? NetState =NETLOOP_FAIL;
+ ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ?} else {
? ? ? ? ? ? ? ? ? ? ? ?puts("\ndone\n");
- ? ? ? ? ? ? ? ? ? ? ? NetState = NfsDownloadState;
+ ? ? ? ? ? ? ? ? ? ? ?net_set_state(NfsDownloadState); ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?break;net/nfs.c +1
-1@@ -679,7 +679,7 @@ NfsStart(void) ? ? ? ?nfs_path = (char *)nfs_path_buff; ? ? ? ?if (nfs_path == NULL) { - ? ? ? ? ? ? ? NetState = NETLOOP_FAIL; + ? ? ? ? ? ? ? net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ?puts("*** ERROR: Fail allocate memory\n"); ? ? ? ? ? ? ? ?return; ? ? ? ?}net/ping.c +1
-1@@ -72,7 +72,7 @@ static int ping_send(void) ?static void ping_timeout(void) ?{ ? ? ? ?eth_halt(); - ? ? ? NetState = NETLOOP_FAIL; ? ? ? ?/* we did not get the reply */ + ? ? ? net_set_state(NETLOOP_FAIL); ? ?/* we did not get the reply */ ?} ?void ping_start(void)@@ -92,7 +92,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)? ? ? ?case
ICMP_ECHO_REPLY:
? ? ? ? ? ? ? ?src_ip =NetReadIP((void *)&ip->ip_src); ? ? ? ? ? ? ? ?if (src_ip== NetPingIP)
- ? ? ? ? ? ? ? ? ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ? ? ? ? ? ? ? ?return;
? ? ? ?caseICMP_ECHO_REQUEST:
? ? ? ? ? ? ? ?debug("Got ICMP ECHO REQUEST, return "net/sntp.c +2
-2@@ -45,7 +45,7 @@ static void ?SntpTimeout(void) ?{ ? ? ? ?puts("Timeout\n"); - ? ? ? NetState = NETLOOP_FAIL; + ? ? ? net_set_state(NETLOOP_FAIL); ? ? ? ?return; ?}@@ -76,7 +76,7 @@ SntpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, ? ? ? ? ? ? ? ?tm.tm_year, tm.tm_mon, tm.tm_mday, ? ? ? ? ? ? ? ?tm.tm_hour, tm.tm_min, tm.tm_sec); - ? ? ? NetState = NETLOOP_SUCCESS; + ? ? ? net_set_state(NETLOOP_SUCCESS); ?}?void
net/tftp.c +1
-1@@ -177,7 +177,7 @@ store_block(unsigned block, uchar *src, unsigned len) ? ? ? ? ? ? ? ?rc = flash_write((char *)src, (ulong)(load_addr+offset), len); ? ? ? ? ? ? ? ?if (rc) { ? ? ? ? ? ? ? ? ? ? ? ?flash_perror(rc); - ? ? ? ? ? ? ? ? ? ? ? NetState = NETLOOP_FAIL; + ? ? ? ? ? ? ? ? ? ? ? net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ? ? ? ? ?return; ? ? ? ? ? ? ? ?}? ? ? ?} else
net/tftp.c +0
-0@@ -300,7 +300,7 @@ static void tftp_complete(void) ? ? ? ?}?#endif
? ? ? ?puts("\ndone\n");
- ? ? ? NetState =NETLOOP_SUCCESS;
+ ? ? ?net_set_state(NETLOOP_SUCCESS);
?}?static void
net/tftp.c +1
-1@@ -627,7 +627,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, ? ? ? ? ? ? ? ? ? ? ? ?if (MasterClient && (TftpBlock >= TftpEndingBlock)) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?puts("\nMulticast tftp done\n"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?mcast_cleanup(); - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NetState = NETLOOP_SUCCESS; + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? net_set_state(NETLOOP_SUCCESS); ? ? ? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ?} else
?#endifnet/tftp.c +0
-0@@ -644,7 +644,7 @@ TftpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,? ? ? ? ? ? ? ?case
TFTP_ERR_ACCESS_DENIED:
? ? ? ? ? ? ? ? ? ? ? ?puts("Not retrying...\n");
Quoted 9 lines
? ? ? ? ? ? ? ? ? ? ? ?eth_halt();
- ? ? ? ? ? ? ? ? ? ? ? NetState =NETLOOP_FAIL;
+ ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ?caseTFTP_ERR_UNDEFINED:
? ? ? ? ? ? ? ?caseTFTP_ERR_DISK_FULL:
--
1.6.0.2
Regards,
Simon
PATCH v2 9/18 net: Refactor to separate the UDP handler from the ARP handler
In reply to Joe HershbergerCall a built-in dummy if none is registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in arp.c)
Clear handlers at the end of net loop
---
Changes for v2:
- Change NULL checks into dummy functions
- Must now call net_set_*_handler(NULL); in init to set dummies
- Eliminate CamelCase for new functions
drivers/net/netconsole.c | 4 +- include/net.h | 9 +++- net/arp.c | 6 +- net/bootp.c | 4 +- net/cdp.c | 8 ---- net/dns.c | 2 +- net/net.c | 95 ++++++++++++++++++++++++++++++---------------- net/nfs.c | 2 +- net/sntp.c | 2 +- net/tftp.c | 4 +- 10 files changed, 80 insertions(+), 56 deletions(-)
drivers/net/netconsole.c +2 -2
@@ -63,12 +63,12 @@ void NcStart(void) {if (!output_packet_len ||memcmp (nc_ether, NetEtherNullAddr,6 )) {/* going to check for input packet */ -NetSetHandler (nc_handler); +net_set_udp_handler (nc_handler);NetSetTimeout (net_timeout, nc_timeout); }else {/* send arp request */ uchar *pkt; -NetSetHandler (nc_wait_arp_handler); +net_set_arp_handler (nc_wait_arp_handler); pkt = (uchar *)NetTxPacket +NetEthHdrSize () +IP_UDP_HDR_SIZE ;memcpy (pkt, output_packet, output_packet_len); NetSendUDPPacket(nc_ether, nc_ip, nc_port, nc_port,
include/net.h +6 -3
@@ -454,8 +454,10 @@ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */extern uint NetCksum (uchar *,int );/* Calculate the checksum */ /* Callbacks */ -extern rxhand_f *NetGetHandler (void );/* Get RX packet handler */ -extern void NetSetHandler (rxhand_f *);/* Set RX packet handler */ +extern rxhand_f *net_get_udp_handler (void );/* Get UDP RX packet handler */ +extern void net_set_udp_handler (rxhand_f *);/* Set UDP RX packet handler */ +extern rxhand_f *net_get_arp_handler (void );/* Get ARP RX packet handler */ +extern void net_set_arp_handler (rxhand_f *);/* Set ARP RX packet handler */ extern void net_set_icmp_handler (rxhand_icmp_f *f);/* Set ICMP RX handler */ extern void NetSetTimeout (ulong ,thand_f *);/* Set timeout handler */
@@ -475,7 +477,8 @@ static inline void NetSendPacket(uchar *pkt, int len) (void )eth_send (pkt, len); } -/* Transmit UDP packet, performing ARP request if needed */ +/* Transmit UDP packet, performing ARP request if needed +(ether will be populated) */ extern int NetSendUDPPacket (uchar *ether,IPaddr_t dest,int dport,int sport,int payload_len);
net/arp.c +3 -3
@@ -192,9 +192,9 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)memcpy (NetArpWaitPacketMAC, &arp->ar_sha,ARP_HLEN ); -#ifdef CONFIG_NETCONSOLE -NetGetHandler ()(0 ,0 ,0 ,0 ,0 ); -#endif +net_get_arp_handler ()((uchar *)arp,0 , + reply_ip_addr,0 , len); +/* modify header, and transmit it */ memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> et_dest, NetArpWaitPacketMAC,ARP_HLEN );
net/bootp.c +2 -2
@@ -671,9 +671,9 @@ BootpRequest(void)#if defined(CONFIG_CMD_DHCP ) dhcp_state =SELECTING ; -NetSetHandler (DhcpHandler); +net_set_udp_handler (DhcpHandler);#else -NetSetHandler (BootpHandler); +net_set_udp_handler (BootpHandler);#endif NetSendPacket (NetTxPacket, pktlen); }
net/cdp.c +0 -8
@@ -237,13 +237,6 @@ CDPTimeout(void)net_set_state (NETLOOP_SUCCESS ); } -static void -CDPDummyHandler (uchar *pkt,unsigned dest,IPaddr_t sip,unsigned src, -unsigned len) -{ -/* nothing */ -} -void CDPReceive (const uchar *pkt,unsigned len) {
@@ -368,7 +361,6 @@ CDPStart(void) CDPApplianceVLAN =htons (-1 );NetSetTimeout (CDP_TIMEOUT , CDPTimeout); -NetSetHandler (CDPDummyHandler);CDPSendTrigger (); }
net/dns.c +1 -1
@@ -200,7 +200,7 @@ DnsStart(void)debug ("%s\n" , __func__);NetSetTimeout (DNS_TIMEOUT , DnsTimeout); -NetSetHandler (DnsHandler); +net_set_udp_handler (DnsHandler);DnsSend (); }
net/net.c +62 -33
174 lines not on this page · raw message
net/nfs.c +1 -1
@@ -735,7 +735,7 @@ NfsStart(void) "Loading: *\b", load_addr);NetSetTimeout (NFS_TIMEOUT , NfsTimeout); -NetSetHandler (NfsHandler); +net_set_udp_handler (NfsHandler); NfsTimeoutCount =0 ; NfsState =STATE_PRCLOOKUP_PROG_MOUNT_REQ ;
net/sntp.c +1 -1
@@ -85,7 +85,7 @@ SntpStart(void)debug ("%s\n" , __func__);NetSetTimeout (SNTP_TIMEOUT , SntpTimeout); -NetSetHandler (SntpHandler); +net_set_udp_handler (SntpHandler);memset (NetServerEther,0 ,6 );SntpSend ();
net/tftp.c +2 -2
@@ -778,7 +778,7 @@ void TftpStart(enum proto_t protocol) TftpTimeoutCountMax = TftpRRQTimeoutCountMax;NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); -NetSetHandler (TftpHandler); +net_set_udp_handler (TftpHandler);#ifdef CONFIG_CMD_TFTPPUT net_set_icmp_handler (icmp_handler);#endif
@@ -840,7 +840,7 @@ TftpStartServer(void)#endif TftpState =STATE_RECV_WRQ ; - NetSetHandler(TftpHandler); + net_set_udp_handler(TftpHandler); }#endif /* CONFIG_CMD_TFTPSRV */
Signature · 1 line
1.6.0.2
PATCH v2 9/18 net: Refactor to separate the UDP handler from the ARP handler
Hi Joe,
Quoted 10 lines · Joe Hershberger
Call a built-in dummy if none is registered... don't require protocols to register a handler (eliminating dummies) NetConsole now uses the ARP handler when waiting on arp (instead of needing a #define hack in
arp.c)
Clear handlers at the end of net loopSigned-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Couple of questions, but not important.
Quoted 55 lines
---
Changes for v2:
? - Change NULL checks into dummy functions
? - Must now call net_set_*_handler(NULL); in init to set dummies ? - Eliminate CamelCase for new functions?drivers/net/netconsole.c | ? ?4 +- ?include/net.h ? ? ? ? ? ?| ? ?9 +++- ?net/arp.c ? ? ? ? ? ? ? ?| ? ?6 +- ?net/bootp.c ? ? ? ? ? ? ?| ? ?4 +- ?net/cdp.c ? ? ? ? ? ? ? ?| ? ?8 ---- ?net/dns.c ? ? ? ? ? ? ? ?| ? ?2 +- ?net/net.c ? ? ? ? ? ? ? ?| ? 95 ++++++++++++++++++++++++++++++---------------- ?net/nfs.c ? ? ? ? ? ? ? ?| ? ?2 +- ?net/sntp.c ? ? ? ? ? ? ? | ? ?2 +- ?net/tftp.c ? ? ? ? ? ? ? | ? ?4 +-?10 files changed, 80 insertions(+), 56 deletions(-)
drivers/net/netconsole.c +0
-0@@ -63,12 +63,12 @@ void NcStart(void) ?{ ? ? ? ?if (!output_packet_len || memcmp(nc_ether, NetEtherNullAddr, 6)) {? ? ? ? ? ? ? ?/* going to check for input packet */
- ? ? ? ? ? ? ?NetSetHandler(nc_handler);
+ ? ? ? ? ? ? ?net_set_udp_handler(nc_handler);
? ? ? ? ? ? ? ?NetSetTimeout(net_timeout,nc_timeout);
? ? ? ?} else {
? ? ? ? ? ? ? ?/* send arp request */
? ? ? ? ? ? ? ?uchar *pkt;
- ? ? ? ? ? ? ?NetSetHandler(nc_wait_arp_handler);
+ ? ? ? ? ? ? ?net_set_arp_handler(nc_wait_arp_handler);
? ? ? ? ? ? ? ?pkt = (uchar *)NetTxPacket +NetEthHdrSize()+IP_UDP_HDR_SIZE; ? ? ? ? ? ? ? ?memcpy(pkt,output_packet,output_packet_len);
? ? ? ? ? ? ? ?NetSendUDPPacket(nc_ether,nc_ip,nc_port,nc_port,include/net.h +0
-0@@ -454,8 +454,10 @@ extern int NetCksumOk(uchar *, int); ? ? ? /* Return true if cksum OK */?extern uint ? ?NetCksum(uchar *, int); ? ? ? ? /* Calculate the checksum */
?/* Callbacks */
include/net.h +4
-2-extern rxhand_f *NetGetHandler(void); ? ? ? ? ?/* Get RX packet handler */ -extern void ? ?NetSetHandler(rxhand_f *); ? ? ?/* Set RX packet handler */ +extern rxhand_f *net_get_udp_handler(void); ? ?/* Get UDP RX packet handler */ +extern void net_set_udp_handler(rxhand_f *); ? /* Set UDP RX packet handler */ +extern rxhand_f *net_get_arp_handler(void); ? ?/* Get ARP RX packet handler */ +extern void net_set_arp_handler(rxhand_f *); ? /* Set ARP RX packet handler */?extern void
net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ ?extern void ? ?NetSetTimeout(ulong,thand_f*);/* Set timeout handler */
include/net.h static inline void NetSendPacket(uchar *pkt, int len) · line 481
Quoted 6 lines
include/net.h +2
-1@@ -475,7 +477,8 @@ static inline void NetSendPacket(uchar *pkt, int len) ? ? ? ?(void) eth_send(pkt, len); ?} -/* Transmit UDP packet, performing ARP request if needed */ +/* Transmit UDP packet, performing ARP request if needed +? (ether will be populated) */
comment style
Quoted 8 lines
include/net.h +0
-0?extern int ? ? NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, ? ? ? ? ? ? ? ? ? ? ? ?int sport, int payload_len);net/arp.c +0
-0
net/arp.c void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) · line 196
Quoted 8 lines
net/arp.c +2
-3@@ -192,9 +192,9 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ? ? ? ? ?memcpy(NetArpWaitPacketMAC, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&arp->ar_sha, ARP_HLEN); -#ifdef CONFIG_NETCONSOLE - ? ? ? ? ? ? ? ? ? ? ? NetGetHandler()(0, 0, 0, 0, 0); -#endif + ? ? ? ? ? ? ? ? ? ? ? net_get_arp_handler()((uchar *)arp, 0, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? reply_ip_addr, 0, len);
I presume this is too long for one line?
Quoted 84 lines
net/arp.c +1
-0+? ? ? ? ? ? ? ? ? ? ? ?/* modify header, and transmit it */
? ? ? ? ? ? ? ? ? ? ? ?memcpy(((structEthernet_hdr*)NetArpWaitTxPacket)-> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?et_dest, NetArpWaitPacketMAC,ARP_HLEN);net/bootp.c +1
-1@@ -671,9 +671,9 @@ BootpRequest(void) ?#if defined(CONFIG_CMD_DHCP) ? ? ? ?dhcp_state = SELECTING; - ? ? ? NetSetHandler(DhcpHandler); + ? ? ? net_set_udp_handler(DhcpHandler);?#else
- ? ? ? NetSetHandler(BootpHandler);
+ ? ? ?net_set_udp_handler(BootpHandler);
?#endif
? ? ? ?NetSendPacket(NetTxPacket, pktlen);
?}net/cdp.c +0
-7@@ -237,13 +237,6 @@ CDPTimeout(void) ? ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ?} -static void -CDPDummyHandler (uchar *pkt,unsigned dest,IPaddr_t sip,unsigned src, - ? ? ? ? ? ? ? unsigned len) -{ - ? ? ? /* nothing */ -} -?void
?CDPReceive(const uchar *pkt, unsigned len)
?{net/cdp.c +0
-1@@ -368,7 +361,6 @@ CDPStart(void) ? ? ? ?CDPApplianceVLAN = htons(-1); ? ? ? ?NetSetTimeout(CDP_TIMEOUT, CDPTimeout); - ? ? ? NetSetHandler(CDPDummyHandler); ? ? ? ?CDPSendTrigger(); ?}net/dns.c +1
-1@@ -200,7 +200,7 @@ DnsStart(void) ? ? ? ?debug("%s\n", __func__); ? ? ? ?NetSetTimeout(DNS_TIMEOUT, DnsTimeout); - ? ? ? NetSetHandler(DnsHandler); + ? ? ? net_set_udp_handler(DnsHandler); ? ? ? ?DnsSend(); ?}net/net.c +0
-0@@ -178,10 +178,13 @@ uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN];?/* Receive packet */
?uchar *NetRxPackets[PKTBUFSRX];net/net.c +4
-2-/* Current RX packet handler */ -static rxhand_f *packetHandler; +/* Current UDP RX packet handler */ +static rxhand_f *udp_packet_handler; +/* Current ARP RX packet handler */ +static rxhand_f *arp_packet_handler;?#ifdef
CONFIG_CMD_TFTPPUTnet/net.c +2
-1-static rxhand_icmp_f *packet_icmp_handler; ? ? /* Current ICMP rx handler */ +/* Current ICMP rx handler */ +static rxhand_icmp_f *packet_icmp_handler;?#endif
?/* Current timeout handler */
?staticthand_f*timeHandler;net/net.c +0
-0@@ -252,6 +255,18 @@ static void NetInitLoop(enum proto_t protocol) ? ? ? ?return; ?}
net/net.c static void NetInitLoop(enum proto_t protocol) · line 267
Quoted 10 lines
net/net.c +10
-0+static void net_clear_handlers (void ) +{ + ? ? ? net_set_udp_handler(NULL); + ? ? ? net_set_arp_handler(NULL); + ? ? ? NetSetTimeout(0, NULL); +} + +static void net_cleanup_loop (void ) +{ + ? ? ? net_clear_handlers();
If this is static anyway, and net_clear_handlers() also clear the timeout, why not just put the three lines of code in here instead of a separate function?
Quoted 197 lines
net/net.c +2
-0+} +?/**********************************************************************/ ?/*
?* ? ? Main network processing loop.net/net.c +9
-10@@ -259,6 +274,7 @@ static void NetInitLoop(enum proto_t protocol) ?int NetLoop(enum proto_t protocol) ?{ + ? ? ? int ? ? i; ? ? ? ?bd_t *bd = gd->bd; ? ? ? ?int ret = -1;@@ -269,17 +285,15 @@ int NetLoop(enum proto_t protocol) ? ? ? ?NetTryCount = 1; ? ? ? ?ArpInit(); + ? ? ? net_clear_handlers(); - ? ? ? if (!NetTxPacket) { - ? ? ? ? ? ? ? int ? ? i; - ? ? ? ? ? ? ? /* - ? ? ? ? ? ? ? ?* ? ? ?Setup packet buffers, aligned correctly. - ? ? ? ? ? ? ? ?*/ - ? ? ? ? ? ? ? NetTxPacket = &PktBuf[0] + (PKTALIGN - 1); - ? ? ? ? ? ? ? NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; - ? ? ? ? ? ? ? for (i = 0; i < PKTBUFSRX; i++) - ? ? ? ? ? ? ? ? ? ? ? NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; - ? ? ? } + ? ? ? /* + ? ? ? ?* ? ? ?Setup packet buffers, aligned correctly. + ? ? ? ?*/ + ? ? ? NetTxPacket = &PktBuf[0] + (PKTALIGN - 1); + ? ? ? NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; + ? ? ? for (i = 0; i < PKTBUFSRX; i++) + ? ? ? ? ? ? ? NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; ? ? ? ?bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); ? ? ? ?eth_halt();@@ -418,6 +432,7 @@ restart:? ? ? ? ? ? ? ? * ? ? ?Abort if ctrl-c was pressed. ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?if (ctrlc()) {
+ ? ? ? ? ? ? ? ? ? ? ?net_cleanup_loop(); ? ? ? ? ? ? ? ? ? ? ? ?eth_halt();
? ? ? ? ? ? ? ? ? ? ? ?puts("\nAbort\n");
? ? ? ? ? ? ? ? ? ? ? ?goto done;net/net.c +0
-0@@ -460,6 +475,7 @@ restart: ? ? ? ? ? ? ? ? ? ? ? ?goto restart;? ? ? ? ? ? ? ?case
NETLOOP_SUCCESS:
+ ? ? ? ? ? ? ? ? ? ? ?net_cleanup_loop();
? ? ? ? ? ? ? ? ? ? ? ?if (NetBootFileXferSize > 0) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?char buf[20];
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?printf("Bytes transferred = %ld (%lx hex)\n",net/net.c +0
-0@@ -476,6 +492,7 @@ restart: ? ? ? ? ? ? ? ? ? ? ? ?goto done;? ? ? ? ? ? ? ?case
NETLOOP_FAIL:
+ ? ? ? ? ? ? ? ? ? ? ?net_cleanup_loop();
? ? ? ? ? ? ? ? ? ? ? ?goto done;? ? ? ? ? ? ? ?case
NETLOOP_CONTINUE:net/net.c +0
-0@@ -486,7 +503,7 @@ restart:?done:
?#ifdefCONFIG_CMD_TFTPPUT
? ? ? ?/* Clear out the handlers */
- ? ? ? NetSetHandler(NULL);
+ ? ? ?net_set_upd_handler(NULL);
? ? ? ?net_set_icmp_handler(NULL);
?#endif
? ? ? ?return ret;net/net.c +1
-8@@ -500,13 +517,6 @@ startAgainTimeout(void) ? ? ? ?net_set_state(NETLOOP_RESTART); ?} -static void -startAgainHandler (uchar *pkt,unsigned dest,IPaddr_t sip, - ? ? ? ? ? ? ? ? unsigned src, unsigned len) -{ - ? ? ? /* Totally ignore the packet */ -} - ?void NetStartAgain(void) ?{ ? ? ? ?char *nretry;@@ -543,7 +553,7 @@ void NetStartAgain(void) ? ? ? ? ? ? ? ?NetRestartWrap = 0; ? ? ? ? ? ? ? ?if (NetDevExists) { ? ? ? ? ? ? ? ? ? ? ? ?NetSetTimeout(10000UL, startAgainTimeout); - ? ? ? ? ? ? ? ? ? ? ? NetSetHandler(startAgainHandler); + ? ? ? ? ? ? ? ? ? ? ? net_set_udp_handler(NULL); ? ? ? ? ? ? ? ?} else { ? ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_FAIL); ? ? ? ? ? ? ? ?}@@ -557,17 +567,36 @@ void NetStartAgain(void)?* ? ? Miscelaneous bits.
?*/net/net.c +3
-2-rxhand_f * -NetGetHandler (void ) +static void dummy_handler (uchar *pkt,unsigned dport, + ? ? ? ? ? ? ? ? ? ? ? IPaddr_t sip, unsigned sport, + ? ? ? ? ? ? ? ? ? ? ? unsigned len)?{
- ? ? ? return packetHandler;
?}net/net.c +13
-2+rxhand_f *net_get_udp_handler (void ) +{ + ? ? ? return udp_packet_handler; +} -void -NetSetHandler (rxhand_f *f) +void net_set_udp_handler (rxhand_f *f) +{ + ? ? ? if (f == NULL) + ? ? ? ? ? ? ? udp_packet_handler = dummy_handler; + ? ? ? else + ? ? ? ? ? ? ? udp_packet_handler = f; +} + +rxhand_f *net_get_arp_handler (void )?{
- ? ? ? packetHandler = f;
+ ? ? ? returnarp_packet_handler;net/net.c +8
-0+} + +void net_set_arp_handler (rxhand_f *f) +{ + ? ? ? if (f == NULL) + ? ? ? ? ? ? ? arp_packet_handler = dummy_handler; + ? ? ? else + ? ? ? ? ? ? ? arp_packet_handler = f;?}
?#ifdef
CONFIG_CMD_TFTPPUTnet/net.c +0
-0@@ -1094,11 +1123,11 @@ NetReceive(uchar *inpkt, int len)? ? ? ? ? ? ? ?/*
? ? ? ? ? ? ? ? * ? ? ?IP header OK. ?Pass the packet to the current handler. ? ? ? ? ? ? ? ? */
- ? ? ? ? ? ? ? (*packetHandler)((uchar *)ip +IP_UDP_HDR_SIZE,
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_dst),
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?src_ip,
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_src),
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_len)-UDP_HDR_SIZE);
+ ? ? ? ? ? ? ? (*udp_packet_handler)((uchar *)ip +IP_UDP_HDR_SIZE,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_dst),
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?src_ip,
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_src),
+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ntohs(ip->udp_len)-UDP_HDR_SIZE); ? ? ? ? ? ? ? ?break;
? ? ? ?}
?}net/nfs.c +1
-1@@ -735,7 +735,7 @@ NfsStart(void) ? ? ? ? ? ? ? ?"Loading: *\b", load_addr); ? ? ? ?NetSetTimeout(NFS_TIMEOUT, NfsTimeout); - ? ? ? NetSetHandler(NfsHandler); + ? ? ? net_set_udp_handler(NfsHandler); ? ? ? ?NfsTimeoutCount = 0; ? ? ? ?NfsState = STATE_PRCLOOKUP_PROG_MOUNT_REQ;net/sntp.c +1
-1@@ -85,7 +85,7 @@ SntpStart(void) ? ? ? ?debug("%s\n", __func__); ? ? ? ?NetSetTimeout(SNTP_TIMEOUT, SntpTimeout); - ? ? ? NetSetHandler(SntpHandler); + ? ? ? net_set_udp_handler(SntpHandler); ? ? ? ?memset(NetServerEther, 0, 6); ? ? ? ?SntpSend();net/tftp.c +1
-1@@ -778,7 +778,7 @@ void TftpStart(enum proto_t protocol) ? ? ? ?TftpTimeoutCountMax = TftpRRQTimeoutCountMax; ? ? ? ?NetSetTimeout(TftpTimeoutMSecs, TftpTimeout); - ? ? ? NetSetHandler(TftpHandler); + ? ? ? net_set_udp_handler(TftpHandler);?#ifdef
CONFIG_CMD_TFTPPUT
? ? ? ?net_set_icmp_handler(icmp_handler);
?#endifnet/tftp.c +0
-0@@ -840,7 +840,7 @@ TftpStartServer(void)?#endif
Quoted 9 lines
? ? ? ?TftpState =
STATE_RECV_WRQ;
- ? ? ? NetSetHandler(TftpHandler);
+ ? ? ?net_set_udp_handler(TftpHandler);
?}
?#endif /*CONFIG_CMD_TFTPSRV*/--
1.6.0.2
Regards,
Simon
PATCH v2 10/18 net: Add NetUpdateEther() to handle ARP and Ping replies
In reply to Joe HershbergerWhen the network is VLAN or SNAP, NetUpdateEther() will preserve the original Ethernet packet header and simply replace the src and dest MACs and the protocol
--- include/net.h | 1 + net/arp.c | 2 +- net/net.c | 23 +++++++++++++++++++++++ net/ping.c | 10 +++++----- 4 files changed, 30 insertions(+), 6 deletions(-)
include/net.h +1 -0
@@ -443,6 +443,7 @@ extern int NetEthHdrSize(void);/* Set ethernet header; returns the size of the header */ extern int NetSetEther (uchar *,uchar *,uint ); +extern int net_update_ether (struct Ethernet_hdr *et,uchar *addr,uint prot);/* Set IP header */ extern void net_set_ip_header (uchar *pkt,IPaddr_t dest,IPaddr_t source);
net/arp.c +1 -1
@@ -158,7 +158,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* reply with our IP address */ debug ("Got ARP REQUEST, return our IP\n" ); pkt = (uchar *)et; - eth_hdr_size =NetSetEther (pkt, et->et_src,PROT_ARP ); + eth_hdr_size =net_update_ether (et, et->et_src,PROT_ARP ); pkt += eth_hdr_size; arp->ar_op =htons (ARPOP_REPLY );memcpy (&arp->ar_tha, &arp->ar_sha,ARP_HLEN );
net/net.c +23 -0
@@ -1279,6 +1279,29 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) } } +int net_update_ether (struct Ethernet_hdr *et,uchar *addr,uint prot) +{ +ushort protlen; + +memcpy (et->et_dest, addr,6 ); +memcpy (et->et_src, NetOurEther,6 ); + protlen =ntohs (et->et_protlen); +if (protlen ==PROT_VLAN ) { +struct VLAN_Ethernet_hdr *vet = + (struct VLAN_Ethernet_hdr *)et; + vet->vet_type =htons (prot); +return VLAN_ETHER_HDR_SIZE ; + }else if (protlen >1514 ) { + et->et_protlen =htons (prot); +return ETHER_HDR_SIZE ; + }else { +/* 802.2 + SNAP */ +struct E802_hdr *et802 = (struct E802_hdr *)et; + et802->et_prot =htons (prot); +return E802_HDR_SIZE ; + } +} +void net_set_ip_header (uchar *pkt,IPaddr_t dest,IPaddr_t source) {struct IP_UDP_hdr *ip = (struct IP_UDP_hdr *)pkt;
net/ping.c +5 -5
@@ -87,6 +87,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) {struct ICMP_hdr *icmph = (struct ICMP_hdr *)&(ip->udp_src);IPaddr_t src_ip; +int eth_hdr_size;switch (icmph->type) {case ICMP_ECHO_REPLY :
@@ -95,11 +96,10 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)net_set_state (NETLOOP_SUCCESS );return ;case ICMP_ECHO_REQUEST : -debug ("Got ICMP ECHO REQUEST, return " -"%d bytes\n" ,ETHER_HDR_SIZE + len); + eth_hdr_size =net_update_ether (et, et->et_src,PROT_IP ); -memcpy (&et->et_dest[0 ], &et->et_src[0 ],6 ); -memcpy (&et->et_src[0 ], NetOurEther,6 ); +debug ("Got ICMP ECHO REQUEST, return " +"%d bytes\n" , eth_hdr_size + len); ip->ip_sum =0 ; ip->ip_off =0 ;
@@ -112,7 +112,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) icmph->checksum =0 ; icmph->checksum = ~NetCksum ((uchar *)icmph, (len -IP_HDR_SIZE ) >>1 ); -NetSendPacket ((uchar *)et,ETHER_HDR_SIZE + len); +NetSendPacket ((uchar *)et, eth_hdr_size + len);return ;/* default: return;*/
Signature · 1 line
1.6.0.2
PATCH v2 10/18 net: Add NetUpdateEther() to handle ARP and Ping replies
Hi Joe,
Quoted 8 lines · Joe Hershberger
When the network is VLAN or SNAP,
NetUpdateEther()will preserve the original Ethernet packet header and simply replace the src and dest MACs and the protocolSigned-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Q below...
Quoted 86 lines
---
?include/net.h | ? ?1 + ?net/arp.c ? ? | ? ?2 +- ?net/net.c ? ? | ? 23 +++++++++++++++++++++++ ?net/ping.c ? ?| ? 10 +++++-----?4 files changed, 30 insertions(+), 6 deletions(-)
include/net.h +0
-0@@ -443,6 +443,7 @@ extern int ?NetEthHdrSize(void);?/* Set ethernet header; returns the size of the header */ ?extern int
NetSetEther(uchar *, uchar *, uint);
+extern intnet_update_ether(struct Ethernet_hdr *et, uchar *addr, uint prot);?/* Set IP header */
?extern voidnet_set_ip_header(uchar *pkt, IPaddr_t dest, IPaddr_t source);net/arp.c +0
-0@@ -158,7 +158,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)? ? ? ? ? ? ? ?/* reply with our IP address */
? ? ? ? ? ? ? ?debug("Got ARP REQUEST, return our IP\n");
? ? ? ? ? ? ? ?pkt = (uchar *)et;
- ? ? ? ? ? ? ?eth_hdr_size=NetSetEther(pkt, et->et_src, PROT_ARP);
+ ? ? ? ? ? ? ?eth_hdr_size=net_update_ether(et, et->et_src, PROT_ARP); ? ? ? ? ? ? ? ?pkt +=eth_hdr_size;
? ? ? ? ? ? ? ?arp->ar_op =htons(ARPOP_REPLY);
? ? ? ? ? ? ? ?memcpy(&arp->ar_tha,&arp->ar_sha,ARP_HLEN);net/net.c +23
-0@@ -1279,6 +1279,29 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) ? ? ? ?} ?} +int net_update_ether (struct Ethernet_hdr *et,uchar *addr,uint prot) +{ + ? ? ? ushort protlen; + + ? ? ? memcpy(et->et_dest, addr, 6); + ? ? ? memcpy(et->et_src, NetOurEther, 6); + ? ? ? protlen = ntohs(et->et_protlen); + ? ? ? if (protlen == PROT_VLAN) { + ? ? ? ? ? ? ? struct VLAN_Ethernet_hdr *vet = + ? ? ? ? ? ? ? ? ? ? ? (struct VLAN_Ethernet_hdr *)et; + ? ? ? ? ? ? ? vet->vet_type = htons(prot); + ? ? ? ? ? ? ? return VLAN_ETHER_HDR_SIZE; + ? ? ? } else if (protlen > 1514) { + ? ? ? ? ? ? ? et->et_protlen = htons(prot); + ? ? ? ? ? ? ? return ETHER_HDR_SIZE; + ? ? ? } else { + ? ? ? ? ? ? ? /* 802.2 + SNAP */ + ? ? ? ? ? ? ? struct E802_hdr *et802 = (struct E802_hdr *)et; + ? ? ? ? ? ? ? et802->et_prot = htons(prot); + ? ? ? ? ? ? ? return E802_HDR_SIZE; + ? ? ? } +} + ?void net_set_ip_header(uchar *pkt, IPaddr_t dest, IPaddr_t source) ?{ ? ? ? ?struct IP_UDP_hdr *ip = (struct IP_UDP_hdr *)pkt;net/ping.c +1
-0@@ -87,6 +87,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ?{ ? ? ? ?struct ICMP_hdr *icmph = (struct ICMP_hdr *)&(ip->udp_src); ? ? ? ?IPaddr_t src_ip; + ? ? ? int eth_hdr_size; ? ? ? ?switch (icmph->type) {? ? ? ?case
ICMP_ECHO_REPLY:net/ping.c +0
-0@@ -95,11 +96,10 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ? ? ? ? ?net_set_state(NETLOOP_SUCCESS); ? ? ? ? ? ? ? ?return;? ? ? ?case
ICMP_ECHO_REQUEST:
- ? ? ? ? ? ? ? debug("Got ICMP ECHO REQUEST, return "
- ? ? ? ? ? ? ? ? ? ? ? "%d bytes\n",ETHER_HDR_SIZE+ len);
+ ? ? ? ? ? ? ?eth_hdr_size=net_update_ether(et, et->et_src, PROT_IP);
Quoted 4 lines
- ? ? ? ? ? ? ?
memcpy(&et->et_dest[0], &et->et_src[0], 6);
- ? ? ? ? ? ? ?memcpy(&et->et_src[0], NetOurEther, 6);
+ ? ? ? ? ? ? ? debug("Got ICMP ECHO REQUEST, return "
+ ? ? ? ? ? ? ? ? ? ? ? "%d bytes\n",eth_hdr_size+ len);
Did you mean to move this?
Quoted 10 lines
? ? ? ? ? ? ? ?ip->ip_sum = 0;
? ? ? ? ? ? ? ?ip->ip_off = 0;net/ping.c +1
-1@@ -112,7 +112,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ?icmph->checksum = 0; ? ? ? ? ? ? ? ?icmph->checksum = ~NetCksum((uchar *)icmph, ? ? ? ? ? ? ? ? ? ? ? ?(len - IP_HDR_SIZE) >> 1); - ? ? ? ? ? ? ? NetSendPacket((uchar *)et, ETHER_HDR_SIZE + len); + ? ? ? ? ? ? ? NetSendPacket((uchar *)et, eth_hdr_size + len); ? ? ? ? ? ? ? ?return;
Quoted 5 lines
?/* ? ? default:
? ? ? ? ? ? ? ?return;*/
--
1.6.0.2
Regards,
Simon
PATCH v2 11/18 net: Don't write the "serverip" env var if configured not to
In reply to Joe HershbergerBefore this patch, bootp would not overwrite the value, but the value was still clobbered in the env
---
Changes for v2:
- Added a comment
common/cmd_net.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
common/cmd_net.c +4 -2
@@ -153,12 +153,14 @@ static void netboot_update_env (void)ip_to_string (NetOurIP, tmp);setenv ("ipaddr" , tmp); } - +#if !defined(CONFIG_BOOTP_SERVERIP ) +/* Only attempt to change serverip if net/bootp.c:BootpCopyNetParams() +could have set it */ if (NetServerIP) {ip_to_string (NetServerIP, tmp);setenv ("serverip" , tmp); } - +#endif if (NetOurDNSIP) {ip_to_string (NetOurDNSIP, tmp);setenv ("dnsip" , tmp);
Signature · 1 line
1.6.0.2
PATCH v2 11/18 net: Don't write the "serverip" env var if configured not to
Quoted 19 lines · Joe Hershberger
Before this patch, bootp would not overwrite the value, but the value was still clobbered in the env
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>---
Changes for v2:
? - Added a comment?common/cmd_net.c | ? ?6 ++++--
?1 files changed, 4 insertions(+), 2 deletions(-)common/cmd_net.c +0
-0
common/cmd_net.c static void netboot_update_env (void) · line 158
Quoted 7 lines
common/cmd_net.c +3
-1@@ -153,12 +153,14 @@ static void netboot_update_env (void) ? ? ? ? ? ? ? ?ip_to_string (NetOurIP, tmp); ? ? ? ? ? ? ? ?setenv ("ipaddr", tmp); ? ? ? ?} - +#if !defined(CONFIG_BOOTP_SERVERIP ) + ? ? ? /* Only attempt to change serverip if net/bootp.c:BootpCopyNetParams() +? ? ? ? ?could have set it */
Comment style
Quoted 12 lines
common/cmd_net.c +1
-2? ? ? ?if (NetServerIP) { ? ? ? ? ? ? ? ?ip_to_string (NetServerIP, tmp); ? ? ? ? ? ? ? ?setenv ("serverip", tmp); ? ? ? ?} - +#endif ? ? ? ?if (NetOurDNSIP) { ? ? ? ? ? ? ? ?ip_to_string (NetOurDNSIP, tmp); ? ? ? ? ? ? ? ?setenv ("dnsip", tmp); --1.6.0.2
PATCH v2 12/18 net: Fix unused variable compile warning
In reply to Joe HershbergerIf CONFIG_BOOTP_SERVERIP is not defined, unused variable warning is reported. This was fixed in origin using a compiler feature instead of a simple reorder of the statements.
--- net/bootp.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
net/bootp.c +3 -4
@@ -20,7 +20,6 @@#ifdef CONFIG_STATUS_LED #include <status_led.h> #endif -#include <linux/compiler.h> #define BOOTP_VENDOR_MAGIC 0x63825363/* RFC1048 Magic Cookie */
@@ -98,15 +97,15 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)*/ static void BootpCopyNetParams (struct Bootp_t *bp) { -__maybe_unused IPaddr_t tmp_ip; - -NetCopyIP (&NetOurIP, &bp->bp_yiaddr);#if !defined(CONFIG_BOOTP_SERVERIP ) +IPaddr_t tmp_ip; +NetCopyIP (&tmp_ip, &bp->bp_siaddr);if (tmp_ip !=0 )NetCopyIP (&NetServerIP, &bp->bp_siaddr);memcpy (NetServerEther, ((struct Ethernet_hdr *)NetRxPacket)->et_src,6 );#endif +NetCopyIP (&NetOurIP, &bp->bp_yiaddr);if (strlen (bp->bp_file) >0 )copy_filename (BootFile, bp->bp_file,sizeof (BootFile));
Signature · 1 line
1.6.0.2
PATCH v2 12/18 net: Fix unused variable compile warning
Hi Joe,
Quoted 4 lines · Joe Hershberger
If
CONFIG_BOOTP_SERVERIPis not defined, unused variable warning is reported. ?This was fixed in origin using a compiler feature instead of a simple reorder of the statements.
What do you mean by 'origin'? You can use more columns in your commit messages.
Quoted 5 lines
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
With commit message fixed:
Quoted 35 lines
---
?net/bootp.c | ? ?7 +++----
?1 files changed, 3 insertions(+), 4 deletions(-)net/bootp.c +0
-0@@ -20,7 +20,6 @@?#ifdef
CONFIG_STATUS_LED
?#include <status_led.h>
?#endif
-#include <linux/compiler.h>?#define
BOOTP_VENDOR_MAGIC? ?0x63825363? ? ?/* RFC1048 Magic Cookie */net/bootp.c +0
-0@@ -98,15 +97,15 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)?*/
?static voidBootpCopyNetParams(struct Bootp_t *bp)
?{
- ? ? ?__maybe_unusedIPaddr_ttmp_ip;
-
- ? ? ?NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
?#if !defined(CONFIG_BOOTP_SERVERIP)
+ ? ? ?IPaddr_ttmp_ip;
+
? ? ? ?NetCopyIP(&tmp_ip,&bp->bp_siaddr);
? ? ? ?if (tmp_ip!= 0)
? ? ? ? ? ? ? ?NetCopyIP(&NetServerIP,&bp->bp_siaddr);
? ? ? ?memcpy(NetServerEther, ((structEthernet_hdr*)NetRxPacket)->et_src, 6); ?#endif
+ ? ? ?NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
? ? ? ?if (strlen(bp->bp_file)> 0)
? ? ? ? ? ? ? ?copy_filename(BootFile,bp->bp_file, sizeof(BootFile));
Quoted 3 lines
--
1.6.0.2
Regards,
Simon
PATCH v2 13/18 net: Add option CONFIG_BOOTP_MAY_FAIL
In reply to Joe HershbergerThis is useful if you want to look for a DHCP server, but try some other settings if not available.
---
Changes for v2:
- Renamed to CONFIG_BOOTP_MAY_FAIL
README | 7 +++++++ net/bootp.c | 5 +++++ 2 files changed, 12 insertions(+), 0 deletions(-)
README +7 -0
@@ -1563,10 +1563,17 @@ The following options need to be configured: CONFIG_BOOTP_NTPSERVER CONFIG_BOOTP_TIMEOFFSET CONFIG_BOOTP_VENDOREX + CONFIG_BOOTP_MAY_FAIL CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip environment variable, not the BOOTP server. + CONFIG_BOOTP_MAY_FAIL - If the DHCP server is not found + after the configured retry count, the call will fail + instead of starting over. This can be used to fail over + to Link-local IP address configuration if the DHCP server + is not available. + CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS serverip from a DHCP server, it is possible that more than one DNS serverip is offered to the client.
net/bootp.c +5 -0
@@ -328,8 +328,13 @@ static voidBootpTimeout (void) {if (BootpTry >=TIMEOUT_COUNT ) { +#ifdef CONFIG_BOOTP_MAY_FAIL +puts ("\nRetry count exceeded\n" ); +NetSetState (NETLOOP_FAIL ); +#else puts ("\nRetry count exceeded; starting again\n" );NetStartAgain (); +#endif }else {NetSetTimeout (TIMEOUT , BootpTimeout);BootpRequest ();
Signature · 1 line
1.6.0.2
PATCH v2 13/18 net: Add option CONFIG_BOOTP_MAY_FAIL
Quoted 7 lines · Joe Hershberger
This is useful if you want to look for a DHCP server, but try some other settings if not available.
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Looks ok to me
Quoted 51 lines
---
Changes for v2:
? - Renamed toCONFIG_BOOTP_MAY_FAIL?README ? ? ?| ? ?7 +++++++
?net/bootp.c | ? ?5 +++++
?2 files changed, 12 insertions(+), 0 deletions(-)README +0
-0@@ -1563,10 +1563,17 @@ The following options need to be configured:? ? ? ? ? ? ? ?CONFIG_BOOTP_NTPSERVER
? ? ? ? ? ? ? ?CONFIG_BOOTP_TIMEOFFSET
? ? ? ? ? ? ? ?CONFIG_BOOTP_VENDOREX
+ ? ? ? ? ? ? ?CONFIG_BOOTP_MAY_FAIL? ? ? ? ? ? ? ?CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip ? ? ? ? ? ? ? ?environment variable, not the BOOTP server.
+ ? ? ? ? ? ? ?
CONFIG_BOOTP_MAY_FAIL- If the DHCP server is not found
+ ? ? ? ? ? ? ? after the configured retry count, the call will fail
+ ? ? ? ? ? ? ? instead of starting over. ?This can be used to fail over
+ ? ? ? ? ? ? ? to Link-local IP address configuration if the DHCP server
+ ? ? ? ? ? ? ? is not available.
+
? ? ? ? ? ? ? ?CONFIG_BOOTP_DNS2 - If a DHCP client requests the DNS ? ? ? ? ? ? ? ?serverip from a DHCP server, it is possible that more ? ? ? ? ? ? ? ?than one DNS serverip is offered to the client.net/bootp.c +5
-1@@ -328,8 +328,13 @@ static void ?BootpTimeout(void) ?{ ? ? ? ?if (BootpTry >= TIMEOUT_COUNT) { +#ifdef CONFIG_BOOTP_MAY_FAIL + ? ? ? ? ? ? ? puts("\nRetry count exceeded\n"); + ? ? ? ? ? ? ? NetSetState(NETLOOP_FAIL); +#else ? ? ? ? ? ? ? ?puts("\nRetry count exceeded; starting again\n"); ? ? ? ? ? ? ? ?NetStartAgain(); +#endif ? ? ? ?} else { ? ? ? ? ? ? ? ?NetSetTimeout(TIMEOUT, BootpTimeout); ? ? ? ? ? ? ? ?BootpRequest(); --1.6.0.2
PATCH v2 14/18 net: Remove static allocation for MAC address in PingSend()
In reply to Joe HershbergerDon't force ARP clients to return the MAC address if they don't care (such as ping)
--- net/arp.c | 9 +++++---- net/ping.c | 10 +++------- 2 files changed, 8 insertions(+), 11 deletions(-)
net/arp.c +5 -4
@@ -170,7 +170,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)case ARPOP_REPLY :/* arp reply */ /* are we waiting for a reply */ -if (!NetArpWaitPacketIP || !NetArpWaitPacketMAC) +if (!NetArpWaitPacketIP)break ;#ifdef CONFIG_KEEP_SERVERADDR
@@ -189,15 +189,16 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) arp->ar_data);/* save address for later use */ -memcpy (NetArpWaitPacketMAC, - &arp->ar_sha,ARP_HLEN ); +if (NetArpWaitPacketMAC !=NULL ) +memcpy (NetArpWaitPacketMAC, + &arp->ar_sha,ARP_HLEN );net_get_arp_handler ()((uchar *)arp,0 , reply_ip_addr,0 , len);/* modify header, and transmit it */ memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, NetArpWaitPacketMAC,ARP_HLEN ); + et_dest, &arp->ar_sha,ARP_HLEN );NetSendPacket (NetArpWaitTxPacket, NetArpWaitTxPacketSize);
net/ping.c +3 -7
@@ -40,22 +40,18 @@ static void set_icmp_header(uchar *pkt, IPaddr_t dest)static int ping_send (void ) { -static uchar mac[6 ];uchar *pkt;int eth_hdr_size;/* XXX always send arp request */ -memcpy (mac, NetEtherNullAddr,6 ); -debug ("sending ARP for %pI4\n" , &NetPingIP); NetArpWaitPacketIP = NetPingIP; - NetArpWaitPacketMAC = mac; - pkt = NetArpWaitTxPacket; - eth_hdr_size =NetSetEther (pkt, mac,PROT_IP ); - pkt += eth_hdr_size; + eth_hdr_size =NetSetEther (NetArpWaitTxPacket, NetEtherNullAddr, +PROT_IP ); + pkt = NetArpWaitTxPacket + eth_hdr_size;set_icmp_header (pkt, NetPingIP);
Signature · 1 line
1.6.0.2
PATCH v2 15/18 net: Remove unused parameter from NetInitLoop()
In reply to Joe Hershberger---
Changes for v2:
- Split from "Fix net buffer initialization"
net/net.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/net.c +2 -2
@@ -231,7 +231,7 @@ void net_auto_load(void)TftpStart (TFTPGET ); } -static void NetInitLoop (enum proto_t protocol) +static void NetInitLoop (void ) {static int env_changed_id;bd_t *bd = gd->bd;
@@ -313,7 +313,7 @@ restart:* here on, this code is a state machine driven by received * packets and timer events. */ -NetInitLoop (protocol); +NetInitLoop ();switch (net_check_prereq (protocol)) {case 1 :
Signature · 1 line
1.6.0.2
PATCH v2 15/18 net: Remove unused parameter from NetInitLoop()
Quoted 4 lines · Joe Hershberger
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
But it is still nice to have a commit message, even if brief.
Quoted 32 lines
---
Changes for v2:
? - Split from "Fix net buffer initialization"?net/net.c | ? ?4 ++--
?1 files changed, 2 insertions(+), 2 deletions(-)net/net.c +1
-1@@ -231,7 +231,7 @@ void net_auto_load(void) ? ? ? ?TftpStart(TFTPGET); ?} -static void NetInitLoop (enum proto_t protocol) +static void NetInitLoop (void ) ?{ ? ? ? ?static int env_changed_id; ? ? ? ?bd_t *bd = gd->bd;@@ -313,7 +313,7 @@ restart:? ? ? ? * ? ? ?here on, this code is a state machine driven by received ? ? ? ? * ? ? ?packets and timer events.
? ? ? ? */
- ? ? ? NetInitLoop(protocol);
+ ? ? ?NetInitLoop();? ? ? ?switch (
net_check_prereq(protocol)) {
? ? ? ?case 1:
--
1.6.0.2
PATCH v2 16/18 net: Fix net buffer initialization
In reply to Joe HershbergerA new non-static function net_init() will initialize buffers and read from the environment. Only update from the env on each entry to NetLoop().
---
Changes for v2:
- Unadded explicit parameter name in net.h for NetLoop
- Eliminate CamelCase from new functions
- Changed null pointer print to an assert
include/net.h | 1 + net/net.c | 44 ++++++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-)
include/net.h +1 -0
@@ -430,6 +430,7 @@ extern IPaddr_t Mcast_addr;#endif /* Initialize the network adapter */ +extern void net_init (void );extern int NetLoop (enum proto_t );/* Shutdown adapters and cleanup */
net/net.c +30 -14
70 lines not on this page · raw message
Signature · 1 line
1.6.0.2
PATCH v2 16/18 net: Fix net buffer initialization
Hi Joe,
Quoted 8 lines · Joe Hershberger
A new non-static function
net_init()will initialize buffers and read from the environment. ?Only update from the env on each entry toNetLoop().Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Some nits, but:
Quoted 29 lines
---
Changes for v2:
? - Unadded explicit parameter name innet.hfor NetLoop ? - Eliminate CamelCase from new functions
? - Changed null pointer print to an assert?include/net.h | ? ?1 +
?net/net.c ? ? | ? 44 ++++++++++++++++++++++++++++++-------------- ?2 files changed, 31 insertions(+), 14 deletions(-)include/net.h +0
-0@@ -430,6 +430,7 @@ extern IPaddr_t Mcast_addr;?#endif
?/* Initialize the network adapter */
+extern voidnet_init(void);
?extern intNetLoop(enum proto_t);?/* Shutdown adapters and cleanup */
net/net.c +0
-0@@ -267,6 +267,30 @@ static void net_cleanup_loop(void) ? ? ? ?net_clear_handlers(); ?}
net/net.c static void net_cleanup_loop(void) · line 278
Quoted 10 lines
net/net.c +9
-0+void net_init (void ) +{ + ? ? ? static int first_call = 1; + + ? ? ? if (first_call) { + ? ? ? ? ? ? ? /* + ? ? ? ? ? ? ? ?* ? ? ?Setup packet buffers, aligned correctly. + ? ? ? ? ? ? ? ?*/ + ? ? ? ? ? ? ? int i;
blank line after
net/net.c static void net_cleanup_loop(void) · line 282
Quoted 4 lines
net/net.c +4
-0+ ? ? ? ? ? ? ? NetTxPacket = &PktBuf[0] + (PKTALIGN - 1); + ? ? ? ? ? ? ? NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; + ? ? ? ? ? ? ? for (i = 0; i < PKTBUFSRX; i++) + ? ? ? ? ? ? ? ? ? ? ? NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
Spaces around operators
Quoted 59 lines
net/net.c +11
-0+ + ? ? ? ? ? ? ? ArpInit(); + ? ? ? ? ? ? ? net_clear_handlers(); + + ? ? ? ? ? ? ? /* Only need to setup buffer pointers once. */ + ? ? ? ? ? ? ? first_call = 0; + ? ? ? } + + ? ? ? NetInitLoop(); +} +?/**********************************************************************/ ?/*
?* ? ? Main network processing loop.net/net.c +6
-14@@ -274,28 +298,15 @@ static void net_cleanup_loop(void) ?int NetLoop(enum proto_t protocol) ?{ - ? ? ? int ? ? i; ? ? ? ?bd_t *bd = gd->bd; ? ? ? ?int ret = -1; ? ? ? ?NetRestarted = 0; ? ? ? ?NetDevExists = 0; - - ? ? ? NetTxPacket = NULL; ? ? ? ?NetTryCount = 1; - ? ? ? ArpInit(); - ? ? ? net_clear_handlers(); - - ? ? ? /* - ? ? ? ?* ? ? ?Setup packet buffers, aligned correctly. - ? ? ? ?*/ - ? ? ? NetTxPacket = &PktBuf[0] + (PKTALIGN - 1); - ? ? ? NetTxPacket -= (ulong)NetTxPacket % PKTALIGN; - ? ? ? for (i = 0; i < PKTBUFSRX; i++) - ? ? ? ? ? ? ? NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN; - ? ? ? ?bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); + ? ? ? net_init(); ? ? ? ?eth_halt(); ? ? ? ?eth_set_current(); ? ? ? ?if (eth_init(bd) < 0) {@@ -627,6 +638,11 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, ? ? ? ?int eth_hdr_size; ? ? ? ?int pkt_hdr_size; + ? ? ? /* make sure the NetTxPacket is initialized (NetInit() was called) */ + ? ? ? assert(NetTxPacket != NULL); + ? ? ? if (NetTxPacket == NULL) + ? ? ? ? ? ? ? return -1; +? ? ? ?/* convert to new style broadcast */
? ? ? ?if (dest == 0)
? ? ? ? ? ? ? ?dest =0xFFFFFFFF;
--
1.6.0.2
PATCH v2 17/18 net: Make sure NetLoop is initialized when using NetConsole
In reply to Joe HershbergerFix NetConsole bug that causes first packet header to claim a source IP address of 0.0.0.0
--- drivers/net/netconsole.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +4 -0
@@ -169,6 +169,10 @@ static int nc_start(void)else memset (nc_ether,0 ,sizeof (nc_ether));/* force arp request */ +/* Initialize the static IP settings and buffer pointers +incase we call NetSendUDPPacket before NetLoop */ +net_init (); +return 0 ; }
Signature · 1 line
1.6.0.2
PATCH v2 17/18 net: Make sure NetLoop is initialized when using NetConsole
Hi Joe,
Quoted 19 lines · Joe Hershberger
Fix NetConsole bug that causes first packet header to claim a source IP address of 0.0.0.0
Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>---
?drivers/net/netconsole.c | ? ?4 ++++
?1 files changed, 4 insertions(+), 0 deletions(-)drivers/net/netconsole.c +0
-0@@ -169,6 +169,10 @@ static int nc_start(void)? ? ? ?else
? ? ? ? ? ? ? ?memset(nc_ether, 0,sizeof(nc_ether)); ?/* force arp request */
Quoted 2 lines
+ ? ? ? /* Initialize the static IP settings and buffer pointers
+ ? ? ? ? ?incase we call NetSendUDPPacket before NetLoop */
Comment style
/*
* Initialize...
*/
Quoted 8 lines
+ ? ? ?
net_init();
+
? ? ? ?return 0;
?}--
1.6.0.2
Regards,
Simon
PATCH v2 18/18 net: Don't copy every packet that waits for an ARP
In reply to Joe HershbergerUse the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket.
This saves a copy and makes the code easier to understand.
--- include/net.h | 4 ++-- net/arp.c | 24 ++++++++++++------------ net/arp.h | 2 -- net/net.c | 24 ++++++------------------ net/ping.c | 5 ++--- 5 files changed, 22 insertions(+), 37 deletions(-)
include/net.h +2 -2
@@ -473,13 +473,13 @@ static inline void net_set_state(enum net_loop_state state) net_state = state; } -/* Transmit "NetTxPacket" */ +/* Transmit a packet */ static inline void NetSendPacket (uchar *pkt,int len) { (void )eth_send (pkt, len); } -/* Transmit UDP packet, performing ARP request if needed +/* Transmit "NetTxPacket" as UDP packet, performing ARP request if needed (ether will be populated) */ extern int NetSendUDPPacket (uchar *ether,IPaddr_t dest,int dport,int sport,int payload_len);
net/arp.c +12 -12
@@ -30,22 +30,22 @@ IPaddr_t NetArpWaitPacketIP;IPaddr_t NetArpWaitReplyIP;/* MAC address of waiting packet's destination */ uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -uchar *NetArpWaitTxPacket;int NetArpWaitTxPacketSize; -uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN +PKTALIGN ];ulong NetArpWaitTimerStart;int NetArpWaitTry; +uchar *NetArpTxPacket;/* THE ARP transmit packet */ +uchar NetArpPacketBuf[PKTSIZE_ALIGN +PKTALIGN ]; +void ArpInit (void ) {/* XXX problem with bss workaround */ NetArpWaitPacketMAC =NULL ; NetArpWaitPacketIP =0 ; NetArpWaitReplyIP =0 ; - NetArpWaitTxPacket = &NetArpWaitPacketBuf[0 ] + (PKTALIGN -1 ); - NetArpWaitTxPacket -= (ulong )NetArpWaitTxPacket %PKTALIGN ; NetArpWaitTxPacketSize =0 ; + NetArpTxPacket = &NetArpPacketBuf[0 ] + (PKTALIGN -1 ); + NetArpTxPacket -= (ulong )NetArpTxPacket %PKTALIGN ; }void ArpRequest (void )
@@ -56,7 +56,7 @@ void ArpRequest(void)debug ("ARP broadcast %d\n" , NetArpWaitTry); - pkt = NetTxPacket; + pkt = NetArpTxPacket; eth_hdr_size =NetSetEther (pkt, NetBcastAddr,PROT_ARP ); pkt += eth_hdr_size;
@@ -88,7 +88,7 @@ void ArpRequest(void) }NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); -NetSendPacket (NetTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); }void ArpTimeoutCheck (void )
@@ -196,11 +196,11 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)net_get_arp_handler ()((uchar *)arp,0 , reply_ip_addr,0 , len); -/* modify header, and transmit it */ -memcpy (((struct Ethernet_hdr *)NetArpWaitTxPacket)-> - et_dest, &arp->ar_sha,ARP_HLEN ); -NetSendPacket (NetArpWaitTxPacket, - NetArpWaitTxPacketSize); +/* set the mac address in the waiting packet's header +and transmit it */ +memcpy (((struct Ethernet_hdr *)NetTxPacket)->et_dest, + &arp->ar_sha,ARP_HLEN ); +NetSendPacket (NetTxPacket, NetArpWaitTxPacketSize);/* no arp request pending now */ NetArpWaitPacketIP =0 ;
net/arp.h +0 -2
@@ -16,8 +16,6 @@extern IPaddr_t NetArpWaitPacketIP;/* MAC address of waiting packet's destination */ extern uchar *NetArpWaitPacketMAC; -/* THE transmit packet */ -extern uchar *NetArpWaitTxPacket;extern int NetArpWaitTxPacketSize;extern ulong NetArpWaitTimerStart;extern int NetArpWaitTry;
net/net.c +6 -18
@@ -443,6 +443,9 @@ restart:* Abort if ctrl-c was pressed. */ if (ctrlc ()) { +/* cancel any ARP that may not have completed */ + NetArpWaitPacketIP =0 ; +net_cleanup_loop ();eth_halt ();puts ("\nAbort\n" );
@@ -634,7 +637,6 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int payload_len) {uchar *pkt; -int need_arp =0 ;int eth_hdr_size;int pkt_hdr_size;
@@ -651,35 +653,21 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,if (dest ==0xFFFFFFFF ) ether = NetBcastAddr; -/* -* if MAC address was not discovered yet, save the packet and do -* an ARP request -*/ -if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) { - need_arp =1 ; - pkt = NetArpWaitTxPacket; - }else - pkt = (uchar *)NetTxPacket; + pkt = (uchar *)NetTxPacket; eth_hdr_size =NetSetEther (pkt, ether,PROT_IP ); pkt += eth_hdr_size;net_set_udp_header (pkt, dest, dport, sport, payload_len); pkt_hdr_size = eth_hdr_size +IP_UDP_HDR_SIZE ; -if (need_arp) { +/* if MAC address was not discovered yet, do an ARP request */ +if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) {debug ("sending ARP for %pI4\n" , &dest);/* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest; NetArpWaitPacketMAC = ether; -/* -* Copy the packet data from the NetTxPacket into the -* NetArpWaitTxPacket to send after arp -*/ -memcpy (pkt +IP_UDP_HDR_SIZE , (uchar *)NetTxPacket + - pkt_hdr_size, payload_len); -/* size of the waiting packet */ NetArpWaitTxPacketSize = pkt_hdr_size + payload_len;
net/ping.c +2 -3
@@ -49,9 +49,8 @@ static int ping_send(void) NetArpWaitPacketIP = NetPingIP; - eth_hdr_size =NetSetEther (NetArpWaitTxPacket, NetEtherNullAddr, -PROT_IP ); - pkt = NetArpWaitTxPacket + eth_hdr_size; + eth_hdr_size =NetSetEther (NetTxPacket, NetEtherNullAddr,PROT_IP ); + pkt = (uchar *)NetTxPacket + eth_hdr_size;set_icmp_header (pkt, NetPingIP);
Signature · 1 line
1.6.0.2
PATCH v2 18/18 net: Don't copy every packet that waits for an ARP
Hi Joe,
Quoted 8 lines · Joe Hershberger
Use the NetArpTxPacket for the ARP packet, not to hold what used to be in NetTxPacket.
This saves a copy and makes the code easier to understand.Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>
Quoted 25 lines
---
?include/net.h | ? ?4 ++-- ?net/arp.c ? ? | ? 24 ++++++++++++------------ ?net/arp.h ? ? | ? ?2 -- ?net/net.c ? ? | ? 24 ++++++------------------ ?net/ping.c ? ?| ? ?5 ++---?5 files changed, 22 insertions(+), 37 deletions(-)
include/net.h +2
-2@@ -473,13 +473,13 @@ static inline void net_set_state(enum net_loop_state state) ? ? ? ?net_state = state; ?} -/* Transmit "NetTxPacket" */ +/* Transmit a packet */ ?static inline void NetSendPacket(uchar *pkt, int len) ?{ ? ? ? ?(void) eth_send(pkt, len); ?} -/* Transmit UDP packet, performing ARP request if needed +/* Transmit "NetTxPacket" as UDP packet, performing ARP request if needed
Quoted 1 line
? ?(ether will be populated) */
Should fix up comment style.
Quoted 23 lines
?extern int ? ?
NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, ? ? ? ? ? ? ? ? ? ? ? ?int sport, int payload_len);net/arp.c +0
-0@@ -30,22 +30,22 @@ IPaddr_t ? ?NetArpWaitPacketIP; ?IPaddr_t ? ? ? NetArpWaitReplyIP;?/* MAC address of waiting packet's destination */ ?uchar ? ? ? ? *NetArpWaitPacketMAC;
net/arp.c +0
-2-/* THE transmit packet */ -uchar ? ? ? ? *NetArpWaitTxPacket;?int ? ? ? ? ? ?NetArpWaitTxPacketSize;
-uchar ? ? ? ? ?NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; ?ulong ? ? ? ? ?NetArpWaitTimerStart;
?int ? ? ? ? ? ?NetArpWaitTry;net/arp.c +3
-0+uchar ? ? ? ? *NetArpTxPacket; /* THE ARP transmit packet */ +uchar ? ? ? ? ?NetArpPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; +?void ArpInit(void)
?{
? ? ? ?/* XXX problem with bss workaround */
Quoted 8 lines
? ? ? ?NetArpWaitPacketMAC = NULL;
? ? ? ?NetArpWaitPacketIP = 0;
? ? ? ?NetArpWaitReplyIP = 0;
- ? ? ? NetArpWaitTxPacket = &NetArpWaitPacketBuf[0] + (PKTALIGN - 1);
- ? ? ? NetArpWaitTxPacket -= (ulong)NetArpWaitTxPacket % PKTALIGN; ? ? ? ?NetArpWaitTxPacketSize = 0;
+ ? ? ? NetArpTxPacket = &NetArpPacketBuf[0] + (PKTALIGN - 1);
+ ? ? ? NetArpTxPacket -= (ulong)NetArpTxPacket % PKTALIGN;
I don't understand what this is doing. Perhaps that is just as well.
Quoted 129 lines
?}
?void ArpRequest(void)
net/arp.c +7
-7@@ -56,7 +56,7 @@ void ArpRequest(void) ? ? ? ?debug("ARP broadcast %d\n", NetArpWaitTry); - ? ? ? pkt = NetTxPacket; + ? ? ? pkt = NetArpTxPacket; ? ? ? ?eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_ARP); ? ? ? ?pkt += eth_hdr_size;@@ -88,7 +88,7 @@ void ArpRequest(void) ? ? ? ?} ? ? ? ?NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP); - ? ? ? NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); + ? ? ? NetSendPacket(NetArpTxPacket, eth_hdr_size + ARP_HDR_SIZE); ?} ?void ArpTimeoutCheck(void)@@ -196,11 +196,11 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ? ? ? ? ?net_get_arp_handler()((uchar *)arp, 0, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?reply_ip_addr, 0, len); - ? ? ? ? ? ? ? ? ? ? ? /* modify header, and transmit it */ - ? ? ? ? ? ? ? ? ? ? ? memcpy(((struct Ethernet_hdr *)NetArpWaitTxPacket)-> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? et_dest, &arp->ar_sha, ARP_HLEN); - ? ? ? ? ? ? ? ? ? ? ? NetSendPacket(NetArpWaitTxPacket, - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NetArpWaitTxPacketSize); + ? ? ? ? ? ? ? ? ? ? ? /* set the mac address in the waiting packet's header + ? ? ? ? ? ? ? ? ? ? ? ? ?and transmit it */ + ? ? ? ? ? ? ? ? ? ? ? memcpy(((struct Ethernet_hdr *)NetTxPacket)->et_dest, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &arp->ar_sha, ARP_HLEN); + ? ? ? ? ? ? ? ? ? ? ? NetSendPacket(NetTxPacket, NetArpWaitTxPacketSize);? ? ? ? ? ? ? ? ? ? ? ?/* no arp request pending now */ ? ? ? ? ? ? ? ? ? ? ? ?NetArpWaitPacketIP = 0;
net/arp.h +0
-0@@ -16,8 +16,6 @@ ?extern IPaddr_t ? ? ? ?NetArpWaitPacketIP;?/* MAC address of waiting packet's destination */ ?extern uchar *NetArpWaitPacketMAC;
net/arp.h +0
-2-/* THE transmit packet */ -extern uchar *NetArpWaitTxPacket;?extern int NetArpWaitTxPacketSize;
?extern ulong NetArpWaitTimerStart;
?extern int NetArpWaitTry;net/net.c +0
-0@@ -443,6 +443,9 @@ restart:? ? ? ? ? ? ? ? * ? ? ?Abort if ctrl-c was pressed.
? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ?if (ctrlc()) {
+ ? ? ? ? ? ? ? ? ? ? ? /* cancel any ARP that may not have completed */
+ ? ? ? ? ? ? ? ? ? ? ? NetArpWaitPacketIP = 0;
+
? ? ? ? ? ? ? ? ? ? ? ?net_cleanup_loop();
? ? ? ? ? ? ? ? ? ? ? ?eth_halt();
? ? ? ? ? ? ? ? ? ? ? ?puts("\nAbort\n");net/net.c +3
-11@@ -634,7 +637,6 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, ? ? ? ? ? ? ? ?int payload_len) ?{ ? ? ? ?uchar *pkt; - ? ? ? int need_arp = 0; ? ? ? ?int eth_hdr_size; ? ? ? ?int pkt_hdr_size;@@ -651,35 +653,21 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, ? ? ? ?if (dest == 0xFFFFFFFF) ? ? ? ? ? ? ? ?ether = NetBcastAddr; - ? ? ? /* - ? ? ? ?* if MAC address was not discovered yet, save the packet and do - ? ? ? ?* an ARP request - ? ? ? ?*/ - ? ? ? if (memcmp(ether, NetEtherNullAddr, 6) == 0) { - ? ? ? ? ? ? ? need_arp = 1; - ? ? ? ? ? ? ? pkt = NetArpWaitTxPacket; - ? ? ? } else - ? ? ? ? ? ? ? pkt = (uchar *)NetTxPacket; + ? ? ? pkt = (uchar *)NetTxPacket; ? ? ? ?eth_hdr_size = NetSetEther(pkt, ether, PROT_IP); ? ? ? ?pkt += eth_hdr_size; ? ? ? ?net_set_udp_header(pkt, dest, dport, sport, payload_len); ? ? ? ?pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE; - ? ? ? if (need_arp) { + ? ? ? /* if MAC address was not discovered yet, do an ARP request */ + ? ? ? if (memcmp(ether, NetEtherNullAddr, 6) == 0) { ? ? ? ? ? ? ? ?debug("sending ARP for %pI4\n", &dest);? ? ? ? ? ? ? ?/* save the ip and eth addr for the packet to send after arp */ ? ? ? ? ? ? ? ?NetArpWaitPacketIP = dest;
? ? ? ? ? ? ? ?NetArpWaitPacketMAC = ether;- ? ? ? ? ? ? ? /*
- ? ? ? ? ? ? ? ?* Copy the packet data from the NetTxPacket into the
- ? ? ? ? ? ? ? ?* ? NetArpWaitTxPacket to send after arp
- ? ? ? ? ? ? ? ?*/
- ? ? ? ? ? ? ? memcpy(pkt +IP_UDP_HDR_SIZE, (uchar *)NetTxPacket +
- ? ? ? ? ? ? ? ? ? ? ?pkt_hdr_size,payload_len);
-
? ? ? ? ? ? ? ?/* size of the waiting packet */
? ? ? ? ? ? ? ?NetArpWaitTxPacketSize =pkt_hdr_size+payload_len;net/ping.c +2
-4@@ -49,9 +49,8 @@ static int ping_send(void) ? ? ? ?NetArpWaitPacketIP = NetPingIP; - ? ? ? eth_hdr_size = NetSetEther(NetArpWaitTxPacket, NetEtherNullAddr, - ? ? ? ? ? ? ? PROT_IP); - ? ? ? pkt = NetArpWaitTxPacket + eth_hdr_size; + ? ? ? eth_hdr_size = NetSetEther(NetTxPacket, NetEtherNullAddr, PROT_IP); + ? ? ? pkt = (uchar *)NetTxPacket + eth_hdr_size; ? ? ? ?set_icmp_header(pkt, NetPingIP); --
Quoted 2 lines
1.6.0.2
Regards,
Simon
v2 cover Add link-local addressing support
In reply to Joe HershbergerLink-local support allows the bootloader to get a usable network address regardless of network environment. Given that bootloaders may not always have access to a DHCP server, this functionality makes accessing it in those environments easier. It is also referred to as zero-configuration IP.
Tested on da850_am18xxevm
Tested on MPC8313ERDB_33
This is dependant on the "Network stack refactoring" patch-series.
This is a portion of the changes split from the series:
"Add link-local addressing support"
Joe Hershberger (3):
net: Separate ArpRequest() into lower-level func
net: Add link-local addressing support
net: Work-around for brain-damaged Cisco equipment with arp-proxy
README | 10 ++ common/cmd_net.c | 31 +++++ doc/README.link-local | 76 +++++++++++ include/net.h | 2 +- net/Makefile | 4 +- net/arp.c | 36 ++++-- net/arp.h | 2 + net/link_local.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++ net/link_local.h | 24 ++++ net/net.c | 13 ++ 10 files changed, 519 insertions(+), 11 deletions(-) create mode 100644 doc/README.link-local create mode 100644 net/link_local.c create mode 100644 net/link_local.h
v3 cover Add link-local addressing support
Link-local support allows the bootloader to get a usable network address regardless of network environment. Given that bootloaders may not always have access to a DHCP server, this functionality makes accessing it in those environments easier. It is also referred to as zero-configuration IP.
Tested on da850_am18xxevm
Tested on MPC8313ERDB_33
This is dependant on the "Network stack refactoring" patch-series.
This is a portion of the changes split from the series:
"Add link-local addressing support"
Joe Hershberger (3):
net: Separate ArpRequest() into lower-level func
net: Add link-local addressing support
net: Work-around for brain-damaged Cisco equipment with arp-proxy
README | 10 ++ common/cmd_net.c | 31 +++++ doc/README.link-local | 76 +++++++++++ include/net.h | 2 +- net/Makefile | 4 +- net/arp.c | 36 ++++-- net/arp.h | 2 + net/link_local.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++ net/link_local.h | 24 ++++ net/net.c | 13 ++ 10 files changed, 519 insertions(+), 11 deletions(-) create mode 100644 doc/README.link-local create mode 100644 net/link_local.c create mode 100644 net/link_local.h
PATCH v3 1/3 net: Separate ArpRequest() into lower-level func
In reply to Joe HershbergerLink-local support will need to send ARP packets, but needs more fine-grained control over the contents. Split the implementation into 2 parts so link-local can share the code.
---
Changes for v2:
- Split from "Add link-local addressing support"
- Eliminate CamelCase from new functions
Changes for v3:
- Rebased onto other changed patches
net/arp.c | 22 +++++++++++++--------- net/arp.h | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-)
net/arp.c +13 -9
@@ -48,7 +48,8 @@ void ArpInit(void) NetArpTxPacket -= (ulong )NetArpTxPacket %PKTALIGN ; } -void ArpRequest (void ) +void arp_raw_request (IPaddr_t sourceIP,const uchar *targetEther, +IPaddr_t targetIP) {uchar *pkt;struct arp_hdr *arp;
@@ -69,12 +70,16 @@ void ArpRequest(void) arp->ar_pln =ARP_PLEN ; arp->ar_op =htons (ARPOP_REQUEST ); -/* source ET addr */ -memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN ); -/* source IP addr */ -NetWriteIP (&arp->ar_spa, NetOurIP); -/* dest ET addr = 0 */ -memset (&arp->ar_tha,0 ,ARP_HLEN ); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );/* source ET addr */ +NetWriteIP (&arp->ar_spa, sourceIP);/* source IP addr */ +memcpy (&arp->ar_tha, targetEther,ARP_HLEN );/* target ET addr */ +NetWriteIP (&arp->ar_tpa, targetIP);/* target IP addr */ + +NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +} + +void ArpRequest (void ) +{if ((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) {if (NetOurGatewayIP ==0 ) {
@@ -87,8 +92,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } -NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); -NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +arp_raw_request (NetOurIP, NetEtherNullAddr, NetArpWaitReplyIP); }void ArpTimeoutCheck (void )
net/arp.h +2 -0
@@ -22,6 +22,8 @@ extern int NetArpWaitTry;void ArpInit (void );void ArpRequest (void ); +void arp_raw_request (IPaddr_t sourceIP,const uchar *targetEther, +IPaddr_t targetIP);void ArpTimeoutCheck (void );void ArpReceive (struct ethernet_hdr *et,struct ip_udp_hdr *ip,int len);
Signature · 1 line
1.6.0.2
PATCH v3 2/3 net: Add link-local addressing support
In reply to Joe HershbergerCode based on networking/zcip.c in busybox
commit 8531d76a15890c2c535908ce888b2e2aed35b172
---
Changes for v2:
- Omitted unrelated whitespace changes
- Made do_link_local() static
- Pushed #ifdef CONFIG_CMD_LINK_LOCAL into header
Changes for v3:
- Rebased onto other changed patches
README | 10 ++ common/cmd_net.c | 31 +++++ doc/README.link-local | 76 +++++++++++ include/net.h | 2 +- net/Makefile | 4 +- net/link_local.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++ net/link_local.h | 24 ++++ net/net.c | 13 ++ 8 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 doc/README.link-local create mode 100644 net/link_local.c create mode 100644 net/link_local.h
README +10 -0
@@ -785,6 +785,8 @@ The following options need to be configured: CONFIG_CMD_JFFS2 * JFFS2 Support CONFIG_CMD_KGDB * kgdb CONFIG_CMD_LDRINFO ldrinfo (display Blackfin loader) + CONFIG_CMD_LINK_LOCAL * link-local IP address auto-configuration + (169.254.*.*) CONFIG_CMD_LOADB loadb CONFIG_CMD_LOADS loads CONFIG_CMD_MD5SUM print md5 message digest
@@ -1633,6 +1635,14 @@ The following options need to be configured: the DHCP timeout and retry process takes a longer than this delay. + - Link-local IP address negotiation: + Negotiate with other link-local clients on the local network + for an address that doesn't require explicit configuration. + This is especially useful if a DHCP server cannot be guaranteed + to exist in all environments that the device must operate. + + See doc/README.link-local for more information. + - CDP Options: CONFIG_CDP_DEVICE_ID
common/cmd_net.c +31 -0
@@ -428,3 +428,34 @@ U_BOOT_CMD( );#endif /* CONFIG_CMD_DNS */ + +#if defined(CONFIG_CMD_LINK_LOCAL ) +static int do_link_local (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +char tmp[22 ]; + +if (NetLoop (LINKLOCAL ) <0 ) +return 1 ; + + NetOurGatewayIP =0 ; +ip_to_string (NetOurGatewayIP, tmp); +setenv ("gatewayip" , tmp); + +ip_to_string (NetOurSubnetMask, tmp); +setenv ("netmask" , tmp); + +ip_to_string (NetOurIP, tmp); +setenv ("ipaddr" , tmp); +setenv ("llipaddr" , tmp);/* store this for next time */ + +return 0 ; +} + +U_BOOT_CMD ( + linklocal,1 ,1 , do_link_local, +"acquire a network IP address using the link-local protocol" , +"" +); + +#endif /* CONFIG_CMD_LINK_LOCAL */
doc/README.link-local new file +76 -0
76 lines not on this page · raw message
include/net.h +1 -1
@@ -395,7 +395,7 @@ extern int NetRestartWrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT +TFTPSRV ,TFTPPUT ,LINKLOCAL };/* from net/net.c */
net/Makefile +3 -1
@@ -32,15 +32,17 @@ COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += link_local.o COBJS-$(CONFIG_CMD_NET) += net.o COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_PING) += ping.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o -COBJS := $(COBJS-y) +COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
net/link_local.c new file +332 -0
332 lines not on this page · raw message
net/link_local.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* RFC3927 ZeroConf IPv4 Link-Local addressing +* (see <http://www.zeroconf.org/>) +* +* Copied from BusyBox - networking/zcip.c +* +* Copyright (C) 2003 by Arthur van Hoff (avh at strangeberry.com) +* Copyright (C) 2004 by David Brownell +* +* Licensed under the GPL v2 or later +*/ + +#if defined(CONFIG_CMD_LINK_LOCAL ) + +#ifndef __LINK_LOCAL_H__ +#define __LINK_LOCAL_H__ + +#include <common.h> + +void link_local_receive_arp (struct arp_hdr *arp,int len); +void link_local_start (void ); + +#endif /* __LINK_LOCAL_H__ */ +#endif
net/net.c +13 -0
@@ -23,6 +23,12 @@* - name of bootfile * Next step: ARP * +* LINK_LOCAL: +* +* Prerequisites: - own ethernet address +* We want: - own IP address +* Next step: ARP +* * RARP: * * Prerequisites: - own ethernet address
@@ -89,6 +95,7 @@#if defined(CONFIG_CMD_DNS )#include "dns.h" #endif +#include "link_local.h" #include "nfs.h" #include "ping.h" #include "rarp.h"
@@ -402,6 +409,11 @@ restart:DnsStart ();break ;#endif +#if defined(CONFIG_CMD_LINK_LOCAL ) +case LINKLOCAL : +link_local_start (); +break ; +#endif default :break ; }
@@ -1194,6 +1206,7 @@ common:case BOOTP :case CDP :case DHCP : +case LINKLOCAL :if (memcmp (NetOurEther,"\0\0\0\0\0\0" ,6 ) ==0 ) {int num =eth_get_dev_index ();
Signature · 1 line
1.6.0.2
PATCH v3 3/3 net: Work-around for brain-damaged Cisco equipment with arp-proxy
In reply to Joe HershbergerCisco's arp-proxy feature fails to ignore the link-local address range This means that a link-local device on a network with this Cisco equipment will reply to ARP requests for our device (in addition to our reply).
If we happen to reply first, the requester's ARP table will be populated with our MAC address, and one packet will be sent to us... shortly following this, the requester will get an ARP reply from the Cisco equipment telling the requester to send packets their way instead of to our device from now on.
This work-around detects this link-local condition and will delay replying to the ARP request for 5ms so that the first packet is sent to the Cisco equipment and all following packets are sent to our device.
---
Changes for v2:
- Guard with #ifdef CONFIG_CMD_LINK_LOCAL
Changes for v3:
- Rebased onto other changed patches
net/arp.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
net/arp.c +14 -0
@@ -169,6 +169,20 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)NetCopyIP (&arp->ar_tpa, &arp->ar_spa);memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );NetCopyIP (&arp->ar_spa, &NetOurIP); + +#ifdef CONFIG_CMD_LINK_LOCAL +/* +* Work-around for brain-damaged Cisco equipment with +* arp-proxy enabled. +* +* If the requesting IP is not on our subnet, wait 5ms to +* reply to ARP request so that our reply will overwrite +* the arp-proxy's instead of the other way around. +*/ +if ((NetReadIP (&arp->ar_tpa) & NetOurSubnetMask) != + (NetReadIP (&arp->ar_spa) & NetOurSubnetMask)) +udelay (5000 ); +#endif NetSendPacket ((uchar *)et, eth_hdr_size +ARP_HDR_SIZE );return ;
Signature · 1 line
1.6.0.2
PATCH v2 1/3 net: Separate ArpRequest() into lower-level func
In reply to Joe HershbergerLink-local support will need to send ARP packets, but needs more fine-grained control over the contents. Split the implementation into 2 parts so link-local can share the code.
---
Changes for v2:
- Split from "Add link-local addressing support"
- Eliminate CamelCase from new functions
net/arp.c | 22 +++++++++++++--------- net/arp.h | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-)
net/arp.c +13 -9
@@ -48,7 +48,8 @@ void ArpInit(void) NetArpTxPacket -= (ulong )NetArpTxPacket %PKTALIGN ; } -void ArpRequest (void ) +void arp_raw_request (IPaddr_t sourceIP,const uchar *targetEther, +IPaddr_t targetIP) {uchar *pkt;struct ARP_hdr *arp;
@@ -69,12 +70,16 @@ void ArpRequest(void) arp->ar_pln =ARP_PLEN ; arp->ar_op =htons (ARPOP_REQUEST ); -/* source ET addr */ -memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN ); -/* source IP addr */ -NetWriteIP (&arp->ar_spa, NetOurIP); -/* dest ET addr = 0 */ -memset (&arp->ar_tha,0 ,ARP_HLEN ); +memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );/* source ET addr */ +NetWriteIP (&arp->ar_spa, sourceIP);/* source IP addr */ +memcpy (&arp->ar_tha, targetEther,ARP_HLEN );/* target ET addr */ +NetWriteIP (&arp->ar_tpa, targetIP);/* target IP addr */ + +NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +} + +void ArpRequest (void ) +{if ((NetArpWaitPacketIP & NetOurSubnetMask) != (NetOurIP & NetOurSubnetMask)) {if (NetOurGatewayIP ==0 ) {
@@ -87,8 +92,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } -NetWriteIP (&arp->ar_tpa, NetArpWaitReplyIP); -NetSendPacket (NetArpTxPacket, eth_hdr_size +ARP_HDR_SIZE ); +arp_raw_request (NetOurIP, NetEtherNullAddr, NetArpWaitReplyIP); }void ArpTimeoutCheck (void )
net/arp.h +2 -0
@@ -22,6 +22,8 @@ extern int NetArpWaitTry;void ArpInit (void );void ArpRequest (void ); +void arp_raw_request (IPaddr_t sourceIP,const uchar *targetEther, +IPaddr_t targetIP);void ArpTimeoutCheck (void );void ArpReceive (struct Ethernet_hdr *et,struct IP_UDP_hdr *ip,int len);
Signature · 1 line
1.6.0.2
PATCH v2 2/3 net: Add link-local addressing support
In reply to Joe HershbergerCode based on networking/zcip.c in busybox
commit 8531d76a15890c2c535908ce888b2e2aed35b172
---
Changes for v2:
- Omitted unrelated whitespace changes
- Made do_link_local() static
- Pushed #ifdef CONFIG_CMD_LINK_LOCAL into header
README | 10 ++ common/cmd_net.c | 31 +++++ doc/README.link-local | 76 +++++++++++ include/net.h | 2 +- net/Makefile | 4 +- net/link_local.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++ net/link_local.h | 24 ++++ net/net.c | 13 ++ 8 files changed, 490 insertions(+), 2 deletions(-) create mode 100644 doc/README.link-local create mode 100644 net/link_local.c create mode 100644 net/link_local.h
README +10 -0
@@ -771,6 +771,8 @@ The following options need to be configured: CONFIG_CMD_JFFS2 * JFFS2 Support CONFIG_CMD_KGDB * kgdb CONFIG_CMD_LDRINFO ldrinfo (display Blackfin loader) + CONFIG_CMD_LINK_LOCAL * link-local IP address auto-configuration + (169.254.*.*) CONFIG_CMD_LOADB loadb CONFIG_CMD_LOADS loads CONFIG_CMD_MD5SUM print md5 message digest
@@ -1604,6 +1606,14 @@ The following options need to be configured: the DHCP timeout and retry process takes a longer than this delay. + - Link-local IP address negotiation: + Negotiate with other link-local clients on the local network + for an address that doesn't require explicit configuration. + This is especially useful if a DHCP server cannot be guaranteed + to exist in all environments that the device must operate. + + See doc/README.link-local for more information. + - CDP Options: CONFIG_CDP_DEVICE_ID
common/cmd_net.c +31 -0
@@ -426,3 +426,34 @@ U_BOOT_CMD( );#endif /* CONFIG_CMD_DNS */ + +#if defined(CONFIG_CMD_LINK_LOCAL ) +static int do_link_local (cmd_tbl_t *cmdtp,int flag,int argc, +char *const argv[]) +{ +char tmp[22 ]; + +if (NetLoop (LINKLOCAL ) <0 ) +return 1 ; + + NetOurGatewayIP =0 ; +ip_to_string (NetOurGatewayIP, tmp); +setenv ("gatewayip" , tmp); + +ip_to_string (NetOurSubnetMask, tmp); +setenv ("netmask" , tmp); + +ip_to_string (NetOurIP, tmp); +setenv ("ipaddr" , tmp); +setenv ("llipaddr" , tmp);/* store this for next time */ + +return 0 ; +} + +U_BOOT_CMD ( + linklocal,1 ,1 , do_link_local, +"acquire a network IP address using the link-local protocol" , +"" +); + +#endif /* CONFIG_CMD_LINK_LOCAL */
doc/README.link-local new file +76 -0
76 lines not on this page · raw message
include/net.h +1 -1
@@ -394,7 +394,7 @@ extern int NetRestartWrap; /* Tried all network devices */enum proto_t {BOOTP ,RARP ,ARP ,TFTPGET ,DHCP ,PING ,DNS ,NFS ,CDP ,NETCONS ,SNTP , -TFTPSRV ,TFTPPUT +TFTPSRV ,TFTPPUT ,LINKLOCAL };/* from net/net.c */
net/Makefile +3 -1
@@ -32,15 +32,17 @@ COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += link_local.o COBJS-$(CONFIG_CMD_NET) += net.o COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o +COBJS-$(CONFIG_CMD_LINK_LOCAL) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_PING) += ping.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o -COBJS := $(COBJS-y) +COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
net/link_local.c new file +332 -0
332 lines not on this page · raw message
net/link_local.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* RFC3927 ZeroConf IPv4 Link-Local addressing +* (see <http://www.zeroconf.org/>) +* +* Copied from BusyBox - networking/zcip.c +* +* Copyright (C) 2003 by Arthur van Hoff (avh at strangeberry.com) +* Copyright (C) 2004 by David Brownell +* +* Licensed under the GPL v2 or later +*/ + +#if defined(CONFIG_CMD_LINK_LOCAL ) + +#ifndef __LINK_LOCAL_H__ +#define __LINK_LOCAL_H__ + +#include <common.h> + +void link_local_receive_arp (struct ARP_hdr *arp,int len); +void link_local_start (void ); + +#endif /* __LINK_LOCAL_H__ */ +#endif
net/net.c +13 -0
@@ -23,6 +23,12 @@* - name of bootfile * Next step: ARP * +* LINK_LOCAL: +* +* Prerequisites: - own ethernet address +* We want: - own IP address +* Next step: ARP +* * RARP: * * Prerequisites: - own ethernet address
@@ -89,6 +95,7 @@#if defined(CONFIG_CMD_DNS )#include "dns.h" #endif +#include "link_local.h" #include "nfs.h" #include "ping.h" #include "rarp.h"
@@ -403,6 +410,11 @@ restart:DnsStart ();break ;#endif +#if defined(CONFIG_CMD_LINK_LOCAL ) +case LINKLOCAL : +link_local_start (); +break ; +#endif default :break ; }
@@ -1196,6 +1208,7 @@ common:case BOOTP :case CDP :case DHCP : +case LINKLOCAL :if (memcmp (NetOurEther,"\0\0\0\0\0\0" ,6 ) ==0 ) {int num =eth_get_dev_index ();
Signature · 1 line
1.6.0.2
PATCH v2 3/3 net: Work-around for brain-damaged Cisco equipment with arp-proxy
In reply to Joe HershbergerCisco's arp-proxy feature fails to ignore the link-local address range This means that a link-local device on a network with this Cisco equipment will reply to ARP requests for our device (in addition to our reply).
If we happen to reply first, the requester's ARP table will be populated with our MAC address, and one packet will be sent to us... shortly following this, the requester will get an ARP reply from the Cisco equipment telling the requester to send packets their way instead of to our device from now on.
This work-around detects this link-local condition and will delay replying to the ARP request for 5ms so that the first packet is sent to the Cisco equipment and all following packets are sent to our device.
---
Changes for v2:
- Guard with #ifdef CONFIG_CMD_LINK_LOCAL
net/arp.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
net/arp.c +14 -0
@@ -169,6 +169,20 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)NetCopyIP (&arp->ar_tpa, &arp->ar_spa);memcpy (&arp->ar_sha, NetOurEther,ARP_HLEN );NetCopyIP (&arp->ar_spa, &NetOurIP); + +#ifdef CONFIG_CMD_LINK_LOCAL +/* +* Work-around for brain-damaged Cisco equipment with +* arp-proxy enabled. +* +* If the requesting IP is not on our subnet, wait 5ms to +* reply to ARP request so that our reply will overwrite +* the arp-proxy's instead of the other way around. +*/ +if ((NetReadIP (&arp->ar_tpa) & NetOurSubnetMask) != + (NetReadIP (&arp->ar_spa) & NetOurSubnetMask)) +udelay (5000 ); +#endif NetSendPacket ((uchar *)et, eth_hdr_size +ARP_HDR_SIZE );return ;
Signature · 1 line
1.6.0.2
PATCH v2 3/3 net: Work-around for brain-damaged Cisco equipment with arp-proxy
Hi Joe,
Quoted 37 lines · Joe Hershberger
Cisco's arp-proxy feature fails to ignore the link-local address range This means that a link-local device on a network with this Cisco equipment will reply to ARP requests for our device (in addition to our reply).
If we happen to reply first, the requester's ARP table will be populated with our MAC address, and one packet will be sent to us... shortly following this, the requester will get an ARP reply from the Cisco equipment telling the requester to send packets their way instead of to our device from now on.
This work-around detects this link-local condition and will delay replying to the ARP request for 5ms so that the first packet is sent to the Cisco equipment and all following packets are sent to our device.Signed-off-by Joe Hershberger <[email protected]>Cc Joe Hershberger <[email protected]>Cc Simon Glass <[email protected]>Cc Mike Frysinger <[email protected]>---
Changes for v2:
? - Guard with #ifdefCONFIG_CMD_LINK_LOCAL?net/arp.c | ? 14 ++++++++++++++
?1 files changed, 14 insertions(+), 0 deletions(-)net/arp.c +4
-0@@ -169,6 +169,20 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) ? ? ? ? ? ? ? ?NetCopyIP(&arp->ar_tpa, &arp->ar_spa); ? ? ? ? ? ? ? ?memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN); ? ? ? ? ? ? ? ?NetCopyIP(&arp->ar_spa, &NetOurIP); + +#ifdef CONFIG_CMD_LINK_LOCAL + ? ? ? ? ? ? ? /* +? ? ? ? ? ? ? ?* Work-around for brain-damaged Cisco equipment with
net/arp.c void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len) · line 185
Quoted 10 lines
net/arp.c +10
-0+? ? ? ? ? ? ? ?* ? arp-proxy enabled. +? ? ? ? ? ? ? ?* +? ? ? ? ? ? ? ?* ? If the requesting IP is not on our subnet, wait 5ms to +? ? ? ? ? ? ? ?* ? reply to ARP request so that our reply will overwrite +? ? ? ? ? ? ? ?* ? the arp-proxy's instead of the other way around. +? ? ? ? ? ? ? ?*/ + ? ? ? ? ? ? ? if ((NetReadIP(&arp->ar_tpa) & NetOurSubnetMask) != + ? ? ? ? ? ? ? ? ? (NetReadIP(&arp->ar_spa) & NetOurSubnetMask)) + ? ? ? ? ? ? ? ? ? ? ? udelay(5000); +#endif
I'm sure this solves the problem, but is 5ms enough, and should we make this a CONFIG option so it can be turned off if needed?
Quoted 6 lines
net/arp.c +0
-1? ? ? ? ? ? ? ?NetSendPacket((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); ? ? ? ? ? ? ? ?return; --1.6.0.2
Regards,
Simon
PATCH v2 3/3 net: Work-around for brain-damaged Cisco equipment with arp-proxy
Hi Simon,
Quoted 8 lines · Simon Glass
Quoted 8 lines
+#ifdef
CONFIG_CMD_LINK_LOCAL
+ ? ? ? ? ? ? ? /*
+ ? ? ? ? ? ? ? ?* Work-around for brain-damaged Cisco equipment with
+ ? ? ? ? ? ? ? ?* ? arp-proxy enabled.
+ ? ? ? ? ? ? ? ?*
+ ? ? ? ? ? ? ? ?* ? If the requesting IP is not on our subnet, wait 5ms to
+ ? ? ? ? ? ? ? ?* ? reply to ARP request so that our reply will overwrite
+ ? ? ? ? ? ? ? ?* ? the arp-proxy's instead of the other way around.
Quoted 8 lines
Quoted 5 lines
+ ? ? ? ? ? ? ? ?*/
+ ? ? ? ? ? ? ? if ((NetReadIP(&arp->ar_tpa)& NetOurSubnetMask) !=
+ ? ? ? ? ? ? ? ? ? (NetReadIP(&arp->ar_spa)& NetOurSubnetMask))
+ ? ? ? ? ? ? ? ? ? ? ? udelay(5000);
+#endifI'm sure this solves the problem, but is 5ms enough, and should we make this a CONFIG option so it can be turned off if needed?
In my experience it is enough. I think I'd rather keep it simple until someone sees an environment where it needs configurability... in which case it should probably be an env variable.
-Joe
PATCH v2 1/1 net: Allow filtering on debug traces in the net subsystem
In reply to Joe Hershberger---
Changes for v2:
- Split from "Add link-local addressing support" patch-series
- This patch is dependant on "Add link-local addressing support" patch-series
- Knobs for enabling filters moved into net.h
drivers/net/netconsole.c | 4 ++++ include/common.h | 14 +++++++------- include/net.h | 5 +++++ net/arp.c | 9 +++++---- net/link_local.c | 26 ++++++++++++++------------ net/net.c | 40 +++++++++++++++++++++++++++++----------- net/ping.c | 4 ++-- net/rarp.c | 4 ++-- 8 files changed, 68 insertions(+), 38 deletions(-)
drivers/net/netconsole.c +4 -0
@@ -83,6 +83,8 @@ int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)if (dest != nc_port || !len)return 0 ;/* not for us */ +debug_cond (DEBUG_DEV_PKT ,"input: \"%*.*s\"\n" , len, len, pkt); +if (input_size ==sizeof (input_buffer))return 1 ;/* no space */ if (len >sizeof (input_buffer) - input_size)
@@ -112,6 +114,8 @@ static void nc_send_packet(const char *buf, int len)uchar *ether;IPaddr_t ip; +debug_cond (DEBUG_DEV_PKT ,"output: \"%*.*s\"\n" , len, len, buf); + eth =eth_get_dev ();if (eth ==NULL )return ;
include/common.h +7 -7
@@ -711,13 +711,6 @@ int gunzip(void *, int, unsigned char *, unsigned long *);int zunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp,int stoponerr,int offset); -/* lib/net_utils.c */ -#include <net.h> -static inline IPaddr_t getenv_IPaddr (char *var) -{ -return (string_to_ip (getenv (var))); -} -/* lib/qsort.c */ void qsort (void *base,size_t nmemb,size_t size,int (*compar)(const void *,const void *));
@@ -786,6 +779,13 @@ void fputc(int file, const char c);int ftstc (int file);int fgetc (int file); +/* lib/net_utils.c */ +#include <net.h> +static inline IPaddr_t getenv_IPaddr (char *var) +{ +return string_to_ip (getenv (var)); +} +/* * CONSOLE multiplexing. */
include/net.h +5 -0
@@ -18,6 +18,10 @@#include <asm/byteorder.h> /* for nton* / ntoh* stuff */ +#define DEBUG_LL_STATE 0 +#define DEBUG_DEV_PKT 0 +#define DEBUG_NET_PKT 0 +#define DEBUG_INT_STATE 0/* * The number of receive packet buffers, and the required packet buffer
@@ -470,6 +474,7 @@ enum net_loop_state {static inline void net_set_state (enum net_loop_state state) {extern enum net_loop_state net_state; +debug_cond (DEBUG_INT_STATE ,"--- NetState set to %d\n" , state); net_state = state; }
net/arp.c +5 -4
@@ -55,7 +55,7 @@ void arp_raw_request(IPaddr_t sourceIP, const uchar *targetEther,struct ARP_hdr *arp;int eth_hdr_size; -debug ("ARP broadcast %d\n" , NetArpWaitTry); +debug_cond (DEBUG_DEV_PKT ,"ARP broadcast %d\n" , NetArpWaitTry); pkt = NetArpTxPacket;
@@ -135,7 +135,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)* address; so if we receive such a packet, we set * the server ethernet address */ -debug ("Got ARP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got ARP\n" ); arp = (struct ARP_hdr *)ip;if (len <ARP_HDR_SIZE ) {
@@ -160,7 +160,7 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)switch (ntohs (arp->ar_op)) {case ARPOP_REQUEST :/* reply with our IP address */ -debug ("Got ARP REQUEST, return our IP\n" ); +debug_cond (DEBUG_DEV_PKT ,"Got ARP REQUEST, return our IP\n" ); pkt = (uchar *)et; eth_hdr_size =net_update_ether (et, et->et_src,PROT_ARP ); pkt += eth_hdr_size;
@@ -203,7 +203,8 @@ void ArpReceive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)/* matched waiting packet's address */ if (reply_ip_addr == NetArpWaitReplyIP) { -debug ("Got ARP REPLY, set eth addr (%pM)\n" , +debug_cond (DEBUG_DEV_PKT , +"Got ARP REPLY, set eth addr (%pM)\n" , arp->ar_data);/* save address for later use */
net/link_local.c +14 -12
@@ -93,7 +93,7 @@ static void configure_wait(void)/* set deadline_ms to the point in time when we timeout */ deadline_ms =MONOTONIC_MS () + timeout_ms; -debug ("...wait %d %s nprobes=%u, nclaims=%u\n" , +debug_cond (DEBUG_DEV_PKT ,"...wait %d %s nprobes=%u, nclaims=%u\n" , timeout_ms,eth_get_name (), nprobes, nclaims);NetSetTimeout (timeout_ms, link_local_timeout);
@@ -131,7 +131,7 @@ static void link_local_timeout(void)have been received, so we can progress through the states */ if (nprobes <PROBE_NUM ) { nprobes++; -debug ("probe/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"probe/%u %s@%pI4\n" , nprobes,eth_get_name (), &ip);arp_raw_request (0 , NetEtherNullAddr, ip); timeout_ms =PROBE_MIN *1000 ;
@@ -140,7 +140,7 @@ static void link_local_timeout(void)/* Switch to announce state */ state =ANNOUNCE ; nclaims =0 ; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -152,7 +152,7 @@ static void link_local_timeout(void)to the announce state */ state =ANNOUNCE ; nclaims =0 ; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -163,7 +163,7 @@ static void link_local_timeout(void)the states */ if (nclaims <ANNOUNCE_NUM ) { nclaims++; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -216,10 +216,11 @@ void link_local_receive_arp(struct ARP_hdr *arp, int len)if ((int )(diff) <0 ) {/* Current time is greater than the expected timeout time. This should never happen */ -debug ("missed an expected timeout\n" ); +debug_cond (DEBUG_LL_STATE , +"missed an expected timeout\n" ); timeout_ms =0 ; }else { -debug ("adjusting timeout\n" ); +debug_cond (DEBUG_INT_STATE ,"adjusting timeout\n" ); timeout_ms = diff |1 ;/* never 0 */ } }
@@ -239,13 +240,13 @@ void link_local_receive_arp(struct ARP_hdr *arp, int len)} */ -debug ("%s recv arp type=%d, op=%d,\n" , +debug_cond (DEBUG_INT_STATE ,"%s recv arp type=%d, op=%d,\n" ,eth_get_name (),ntohs (arp->ar_pro),ntohs (arp->ar_op)); -debug ("\tsource=%pM %pI4\n" , +debug_cond (DEBUG_INT_STATE ,"\tsource=%pM %pI4\n" , &arp->ar_sha, &arp->ar_spa); -debug ("\ttarget=%pM %pI4\n" , +debug_cond (DEBUG_INT_STATE ,"\ttarget=%pM %pI4\n" , &arp->ar_tha, &arp->ar_tpa);
@@ -271,8 +272,9 @@ void link_local_receive_arp(struct ARP_hdr *arp, int len) target_ip_conflict =1 ; } -debug ("state = %d, source ip conflict = %d, target ip conflict = %d\n" , - state, source_ip_conflict, target_ip_conflict); +debug_cond (DEBUG_NET_PKT , +"state = %d, source ip conflict = %d, target ip conflict = " +"%d\n" , state, source_ip_conflict, target_ip_conflict);switch (state) {case PROBE :case ANNOUNCE :
net/net.c +29 -11
@@ -311,6 +311,7 @@ int NetLoop(enum proto_t protocol) NetRestarted =0 ; NetDevExists =0 ; NetTryCount =1 ; +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Entry\n" );bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" );net_init ();
@@ -331,6 +332,7 @@ restart:* here on, this code is a state machine driven by received * packets and timer events. */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Init\n" );NetInitLoop ();switch (net_check_prereq (protocol)) {
@@ -461,6 +463,9 @@ restart:net_cleanup_loop ();eth_halt ();puts ("\nAbort\n" ); +/* include a debug print as well incase the debug +messages are directed to stderr */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Abort!\n" ); goto done; }
@@ -488,6 +493,7 @@ restart: }#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_MII, ... */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop timeout\n" ); x = timeHandler; timeHandler = (thand_f *)0 ; (*x)();
@@ -515,10 +521,12 @@ restart: }eth_halt (); ret = NetBootFileXferSize; +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Success!\n" ); goto done;case NETLOOP_FAIL :net_cleanup_loop (); +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Fail!\n" ); goto done;case NETLOOP_CONTINUE :
@@ -606,6 +614,7 @@ rxhand_f *net_get_udp_handler(void)void net_set_udp_handler (rxhand_f *f) { +debug_cond (DEBUG_INT_STATE ,"--- NetLoop UDP handler set (%p)\n" , f);if (f ==NULL ) udp_packet_handler = dummy_handler;else
@@ -619,6 +628,7 @@ rxhand_f *net_get_arp_handler(void)void net_set_arp_handler (rxhand_f *f) { +debug_cond (DEBUG_INT_STATE ,"--- NetLoop ARP handler set (%p)\n" , f);if (f ==NULL ) arp_packet_handler = dummy_handler;else
@@ -636,8 +646,12 @@ void NetSetTimeout(ulong iv, thand_f *f) {if (iv ==0 ) { +debug_cond (DEBUG_INT_STATE , +"--- NetLoop timeout handler cancelled\n" ); timeHandler = (thand_f *)0 ; }else { +debug_cond (DEBUG_INT_STATE , +"--- NetLoop timeout handler set (%p)\n" , f); timeHandler = f; timeStart =get_timer (0 ); timeDelta = iv;
@@ -674,7 +688,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,/* if MAC address was not discovered yet, do an ARP request */ if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) { -debug ("sending ARP for %pI4\n" , &dest); +debug_cond (DEBUG_DEV_PKT ,"sending ARP for %pI4\n" , &dest);/* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest;
@@ -689,7 +703,8 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,ArpRequest ();return 1 ;/* waiting */ }else { -debug ("sending UDP to %pI4/%pM\n" , &dest, ether); +debug_cond (DEBUG_DEV_PKT ,"sending UDP to %pI4/%pM\n" , + &dest, ether);NetSendPacket (NetTxPacket, pkt_hdr_size + payload_len);return 0 ;/* transmitted */ }
@@ -912,7 +927,7 @@ NetReceive(uchar *inpkt, int len)#endif ushort cti =0 , vlanid =VLAN_NONE , myvlanid, mynvlanid; -debug ("packet received\n" ); +debug_cond (DEBUG_NET_PKT ,"packet received\n" ); NetRxPacket = inpkt; NetRxPacketLen = len;
@@ -943,8 +958,6 @@ NetReceive(uchar *inpkt, int len) eth_proto =ntohs (et->et_protlen); -debug ("packet received\n" ); -if (eth_proto <1514 ) {struct E802_hdr *et802 = (struct E802_hdr *)et;/*
@@ -964,7 +977,7 @@ NetReceive(uchar *inpkt, int len)struct VLAN_Ethernet_hdr *vet = (struct VLAN_Ethernet_hdr *)et; -debug ("VLAN packet received\n" ); +debug_cond (DEBUG_NET_PKT ,"VLAN packet received\n" );/* too small packet? */ if (len <VLAN_ETHER_HDR_SIZE )
@@ -986,7 +999,7 @@ NetReceive(uchar *inpkt, int len) len -=VLAN_ETHER_HDR_SIZE ; } -debug ("Receive from protocol 0x%x\n" , eth_proto); +debug_cond (DEBUG_NET_PKT ,"Receive from protocol 0x%x\n" , eth_proto);#if defined(CONFIG_CMD_CDP )if (iscdp) {
@@ -1015,7 +1028,7 @@ NetReceive(uchar *inpkt, int len)break ;#endif case PROT_IP : -debug ("Got IP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got IP\n" );/* Before we start poking the header, make sure it is there */ if (len <IP_UDP_HDR_SIZE ) { debug("len bad %d < %lu\n", len,
@@ -1024,11 +1037,12 @@ NetReceive(uchar *inpkt, int len) }/* Check the packet length */ if (len <ntohs (ip->ip_len)) { -printf ("len bad %d < %d\n" , len,ntohs (ip->ip_len)); +debug ("len bad %d < %d\n" , len,ntohs (ip->ip_len));return ; } len =ntohs (ip->ip_len); -debug ("len=%d, v=%02x\n" , len, ip->ip_hl_v &0xff ); +debug_cond (DEBUG_NET_PKT ,"len=%d, v=%02x\n" , + len, ip->ip_hl_v &0xff );/* Can't deal with anything except IPv4 */ if ((ip->ip_hl_v &0xf0 ) !=0x40 )
@@ -1038,7 +1052,7 @@ NetReceive(uchar *inpkt, int len)return ;/* Check the Checksum of the header */ if (!NetCksumOk ((uchar *)ip,IP_HDR_SIZE /2 )) { -puts ("checksum bad\n" ); +debug ("checksum bad\n" );return ; }/* If it is not for us, ignore it */
@@ -1087,6 +1101,10 @@ NetReceive(uchar *inpkt, int len)return ; } +debug_cond (DEBUG_DEV_PKT , +"received UDP (to=%pI4, from=%pI4, len=%d)\n" , + &dst_ip, &src_ip, len); +#ifdef CONFIG_UDP_CHECKSUM if (ip->udp_xsum !=0 ) {ulong xsum;
net/ping.c +2 -2
@@ -45,7 +45,7 @@ static int ping_send(void)/* XXX always send arp request */ -debug ("sending ARP for %pI4\n" , &NetPingIP); +debug_cond (DEBUG_DEV_PKT ,"sending ARP for %pI4\n" , &NetPingIP); NetArpWaitPacketIP = NetPingIP;
@@ -93,7 +93,7 @@ void ping_receive(struct Ethernet_hdr *et, struct IP_UDP_hdr *ip, int len)case ICMP_ECHO_REQUEST : eth_hdr_size =net_update_ether (et, et->et_src,PROT_IP ); -debug ("Got ICMP ECHO REQUEST, return " +debug_cond (DEBUG_DEV_PKT ,"Got ICMP ECHO REQUEST, return " "%d bytes\n" , eth_hdr_size + len); ip->ip_sum =0 ;
net/rarp.c +2 -2
@@ -45,7 +45,7 @@ void rarp_receive(struct IP_UDP_hdr *ip, unsigned len) {struct ARP_hdr *arp; -debug ("Got RARP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got RARP\n" ); arp = (struct ARP_hdr *)ip;if (len <ARP_HDR_SIZE ) {printf ("bad length %d < %d\n" , len,ARP_HDR_SIZE );
@@ -63,7 +63,7 @@ void rarp_receive(struct IP_UDP_hdr *ip, unsigned len)if (NetServerIP ==0 )NetCopyIP (&NetServerIP, &arp->ar_data[6 ]);memcpy (NetServerEther, &arp->ar_data[0 ],6 ); -debug ("Got good RARP\n" ); +debug_cond (DEBUG_DEV_PKT ,"Got good RARP\n" );net_auto_load (); } }
Signature · 1 line
1.6.0.2
PATCH v3 1/1 net: Allow filtering on debug traces in the net subsystem
Add several levels of DEBUG prints so that you can limit the noise to the severety of your problem.
DEBUG_LL_STATE = Link local state machine changes DEBUG_DEV_PKT = Packets or info directed to the device DEBUG_NET_PKT = Packets on info on the network at large DEBUG_INT_STATE = Internal network state changes
---
Changes for v2:
- Split from "Add link-local addressing support" patch-series
- This patch is dependant on "Add link-local addressing support" patch-series
- Knobs for enabling filters moved into net.h
Changes for v3:
- Rebased onto other changed patches
drivers/net/netconsole.c | 4 ++++ include/common.h | 14 +++++++------- include/net.h | 5 +++++ net/arp.c | 9 +++++---- net/link_local.c | 26 ++++++++++++++------------ net/net.c | 40 +++++++++++++++++++++++++++++----------- net/ping.c | 4 ++-- net/rarp.c | 4 ++-- 8 files changed, 68 insertions(+), 38 deletions(-)
drivers/net/netconsole.c +4 -0
@@ -83,6 +83,8 @@ int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len)if (dest != nc_port || !len)return 0 ;/* not for us */ +debug_cond (DEBUG_DEV_PKT ,"input: \"%*.*s\"\n" , len, len, pkt); +if (input_size ==sizeof (input_buffer))return 1 ;/* no space */ if (len >sizeof (input_buffer) - input_size)
@@ -112,6 +114,8 @@ static void nc_send_packet(const char *buf, int len)uchar *ether;IPaddr_t ip; +debug_cond (DEBUG_DEV_PKT ,"output: \"%*.*s\"\n" , len, len, buf); + eth =eth_get_dev ();if (eth ==NULL )return ;
include/common.h +7 -7
@@ -729,13 +729,6 @@ int gunzip(void *, int, unsigned char *, unsigned long *);int zunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp,int stoponerr,int offset); -/* lib/net_utils.c */ -#include <net.h> -static inline IPaddr_t getenv_IPaddr (char *var) -{ -return (string_to_ip (getenv (var))); -} -/* lib/qsort.c */ void qsort (void *base,size_t nmemb,size_t size,int (*compar)(const void *,const void *));
@@ -804,6 +797,13 @@ void fputc(int file, const char c);int ftstc (int file);int fgetc (int file); +/* lib/net_utils.c */ +#include <net.h> +static inline IPaddr_t getenv_IPaddr (char *var) +{ +return string_to_ip (getenv (var)); +} +/* * CONSOLE multiplexing. */
include/net.h +5 -0
@@ -19,6 +19,10 @@#include <asm/cache.h> #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ +#define DEBUG_LL_STATE 0/* Link local state machine changes */ +#define DEBUG_DEV_PKT 0/* Packets or info directed to the device */ +#define DEBUG_NET_PKT 0/* Packets on info on the network at large */ +#define DEBUG_INT_STATE 0/* Internal network state changes */ /* * The number of receive packet buffers, and the required packet buffer
@@ -480,6 +484,7 @@ static inline void net_set_state(enum net_loop_state state) {extern enum net_loop_state net_state; +debug_cond (DEBUG_INT_STATE ,"--- NetState set to %d\n" , state); net_state = state; }
net/arp.c +5 -4
@@ -55,7 +55,7 @@ void arp_raw_request(IPaddr_t sourceIP, const uchar *targetEther,struct arp_hdr *arp;int eth_hdr_size; -debug ("ARP broadcast %d\n" , NetArpWaitTry); +debug_cond (DEBUG_DEV_PKT ,"ARP broadcast %d\n" , NetArpWaitTry); pkt = NetArpTxPacket;
@@ -135,7 +135,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)* address; so if we receive such a packet, we set * the server ethernet address */ -debug ("Got ARP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got ARP\n" ); arp = (struct arp_hdr *)ip;if (len <ARP_HDR_SIZE ) {
@@ -160,7 +160,7 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)switch (ntohs (arp->ar_op)) {case ARPOP_REQUEST :/* reply with our IP address */ -debug ("Got ARP REQUEST, return our IP\n" ); +debug_cond (DEBUG_DEV_PKT ,"Got ARP REQUEST, return our IP\n" ); pkt = (uchar *)et; eth_hdr_size =net_update_ether (et, et->et_src,PROT_ARP ); pkt += eth_hdr_size;
@@ -203,7 +203,8 @@ void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)/* matched waiting packet's address */ if (reply_ip_addr == NetArpWaitReplyIP) { -debug ("Got ARP REPLY, set eth addr (%pM)\n" , +debug_cond (DEBUG_DEV_PKT , +"Got ARP REPLY, set eth addr (%pM)\n" , arp->ar_data);/* save address for later use */
net/link_local.c +14 -12
@@ -93,7 +93,7 @@ static void configure_wait(void)/* set deadline_ms to the point in time when we timeout */ deadline_ms =MONOTONIC_MS () + timeout_ms; -debug ("...wait %d %s nprobes=%u, nclaims=%u\n" , +debug_cond (DEBUG_DEV_PKT ,"...wait %d %s nprobes=%u, nclaims=%u\n" , timeout_ms,eth_get_name (), nprobes, nclaims);NetSetTimeout (timeout_ms, link_local_timeout);
@@ -131,7 +131,7 @@ static void link_local_timeout(void)have been received, so we can progress through the states */ if (nprobes <PROBE_NUM ) { nprobes++; -debug ("probe/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"probe/%u %s@%pI4\n" , nprobes,eth_get_name (), &ip);arp_raw_request (0 , NetEtherNullAddr, ip); timeout_ms =PROBE_MIN *1000 ;
@@ -140,7 +140,7 @@ static void link_local_timeout(void)/* Switch to announce state */ state =ANNOUNCE ; nclaims =0 ; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -152,7 +152,7 @@ static void link_local_timeout(void)to the announce state */ state =ANNOUNCE ; nclaims =0 ; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -163,7 +163,7 @@ static void link_local_timeout(void)the states */ if (nclaims <ANNOUNCE_NUM ) { nclaims++; -debug ("announce/%u %s@%pI4\n" , +debug_cond (DEBUG_LL_STATE ,"announce/%u %s@%pI4\n" , nclaims,eth_get_name (), &ip);arp_raw_request (ip, NetOurEther, ip); timeout_ms =ANNOUNCE_INTERVAL *1000 ;
@@ -216,10 +216,11 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)if ((int )(diff) <0 ) {/* Current time is greater than the expected timeout time. This should never happen */ -debug ("missed an expected timeout\n" ); +debug_cond (DEBUG_LL_STATE , +"missed an expected timeout\n" ); timeout_ms =0 ; }else { -debug ("adjusting timeout\n" ); +debug_cond (DEBUG_INT_STATE ,"adjusting timeout\n" ); timeout_ms = diff |1 ;/* never 0 */ } }
@@ -239,13 +240,13 @@ void link_local_receive_arp(struct arp_hdr *arp, int len)} */ -debug ("%s recv arp type=%d, op=%d,\n" , +debug_cond (DEBUG_INT_STATE ,"%s recv arp type=%d, op=%d,\n" ,eth_get_name (),ntohs (arp->ar_pro),ntohs (arp->ar_op)); -debug ("\tsource=%pM %pI4\n" , +debug_cond (DEBUG_INT_STATE ,"\tsource=%pM %pI4\n" , &arp->ar_sha, &arp->ar_spa); -debug ("\ttarget=%pM %pI4\n" , +debug_cond (DEBUG_INT_STATE ,"\ttarget=%pM %pI4\n" , &arp->ar_tha, &arp->ar_tpa);
@@ -271,8 +272,9 @@ void link_local_receive_arp(struct arp_hdr *arp, int len) target_ip_conflict =1 ; } -debug ("state = %d, source ip conflict = %d, target ip conflict = %d\n" , - state, source_ip_conflict, target_ip_conflict); +debug_cond (DEBUG_NET_PKT , +"state = %d, source ip conflict = %d, target ip conflict = " +"%d\n" , state, source_ip_conflict, target_ip_conflict);switch (state) {case PROBE :case ANNOUNCE :
net/net.c +29 -11
@@ -310,6 +310,7 @@ int NetLoop(enum proto_t protocol) NetRestarted =0 ; NetDevExists =0 ; NetTryCount =1 ; +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Entry\n" );bootstage_mark_name (BOOTSTAGE_ID_ETH_START ,"eth_start" );net_init ();
@@ -330,6 +331,7 @@ restart:* here on, this code is a state machine driven by received * packets and timer events. */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Init\n" );NetInitLoop ();switch (net_check_prereq (protocol)) {
@@ -460,6 +462,9 @@ restart:net_cleanup_loop ();eth_halt ();puts ("\nAbort\n" ); +/* include a debug print as well incase the debug +messages are directed to stderr */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Abort!\n" ); goto done; }
@@ -487,6 +492,7 @@ restart: }#endif /* CONFIG_SYS_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_MII, ... */ +debug_cond (DEBUG_INT_STATE ,"--- NetLoop timeout\n" ); x = timeHandler; timeHandler = (thand_f *)0 ; (*x)();
@@ -514,10 +520,12 @@ restart: }eth_halt (); ret = NetBootFileXferSize; +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Success!\n" ); goto done;case NETLOOP_FAIL :net_cleanup_loop (); +debug_cond (DEBUG_INT_STATE ,"--- NetLoop Fail!\n" ); goto done;case NETLOOP_CONTINUE :
@@ -605,6 +613,7 @@ rxhand_f *net_get_udp_handler(void)void net_set_udp_handler (rxhand_f *f) { +debug_cond (DEBUG_INT_STATE ,"--- NetLoop UDP handler set (%p)\n" , f);if (f ==NULL ) udp_packet_handler = dummy_handler;else
@@ -618,6 +627,7 @@ rxhand_f *net_get_arp_handler(void)void net_set_arp_handler (rxhand_f *f) { +debug_cond (DEBUG_INT_STATE ,"--- NetLoop ARP handler set (%p)\n" , f);if (f ==NULL ) arp_packet_handler = dummy_handler;else
@@ -635,8 +645,12 @@ void NetSetTimeout(ulong iv, thand_f *f) {if (iv ==0 ) { +debug_cond (DEBUG_INT_STATE , +"--- NetLoop timeout handler cancelled\n" ); timeHandler = (thand_f *)0 ; }else { +debug_cond (DEBUG_INT_STATE , +"--- NetLoop timeout handler set (%p)\n" , f); timeHandler = f; timeStart =get_timer (0 ); timeDelta = iv;
@@ -672,7 +686,7 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,/* if MAC address was not discovered yet, do an ARP request */ if (memcmp (ether, NetEtherNullAddr,6 ) ==0 ) { -debug ("sending ARP for %pI4\n" , &dest); +debug_cond (DEBUG_DEV_PKT ,"sending ARP for %pI4\n" , &dest);/* save the ip and eth addr for the packet to send after arp */ NetArpWaitPacketIP = dest;
@@ -687,7 +701,8 @@ int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport,ArpRequest ();return 1 ;/* waiting */ }else { -debug ("sending UDP to %pI4/%pM\n" , &dest, ether); +debug_cond (DEBUG_DEV_PKT ,"sending UDP to %pI4/%pM\n" , + &dest, ether);NetSendPacket (NetTxPacket, pkt_hdr_size + payload_len);return 0 ;/* transmitted */ }
@@ -910,7 +925,7 @@ NetReceive(uchar *inpkt, int len)#endif ushort cti =0 , vlanid =VLAN_NONE , myvlanid, mynvlanid; -debug ("packet received\n" ); +debug_cond (DEBUG_NET_PKT ,"packet received\n" ); NetRxPacket = inpkt; NetRxPacketLen = len;
@@ -941,8 +956,6 @@ NetReceive(uchar *inpkt, int len) eth_proto =ntohs (et->et_protlen); -debug ("packet received\n" ); -if (eth_proto <1514 ) {struct e802_hdr *et802 = (struct e802_hdr *)et;/*
@@ -962,7 +975,7 @@ NetReceive(uchar *inpkt, int len)struct vlan_ethernet_hdr *vet = (struct vlan_ethernet_hdr *)et; -debug ("VLAN packet received\n" ); +debug_cond (DEBUG_NET_PKT ,"VLAN packet received\n" );/* too small packet? */ if (len <VLAN_ETHER_HDR_SIZE )
@@ -984,7 +997,7 @@ NetReceive(uchar *inpkt, int len) len -=VLAN_ETHER_HDR_SIZE ; } -debug ("Receive from protocol 0x%x\n" , eth_proto); +debug_cond (DEBUG_NET_PKT ,"Receive from protocol 0x%x\n" , eth_proto);#if defined(CONFIG_CMD_CDP )if (iscdp) {
@@ -1013,7 +1026,7 @@ NetReceive(uchar *inpkt, int len)break ;#endif case PROT_IP : -debug ("Got IP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got IP\n" );/* Before we start poking the header, make sure it is there */ if (len <IP_UDP_HDR_SIZE ) { debug("len bad %d < %lu\n", len,
@@ -1022,11 +1035,12 @@ NetReceive(uchar *inpkt, int len) }/* Check the packet length */ if (len <ntohs (ip->ip_len)) { -printf ("len bad %d < %d\n" , len,ntohs (ip->ip_len)); +debug ("len bad %d < %d\n" , len,ntohs (ip->ip_len));return ; } len =ntohs (ip->ip_len); -debug ("len=%d, v=%02x\n" , len, ip->ip_hl_v &0xff ); +debug_cond (DEBUG_NET_PKT ,"len=%d, v=%02x\n" , + len, ip->ip_hl_v &0xff );/* Can't deal with anything except IPv4 */ if ((ip->ip_hl_v &0xf0 ) !=0x40 )
@@ -1036,7 +1050,7 @@ NetReceive(uchar *inpkt, int len)return ;/* Check the Checksum of the header */ if (!NetCksumOk ((uchar *)ip,IP_HDR_SIZE /2 )) { -puts ("checksum bad\n" ); +debug ("checksum bad\n" );return ; }/* If it is not for us, ignore it */
@@ -1085,6 +1099,10 @@ NetReceive(uchar *inpkt, int len)return ; } +debug_cond (DEBUG_DEV_PKT , +"received UDP (to=%pI4, from=%pI4, len=%d)\n" , + &dst_ip, &src_ip, len); +#ifdef CONFIG_UDP_CHECKSUM if (ip->udp_xsum !=0 ) {ulong xsum;
net/ping.c +2 -2
@@ -45,7 +45,7 @@ static int ping_send(void)/* XXX always send arp request */ -debug ("sending ARP for %pI4\n" , &NetPingIP); +debug_cond (DEBUG_DEV_PKT ,"sending ARP for %pI4\n" , &NetPingIP); NetArpWaitPacketIP = NetPingIP;
@@ -93,7 +93,7 @@ void ping_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)case ICMP_ECHO_REQUEST : eth_hdr_size =net_update_ether (et, et->et_src,PROT_IP ); -debug ("Got ICMP ECHO REQUEST, return " +debug_cond (DEBUG_DEV_PKT ,"Got ICMP ECHO REQUEST, return " "%d bytes\n" , eth_hdr_size + len); ip->ip_sum =0 ;
net/rarp.c +2 -2
@@ -45,7 +45,7 @@ void rarp_receive(struct ip_upd_hdr *ip, unsigned len) {struct arp_hdr *arp; -debug ("Got RARP\n" ); +debug_cond (DEBUG_NET_PKT ,"Got RARP\n" ); arp = (struct arp_hdr *)ip;if (len <ARP_HDR_SIZE ) {printf ("bad length %d < %d\n" , len,ARP_HDR_SIZE );
@@ -63,7 +63,7 @@ void rarp_receive(struct ip_upd_hdr *ip, unsigned len)if (NetServerIP ==0 )NetCopyIP (&NetServerIP, &arp->ar_data[6 ]);memcpy (NetServerEther, &arp->ar_data[0 ],6 ); -debug ("Got good RARP\n" ); +debug_cond (DEBUG_DEV_PKT ,"Got good RARP\n" );net_auto_load (); } }
Signature · 1 line
1.6.0.2
cover Add link-local addressing support
In reply to Joe HershbergerDear Joe Hershberger,
Quoted 290 lines
Link-local support allows the bootloader to get a usable network address regardless of network environment. Given that bootloaders may not always have access to a DHCP server, this functionality makes accessing it in those environments easier. It is also referred to as zero-configuration IP.
The following script allows the network to be configured for DHCP, link-local, and static IP addresses configurably by the environment using "dhcpenabled" and "linklocalenabled".
#define CONFIG_EXTRA_ENV_SETTINGS \ "ipconfigcmd=if test \\\"$dhcpenabled\\\" -ne 0;" \ "then " \ "dhcpfail=0;dhcp || dhcpfail=1;" \ "else " \ "dhcpfail=-1;" \ "fi;" \ "if test \\\"$linklocalenabled\\\" -ne 0 -a " \ "\\\"$dhcpfail\\\" -ne 0;" \ "then " \ "linklocal;" \ "llfail=0;" \ "else " \ "llfail=-1;" \ "fi;" \ "if test \\\"$llfail\\\" -ne 0 -a " \ "\\\"$dhcpfail\\\" -ne 0; " \ "then " \ "setenv ipaddr $sipaddr; " \ "setenv netmask $snetmask; " \ "setenv gatewayip $sgatewayip; " \ "fi;\0" \Some refactoring of
net/was done to make adding link-local support cleaner as well as generally improving the readability and organization of the code.Tested on
da850_am18xxevm
Tested onMPC8313ERDB_33check-patch
No warnings or errors (depends on ignoringCONSIDER_KSTRTO)MAKEALL -a powerpc
No additional warnings or errors beyond masterMAKEALL -a arm
No additional warnings or errors beyond mastergit-test-sequence
Cleanly bisectable
Code-size affects onMPC8313ERDB_33shown belowQuoted 1 line
cat sizeofMCP8313
make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes distclean >
/dev/null&& \ make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-MPC8313ERDB_33_config>/dev/null&& \
make BUILD_DIR=/tmp/u-boot-build/ ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- USE_PRIVATE_LIBGG=yes >/dev/null&& \
powerpc-linux-gnu-size/tmp/u-boot-build/u-bootQuoted 1 line
git-test-sequence origin/master.. './sizeofMCP8313'
Testing ./sizeofMCP8313
HEAD is now at 4dbe8d8 net: Remove volatile from all of net except the eth
driver interface text data bss dec hex filename
264917 24880 42104 331901 5107d/tmp/u-boot-build/ppc/u-boot
Passed:90ea672853753b5a4244db60d095e5f99cdcfe7d.
Testing ./sizeofMCP8313
HEAD is now at 92893c4 net: cosmetic: checkpatch compliance
text data bss dec hex filename
264917 24880 42104 331901 5107d/tmp/u-boot-build/ppc/u-boot
Passed:12b0b6e953406a1ed98d1c4dd9701078d1dfe00d.
Testing ./sizeofMCP8313
HEAD is now at d6c19a3 net: Movemv64x6x_eth_initialize()toboard_eth_init()text data bss dec hex filename
264917 24880 42104 331901 5107d/tmp/u-boot-build/ppc/u-boot
Passed:cf9f493ab5d08a282ec9905797fa58d82b15714d.
Testing ./sizeofMCP8313
HEAD is now at 52403e8 net: Make the MAC-seeded random number generator
available to /net text data bss dec hex filename
264917 24880 42104 331901 5107d/tmp/u-boot-build/ppc/u-boot
Passed:a92c9c9e8f68337a78ee2d7c6775299d7c057b52.
Testing ./sizeofMCP8313
HEAD is now at ff86c81 net: Move CDP out ofnet.c
text data bss dec hex filename
264917 24880 42104 331901 5107d/tmp/u-boot-build/ppc/u-boot
Passed:9bf01065cb04c34e43cc5d56162aa2dac9d61f3e.
Testing ./sizeofMCP8313
HEAD is now at da1998d net: Move ARP out ofnet.c
text data bss dec hex filename
265045 24928 42104 332077 5112d/tmp/u-boot-build/ppc/u-boot
Passed:621d67b8c6126ef6510d0a2b2c06ce410cd60327.
Testing ./sizeofMCP8313
HEAD is now at 408b8ab net: Move PING out ofnet.c
text data bss dec hex filename
265237 24976 42096 332309 51215/tmp/u-boot-build/ppc/u-boot
Passed:e8aaa7382de39137c91809ba2e121f87338627d5.
Testing ./sizeofMCP8313
HEAD is now at 1b3ed14 net: Move RARP receive logic out ofnet.c
text data bss dec hex filename
265237 24976 42096 332309 51215/tmp/u-boot-build/ppc/u-boot
Passed:7a8216874def295337178da67078758cbf909681.
Testing ./sizeofMCP8313
HEAD is now at 50eb857 net: cosmetic: Un-typedef variables in net
text data bss dec hex filename
265237 24976 42096 332309 51215/tmp/u-boot-build/ppc/u-boot
Passed:b679739af8ffc6f9a31264c175077f4ac96c236d.
Testing ./sizeofMCP8313
HEAD is now at 22259f9 net: cosmetic: Improve variable names and code
readability text data bss dec hex filename
265237 24976 42096 332309 51215/tmp/u-boot-build/ppc/u-boot
Passed:834a569897337636fe861797625fbdbbe1373f75.
Testing ./sizeofMCP8313
HEAD is now at 5340a18 net: Refactor IP, UPD, and ICMP header writing
functions text data bss dec hex filename
265237 24972 42096 332305 51211/tmp/u-boot-build/ppc/u-boot
Passed:20b84dcfa7d355010cacc3493e1e86521b00879f.
Testing ./sizeofMCP8313
HEAD is now at 275e230 net: Refactor packet length computations
text data bss dec hex filename
265221 24972 42096 332289 51201/tmp/u-boot-build/ppc/u-boot
Passed:d078d84d959dbb40a67baa16e8b0d210e6472c79.
Testing ./sizeofMCP8313
HEAD is now at c1214f2 net: Refactor bootp packet length computations
text data bss dec hex filename
265221 24972 42096 332289 51201/tmp/u-boot-build/ppc/u-boot
Passed:3ff5dfd46c8f70ec2304a150a606871b7504cf42.
Testing ./sizeofMCP8313
HEAD is now at 9cff376 net: Refactor ping recieve handler
text data bss dec hex filename
265093 24968 42096 332157 5117d/tmp/u-boot-build/ppc/u-boot
Passed:e531ec8d3986f45d30862eacce73b0db55e2fb13.
Testing ./sizeofMCP8313
HEAD is now at e47e5ac net: Refactor to callNetSendPacket()instead of
callingeth_send()text data bss dec hex filename
265093 24968 42096 332157 5117d/tmp/u-boot-build/ppc/u-boot
Passed:4a78d3ab2514c8d00bc18978f7a489a800a3a77b.
Testing ./sizeofMCP8313
HEAD is now at 9bcb672 net: Refactor to protect access to the NetState
variable text data bss dec hex filename
265109 24956 42096 332161 51181/tmp/u-boot-build/ppc/u-boot
Passed:8ecfa86d86fe2624cb509c41fbaec8dcf13a9945.
Testing ./sizeofMCP8313
HEAD is now at a2c79e3 net: Refactor to separate the UDP handler from the
ARP handler text data bss dec hex filename
265317 24956 42112 332385 51261/tmp/u-boot-build/ppc/u-boot
Passed:f66f88edda9ec16b3de20a10faa1c6bb35f316c2.
Testing ./sizeofMCP8313
HEAD is now at 502deaa net: AddNetUpdateEther()to handle ARP or Ping
replies (VLAN or SNAP) text data bss dec hex filename
265429 24952 42112 332493 512cd/tmp/u-boot-build/ppc/u-boot
Passed:3daff36dc0b5b65b8df7a3a7011f1e5f89eb5a9d.
Testing ./sizeofMCP8313
HEAD is now at 315bd4d net: Don't write the "serverip" env var if told not
to in the config text data bss dec hex filename
265429 24952 42112 332493 512cd/tmp/u-boot-build/ppc/u-boot
Passed:b0e7a73485c771eed710d6b9afd1e80e0ccc2cfa.
Testing ./sizeofMCP8313
HEAD is now at 82b1968 net: Fix compile warning ifCONFIG_BOOTP_SERVERIPis
not defined text data bss dec hex filename
265429 24952 42112 332493 512cd/tmp/u-boot-build/ppc/u-boot
Passed:121eb763232d5cf6a4e66f6c100713537f6036cf.
Testing ./sizeofMCP8313
HEAD is now at cebdefe net: Remove unneeded static allocation for MAC
address inPingSend()text data bss dec hex filename
265397 24944 42104 332445 5129d/tmp/u-boot-build/ppc/u-boot
Passed:1366a9b1529e9752dd4a47d7c82545b13e11b461.
Testing ./sizeofMCP8313
HEAD is now at 8f856ad net: Fix net buffer initialization
text data bss dec hex filename
265605 24956 42104 332665 51379/tmp/u-boot-build/ppc/u-boot
Passed:16cbef4189d5be4837c3de9dc2ac0bcf8d89fa75.
Testing ./sizeofMCP8313
HEAD is now at 002991b net: Refactor NetSendUDPPacket to share more code
text data bss dec hex filename
265557 24956 42104 332617 51349/tmp/u-boot-build/ppc/u-boot
Passed:7f001d4025dc564fe2a96a1e32214e194b891bd1.
Testing ./sizeofMCP8313
HEAD is now at 314902e net: Don't copy every packet that waits for an ARP
text data bss dec hex filename
265573 24956 42104 332633 51359/tmp/u-boot-build/ppc/u-boot
Passed:3be3cdd2224c88c88442e48c0f4f836d7be1d8ae.
Testing ./sizeofMCP8313
HEAD is now at 2a43805 net: Add optionCONFIG_BOOTP_CAN_FAIL
text data bss dec hex filename
265573 24956 42104 332633 51359/tmp/u-boot-build/ppc/u-boot
Passed:4d578ba84228e51a56249035207085f0845d3be8.
Testing ./sizeofMCP8313
HEAD is now at defb33c net: Add link-local addressing support
text data bss dec hex filename
265577 24956 42104 332637 5135d/tmp/u-boot-build/ppc/u-boot
Passed:cb6b29e82f292b5b27aec6f51f2f9d50e1f8b0f8.
Testing ./sizeofMCP8313
HEAD is now at 615c707 net: Work-around for brain-damaged Cisco routers
with arp-proxy text data bss dec hex filename
265657 24956 42104 332717 513ad/tmp/u-boot-build/ppc/u-boot
Passed:63a3ddaf7e029bb7ec71b1edb42473ae6a208dec.
Testing ./sizeofMCP8313
HEAD is now at 7d5229d net: Allow filtering on debug traces in the net
subsystem text data bss dec hex filename
265594 24948 42104 332646 51366/tmp/u-boot-build/ppc/u-boot
Passed:1cf14c686c5b60bfa48d8bfd6eb40e20ac0c378b.
All's well.Joe Hershberger (28):
net: Remove volatile from all of net except the eth driver interface
net: cosmetic: checkpatch compliance
net: Movemv64x6x_eth_initialize()toboard_eth_init()
net: Make the MAC-seeded random number generator available to /net
net: Move CDP out ofnet.c
net: Move ARP out ofnet.c
net: Move PING out ofnet.c
net: Move RARP receive logic out ofnet.c
net: cosmetic: Un-typedef variables in net
net: cosmetic: Improve variable names and code readability
net: Refactor IP, UPD, and ICMP header writing functions
net: Refactor packet length computations
net: Refactor bootp packet length computations
net: Refactor ping recieve handler
net: Refactor to callNetSendPacket()instead of callingeth_send()
net: Refactor to protect access to the NetState variable
net: Refactor to separate the UDP handler from the ARP handler
net: AddNetUpdateEther()to handle ARP or Ping replies (VLAN or
SNAP)
net: Don't write the "serverip" env var if told not to in the config
net: Fix compile warning ifCONFIG_BOOTP_SERVERIPis not defined
net: Remove unneeded static allocation for MAC address inPingSend()
net: Fix net buffer initialization
net: Refactor NetSendUDPPacket to share more code
net: Don't copy every packet that waits for an ARP
net: Add optionCONFIG_BOOTP_CAN_FAIL
net: Add link-local addressing support
net: Work-around for brain-damaged Cisco routers with arp-proxy
net: Allow filtering on debug traces in the net subsystemREADME | 22 +- arch/powerpc/cpu/mpc8260/ether_fcc.c | 10 +- arch/powerpc/cpu/mpc8xx/fec.c | 2 +- board/Marvell/db64360/db64360.c | 12 +- board/Marvell/db64360/mv_eth.c | 78 ++- board/Marvell/db64360/mv_eth.h | 63 +-- board/Marvell/db64460/db64460.c | 12 +- board/Marvell/db64460/mv_eth.c | 78 ++- board/Marvell/db64460/mv_eth.h | 63 +-- board/esd/cpci750/cpci750.c | 6 + board/esd/cpci750/mv_eth.c | 78 ++- board/esd/cpci750/mv_eth.h | 63 +-- board/prodrive/p3mx/mv_eth.c | 78 ++- board/prodrive/p3mx/mv_eth.h | 63 +-- board/prodrive/p3mx/p3mx.c | 6 + common/cmd_net.c | 34 +- common/main.c | 1 - drivers/net/netconsole.c | 130 ++-- include/common.h | 4 + include/configs/am3517_crane.h | 2 +- include/configs/am3517_evm.h | 2 +- include/configs/origen.h | 2 +- include/net.h | 206 ++++--- net/Makefile | 8 +- net/arp.c | 242 +++++++ net/arp.h | 30 + net/bootp.c | 435 ++++++------- net/bootp.h | 60 +- net/cdp.c | 372 +++++++++++ net/cdp.h | 18 + net/dns.c | 12 +- net/eth.c | 75 +-- net/link_local.c | 340 ++++++++++ net/link_local.h | 21 + net/net.c | 1152 +++++++++------------------------- net/net_rand.c | 68 ++ net/net_rand.h | 18 + net/nfs.c | 306 +++++----- net/nfs.h | 2 +- net/ping.c | 119 ++++ net/ping.h | 20 + net/rarp.c | 77 ++- net/rarp.h | 5 +- net/sntp.c | 37 +- net/sntp.h | 2 +- net/tftp.c | 50 +- net/tftp.h | 2 +- 47 files changed, 2625 insertions(+), 1861 deletions(-) create mode 100644 net/arp.c create mode 100644 net/arp.h
Quoted 9 lines
create mode 100644 net/cdp.c create mode 100644 net/cdp.h create mode 100644 net/link_local.c create mode 100644 net/link_local.h create mode 100644 net/net_rand.c create mode 100644 net/net_rand.h create mode 100644 net/ping.c create mode 100644 net/ping.h
is it correct you're the new network custodian in uboot?
cover Add link-local addressing support
Quoted 1 line · Marek Vasut
is it correct you're the new network custodian in uboot?
Yes, that is correct.
Joe
cover Add link-local addressing support
Dear Joe Hershberger,
Quoted 4 lines · Marek Vasut
Quoted 1 line
is it correct you're the new network custodian in uboot?
Yes, that is correct.
Hey, welcome abroad! :-)
btw. I reassigned most of the net patches in patchwork to you, hope you don't mind.
Quoted 2 lines
Joe
Best regards,
Marek Vasut
cover Add link-local addressing support
Quoted 11 lines · Marek Vasut
Dear Joe Hershberger,
Quoted 4 lines · Marek Vasut
Quoted 1 line
is it correct you're the new network custodian in uboot?
Yes, that is correct.
Hey, welcome abroad! :-)
btw. I reassigned most of the net patches in patchwork to you, hope you don't mind.
Don't mind at all. Quite the opposite actually. Thank you. Easier to find the patches to potentially merge.
Joe