aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-10-20 22:26:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-20 22:26:38 +0200
commit5d374e9b148b85954816e9f79e4be160ed3054bd (patch)
treecdcd9a32b0313935d3a3668810ecefe194cb179b /networking/udhcp
parentc72c1d7b317ecd7dc93bae86ad24e40402b9a2d1 (diff)
downloadbusybox-w32-5d374e9b148b85954816e9f79e4be160ed3054bd.tar.gz
busybox-w32-5d374e9b148b85954816e9f79e4be160ed3054bd.tar.bz2
busybox-w32-5d374e9b148b85954816e9f79e4be160ed3054bd.zip
udhcpc: exit if iface disappeared; use correct MAC if it changes
function old new delta udhcpc_main 2560 2618 +58 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/dhcpc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 7b679d10f..cef0ab957 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -928,6 +928,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
928 uint8_t *temp, *message; 928 uint8_t *temp, *message;
929 const char *str_V, *str_h, *str_F, *str_r; 929 const char *str_V, *str_h, *str_F, *str_r;
930 IF_FEATURE_UDHCP_PORT(char *str_P;) 930 IF_FEATURE_UDHCP_PORT(char *str_P;)
931 void *clientid_mac_ptr;
931 llist_t *list_O = NULL; 932 llist_t *list_O = NULL;
932 llist_t *list_x = NULL; 933 llist_t *list_x = NULL;
933 int tryagain_timeout = 20; 934 int tryagain_timeout = 20;
@@ -1004,7 +1005,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1004 IF_FEATURE_UDHCP_PORT( OPT_P = 1 << OPTBIT_P,) 1005 IF_FEATURE_UDHCP_PORT( OPT_P = 1 << OPTBIT_P,)
1005 }; 1006 };
1006 1007
1007 /* Default options. */ 1008 /* Default options */
1008 IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) 1009 IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;)
1009 IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) 1010 IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;)
1010 client_config.interface = "eth0"; 1011 client_config.interface = "eth0";
@@ -1086,11 +1087,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1086 return 1; 1087 return 1;
1087 } 1088 }
1088 1089
1090 clientid_mac_ptr = NULL;
1089 if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, DHCP_CLIENT_ID)) { 1091 if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, DHCP_CLIENT_ID)) {
1090 /* not suppressed and not set, set the default client ID */ 1092 /* not suppressed and not set, set the default client ID */
1091 client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, "", 7); 1093 client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, "", 7);
1092 client_config.clientid[OPT_DATA] = 1; /* type: ethernet */ 1094 client_config.clientid[OPT_DATA] = 1; /* type: ethernet */
1093 memcpy(client_config.clientid + OPT_DATA+1, client_config.client_mac, 6); 1095 clientid_mac_ptr = client_config.clientid + OPT_DATA+1;
1096 memcpy(clientid_mac_ptr, client_config.client_mac, 6);
1094 } 1097 }
1095 if (str_V[0] != '\0') 1098 if (str_V[0] != '\0')
1096 client_config.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0); 1099 client_config.vendorclass = alloc_dhcp_option(DHCP_VENDOR, str_V, 0);
@@ -1173,10 +1176,15 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1173 * or if the status of the bridge changed). 1176 * or if the status of the bridge changed).
1174 * Refresh ifindex and client_mac: 1177 * Refresh ifindex and client_mac:
1175 */ 1178 */
1176 udhcp_read_interface(client_config.interface, 1179 if (udhcp_read_interface(client_config.interface,
1177 &client_config.ifindex, 1180 &client_config.ifindex,
1178 NULL, 1181 NULL,
1179 client_config.client_mac); 1182 client_config.client_mac)
1183 ) {
1184 return 1; /* iface is gone? */
1185 }
1186 if (clientid_mac_ptr)
1187 memcpy(clientid_mac_ptr, client_config.client_mac, 6);
1180 1188
1181 /* We will restart the wait in any case */ 1189 /* We will restart the wait in any case */
1182 already_waited_sec = 0; 1190 already_waited_sec = 0;