You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ar...@apache.org on 2026/10/20 12:39:18 UTC

(nuttx) branch master updated (14f2daaa2d3 -> 05920ae3e3d)

This is an automated email from the ASF dual-hosted git repository.

anchao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


    from 14f2daaa2d3 arch/arm/src/common/stm32: fix WWDG time left in WDIOC_GETSTATUS
     new 09f0300894f net: adjust the option sort of level SOL_SOCKET
     new 548c7bccfa6 sim/usrsock: align socket option with sys/socket.h
     new aa86cb99193 sys/socket: adjust SO_RCVTIMEO/SO_SENDTIMEO
     new 05920ae3e3d sim/usrsock: add TCP socket option support in host usrsock

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/sim/src/sim/posix/sim_hostusrsock.c | 40 +++++++++++----
 arch/sim/src/sim/sim_hostusrsock.h       | 46 +++++++++++-------
 include/sys/socket.h                     | 83 +++++++++++++++++---------------
 3 files changed, 105 insertions(+), 64 deletions(-)


(nuttx) 03/04: sys/socket: adjust SO_RCVTIMEO/SO_SENDTIMEO

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit aa86cb99193cab52538c974ff8879edb7057dce2
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Mon Jan 12 11:36:02 2026 +0800

    sys/socket: adjust SO_RCVTIMEO/SO_SENDTIMEO
    
    to avoid s_options overflow
    
    Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
 arch/sim/src/sim/sim_hostusrsock.h | 28 ++++++++++++------------
 include/sys/socket.h               | 44 +++++++++++++++++++-------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/arch/sim/src/sim/sim_hostusrsock.h b/arch/sim/src/sim/sim_hostusrsock.h
index 672cdd6e74a..367e98ae7d7 100644
--- a/arch/sim/src/sim/sim_hostusrsock.h
+++ b/arch/sim/src/sim/sim_hostusrsock.h
@@ -140,22 +140,22 @@
 #define NUTTX_SO_OOBINLINE          7
 #define NUTTX_SO_TIMESTAMPS         8
 #define NUTTX_SO_TIMESTAMPING       9
+#define NUTTX_SO_RCVTIMEO           10
+#define NUTTX_SO_SNDTIMEO           11
 #define NUTTX_SO_RCVBUF             64
 #define NUTTX_SO_RCVLOWAT           65
-#define NUTTX_SO_RCVTIMEO           66
-#define NUTTX_SO_SNDBUF             67
-#define NUTTX_SO_SNDLOWAT           68
-#define NUTTX_SO_SNDTIMEO           69
-#define NUTTX_SO_TYPE               70
-#define NUTTX_SO_ERROR              71
-#define NUTTX_SO_BINDTODEVICE       72
-#define NUTTX_SO_PEERCRED           73
-#define NUTTX_SO_PRIORITY           74
-#define NUTTX_SO_ACCEPTCONN         75
-
-#define NUTTX_SO_SNDBUFFORCE        76
-#define NUTTX_SO_RCVBUFFORCE        77
-#define NUTTX_SO_RXQ_OVFL           78
+#define NUTTX_SO_SNDBUF             66
+#define NUTTX_SO_SNDLOWAT           67
+#define NUTTX_SO_TYPE               68
+#define NUTTX_SO_ERROR              69
+#define NUTTX_SO_BINDTODEVICE       70
+#define NUTTX_SO_PEERCRED           71
+#define NUTTX_SO_PRIORITY           72
+#define NUTTX_SO_ACCEPTCONN         73
+
+#define NUTTX_SO_SNDBUFFORCE        74
+#define NUTTX_SO_RCVBUFFORCE        75
+#define NUTTX_SO_RXQ_OVFL           76
 
 #define NUTTX_SOL_IP                NUTTX_IPPROTO_IP
 #define NUTTX_SOL_IPV6              NUTTX_IPPROTO_IPV6
