rtems_bsdnet_ifconfig issue on big endian platform

ruizx ruizx at qq.com
Thu Aug 22 01:33:23 UTC 2013


Hi all,
We find a issue in rtems_bsdnet_ifconfig function on bigendian platform.
It can be produced easily by using ifconfig shell to up/down a net adapter.
The root cause is convert variable type from int(32bit) to short(16bit) directly by memory address, like "*((short*) param)"
The result is correct on little endian platform while error on big endian platform.
Please notice.

  case SIOCGIFFLAGS:
  case SIOCSIFFLAGS:
   if ((r = ioctl (s, SIOCGIFFLAGS, &ifreq)) < 0)
    break;
   if (cmd == SIOCGIFFLAGS) {
    *((short*) param) = ifreq.ifr_flags;//can not use memory address directly
    break;
   }
   ifreq.ifr_flags |= *((short*) param);
   if ( (*((short*) param) & IFF_UP ) == 0 ) {
       /* set the interface down */
       ifreq.ifr_flags &= ~(IFF_UP);
   }
   r = ioctl (s, SIOCSIFFLAGS, &ifreq);
   break;

Thanks & Best regards,
Rui Zhengxin




More information about the users mailing list