Browse Source

repair ifaddr ifconfig ifdown command bug for loongson3a-780e.we can't set ip address more than once using ifaddr command,ifconfig command

ping address failed in some situation,ifdown command will cause some bug using with ifup and ifaddr command.So we update the code.

Signed-off-by: xiaqichao <xiaqichao@ict.ac.cn>
master
sizhiying 13 years ago
committed by xiaqichao
parent
commit
6c2f84855f
  1. 10
      pmon/cmds/mycmd.c
  2. 3
      pmon/netio/ifconfig.c

10
pmon/cmds/mycmd.c

@ -1209,10 +1209,10 @@ int i;
break; break;
default: default:
while(ioctl(s, SIOCGIFADDR, ifra)==0) //while(ioctl(s, SIOCGIFADDR, ifra)==0)
{ //{
(void) ioctl(s, SIOCDIFADDR, ifr); //(void) ioctl(s, SIOCDIFADDR, ifr);
} //}
setsin (SIN(ifra->ifra_addr), AF_INET, inet_addr(argv[2])); setsin (SIN(ifra->ifra_addr), AF_INET, inet_addr(argv[2]));
(void) ioctl(s, SIOCSIFADDR, ifra); (void) ioctl(s, SIOCSIFADDR, ifra);
if(argc>=4) if(argc>=4)
@ -1239,7 +1239,7 @@ bzero (&ifr, sizeof(ifr));
strcpy(ifr.ifr_name,argv[1]); strcpy(ifr.ifr_name,argv[1]);
(void) ioctl(s, SIOCGIFADDR, &ifr); (void) ioctl(s, SIOCGIFADDR, &ifr);
printf("%s",inet_ntoa(satosin(&ifr.ifr_addr)->sin_addr)); printf("%s",inet_ntoa(satosin(&ifr.ifr_addr)->sin_addr));
(void) ioctl(s, SIOCDIFADDR, &ifr); //(void) ioctl(s, SIOCDIFADDR, &ifr);
ifr.ifr_flags=0; ifr.ifr_flags=0;
(void) ioctl(s,SIOCSIFFLAGS,(void *)&ifr); (void) ioctl(s,SIOCSIFFLAGS,(void *)&ifr);
close(s); close(s);

3
pmon/netio/ifconfig.c

@ -183,6 +183,7 @@ ifconfig (ifname, ipaddr)
local = *SAD(addreq.ifra_addr); local = *SAD(addreq.ifra_addr);
/* now set our actual address */ /* now set our actual address */
ioctl(s, SIOCSIFADDR, &addreq);
if (ioctl(s, SIOCAIFADDR, &addreq) < 0) { if (ioctl(s, SIOCAIFADDR, &addreq) < 0) {
/* Assume this means no network interface to attach to */ /* Assume this means no network interface to attach to */
fprintf (stderr, "\nNOTICE: No network interface available\n"); fprintf (stderr, "\nNOTICE: No network interface available\n");
@ -205,7 +206,7 @@ ifconfig (ifname, ipaddr)
perror("ioctl (SIOCAIFADDR) loopback"); perror("ioctl (SIOCAIFADDR) loopback");
close (s); close (s);
return(0); return(0);
} }
/* /*
* Now setup the routing tables, equivalent to: * Now setup the routing tables, equivalent to:

Loading…
Cancel
Save