aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-13 09:02:16 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-13 09:02:16 +0000
commit8b08bda66b899cde8fae05fc6f76a18a62a25400 (patch)
treed1e58bc905039e8f69340d32cf662a44b4d7a406
parent25fe94fd32f39a76294456a7bc7b8dd0595afb0d (diff)
downloadbusybox-w32-8b08bda66b899cde8fae05fc6f76a18a62a25400.tar.gz
busybox-w32-8b08bda66b899cde8fae05fc6f76a18a62a25400.tar.bz2
busybox-w32-8b08bda66b899cde8fae05fc6f76a18a62a25400.zip
Fix bug when reading mac from command line, continue; if hwaddrr not found
-rw-r--r--networking/nameif.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/networking/nameif.c b/networking/nameif.c
index 1edd64111..4b2d090ca 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -67,7 +67,7 @@ static void serror_msg_and_die(const char use_syslog, const char *s, ...)
67 } 67 }
68 68
69 va_end(ap); 69 va_end(ap);
70 70
71 exit(EXIT_FAILURE); 71 exit(EXIT_FAILURE);
72} 72}
73 73
@@ -121,7 +121,7 @@ int nameif_main(int argc, char **argv)
121 ch = xcalloc(1, sizeof(mactable_t)); 121 ch = xcalloc(1, sizeof(mactable_t));
122 ch->ifname = strdup(argv[optind - 1]); 122 ch->ifname = strdup(argv[optind - 1]);
123 ch->mac = xcalloc(1, ETH_ALEN); 123 ch->mac = xcalloc(1, ETH_ALEN);
124 memcpy(ch->mac, &mac, ETH_ALEN); 124 memcpy(ch->mac, mac, ETH_ALEN);
125 optind++; 125 optind++;
126 if (clist) 126 if (clist)
127 clist->pprev = &ch->next; 127 clist->pprev = &ch->next;
@@ -186,7 +186,8 @@ int nameif_main(int argc, char **argv)
186 memset(&ifr, 0, sizeof(struct ifreq)); 186 memset(&ifr, 0, sizeof(struct ifreq));
187 strncpy(ifr.ifr_name, line_ptr, iface_name_length); 187 strncpy(ifr.ifr_name, line_ptr, iface_name_length);
188 if (ioctl(ctl_sk, SIOCGIFHWADDR, &ifr) < 0) { 188 if (ioctl(ctl_sk, SIOCGIFHWADDR, &ifr) < 0) {
189 serror_msg_and_die(use_syslog, "cannot change name of %s to %s: %s", ifr.ifr_name, ch->ifname, strerror(errno)); 189// serror_msg(use_syslog, "cannot read hardware address of %s: %s", ifr.ifr_name, strerror(errno));
190 continue;
190 } 191 }
191 for (ch = clist; ch; ch = ch->next) 192 for (ch = clist; ch; ch = ch->next)
192 if (!memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN)) 193 if (!memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN))
@@ -194,6 +195,7 @@ int nameif_main(int argc, char **argv)
194 if (ch == NULL) { 195 if (ch == NULL) {
195 continue; 196 continue;
196 } 197 }
198
197 strcpy(ifr.ifr_newname, ch->ifname); 199 strcpy(ifr.ifr_newname, ch->ifname);
198 200
199 if (ioctl(ctl_sk, SIOCSIFNAME, &ifr) < 0) {; 201 if (ioctl(ctl_sk, SIOCSIFNAME, &ifr) < 0) {;