apache / nuttx

Apache NuttX is a mature, real-time embedded operating system (RTOS)
https://nuttx.apache.org/
Apache License 2.0
2.88k stars 1.17k forks source link

Network address was changed unexpectedly #4845

Open SPRESENSE opened 3 years ago

SPRESENSE commented 3 years ago

When connecting to a network with a device such as gs2200m (eth0), if you try to change the address of the appropriate interface device name (e.g., hoge0) in ifconfig, the network address of eth0 will be changed.

Is this behavior correct? ifconfig

Thank you very much in advance.

acassis commented 3 years ago

No, it is not a feature, it is a bug! :-D

gustavonihei commented 2 years ago

This might be related to the usage of USRSOCK component.

netlib does not perform any validation on the interface name before requesting the IP change to the network stack. https://github.com/apache/incubator-nuttx-apps/blob/master/netutils/netlib/netlib_setipv4addr.c#L66

When USRSOCK is enabled, the NuttX netstack is bypassed and the handling of the SIOCSIFADDR ioctl command is delegated to the USRSOCK daemon, which in this case is gs2200m. So, in the current state, it is up to the device driver connected via USRSOCK to do the right processing, similar to what netdev does: https://github.com/apache/incubator-nuttx/blob/master/net/netdev/netdev_ioctl.c#L605-L617

So, most probably the issue is that GS2200m is simply setting the IP regardless of the interface name being set: https://github.com/apache/incubator-nuttx/blob/master/drivers/wireless/gs2200m.c#L2857-L2861