[U-Boot] [PATCH 21/28] net: Remove unneeded static allocation for MAC address in PingSend()

Joe Hershberger joe.hershberger at ni.com
Fri Jan 20 01:53:24 CET 2012


Don't force ARP clients to return the MAC address if they don't
   care about it (such as ping)

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
Cc: Wolfgang Denk <wd at denx.de>
---
 net/arp.c  |    9 +++++----
 net/ping.c |   10 +++-------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/net/arp.c b/net/arp.c
index 8c3557b..b3be0a6 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -170,7 +170,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *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,8 +189,9 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *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);
 
 			if (NetGetARPHandler() != NULL)
 				NetGetARPHandler()((uchar *)arp, 0,
@@ -198,7 +199,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len)
 
 			/* modify header, and transmit it */
 			memcpy(((struct Ethernet_t *)NetArpWaitTxPacket)->
-				et_dest, NetArpWaitPacketMAC, ARP_HLEN);
+				et_dest, &arp->ar_sha, ARP_HLEN);
 			NetSendPacket(NetArpWaitTxPacket,
 					NetArpWaitTxPacketSize);
 
diff --git a/net/ping.c b/net/ping.c
index 913506b..687c5aa 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -40,22 +40,18 @@ static void SetICMPHeader(uchar *pkt, IPaddr_t dest)
 
 static int PingSend(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;
 
 	SetICMPHeader(pkt, NetPingIP);
 
-- 
1.6.0.2



More information about the U-Boot mailing list