You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/30 13:39:36 UTC

[incubator-nuttx] branch pr185 updated (5a24d49 -> 5b3c16f)

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

gnutt pushed a change to branch pr185
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 5a24d49  boards: spresense: Add posix_spawn configuration
     new 08c6f62  Fix net checksum related issue
     new 1a9265e  net_dsec2tick return type should unsigned int
     new 5b3c16f  Fix the wrong mask calculation in net_ipv6_pref2mask

The 3 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:
 include/nuttx/net/netdev.h     | 21 ---------------------
 net/utils/Kconfig              |  7 +++----
 net/utils/net_chksum.c         | 15 ---------------
 net/utils/net_dsec2tick.c      |  4 +++-
 net/utils/net_dsec2timeval.c   |  3 ---
 net/utils/net_icmpchksum.c     |  5 -----
 net/utils/net_incr32.c         |  9 ---------
 net/utils/net_ipchksum.c       |  2 --
 net/utils/net_ipv6_mask2pref.c |  5 +----
 net/utils/net_ipv6_maskcmp.c   |  2 --
 net/utils/net_ipv6_pref2mask.c |  4 ++--
 net/utils/net_tcpchksum.c      |  6 ------
 net/utils/net_udpchksum.c      |  4 ----
 net/utils/utils.h              | 10 ++--------
 14 files changed, 11 insertions(+), 86 deletions(-)


[incubator-nuttx] 01/03: Fix net checksum related issue

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

gnutt pushed a commit to branch pr185
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 08c6f62256c05acc21751237f0d45c611e097ad0
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jan 30 15:45:15 2020 +0800

    Fix net checksum related issue
    
    1.Remove the unused and unimplemented ipv6_chksum declaration
    2.Update NET_ARCH_CHKSUM description to align with the implementation
    3.Declare all checksum function prototype regardless CONFIG_NET_ARCH_CHKSUM
    4.Remove the CONFIG_NET_ARCH_CHKSUM guard for tcp_ipv[4|6]_chksum
    
    Change-Id: I43189b8a835aaaca336e8c2d7ff4a790f7ea2de5
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/nuttx/net/netdev.h | 21 ---------------------
 net/utils/Kconfig          |  7 +++----
 net/utils/net_chksum.c     | 15 ---------------
 net/utils/net_icmpchksum.c |  5 -----
 net/utils/net_incr32.c     |  9 ---------
 net/utils/net_ipchksum.c   |  2 --
 net/utils/net_tcpchksum.c  |  6 ------
 net/utils/net_udpchksum.c  |  4 ----
 net/utils/utils.h          | 10 ++--------
 9 files changed, 5 insertions(+), 74 deletions(-)

diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h
index 6c67c56..3ab2fc9 100644
--- a/include/nuttx/net/netdev.h
+++ b/include/nuttx/net/netdev.h
@@ -697,27 +697,6 @@ uint16_t ipv4_chksum(FAR struct net_driver_s *dev);
 #endif
 
 /****************************************************************************
- * Name: ipv6_chksum
- *
- * Description:
- *   Calculate the IPv6 header checksum of the packet header in d_buf.
- *
- *   The IPv6 header checksum is the Internet checksum of the 40 bytes of
- *   the IPv6 header.
- *
- *   If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
- *   provided by architecture-specific logic.
- *
- * Returned Value:
- *   The IPv6 header checksum of the IPv6 header in the d_buf buffer.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-uint16_t ipv6_chksum(FAR struct net_driver_s *dev);
-#endif
-
-/****************************************************************************
  * Name: netdev_ipv4_hdrlen
  *
  * Description:
diff --git a/net/utils/Kconfig b/net/utils/Kconfig
index 771bb2b..7eeb537 100644
--- a/net/utils/Kconfig
+++ b/net/utils/Kconfig
@@ -19,9 +19,8 @@ config NET_ARCH_CHKSUM
 		Define if you architecture provided an optimized version of
 		functions with the following prototypes:
 
+			uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len)
 			uint16_t net_chksum(FAR uint16_t *data, uint16_t len)
 			uint16_t ipv4_chksum(FAR struct net_driver_s *dev)
-			uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev);
-			uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev);
-			uint16_t udp_ipv4_chksum(FAR struct net_driver_s *dev);
-			uint16_t udp_ipv6_chksum(FAR struct net_driver_s *dev);
+			uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
+			uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto, unsigned int iplen)
diff --git a/net/utils/net_chksum.c b/net/utils/net_chksum.c
index ac5095f..0242159 100644
--- a/net/utils/net_chksum.c
+++ b/net/utils/net_chksum.c
@@ -41,24 +41,9 @@
 #include <nuttx/config.h>
 #ifdef CONFIG_NET
 
-#include <stdint.h>
-#include <debug.h>
-
-#include <nuttx/net/netconfig.h>
-#include <nuttx/net/netdev.h>
-#include <nuttx/net/ip.h>
-#include <nuttx/net/icmp.h>
-
 #include "utils/utils.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define IPv4BUF   ((struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
-#define IPv6BUF   ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
diff --git a/net/utils/net_icmpchksum.c b/net/utils/net_icmpchksum.c
index b17f532..dc9d84f 100644
--- a/net/utils/net_icmpchksum.c
+++ b/net/utils/net_icmpchksum.c
@@ -40,10 +40,6 @@
 #include <nuttx/config.h>
 #ifdef CONFIG_NET
 
-#include <stdint.h>
-#include <debug.h>
-
-#include <nuttx/net/netconfig.h>
 #include <nuttx/net/netdev.h>
 #include <nuttx/net/icmp.h>
 
@@ -55,7 +51,6 @@
 
 #define IPv4BUF     ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
 #define ICMPBUF(hl) ((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
-#define ICMPv6BUF   ((struct icmp_ipv6hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
 
 /****************************************************************************
  * Public Functions
diff --git a/net/utils/net_incr32.c b/net/utils/net_incr32.c
index c50695e..841de1d 100644
--- a/net/utils/net_incr32.c
+++ b/net/utils/net_incr32.c
@@ -39,16 +39,7 @@
  ****************************************************************************/
 
 #include <nuttx/config.h>
