Commit Graph

148 Commits

Author SHA1 Message Date
Norman Rasmussen 48311cc61f Fix unaligned memory access when creating ICMP Port Unreachable messages
commit 3b69d09c80 corrected the
unreachable handling for net/udp/icmp but introduced an unaligned store.
This splits the uint32_t data field into a two element uint16_t data
field to avoid the unaligned store.
2021-12-28 03:51:53 -06:00
chao.an 3b69d09c80 net/udp/icmp: correct the unreadchable handling
Reference RFC1122:
https://datatracker.ietf.org/doc/html/rfc1122
----------------------------------------------

4.1.3  SPECIFIC ISSUES

  4.1.3.1  Ports

    If a datagram arrives addressed to a UDP port for which
    there is no pending LISTEN call, UDP SHOULD send an ICMP
    Port Unreachable message.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-26 08:47:54 -06:00
Alexander Lunev 1e25602678 net/can,icmp,icmpv6,tcp,tcp_timer,udp: device should poll only those connections that are bound to the device.
tcp_timer: eliminated false decrements of conn->timer in case of multiple network adapters.
The false timer decrements sometimes provoked TCP spurious retransmissions due to premature timeouts.
2021-10-11 23:09:00 -07:00
Alexander Lunev 36fbedcbfc net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.

Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
  and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
  It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
  while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
  and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-09-18 21:01:39 -05:00
Huang Qi e5c278981a net: Rename IP_TTL to IP_TTL_DEFAULT
Since a SOL option IP_TTL exist, we should rename this IP_TTL
in netconfig.h to avoid confusion.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Ib04c36553f23bce8d362e97294a8b83eaa050cf3
2021-07-12 16:30:37 -03:00
Xiang Xiao 5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
chao.an 39245f63fe net/icmp: fix race condition in icmp recvmsg
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an ae613446c8 net/icmp: add nonblocking support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an 9c1fb4c04b net/icmp: consume the data length to avoid duplicate packet
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an b0ac97adab net/icmp: fix invalid condition comparison
up_assert: Assertion failed at file:
  icmp/icmp_recvmsg.c line: 175 task: net_tasklet

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
Gustavo Henrique Nihei 330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08: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
Alin Jerpelea 7dc7ef45f1 net: nxstyle fixes
Nxstyle fixes to pass CI.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-20 00:38:18 -08: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
chao.an a97aefe10a net/icmp: add sanity check to avoid wild data length
net device buffer overflow if the icmp packet is too large

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-27 06:45:16 -08:00
YAMAMOTO Takashi bf9ba474a5 net/icmp/icmp_recvfrom.c: fix a NULL dereference
Found by clang-check:

icmp/icmp_recvfrom.c:374:30: warning: Dereference of null pointer (loaded from variable 'fromlen')
      if (fromlen == NULL && *fromlen < sizeof(struct sockaddr_in))
                             ^~~~~~~~
1 warning generated.
2020-07-30 16:16:21 +02:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Gregory Nutt 57bc329aac Run nxstyle all .c and .h files modified by PR. 2020-05-17 14:01:00 -03: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
Nathan Hartman 8ee6be0780 net/icmp/icmp_input.c: Fix memset() implicit decl warning 2020-02-25 12:17:55 -06:00
Gregory Nutt 1f1356a2f5 net/icmp/icmp_input.c: Clear sin_zero
This should have been part of commit 861efdf8a3 but was overlooked.
2020-02-25 09:32:54 -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
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
Gregory Nutt 98f431d8d8 net/: Run all .c files under net/ through tools/nxstyle and fix all resulting complaints. 2020-01-11 13:41:33 -03:00
Xiang Xiao 5c5c08efcd network: simplify the timeout process logic
1.Consolidate absolute to relative timeout conversion into one place(_net_timedwait)
2.Drive the wait timeout logic by net_timedwait instead of devif_timer
This patch help us remove devif_timer(period tick) to save the power in the future.

