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. 1
      pmon/netio/ifconfig.c

10
pmon/cmds/mycmd.c

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

1
pmon/netio/ifconfig.c

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

Loading…
Cancel
Save