From: Felix Fietkau Date: Thu, 9 Nov 2006 23:41:50 +0000 (+0000) Subject: add support for -t 0 (infinite retry) in busybox udhcpc and use it in the network... X-Git-Tag: whiterussian_0.9~86 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6b8e8dcb982dff3ce15f57758ba7a386ef5e6606;p=openwrt%2Fsvn-archive%2Fopenwrt.git add support for -t 0 (infinite retry) in busybox udhcpc and use it in the network scripts SVN-Revision: 5493 --- diff --git a/openwrt/package/base-files/default/etc/functions.sh b/openwrt/package/base-files/default/etc/functions.sh index fd0bc64711..55464f72a0 100755 --- a/openwrt/package/base-files/default/etc/functions.sh +++ b/openwrt/package/base-files/default/etc/functions.sh @@ -75,7 +75,7 @@ do_ifup() { mtu=$(nvram get ${2}_mtu) $DEBUG ifconfig $if $DHCP_IP ${DHCP_NETMASK:+netmask $DHCP_NETMASK} ${mtu:+mtu $(($mtu))} broadcast + up - DHCP_ARGS="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile" + DHCP_ARGS="-i $if ${DHCP_IP:+-r $DHCP_IP} -b -p $pidfile -t 0" DHCP_HOSTNAME=$(nvram get ${2}_hostname) DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*} [ -z $DHCP_HOSTNAME ] || DHCP_ARGS="$DHCP_ARGS -H $DHCP_HOSTNAME" diff --git a/openwrt/package/busybox/patches/240-udhcpc_retries.patch b/openwrt/package/busybox/patches/240-udhcpc_retries.patch new file mode 100644 index 0000000000..0666cc437d --- /dev/null +++ b/openwrt/package/busybox/patches/240-udhcpc_retries.patch @@ -0,0 +1,74 @@ +diff -ur busybox.old/networking/udhcp/dhcpc.c busybox.dev/networking/udhcp/dhcpc.c +--- busybox.old/networking/udhcp/dhcpc.c 2006-11-10 00:20:17.000000000 +0100 ++++ busybox.dev/networking/udhcp/dhcpc.c 2006-11-10 00:27:52.000000000 +0100 +@@ -69,6 +69,7 @@ + clientid: NULL, + hostname: NULL, + ifindex: 0, ++ retries: 3, + arp: "\0\0\0\0\0\0", /* appease gcc-3.0 */ + }; + +@@ -92,6 +93,7 @@ + " -r, --request=IP IP address to request (default: none)\n" + " -s, --script=file Run file at dhcp events (default:\n" + " " DEFAULT_SCRIPT ")\n" ++" -t, --retries Maximum retries\n" + " -v, --version Display version\n" + ); + exit(0); +@@ -208,13 +210,14 @@ + {"request", required_argument, 0, 'r'}, + {"script", required_argument, 0, 's'}, + {"version", no_argument, 0, 'v'}, ++ {"retries", required_argument, 0, 't'}, + {0, 0, 0, 0} + }; + + /* get options */ + while (1) { + int option_index = 0; +- c = getopt_long(argc, argv, "c:fbH:h:i:np:qRr:s:v", arg_options, &option_index); ++ c = getopt_long(argc, argv, "c:fbH:h:i:np:qRr:s:t:v", arg_options, &option_index); + if (c == -1) break; + + switch (c) { +@@ -263,6 +266,9 @@ + case 's': + client_config.script = optarg; + break; ++ case 't': ++ client_config.retries = atoi(optarg); ++ break; + case 'v': + printf("udhcpcd, version %s\n\n", VERSION); + return 0; +@@ -321,7 +327,7 @@ + /* timeout dropped to zero */ + switch (state) { + case INIT_SELECTING: +- if (packet_num < 3) { ++ if (!client_config.retries || (packet_num < client_config.retries)) { + if (packet_num == 0) + xid = random_xid(); + +@@ -346,7 +352,7 @@ + break; + case RENEW_REQUESTED: + case REQUESTING: +- if (packet_num < 3) { ++ if (!client_config.retries || (packet_num < client_config.retries)) { + /* send request packet */ + if (state == RENEW_REQUESTED) + send_renew(xid, server_addr, requested_ip); /* unicast */ +diff -ur busybox.old/networking/udhcp/dhcpc.h busybox.dev/networking/udhcp/dhcpc.h +--- busybox.old/networking/udhcp/dhcpc.h 2006-11-10 00:20:17.000000000 +0100 ++++ busybox.dev/networking/udhcp/dhcpc.h 2006-11-10 00:24:04.000000000 +0100 +@@ -30,6 +30,7 @@ + uint8_t *hostname; /* Optional hostname to use */ + int ifindex; /* Index number of the interface to use */ + uint8_t arp[6]; /* Our arp address */ ++ int retries; /* Maximum retries */ + }; + + extern struct client_config_t client_config;