diff --git a/include/sys/socket.h b/include/sys/socket.h
index fd3ddfee8cc..538a2bf9777 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -185,8 +185,18 @@
                             */
 #define SO_TIMESTAMPING  9 /* Generates timestamp for each output packet
                             */
+#define SO_RCVTIMEO     10 /* Sets the timeout value that specifies the maximum
+                            * amount of time an input function waits until it
+                            * completes (get/set).
+                            * arg: struct timeval
+                            */
+#define SO_SNDTIMEO     11 /* Sets the timeout value specifying the amount of
+                            * time that an output function blocks because flow
+                            * control prevents data from being sent(get/set).
+                            * arg: struct timeval
+                            */
 
-#define __SO_PROTOCOL    9 /* Protocol-level socket options may begin with this
+#define __SO_PROTOCOL   11 /* Protocol-level socket options may begin with this
                             * value. The current value is determined by the option
                             * in SOL_SOCKET that uses the highest bit, which
                             * is SO_TIMESTAMPNS
@@ -201,48 +211,38 @@
                             * socket input (get/set).
                             * arg: integer value
                             */
-#define SO_RCVTIMEO     66 /* Sets the timeout value that specifies the maximum
-                            * amount of time an input function waits until it
-                            * completes (get/set).
-                            * arg: struct timeval
-                            */
-#define SO_SNDBUF       67 /* Sets send buffer size (get/set).
+#define SO_SNDBUF       66 /* Sets send buffer size (get/set).
                             * arg: integer value
                             */
-#define SO_SNDLOWAT     68 /* Sets the minimum number of bytes to process for
+#define SO_SNDLOWAT     67 /* Sets the minimum number of bytes to process for
                             * socket output (get/set).
                             * arg: integer value
                             */
-#define SO_SNDTIMEO     69 /* Sets the timeout value specifying the amount of
-                            * time that an output function blocks because flow
-                            * control prevents data from being sent(get/set).
-                            * arg: struct timeval
-                            */
-#define SO_TYPE         70 /* Reports the socket type (get only).
+#define SO_TYPE         68 /* Reports the socket type (get only).
                             * return: int
                             */
-#define SO_ERROR        71 /* Reports and clears error status (get only).
+#define SO_ERROR        69 /* Reports and clears error status (get only).
                             * arg: returns an integer value
                             */
-#define SO_BINDTODEVICE 72 /* Bind this socket to a specific network device.
+#define SO_BINDTODEVICE 70 /* Bind this socket to a specific network device.
                             */
-#define SO_PEERCRED     73 /* Return the credentials of the peer process
+#define SO_PEERCRED     71 /* Return the credentials of the peer process
                             * connected to this socket.
                             */
-#define SO_PRIORITY     74 /* Set the priority for all packets to be sent on this
+#define SO_PRIORITY     72 /* Set the priority for all packets to be sent on this
                             * socket.  Nuttx uses this value to order the
                             * networking queues: packets with a higher priority
                             * may be processed first depending on the selected
                             * device queueing discipline.
                             */
-#define SO_ACCEPTCONN   75 /* Reports whether socket listening is enabled
+#define SO_ACCEPTCONN   73 /* Reports whether socket listening is enabled
                             * (get only).
                             * arg: pointer to integer containing a boolean
                             * value
                             */
