NuttX provides the UDP_BINDTODEVICE socket option. This is a UDP protocol-specific implementation of the semi-standard Linux SO_BINDTODEVICE socket option: "SO_BINDTODEVICE forces packets on the socket to only egress the bound interface, regardless of what the IP routing table would normally choose. Similarly only packets which ingress the bound interface will be received on the socket, packets from other interfaces will not be delivered to the socket." https://codingrelic.geekhold.com/2009/10/code-snippet-sobindtodevice.html
If CONFIG_NET_UDP_BINDTODEVICE is selected and a UDP socket is bound to the device, then unrecognized packets UDP packets must not be dropped, but must be forwarded along to the bound socket unconditionally.
It the typical case, this should have no impact. It does effect the applications that use DHCP and do select the UDP_BINDTODEVICE socket option.
This PR replace existing improper logic in the code and also the improper attempts to fix problems from PR #3601 and PR #3598. Those changes are improper because they expose DHCP appliction dependencies in the OS, breaking modularity and independence of the OS and application.
Tested with stm32f4discovery:netnsh with CONFIG_NET_UDP_BINDTODEVICE. A proper DHCP test setup is needed, however.
Several licenses were missed in the initial work
David Sidrane has submitted the ICLA and we can migrate the licenses
to Apache.
Gregory Nutt has submitted the SGA and we can migrate the licenses
to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Summary:
- In arp_wait_setup() and arp_wait_cancel(), g_arp_waiters
is protected by a critical section.
- However, I noticed that arp_notify() does not protect the
g_arp_waiters that would cause memory corruption
- This commit fixes the issue.
Impact:
- None
Testing:
- Tested with spresense:rndis_smp, spresense:rndis
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Summary:
- In arp_send(), arp_wait_setup() adds a notify object to g_arp_waiters
which is removed in arp_wait() in normal case.
- However, in timeout and error cases, the object was not removed and
caused memory corruption.
- This commit fixes this issue.
Impact:
- None
Testing:
- Tested with spresense:rndis_smp
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
My recent changes to buffered tcp send broke this. [1]
One of my local apps using non-blocking tcp is working
again with this fix.
[1]
```
commit 837e1a72a4
Author: YAMAMOTO Takashi <yamamoto@midokura.com>
Date: Mon Mar 15 16:19:42 2021 +0900
tcp_send_buffered.c: improve tcp write buffering
```
reset the connection refcount if SYN retry count has elapsed
Assertion:
up_assert: Assertion failed at file:tcp/tcp_conn.c line: 764 task: netdev_wq
N/A
Signed-off-by: chao.an <anchao@xiaomi.com>
Add more sanity checks to avoid TCP moniter start fail if the
TCP handle unestablished, the dup(2) operation should work at any time
Signed-off-by: chao.an <anchao@xiaomi.com>
Forget to remove in:
commit e223f60c09
Author: Peter Bee <bijunda1@xiaomi.com>
Date: Tue Dec 1 14:55:16 2020 +0800
net/socket: move si_send/recv into sendmsg/recvmsg
Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Summary:
- Based on the discussion (PR#2772), let me revert the commit
Impact:
- None
Testing:
- N/A
This reverts commit ec8bf5c8c1.
Suggested-by: YAMAMOTO Takashi <yamamoto@midokura.com>
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.
Change-Id: I7b858556996e0862df22807a6edf6d7cfe6518fc
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
to avoid the user create socket under the real filesystem
which isn't supported by nuttx VFS yet.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib04c90e9c3c5a215bfda65515498d81e5f834895
this change to support receive the udp data from the specified
port without obtaining the address.
e.g: disable the Bootstrap flag on dhcpc handshake
Reference:
RFC1542: Clarifications and Extensions for the Bootstrap Protocol.
Signed-off-by: chao.an <anchao@xiaomi.com>
Summary:
- This commit adds DEBUGASSERT() to check the IOB size
Impact:
- None
Testing:
- Tested with sabre-6quad:netnsh with QEMU
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>