Hello,
We are using kernel-level auto configuration in order to use udpcast
with a nfs root file system, however, the generic udpcast system still
tries to configure eth0 even though it is already configured. The patch
below will simply check whether eth0 is already configured, and if so
not do anything further (this is similar to the network driver module,
in that case it checked for a MAC address, now I check for an IP address).
unlike the mac check I don't actually return the mac, I simply return
whether there exists an ip.
I also included a trivial fix to the code checking for the mac addr, it
forgot to close sockfd in case of failure (which if abused seriously
could lead to the system running out of sockets but in the case of
udpcast this is probably not of any concern plus you have to *really*
abuse it).
===================== udpcast.kernelip.patch ===============
==--- busybox-0.60.5.orig/udpc_netconfig.c 2004-01-13
12:46:15.638629976 +0
200
+++ busybox-0.60.5.new/udpc_netconfig.c 2004-01-13 12:20:27.342006840 +0200
@@ -137,7 +137,9 @@
if(sockfd < 0)
return -1;
strcpy(ifc.ifr_name, ifname);
- if(ioctl(sockfd, SIOCGIFHWADDR, &ifc) < 0) {
+ if(ioctl(sockfd, SIOCGIFHWADDR, &ifc) < 0)
+ {
+ close(sockfd);
return -1;
}
close(sockfd);
@@ -151,6 +153,19 @@
return mac;
}
+bool udpc_hasIP(const char *ifname)
+{
+ struct ifreq ifc;
+ int res;
+ int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if(sockfd < 0)
+ return false;
+ strcpy(ifc.ifr_name, ifname);
+ res = ioctl(sockfd, SIOCGIFADDR, &ifc);
+ close(sockfd);
+ return !(res < 0);
+}
+
static int ipMacRead=0;
static int readIpMacFiles()
@@ -203,6 +218,8 @@
if(udpc_config.automatic != 1)
forceManual=1;
while(1) {
+ if(udpc_hasIP("eth0"))
+ return 0;
switch(step) {
case STEP_NETCFG+1:
if(setDoDhcp(forceManual) < 0)
===========================================================
Then I've also got another patch which simply improves the config file
reading, and was actually wondering why this wasn't done in the first place?
================== udpcast.whitespace.patch ===============
--- busybox-0.60.5.orig/udpc_conffile.c 2004-01-13 12:46:15.627631648 +0200
+++ busybox-0.60.5.new/udpc_conffile.c 2004-01-13 12:42:25.699586024 +0200
@@ -123,9 +123,8 @@
}
/* Skip leading spaces */
- while(*ptr == ' ' || *ptr == '\t') {
- ptr++;
- }
+ while(isspace(*ptr))
+ ptr++;
/* If this is a comment, skip it */
if(ptr[0] == '#') {
===========================================================
This will check for any leading whitespace and ignore it. This is just
a slightly more generic aproach.
Jaco