-#define SO_SNDBUFFORCE  76
-#define SO_RCVBUFFORCE  77
-#define SO_RXQ_OVFL     78
+#define SO_SNDBUFFORCE  74
+#define SO_RCVBUFFORCE  75
+#define SO_RXQ_OVFL     76
 
 /* SO_TIMESTAMPING flags, with the same values as Linux so that they can
  * also describe the capabilities of an interface (ETHTOOL_GET_TS_INFO).


(nuttx) 04/04: sim/usrsock: add TCP socket option support in host usrsock

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 05920ae3e3d1d1763cd4b2cc97b6bd4cc3cfde94
Author: yangjianqing <ya...@xiaomi.com>
AuthorDate: Mon Mar 2 16:42:30 2026 +0800

    sim/usrsock: add TCP socket option support in host usrsock
    
    Add TCP-level socket option mapping (TCP_NODELAY, TCP_KEEPIDLE,
    TCP_KEEPINTVL, TCP_KEEPCNT, TCP_MAXSEG, TCP_CORK) to the sim
    host usrsock implementation.
    
    Signed-off-by: yangjianqing <ya...@xiaomi.com>
---
 arch/sim/src/sim/posix/sim_hostusrsock.c | 40 +++++++++++++++++++++++++-------
 arch/sim/src/sim/sim_hostusrsock.h       | 12 ++++++++--
 2 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/arch/sim/src/sim/posix/sim_hostusrsock.c b/arch/sim/src/sim/posix/sim_hostusrsock.c
index 52cd495ecad..1975e9c3344 100644
--- a/arch/sim/src/sim/posix/sim_hostusrsock.c
+++ b/arch/sim/src/sim/posix/sim_hostusrsock.c
@@ -40,6 +40,7 @@
 #include <syslog.h>
 
 #include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <sys/un.h>
 
 #include "sim_internal.h"
@@ -261,6 +262,34 @@ static int optname_to_native(int optname)
     }
 }
 
+static int tcp_optname_to_native(int optname)
+{
+  switch (optname)
+    {
+      case NUTTX_TCP_NODELAY:
+        return TCP_NODELAY;
+
+      case NUTTX_TCP_KEEPIDLE:
+        return TCP_KEEPIDLE;
+
+      case NUTTX_TCP_KEEPINTVL:
+        return TCP_KEEPINTVL;
+
+      case NUTTX_TCP_KEEPCNT:
+        return TCP_KEEPCNT;
+
+      case NUTTX_TCP_MAXSEG:
+        return TCP_MAXSEG;
+
+      case NUTTX_TCP_CORK:
+        return TCP_CORK;
+
+      default:
+        syslog(LOG_ERR, "Invalid TCP optname: %x\n", optname);
+        return -ENOPROTOOPT;
+    }
+}
+
 static int host_usrsock_sockopt(int sockfd, int level, int optname,
                                 const void *optval, nuttx_socklen_t *optlen,
                                 bool set)
@@ -274,25 +303,18 @@ static int host_usrsock_sockopt(int sockfd, int level, int optname,
   if (level == NUTTX_SOL_SOCKET)
     {
       level = SOL_SOCKET;
+      optname = optname_to_native(optname);
     }
   else if (level == NUTTX_IPPROTO_TCP)
     {
       level = IPPROTO_TCP;
-    }
-  else if (level == NUTTX_IPPROTO_UDP)
-    {
-      level = IPPROTO_UDP;
-    }
-  else if (level == NUTTX_IPPROTO_IP)
-    {
-      level = IPPROTO_IP;
+      optname = tcp_optname_to_native(optname);
     }
   else
     {
       return -ENOPROTOOPT;
     }
 
-  optname = optname_to_native(optname);
   if (optname < 0)
     {
       return optname;
diff --git a/arch/sim/src/sim/sim_hostusrsock.h b/arch/sim/src/sim/sim_hostusrsock.h
index 367e98ae7d7..3507f64ff92 100644
--- a/arch/sim/src/sim/sim_hostusrsock.h
+++ b/arch/sim/src/sim/sim_hostusrsock.h
@@ -142,6 +142,9 @@
 #define NUTTX_SO_TIMESTAMPING       9
 #define NUTTX_SO_RCVTIMEO           10
 #define NUTTX_SO_SNDTIMEO           11
+
+#define NUTTX__SO_PROTOCOL          11
+
 #define NUTTX_SO_RCVBUF             64
 #define NUTTX_SO_RCVLOWAT           65
 #define NUTTX_SO_SNDBUF             66
@@ -167,8 +170,6 @@
 #define NUTTX_SOL_SCO               17
 #define NUTTX_SOL_RFCOMM            18
 
-#define NUTTX___SO_PROTOCOL         16
-
 #define NUTTX_SHUT_RD               1
 #define NUTTX_SHUT_WR               2
 #define NUTTX_SHUT_RDWR             3
@@ -177,6 +178,13 @@
 #define NUTTX_SCM_CREDENTIALS       0x02
 #define NUTTX_SCM_SECURITY          0x03
 
+#define NUTTX_TCP_NODELAY               (NUTTX__SO_PROTOCOL + 0)  /* Avoid coalescing of small segments */
+#define NUTTX_TCP_KEEPIDLE              (NUTTX__SO_PROTOCOL + 1)  /* Start keepalives after this IDLE period */
+#define NUTTX_TCP_KEEPINTVL             (NUTTX__SO_PROTOCOL + 2)  /* Interval between keepalives */
+#define NUTTX_TCP_KEEPCNT               (NUTTX__SO_PROTOCOL + 3)  /* Number of keepalives before death */
+#define NUTTX_TCP_MAXSEG                (NUTTX__SO_PROTOCOL + 4)  /* The maximum segment size */
+#define NUTTX_TCP_CORK                  (NUTTX__SO_PROTOCOL + 5)  /* Coalescing of small segments */
+
 #define NUTTX_IP_MULTICAST_IF           (NUTTX__SO_PROTOCOL + 1)
 #define NUTTX_IP_MULTICAST_TTL          (NUTTX__SO_PROTOCOL + 2)
 #define NUTTX_IP_MULTICAST_LOOP         (NUTTX__SO_PROTOCOL + 3)


