[BusyBox-cvs] busybox/networking/udhcp arpping.c, 1.5, 1.6 arpping.h, 1.2, 1.3
Glenn McGrath
bug1 at busybox.net
Fri Mar 5 14:25:51 UTC 2004
Update of /var/cvs/busybox/networking/udhcp
In directory nail:/tmp/cvs-serv25606/networking/udhcp
Modified Files:
arpping.c arpping.h
Log Message:
Patch by Andrew Victor,
In arpping.h, fix structure alignment of "struct arpMsg".
GCC can insert padding in the structure which causes udhcpd to send an
invalid ARP packet on the network. It will then not receive a valid
reply, which can cause it to assign an IP address that's already in use
on the network.
(With kernels before 2.4.20, the "struct ethhdr" in linux/if_ether.h
wasn't marked as packed. This is also an issue if your toolchain was
built with a pre-2.4.20 kernel).
Index: arpping.h
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/arpping.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/arpping.h 30 Jan 2004 23:45:12 -0000 1.2
+++ b/arpping.h 5 Mar 2004 14:25:49 -0000 1.3
@@ -11,7 +11,12 @@
#include <netinet/in.h>
struct arpMsg {
- struct ethhdr ethhdr; /* Ethernet header */
+ /* Ethernet header */
+ u_char h_dest[6]; /* destination ether addr */
+ u_char h_source[6]; /* source ether addr */
+ u_short h_proto; /* packet type ID field */
+
+ /* ARP packet */
uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */
uint16_t ptype; /* protocol type (must be ETH_P_IP) */
uint8_t hlen; /* hardware address length (must be 6) */
@@ -22,7 +27,7 @@
uint8_t tHaddr[6]; /* target's hardware address */
uint8_t tInaddr[4]; /* target's IP address */
uint8_t pad[18]; /* pad for min. Ethernet payload (60 bytes) */
-};
+} __attribute__ ((packed));
/* function prototypes */
int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface);
Index: arpping.c
===================================================================
RCS file: /var/cvs/busybox/networking/udhcp/arpping.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/arpping.c 30 Jan 2004 23:45:12 -0000 1.5
+++ b/arpping.c 5 Mar 2004 14:25:49 -0000 1.6
@@ -60,9 +60,9 @@
/* send arp request */
memset(&arp, 0, sizeof(arp));
- memcpy(arp.ethhdr.h_dest, MAC_BCAST_ADDR, 6); /* MAC DA */
- memcpy(arp.ethhdr.h_source, mac, 6); /* MAC SA */
- arp.ethhdr.h_proto = htons(ETH_P_ARP); /* protocol type (Ethernet) */
+ memcpy(arp.h_dest, MAC_BCAST_ADDR, 6); /* MAC DA */
+ memcpy(arp.h_source, mac, 6); /* MAC SA */
+ arp.h_proto = htons(ETH_P_ARP); /* protocol type (Ethernet) */
arp.htype = htons(ARPHRD_ETHER); /* hardware type */
arp.ptype = htons(ETH_P_IP); /* protocol type (ARP message) */
arp.hlen = 6; /* hardware address length */
More information about the busybox-cvs
mailing list