Commit Graph

75 Commits

Author SHA1 Message Date
Michael Jung f208c4bbd4 Fix ENOENT errors when polling on Netlink socket
When a Netlink response is issued, which a task is currently polling for
on the corresponding AF_NETLINK socket, then the poll call will return
with a ENOENT error.  This is due to the fact that the Netlink response
notifier is automatically torn down after the notification.

Fixed by making netlink_notifier_teardown a best-effort function that
does not return a result code.

Signed-off-by: Michael Jung <michael.jung@secore.ly>
2022-05-14 00:35:29 +03:00
hejianliang3 e9648d8a73 net:fix coverity warning
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
Xiang Xiao 7598070508 net: Remove the unnecessary initialization code
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-12 19:24:17 +02:00
chao.an 99cde13a11 net/inet: move socket flags into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an 69c4f6651e net/netlink: replace the common connect prologue
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an a9d0dd7051 net/netlink: fix build warning if disable CONFIG_NETLINK_ROUTE
netlink/netlink_sockif.c: In function ‘netlink_sendmsg’:
netlink/netlink_sockif.c:676:10: warning: unused variable ‘len’ [-Wunused-variable]
  676 |   size_t len = msg->msg_iov->iov_len;
      |          ^~~

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-17 13:34:49 +08:00
chao.an 504f1d1b5f net/misc: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-04 14:36:07 +08:00
Virus.V 94f45d5c06 netlink: fix compile error when enable netlink
Signed-off-by: Virus.V <virusv@live.com>
2021-07-01 06:55:57 -05:00
Peter Bee e223f60c09 net/socket: move si_send/recv into sendmsg/recvmsg
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>
2021-03-05 04:46:13 -08:00
Alin Jerpelea 37d5c1b0d9 net: Author Gregory Nutt: update 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>
2021-02-20 00:38:18 -08:00
Xiang Xiao 0536953ded Kernel module should prefer functions with nx/kmm prefix
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-13 08:57:58 +01:00
Juha Niskanen de1ad1fdb3 net: fix typos, incorrect comments, nxstyle
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-13 09:06:28 -06:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Gregory Nutt a569006fd8 sched/: Make more naming consistent
Rename various functions per the quidelines of https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions

    nxsem_setprotocol -> nxsem_set_protocol
    nxsem_getprotocol -> nxsem_get_protocol
    nxsem_getvalue -> nxsem_get_value
2020-05-17 14:01:00 -03:00
chao.an 10acadb64b netlink: add netlink route notify support 2020-04-16 11:49:53 -06:00
Xiang Xiao 6f1c86d934 netlink: Fix the compiler warning in netlink_add_broadcast
netlink/netlink_conn.c: In function 'netlink_add_broadcast':
netlink/netlink_conn.c:319:45: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
  319 |       if (conn->groups & (1 << (group - 1)) == 0)
      |                          ~~~~~~~~~~~~~~~~~~~^~~~
2020-04-16 11:49:40 -06:00
Xiang Xiao bd39813883 netlink: Add netlink_add_broadcast function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I1bee7933dca1bdd118d0034a564b4306e1ae5684
2020-04-16 17:40:03 +08:00
chao.an 755265506c netlink: replace the operation handle to connection
Change-Id: Ie55d65823fe7eb7e917349c095cf8fd4f6326e8f
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-04-16 17:39:37 +08:00
chao.an 16c0c61e3e netlink/route: reuse response terminator
Change-Id: I19c3d97b088231d96909d415d286c728ffe83881
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-04-16 17:39:06 +08:00
chao.an 85dce03d22 netlink/route: remove domain check
Change-Id: I965788c3bd2e6bfa41048b87d8c26f111f61c48e
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-04-16 17:39:06 +08:00
Xiang Xiao 581dbb22fe netlink: Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao 369a0fa4fb netlink: all request to NETLINK_ROUTE should use rtgenmsg
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib7a05dbf08277f56882e19a886a12a153889ca38
2020-04-10 08:18:07 -06:00
Xiang Xiao 70012bc4a2 netlink: Remove netlink_route_recvfrom
The same functionality could be implemented in the common place(netlink_recvfrom)

Change-Id: I8aedb29c4f0572f020ca5c0775f06c5e1e17ae4a
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao 16dbe373c0 netlink: Implement netlink_connect and netlink_getpeername
and refine netlink_bind and netlink_send implmentation

Change-Id: I2b3e7980eac01dc42927cfaa0a64874df52d6bf5
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao 5708015674 netlink: Sync the macro with Linux definition
Change-Id: I0c0895fa17e167c67fb12acfdfc6dc3a7fb63b3b
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao e6c30629a1 netlink: Return -EBUSY if some notifier was setup in netlink_notifier_setup
Change-Id: I62d036bb43420934efbf0e9b990ca2cf3dd0b2e5
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao 3421ec90b4 netlink: Shouldn't call netlink_notify_response in netlink_poll
to avoid sleep inside netlink_poll