(nuttx) 01/04: net: adjust the option sort of level SOL_SOCKET

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 09f0300894fc06eccce1fcd299a47985efd58383
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Wed Dec 3 17:54:39 2025 +0800

    net: adjust the option sort of level SOL_SOCKET
    
    Adjust the order of all options where the level is SOL_SOCKET. If an
    option occupies a bit in socket_conn_s:s_options, place it at the front.
    This is to save bits for options of other levels and prevent the 32-bit
    overflow of socket_conn_s:s_options.
    
    The definition of many options for other levels uses _SO_PROTOCOL as the
    base value. If _SO_PROTOCOL is relatively small, more bits will be left
    for options of other levels. Before adjustment, there were 16 bits
    available; after adjustment, this number has increased to 23 bits.
    
    Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
 include/sys/socket.h | 73 ++++++++++++++++++++++++++++------------------------
 1 file changed, 40 insertions(+), 33 deletions(-)

diff --git a/include/sys/socket.h b/include/sys/socket.h
index 6471fdc2f0a..fd3ddfee8cc 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -146,8 +146,7 @@
 
 /* Socket-level options */
 
-#define SO_ACCEPTCONN    0 /* Reports whether socket listening is enabled
-                            * (get only).
+#define SO_REUSEADDR     0 /* Allow reuse of local addresses (get/set)
                             * arg: pointer to integer containing a boolean
                             * value
                             */
@@ -165,8 +164,8 @@
                             * arg: pointer to integer containing a boolean
                             * value
                             */
-#define SO_ERROR         4 /* Reports and clears error status (get only).
-                            * arg: returns an integer value
+#define SO_TIMESTAMP     4 /* Generates a timestamp in us for each incoming packet
+                            * arg: integer value
                             */
 #define SO_KEEPALIVE     5 /* Keeps connections active by enabling the periodic
                             * transmission of messages (get/set).
@@ -181,54 +180,69 @@
                             * (get/set) arg: pointer to integer containing a
                             * boolean value
                             */