-
-#include <stdint.h>
-#include <debug.h>
-
-#include <nuttx/net/netconfig.h>
 #include <nuttx/net/netdev.h>
-#include <nuttx/net/ip.h>
-#include <nuttx/net/icmp.h>
-
-#include "utils/utils.h"
 
 #ifndef CONFIG_NET_ARCH_INCR32
 
diff --git a/net/utils/net_ipchksum.c b/net/utils/net_ipchksum.c
index 1ec2951..d3e4057 100644
--- a/net/utils/net_ipchksum.c
+++ b/net/utils/net_ipchksum.c
@@ -40,10 +40,8 @@
 
 #include <nuttx/config.h>
 
-#include <stdint.h>
 #include <assert.h>
 
-#include <nuttx/net/netconfig.h>
 #include <nuttx/net/netdev.h>
 #include <nuttx/net/ip.h>
 
diff --git a/net/utils/net_tcpchksum.c b/net/utils/net_tcpchksum.c
index 2f96f2a..3c53890 100644
--- a/net/utils/net_tcpchksum.c
+++ b/net/utils/net_tcpchksum.c
@@ -39,10 +39,6 @@
  ****************************************************************************/
 
 #include <nuttx/config.h>
-
-#include <stdint.h>
-
-#include <nuttx/net/netconfig.h>
 #include <nuttx/net/netdev.h>
 
 #include "utils/utils.h"
@@ -72,7 +68,6 @@
  *
  ****************************************************************************/
 
-#ifndef CONFIG_NET_ARCH_CHKSUM
 #ifdef CONFIG_NET_IPv4
 uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev)
 {
@@ -86,7 +81,6 @@ uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev)
   return ipv6_upperlayer_chksum(dev, IP_PROTO_TCP, IPv6_HDRLEN);
 }
 #endif /* CONFIG_NET_IPv6 */
-#endif /* !CONFIG_NET_ARCH_CHKSUM */
 
 #if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
 uint16_t tcp_chksum(FAR struct net_driver_s *dev)
diff --git a/net/utils/net_udpchksum.c b/net/utils/net_udpchksum.c
index 533475b..462ba1a 100644
--- a/net/utils/net_udpchksum.c
+++ b/net/utils/net_udpchksum.c
@@ -39,10 +39,6 @@
  ****************************************************************************/
 
 #include <nuttx/config.h>
-
-#include <stdint.h>
-
-#include <nuttx/net/netconfig.h>
 #include <nuttx/net/netdev.h>
 
 #include "utils/utils.h"
diff --git a/net/utils/utils.h b/net/utils/utils.h
index a09b905..e47ded9 100644
--- a/net/utils/utils.h
+++ b/net/utils/utils.h
@@ -234,9 +234,7 @@ void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask);
  *
  ****************************************************************************/
 
-#ifndef CONFIG_NET_ARCH_CHKSUM
 uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
-#endif
 
 /****************************************************************************
  * Name: net_chksum
@@ -263,9 +261,7 @@ uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
  *
  ****************************************************************************/
 
-#ifndef CONFIG_NET_ARCH_CHKSUM
 uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
-#endif
 
 /****************************************************************************
  * Name: ipv4_upperlayer_chksum
@@ -284,7 +280,7 @@ uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
  *
  ****************************************************************************/
 
-#if !defined(CONFIG_NET_ARCH_CHKSUM) && defined(CONFIG_NET_IPv4)
+#ifdef CONFIG_NET_IPv4
 uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
 #endif
 
@@ -308,7 +304,7 @@ uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
  *
  ****************************************************************************/
 