Change-Id: Id801c2dae805455a9b91f2e091d001679f0b3d4b
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
Xiang Xiao 9fb6eee5fe netlink: Remove the unused netlink_active
Change-Id: I976b3fbab033baa4eaec35f8f443d4eb971db142
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-10 08:18:07 -06:00
chao.an 42d97079de net/netlink/netlink_route.c: Correct the return value 2020-02-25 07:33:18 -06:00
Xiang Xiao cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
Xiang Xiao bd4e8e19d3 Run codespell -w against all files
and fix the wrong correction
2020-02-22 14:45:07 -06:00
chao.an c65d8e6a23 net/socket: add MSG_DONTWAIT support
MSG_DONTWAIT (since Linux 2.2)
  Enables nonblocking operation; if the operation would block, the
  call fails with the error EAGAIN or EWOULDBLOCK. This provides
  similar behavior to setting the O_NONBLOCK flag (via the fcntl(2)
  F_SETFL operation), but differs in that MSG_DONTWAIT is a per-call
  option, whereas O_NONBLOCK is a setting on the open file description
  (see open(2)), which will affect all threads in the calling process
  and as well as other processes that hold file descriptors referring
  to the same open file description.
2020-02-19 12:21:28 -06:00
Gregory Nutt 0b25b96759 net/netlink/netlink_route.c: Fix a typo. 2020-02-13 15:04:45 -03:00
Xiang Xiao 5c80b94820 Replace #include <semaphore.h> to #include <nuttx/semaphore.h>
Since the kernel side should call nxsem_xxx instead and remove the unused inclusion
2020-02-01 08:27:30 -06:00
Xiang Xiao 6e6c670190 Move _SF_BOUND and _SF_CONNECTED modification to common place 2020-01-31 13:45:14 -06:00
Xiang Xiao 68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
chao.an a4aa8ae491 wqueue/notifier: update the work notifier usage
usage changed after commit 90c52e6f8f

Change-Id: Ifb0d739b046a6794b5b3ac177f489fb9a1c5c799
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-01-21 14:16:19 +08:00
Xiang Xiao 6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Gregory Nutt 16b1c276bd net/netlink/netlink_conn.c: Fix some really basic errors in the redesign of the asynchronous Netlink response logic. 2019-11-28 16:14:59 -06:00
Gregory Nutt 4ae09a3b80 net/netlink: Redesign the logic that handles notifications of when response data is available. Signal handlers are sub-optimal inside the OS (especially after the preceding change which forces the hand). Instead, use the work queue notifiers as is done with all other network notifiers. 2019-11-28 14:20:40 -06:00
Gregory Nutt 69318b1024 Re-implements reverted commit 344f7bc9f6 in a way that should not have the undesired side-effect. include/nuttx/sched.h: Add a bit to the TCB flags to indicat the thread is a user thread in a syscall. sched/nuttx/nxsig_dispatch.c: Delay dispatching to signal handlers if within a system call. In all syscall implementations: Process delayed signal handling when exiting system call. 2019-11-28 12:47:36 -06:00
Gregory Nutt cbdd590c82 Revert "include/nuttx/sched.h: Add storage for a previous signal mask. arch/: In all syscall implementations, block all signals before dispatching a system call; resotre signal mask when the system call returns."
Using the sigprocmask() for this purpose has too many side-effects.

This reverts commit 344f7bc9f6.
2019-11-28 11:57:54 -06:00
Gregory Nutt 344f7bc9f6 include/nuttx/sched.h: Add storage for a previous signal mask. arch/: In all syscall implemenations, block all signals before dispatching a system call; resotre signal mask when the system call returnes. 2019-11-28 10:51:29 -06:00
Gregory Nutt d1593bb336 Squashed commit of the following:
net/netlink/netlink_sockif.c:  At implementation of response available signal handler needed for POLLIN logic.
    net/netlink/netlink_sockif.c:  Add logic to set up signal handler to receive the response notification.
2019-11-27 21:30:01 -06:00
Gregory Nutt a8f3c3651a net/netlink/netlink_conn.c: Use nxsig_queue() instead of nxsig_kill() so that we can pass a reference to the connection structure with the signal. 2019-11-27 19:31:23 -06:00
Gregory Nutt 93ed8b66d9 net/netlink: Add partial support for the NETLINK poll() operation. Still missing is some signal handling logic that actually wakes up the poll() when an asynchronous NETLLINK response is available.
So although the poll() implemenation is still not yet usable, the commit is useful because it (1) does not harm, and (2) incidentally fixes a few other issues in the NETLONK response queuing that I noted in the process.
2019-11-26 18:52:22 -06:00
Gregory Nutt bc8d964cb9 net/netlink: Add some comments about 'Input Parameters' 2019-11-19 20:46:43 -06:00
Gregory Nutt b72f7cf47f net/netlink/netlink_route.c: Fix a case where #if was used but #ifdef was intended. 2019-11-19 09:47:57 -06:00
Gregory Nutt b659c74440 net/netlink/netlink_sockif.c: Netlink sockets may be set to non-blocking. 2019-11-19 07:50:46 -06:00
Gregory Nutt 936d69da1f net/netlink and include/nuttx/net/netlink.h: Make netlink_add_response() a globally access part of the network interface. This is necesssary to support netlink components that reside outside of the net/ sandbox. 2019-11-18 21:12:50 -06:00