-#define SO_RCVBUF        8 /* Sets receive buffer size.
+#define SO_TIMESTAMPNS   8 /* Generates a timestamp in ns for each incoming packet
+                            * arg: integer value
+                            */
+#define SO_TIMESTAMPING  9 /* Generates timestamp for each output packet
+                            */
+
+#define __SO_PROTOCOL    9 /* Protocol-level socket options may begin with this
+                            * value. The current value is determined by the option
+                            * in SOL_SOCKET that uses the highest bit, which
+                            * is SO_TIMESTAMPNS
+                            */
+
+/* Start from 64 to avoid redefinition with other protocol options. */
+
+#define SO_RCVBUF       64 /* Sets receive buffer size.
                             * arg: integer value (get/set).
                             */
-#define SO_RCVLOWAT      9 /* Sets the minimum number of bytes to process for
+#define SO_RCVLOWAT     65 /* Sets the minimum number of bytes to process for
                             * socket input (get/set).
                             * arg: integer value
                             */
-#define SO_RCVTIMEO     10 /* Sets the timeout value that specifies the maximum
+#define SO_RCVTIMEO     66 /* Sets the timeout value that specifies the maximum
                             * amount of time an input function waits until it
                             * completes (get/set).
                             * arg: struct timeval
                             */
-#define SO_REUSEADDR    11 /* Allow reuse of local addresses (get/set)
-                            * arg: pointer to integer containing a boolean
-                            * value
-                            */
-#define SO_SNDBUF       12 /* Sets send buffer size (get/set).
+#define SO_SNDBUF       67 /* Sets send buffer size (get/set).
                             * arg: integer value
                             */
-#define SO_SNDLOWAT     13 /* Sets the minimum number of bytes to process for
+#define SO_SNDLOWAT     68 /* Sets the minimum number of bytes to process for
                             * socket output (get/set).
                             * arg: integer value
                             */
-#define SO_SNDTIMEO     14 /* Sets the timeout value specifying the amount of
+#define SO_SNDTIMEO     69 /* Sets the timeout value specifying the amount of
                             * time that an output function blocks because flow
                             * control prevents data from being sent(get/set).
                             * arg: struct timeval
                             */
-#define SO_TYPE         15 /* Reports the socket type (get only).
+#define SO_TYPE         70 /* Reports the socket type (get only).
                             * return: int
                             */
-#define SO_TIMESTAMP    16 /* Generates a timestamp in us for each incoming packet
-                            * arg: integer value
+#define SO_ERROR        71 /* Reports and clears error status (get only).
+                            * arg: returns an integer value
                             */
-#define SO_BINDTODEVICE 17 /* Bind this socket to a specific network device.
+#define SO_BINDTODEVICE 72 /* Bind this socket to a specific network device.
                             */
-#define SO_PEERCRED     18 /* Return the credentials of the peer process
+#define SO_PEERCRED     73 /* Return the credentials of the peer process
                             * connected to this socket.
                             */
-#define SO_TIMESTAMPNS  20 /* Generates a timestamp in ns for each incoming packet
-                            * arg: integer value
+#define SO_PRIORITY     74 /* Set the priority for all packets to be sent on this
+                            * socket.  Nuttx uses this value to order the
+                            * networking queues: packets with a higher priority
+                            * may be processed first depending on the selected
+                            * device queueing discipline.
                             */
-#define SO_TIMESTAMPING 21 /* Generates timestamp for each output packet
+#define SO_ACCEPTCONN   75 /* Reports whether socket listening is enabled
+                            * (get only).
+                            * arg: pointer to integer containing a boolean
+                            * value
                             */