Change-Id: I534748a5d767ca6da8a7843c3c2f993ed9ea77d4
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-11 08:24:49 -06:00
Nathan Hartman f9f8c6a79b net/icmp/icmp_netpoll.c: Fix return of uninitialized 'ret' when no error occurs. That is, on what should be a successful return from this function, an uninitialized value was returned, which may indicate an undeserved error. 2020-01-02 14:40:08 -06:00
Nathan Hartman c854b1f039 net/icmp/icmp_netpoll.c: Fix warning: implicit declaration of nxsem_post(). This appeared after include of nuttx/kmalloc.h was removed recently. 2020-01-02 14:37:14 -06: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
Xiang Xiao 90c52e6f8f Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .h and .c files modified in last PR through nxstyle.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Net cleanup (#17)

    * Fix the semaphore usage issue found in tcp/udp

    1. The count semaphore need disable priority inheritance
    2. Loop again if net_lockedwait return -EINTR
    3. Call nxsem_trywait to avoid the race condition
    4. Call nxsem_post instead of sem_post

    * Put the work notifier into free list to avoid the heap fragment in the long run.  Since the allocation strategy is encapsulated internally, we can even refine the implementation later.

    * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include:

    1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer
    2. Remove the net lock since xxx_callback_free already do the same thing
    3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all

    * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention

    * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
2019-12-31 09:26:14 -06:00
Nathan Hartman 9655730ef8 Fix various typos and spelling errors. 2019-12-12 07:41:51 -06:00
Xiang Xiao e1e192fc33 net/: icmp[v6] fix ping[6] complain 'WARNING: Received after timeout'. The root cause is that icmp[v6]_pollsetup monitors ICMP[v6]_NEWDATA, but icmp[v6]_input reports ICMP[v6]_ECHOREPLY. This change lets icmp[v6]_input report report ICMP[v6]_NEWDATA to fix this issue and remove ICMP[v6]_ECHOREPLY to avoid the wrong usage in the future. 2019-11-27 08:09:51 -06:00
Xiang Xiao 250bde034d net/: icmp[v6]_pollsetup should always return POLLWRNORM if the caller requests it since ICMP[v6] doesn't utilize IOB buffer for sending and always needs to wait for an ICMP[v6]_POLL. 2019-11-27 08:04:14 -06:00
Xiang Xiao 1905e01fda net/: ICMP/ICMPv6/TCP/UDP poll shouldn't set POLLHUP and POLLOUT at the same time the standard require that only report POLLHUP:
https://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html.
2019-11-25 09:59:50 -06:00
Xiang Xiao 34ec7c97eb net/icmp/icmp_netpoll.c and icmpv6/icmpv6_netpoll.c: ICMP/ICMPv6 should always report POLLHUP and POLLERR, regardless of requested 'events'. 2019-11-25 09:57:49 -06:00
Gregory Nutt 3b275fcf4e net/: Run nxstyle against all C files. 2019-10-25 11:31:42 -06:00
Gregory Nutt 6266e067e9 net/: Re-order the content of all address-family socket 'connection' structures so that they begin with a comomon prologue. This permits better use of logic for different address family types. 2019-09-01 08:47:01 -06:00
Gregory Nutt a52ceac13e net/: Now handles reception of IPv4 packets with larger IPv4 headers containing options. 2019-08-31 12:25:30 -06:00
Anthony Merlino 70404ed0dc Merged in antmerlino/nuttx/iobinstrumentation (pull request #1001)
Iobinstrumentation

* mm/iob: Introduces producer/consumer id to every iob call. This is so that the calls can be instrumented to monitor the IOB resources.

* iob instrumentation - Merges producer/consumer enumeration for simpler IOB user.

* fs/procfs: Starts adding support for /proc/iobinfo

* fs/procfs: Finishes first pass of simple IOB user stastics and /proc/iobinfo entry

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-08-16 22:42:25 +00:00
Gregory Nutt b49be4bb20 Squashed commit of the following:
arch/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    sched/ audio/ crypto/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    Documentation/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    fs/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    graphics/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    net/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    drivers/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    include/, syscall/, wireless/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    configs/:  Remove all references to CONFIG_DISABLE_POLL.  Standard POSIX poll can no longer be disabled.
2019-05-21 18:57:54 -06:00
anchao c9b73f5139 net/icmp and icmpv6: Bind icmp callback from device to connection. Resolves the issue that bind() could not be called before send() 2019-03-19 09:43:32 -06:00
Xiang Xiao eb31dc69ac net/: Remove the unnecessary arp.h inclusion 2018-11-09 14:01:12 -06:00
Xiang Xiao 44bcd2c44d net/: add NET_ICMP[v6]_NO_STACK for usrsock case 2018-11-09 11:25:57 -06:00
Gregory Nutt dcb7ce8afd tools/nxstyle.c: Add logic to catch another formatting error and to eliminate some false alarms. Includes cosmetic changes to several files ... mostly as a result of testing nxstyle and finding issues. 2018-10-29 16:25:57 -06:00
Gregory Nutt 7d2b250cbc net/netdev: All utility functions that lookup network devices should begin with netdev_findby_. Also correct some comments and the name of a formal parameter. 2018-10-29 12:21:22 -06:00
Gregory Nutt 9546481054 Fix some typographical errors. 2018-09-14 06:55:45 -06:00
dongjianli 09c689ea15 net/icmp and icmpv6: Fix failure to poll ICMP socket issue. 2018-08-26 15:37:03 -06:00
Xiang Xiao 40b0e98d25 net/icmp/icmp_conn.c and net/icmpv6/icmpv6_conn.c: Change the type of id in icmpv[6]_findconn to uint16_t 2018-08-26 15:28:02 -06:00
ligd e840038f2d net/ and include/nuttx/net: Add getpeername() support 2018-07-19 07:16:30 -06:00