-#if !defined(CONFIG_NET_ARCH_CHKSUM) && defined(CONFIG_NET_IPv6)
+#ifdef CONFIG_NET_IPv6
 uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev,
                                 uint8_t proto, unsigned int iplen);
 #endif
@@ -337,8 +333,6 @@ uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev);
 #endif
 
 #ifdef CONFIG_NET_IPv6
-/* REVIST: Is this used? */
-
 uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev);
 #endif
 


[incubator-nuttx] 02/03: net_dsec2tick return type should unsigned int

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

gnutt pushed a commit to branch pr185
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1a9265e285f17431fb582d1a2e7a2e7b7dba6fe7
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jan 30 16:07:19 2020 +0800

    net_dsec2tick return type should unsigned int
    
    Change-Id: I4b73b691d2a0983d2dd14121bcfe1d4b436fbf5b
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 net/utils/net_dsec2tick.c    | 4 +++-
 net/utils/net_dsec2timeval.c | 3 ---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/utils/net_dsec2tick.c b/net/utils/net_dsec2tick.c
index 258f6cb..7e97965 100644
--- a/net/utils/net_dsec2tick.c
+++ b/net/utils/net_dsec2tick.c
@@ -40,6 +40,8 @@
 #include <nuttx/config.h>
 #include <nuttx/clock.h>
 
+#include "utils/utils.h"
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -58,7 +60,7 @@
  *
  ****************************************************************************/
 
-int net_dsec2tick(int dsec)
+unsigned int net_dsec2tick(int dsec)
 {
   /* Convert the deci-second comparison value to clock ticks.  The CLK_TCK
    * value is the number of clock ticks per second; decisecs argument is the
diff --git a/net/utils/net_dsec2timeval.c b/net/utils/net_dsec2timeval.c
index 990f1f3..41c48f6 100644
--- a/net/utils/net_dsec2timeval.c
+++ b/net/utils/net_dsec2timeval.c
@@ -39,10 +39,7 @@
 
 #include <nuttx/config.h>
 
-#include <sys/socket.h>
 #include <sys/time.h>
-#include <stdint.h>
-#include <errno.h>
 
 #include <nuttx/clock.h>
 


[incubator-nuttx] 03/03: Fix the wrong mask calculation in net_ipv6_pref2mask

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

gnutt pushed a commit to branch pr185
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5b3c16f77d6865537d78ad7f13305d7a6e9391de
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jan 30 16:22:18 2020 +0800

    Fix the wrong mask calculation in net_ipv6_pref2mask
    
    Change-Id: Id1a281a3f4d4e4c182848a9de96752ab72ad4529
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 net/utils/net_ipv6_mask2pref.c | 5 +----
 net/utils/net_ipv6_maskcmp.c   | 2 --
 net/utils/net_ipv6_pref2mask.c | 4 ++--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/utils/net_ipv6_mask2pref.c b/net/utils/net_ipv6_mask2pref.c
index 7800900..562fe40 100644
--- a/net/utils/net_ipv6_mask2pref.c
+++ b/net/utils/net_ipv6_mask2pref.c
@@ -39,9 +39,6 @@
 
 #include <nuttx/config.h>
 
-#include <stdint.h>
-#include <arpa/inet.h>
-
 #include "utils/utils.h"
 
 #ifdef CONFIG_NET_IPv6
@@ -71,7 +68,7 @@ static const uint8_t g_nibblemap[16] =
 
 static inline uint8_t net_msbits4(uint8_t nibble)
 {
-  /* Return the number of leading zeroes: 0-4) */
+  /* Return the number of leading ones: 0-4) */
 
   return g_nibblemap[nibble];
 }
diff --git a/net/utils/net_ipv6_maskcmp.c b/net/utils/net_ipv6_maskcmp.c
index 34d86e1..e8f7e00 100644
--- a/net/utils/net_ipv6_maskcmp.c
+++ b/net/utils/net_ipv6_maskcmp.c
@@ -41,8 +41,6 @@
 
 #include <nuttx/net/ip.h>
 
-#include "utils/utils.h"
-
 #ifdef CONFIG_NET_IPv6
 
 /****************************************************************************
diff --git a/net/utils/net_ipv6_pref2mask.c b/net/utils/net_ipv6_pref2mask.c
index 56dc444..f7521f6 100644
--- a/net/utils/net_ipv6_pref2mask.c
+++ b/net/utils/net_ipv6_pref2mask.c
@@ -101,12 +101,12 @@ void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask)
           else
             {
               /* Eg. preflen = 38, bit = {32}
-               *     bit - preflen = 6
+               *     preflen - bit = 6
                *     mask = 0xffff << (16-6)
                *          = 0xfc00
                */
 
-              mask[i]  = 0xffff << (16 - (bit - preflen));
+              mask[i] = 0xffff << (16 - (preflen - bit));
             }
         }
       else