-
-/* Protocol-level socket options may begin with this value */
-
-#define __SO_PROTOCOL   16
+#define SO_SNDBUFFORCE  76
+#define SO_RCVBUFFORCE  77
+#define SO_RXQ_OVFL     78
 
 /* SO_TIMESTAMPING flags, with the same values as Linux so that they can
  * also describe the capabilities of an interface (ETHTOOL_GET_TS_INFO).
@@ -249,13 +263,6 @@
 #define SOF_TIMESTAMPING_SYS_HARDWARE (1 << 5)
 #define SOF_TIMESTAMPING_RAW_HARDWARE (1 << 6)
 
-/* The options are unsupported but included for compatibility
- * and portability
- */
-#define SO_SNDBUFFORCE  32
-#define SO_RCVBUFFORCE  33
-#define SO_RXQ_OVFL     40
-
 /* Protocol-level socket operations. */
 
 #define SOL_IP          IPPROTO_IP     /* See options in include/netinet/in.h */


(nuttx) 02/04: sim/usrsock: align socket option with sys/socket.h

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 548c7bccfa61b9e02be39a65c7b285ebdf16312b
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Tue Jan 6 15:57:45 2026 +0800

    sim/usrsock: align socket option with sys/socket.h
    
    new socket option definition introduced by commit:
    I254b84e871012361c56f26f356ce27c0f740785f
    
    Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
 arch/sim/src/sim/sim_hostusrsock.h | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/arch/sim/src/sim/sim_hostusrsock.h b/arch/sim/src/sim/sim_hostusrsock.h
index 34a2ce243b5..672cdd6e74a 100644
--- a/arch/sim/src/sim/sim_hostusrsock.h
+++ b/arch/sim/src/sim/sim_hostusrsock.h
@@ -130,28 +130,32 @@
 #define NUTTX_MSG_MORE              0x8000
 
 #define NUTTX_SOL_SOCKET            1
-#define NUTTX_SO_ACCEPTCONN         0
+#define NUTTX_SO_REUSEADDR          0
 #define NUTTX_SO_BROADCAST          1
 #define NUTTX_SO_DEBUG              2
 #define NUTTX_SO_DONTROUTE          3
-#define NUTTX_SO_ERROR              4
+#define NUTTX_SO_TIMESTAMP          4
 #define NUTTX_SO_KEEPALIVE          5
 #define NUTTX_SO_LINGER             6
 #define NUTTX_SO_OOBINLINE          7
-#define NUTTX_SO_RCVBUF             8
-#define NUTTX_SO_RCVLOWAT           9
-#define NUTTX_SO_RCVTIMEO           10
-#define NUTTX_SO_REUSEADDR          11
-#define NUTTX_SO_SNDBUF             12
-#define NUTTX_SO_SNDLOWAT           13
-#define NUTTX_SO_SNDTIMEO           14
-#define NUTTX_SO_TYPE               15
-#define NUTTX_SO_TIMESTAMP          16
-#define NUTTX_SO_BINDTODEVICE       17
-
-#define NUTTX_SO_SNDBUFFORCE        32
-#define NUTTX_SO_RCVBUFFORCE        33
-#define NUTTX_SO_RXQ_OVFL           40
+#define NUTTX_SO_TIMESTAMPS         8
+#define NUTTX_SO_TIMESTAMPING       9
+#define NUTTX_SO_RCVBUF             64
+#define NUTTX_SO_RCVLOWAT           65
+#define NUTTX_SO_RCVTIMEO           66
+#define NUTTX_SO_SNDBUF             67
+#define NUTTX_SO_SNDLOWAT           68
+#define NUTTX_SO_SNDTIMEO           69
+#define NUTTX_SO_TYPE               70
+#define NUTTX_SO_ERROR              71
+#define NUTTX_SO_BINDTODEVICE       72
+#define NUTTX_SO_PEERCRED           73
+#define NUTTX_SO_PRIORITY           74
+#define NUTTX_SO_ACCEPTCONN         75
+
+#define NUTTX_SO_SNDBUFFORCE        76
+#define NUTTX_SO_RCVBUFFORCE        77
+#define NUTTX_SO_RXQ_OVFL           78
 
 #define NUTTX_SOL_IP                NUTTX_IPPROTO_IP
 #define NUTTX_SOL_IPV6              NUTTX_IPPROTO_IPV6