Commit Graph

154 Commits

Author SHA1 Message Date
Petro Karashchenko 08043fb5bc net: unify FAR keyword usage for all net buffer memory mapped buffers
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-20 01:42:56 +08:00
songlinzhang 22df553443 net/arp: clean the arp table when netdev carrier off
Fix the arp address changed if netdev renew, since the
arp table should be cleared when the netdev carrier off

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2021-11-27 06:19:50 -06: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
Masayuki Ishikawa 59ed02c604 net: arp: Fix a potential bug in arp_notify()
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>
2021-03-31 12:23:35 -05:00
Masayuki Ishikawa b3f7cf9ad9 net: arp: Fix memory corruption in arp_send()
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>
2021-03-31 12:23:35 -05:00
chao.an 9bdf4ccd68 net/arp: add timeout to avoid infinite send wait
add timeout to avoid infinite send wait if the network device is unreachable

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-23 00:28:43 -07: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
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
Xiang Xiao 517974787f Rename clock_systime[r|spec] to clock_systime_[ticks|timespec]
follow up the new naming convention:
https://cwiki.apache.org/confluence/display/NUTTX/Naming+of+OS+Internal+Functions
2020-05-10 14:35:50 -06:00
Gregory Nutt ca2b0a3657 Fix more warnings noted in PR checks
arp/arp_notify.c:132:43: warning: for loop has empty body [-Wempty-body]
           prev = curr, curr = curr->nt_flink);
                                              ^

    sixlowpan/sixlowpan_tcpsend.c:806:31: warning: implicit conversion from 'unsigned int' to 'uint16_t' (aka 'unsigned short') changes value from 4294967295 to 65535 [-Wconstant-conversion]
                                  _SO_TIMEOUT(psock->s_sndtimeo));
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Numerous warnings like:

    ieee802154_getreq.c:93:3: warning: implicit declaration of function 'memcpy' is invalid in C99 [-Wimplicit-function-declaration]
      IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
      ^

    nxfonts/nxfonts_cache.c:839:35: warning: for loop has empty body [-Wempty-body]
               fcache = fcache->flink);

    bluetooth/bluetooth_finddev.c💯11: warning: implicit declaration of function 'memcmp' is invalid in C99 [-Wimplicit-function-declaration]
          if (BLUETOOTH_ADDRCMP(dev->d_mac.radio.nv_addr, match->bf_addr))
              ^

    rwbuffer.c:559:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
      if (rwb->rhmaxblocks > 0 && rwb->rhnblocks > 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-04-13 02:09:34 +08: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
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
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
chao.an 97bead5496 net: complement wireless handling as ethernet
Change-Id: I13cc4cbfc1e305e17c0630f11a1173afe96e8a03
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-01-11 08:04:18 -03: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 dbbabcd33c Squashed commit of the following:
net/netlink/netlink_route.c:  Add Netlink socket NETLINK_ROUTE support for getting a snopshot of the Neighbor table.

    net/neighbor/neighbor_snapshot.c:  Add neighbor_snapshot() that will eventually be used by the Netlink sockets.  Also fixed naming violation 'struct neighbor_entry' -> 'struct neighbor_entry_s'.

    include/nuttx/net/neighbor.h:  Expose format of the IPv6 neighbor table for use with Netlink sockets.
2019-11-08 11:16:04 -06:00
Gregory Nutt 6d13705e93 net/netlink: The NETLINK_ROUTE logic needs to return the first queued response and not attempt to match up reponses with requests. That is the Linux compatible way. Also, use queue.h functions for list management and fix an error in arp_snapshot(). 2019-11-04 09:02:14 -06:00
Gregory Nutt 7bd045130c net/netlink/: Misc bugfixes from initial testing using NSH 'arp -t' command. 2019-11-03 19:27:58 -06:00
Gregory Nutt 2991987018 net/netlink/netlink_route.c (mostly): This completes a minimal netlink implementation that will retrieve the ARP table.
net/netlink:  Add basic hooks (only) to support the NETLINK_ROUTE protocol.
2019-11-03 13:59:42 -06:00
Gregory Nutt 3b275fcf4e net/: Run nxstyle against all C files. 2019-10-25 11:31:42 -06:00
Gregory Nutt 100fe59ff2 net/arp/arp.h: Remove an unused structure definition. 2019-09-01 17:49:44 -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 1346f29151 net/: Fix alignment and spacing problems found by tools/nxstyle. 2019-07-02 18:02:23 -06:00
Gregory Nutt f6b00e1966 tools/nxstyle.c: Fix logic error that prevent detecion of '/' and '/=' as operators. net/: Minor updates resulting from testing tools/nxstyle. 2019-03-11 12:48:39 -06:00
Gregory Nutt 1bbcd1ad96 Update some comments and cosmetic spacing. 2019-02-04 07:24:45 -06:00
Gregory Nutt 68a115aed9 net/icmpv6/icmpv6_autoconfig.c and icmpv6_rnotify.c: Don't take the network device down when reconfiguring only the IP address from within ICMPv6 logic. Recommended by Xiang Xiao in order to avoid the long delays of bringing some networks back up.
Normally it is required that the network be in the "down" state when re-configuring the network interface.  This is thought not to be a necessary here because.

  1. The ICMPv6 logic here runs with the network locked so there can be no outgoing packets with bad source IP addresses from any asynchronous network activity using the device being reconfigured.
  2. Incoming packets depend only upon the MAC filtering.  Network drivers do not use the IP address; they filter incoming packets using only the MAC address which is not being changed here.
2018-11-10 07:13:54 -06:00
Xiang Xiao a139b7f9b1 net/arp and icmpv6: Double the delay time on each iteration for ARP/ICMP to fight work jitter better. 2018-11-09 15:55:38 -06:00
Xiang Xiao bdf93a8abf net/arp/arp_send.c: Check ifname match before sending packet 2018-11-09 13:57:16 -06:00
Xiang Xiao 43706cd797 net/arp: Redesign ARP table aging to simplify the net initialization 2018-11-09 13:54:55 -06:00
Xiang Xiao 26ae4176f0 net/arp and net/icmpv6: don't call d_txavail directly since it may point to NULL 2018-11-09 11:22:58 -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 a85f0e4cd5 networking: Update some comments to correct the naming used for the link layer. 2018-10-20 06:35:39 -06:00
Gregory Nutt bb92b98dc0 net/arp/arp_out.c: Fix some backward logic in an if condition. 2018-08-29 10:51:44 -06:00
Gregory Nutt 3bf96c8e7e net/arp: Improve arp_find() commit 9774d35010 to reduce the amount and frequency of data copies. 2018-08-25 07:12:21 -06:00
Gregory Nutt 324e1412ef net/arp: Costmetic update to comments. 2018-08-24 17:57:15 -06:00
Gregory Nutt 9774d35010 net/arp: Make the function arp_find() thread-safe. It now returns a copy of the ARP table entry, rather than a potentially unstable reference to the ARP table entry. 2018-08-24 17:36:08 -06:00
Xiang Xiao f74ddd2a04 net/arp: arp_find() now checks if the target IP belongs to one of the local network devices. 2018-08-24 09:04:29 -06:00
Gregory Nutt 1acfac3eb6 net/: More fixes to wrong comments from old change from the interrupt driven network to the work-queue driven network. 2018-06-23 15:03:01 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt 7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Louis Mayencourt aa1a068999 net/arp: Fix IGMP multicast address computation on Nuttx network stack. This change fixes the IGMP address computation to allow multicast UDP messages. The destination address was created with the incorrect bytes of the given IPv4 address. 2018-01-02 11:19:30 -06:00
Gregory Nutt c3d3e91a3f arch/arm/src/lpc54xx: Correct handling of the Ethernet RBU error. With this fix, Ethernet now appears to be fully functional although still undertested. 2018-01-01 15:08:19 -06:00
Gregory Nutt c93320ccd6 net/: Fix some issues with regard to UDP broadcast handling. This is Bitbucket Issue #77. This commit tentatively closes the issues, subject to verification. 2017-11-22 12:06:36 -06:00
Gregory Nutt 42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt 83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Louis Mayencourt b55005669a net/arp/arp_out.c: Fix IGMP Ethernet address computation 2017-09-28 07:50:52 -06:00