You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/01/12 16:19:32 UTC

[1/4] incubator-mynewt-core git commit: mn_socket unit test; clear scope_id of v6 sockaddr.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 0845466b6 -> a6ab2016d


mn_socket unit test; clear scope_id of v6 sockaddr.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/bc7a4f5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/bc7a4f5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/bc7a4f5e

Branch: refs/heads/develop
Commit: bc7a4f5e2dcea9a337ebccfceaa77483c9b47922
Parents: 0845466
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jan 12 08:13:37 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jan 12 08:13:37 2017 -0800

----------------------------------------------------------------------
 net/ip/mn_socket/test/src/mn_sock_util.c | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bc7a4f5e/net/ip/mn_socket/test/src/mn_sock_util.c
----------------------------------------------------------------------
diff --git a/net/ip/mn_socket/test/src/mn_sock_util.c b/net/ip/mn_socket/test/src/mn_sock_util.c
index aea436e..bbbaa19 100644
--- a/net/ip/mn_socket/test/src/mn_sock_util.c
+++ b/net/ip/mn_socket/test/src/mn_sock_util.c
@@ -677,6 +677,7 @@ sock_udp_mcast_v6(void)
     msin6.msin6_family = MN_AF_INET6;
     msin6.msin6_len = sizeof(msin6);
     msin6.msin6_port = htons(44344);
+    msin6.msin6_scope_id = 0;
     memset(&msin6.msin6_addr, 0, sizeof(msin6.msin6_addr));
 
     rc = mn_socket(&rx_sock, MN_PF_INET6, MN_SOCK_DGRAM, 0);


[2/4] incubator-mynewt-core git commit: oic; ble - count incoming/outgoing frames separate from fragments.

Posted by ma...@apache.org.
oic; ble - count incoming/outgoing frames separate from fragments.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4aad7931
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4aad7931
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4aad7931

Branch: refs/heads/develop
Commit: 4aad793167d60202d26440f78b308344fbc797c4
Parents: bc7a4f5
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jan 12 08:14:57 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jan 12 08:14:57 2017 -0800

----------------------------------------------------------------------
 net/oic/src/port/mynewt/ble_adaptor.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4aad7931/net/oic/src/port/mynewt/ble_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/ble_adaptor.c b/net/oic/src/port/mynewt/ble_adaptor.c
index cf7075e..b3ff59e 100644
--- a/net/oic/src/port/mynewt/ble_adaptor.c
+++ b/net/oic/src/port/mynewt/ble_adaptor.c
@@ -58,18 +58,22 @@ static const uint8_t oc_gatt_rsp_chr_uuid[16] = {
 };
 
 STATS_SECT_START(oc_ble_stats)
+    STATS_SECT_ENTRY(iframe)
     STATS_SECT_ENTRY(iseg)
     STATS_SECT_ENTRY(ibytes)
     STATS_SECT_ENTRY(ierr)
+    STATS_SECT_ENTRY(oframe)
     STATS_SECT_ENTRY(oseg)
     STATS_SECT_ENTRY(obytes)
     STATS_SECT_ENTRY(oerr)
 STATS_SECT_END
 static STATS_SECT_DECL(oc_ble_stats) oc_ble_stats;
 STATS_NAME_START(oc_ble_stats)
+    STATS_NAME(oc_ble_stats, iframe)
     STATS_NAME(oc_ble_stats, iseg)
     STATS_NAME(oc_ble_stats, ibytes)
     STATS_NAME(oc_ble_stats, ierr)
+    STATS_NAME(oc_ble_stats, oframe)
     STATS_NAME(oc_ble_stats, oseg)
     STATS_NAME(oc_ble_stats, obytes)
     STATS_NAME(oc_ble_stats, oerr)
@@ -143,6 +147,7 @@ oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle)
 
             if (coap_tcp_msg_size(hdr, sizeof(hdr)) <= pkt2->omp_len) {
                 STAILQ_REMOVE(&oc_ble_reass_q, pkt2, os_mbuf_pkthdr, omp_next);
+                STATS_INC(oc_ble_stats, iframe);
                 oc_recv_message(om2);
             }
             pkt1 = NULL;
@@ -176,6 +181,7 @@ oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle)
           coap_tcp_msg_size(hdr, sizeof(hdr)) > pkt2->omp_len) {
             STAILQ_INSERT_TAIL(&oc_ble_reass_q, pkt2, omp_next);
         } else {
+            STATS_INC(oc_ble_stats, iframe);
             oc_recv_message(om2);
         }
     }
@@ -332,7 +338,7 @@ oc_send_buffer_gatt(struct os_mbuf *m)
 
 #if (MYNEWT_VAL(OC_SERVER) == 1)
 
-    STATS_INC(oc_ble_stats, oseg);
+    STATS_INC(oc_ble_stats, oframe);
     STATS_INCN(oc_ble_stats, obytes, OS_MBUF_PKTLEN(m));
 
     mtu = ble_att_mtu(conn_handle);
@@ -348,6 +354,7 @@ oc_send_buffer_gatt(struct os_mbuf *m)
         return;
     }
     while (1) {
+        STATS_INC(oc_ble_stats, oseg);
         pkt = STAILQ_NEXT(OS_MBUF_PKTHDR(m), omp_next);
 
         ble_gattc_notify_custom(conn_handle, oc_ble_coap_rsp_handle, m);


[4/4] incubator-mynewt-core git commit: oic unit test; do statistics during unit test.

Posted by ma...@apache.org.
oic unit test; do statistics during unit test.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a6ab2016
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a6ab2016
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a6ab2016

Branch: refs/heads/develop
Commit: a6ab2016d15152ce15c7ae95ee3441d0e0c922a4
Parents: 0573c34
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jan 12 08:18:39 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jan 12 08:18:39 2017 -0800

----------------------------------------------------------------------
 net/oic/test/pkg.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a6ab2016/net/oic/test/pkg.yml
----------------------------------------------------------------------
diff --git a/net/oic/test/pkg.yml b/net/oic/test/pkg.yml
index 538b114..ce98a54 100644
--- a/net/oic/test/pkg.yml
+++ b/net/oic/test/pkg.yml
@@ -27,6 +27,7 @@ pkg.deps:
     - encoding/tinycbor
     - encoding/cborattr
     - test/testutil
+    - sys/stats
 
 pkg.deps.SELFTEST:
     - sys/console/stub


[3/4] incubator-mynewt-core git commit: oic; ip - multicast TX was not right. Fix mbuf frees on failure paths. Add statistics.

Posted by ma...@apache.org.
oic; ip - multicast TX was not right. Fix mbuf frees on failure
paths. Add statistics.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0573c340
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0573c340
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0573c340

Branch: refs/heads/develop
Commit: 0573c3409d546ac278c63f9828381bb16acee0b2
Parents: 4aad793
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Jan 12 08:16:58 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Jan 12 08:16:58 2017 -0800

----------------------------------------------------------------------
 net/oic/src/port/mynewt/ip_adaptor.c | 87 +++++++++++++++++++++----------
 1 file changed, 60 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0573c340/net/oic/src/port/mynewt/ip_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/ip_adaptor.c b/net/oic/src/port/mynewt/ip_adaptor.c
index a228128..6f5846f 100644
--- a/net/oic/src/port/mynewt/ip_adaptor.c
+++ b/net/oic/src/port/mynewt/ip_adaptor.c
@@ -27,6 +27,7 @@
 
 #include <log/log.h>
 #include <mn_socket/mn_socket.h>
+#include <stats/stats.h>
 
 #include "port/oc_connectivity.h"
 #include "oic/oc_log.h"
@@ -51,12 +52,31 @@ static const struct mn_in6_addr coap_all_nodes_v6 = {
                0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFD}
 };
 
+STATS_SECT_START(oc_ip_stats)
+    STATS_SECT_ENTRY(iframe)
+    STATS_SECT_ENTRY(ibytes)
+    STATS_SECT_ENTRY(ierr)
+    STATS_SECT_ENTRY(oucast)
+    STATS_SECT_ENTRY(omcast)
+    STATS_SECT_ENTRY(obytes)
+    STATS_SECT_ENTRY(oerr)
+STATS_SECT_END
+static STATS_SECT_DECL(oc_ip_stats) oc_ip_stats;
+STATS_NAME_START(oc_ip_stats)
+    STATS_NAME(oc_ip_stats, iframe)
+    STATS_NAME(oc_ip_stats, ibytes)
+    STATS_NAME(oc_ip_stats, ierr)
+    STATS_NAME(oc_ip_stats, oucast)
+    STATS_NAME(oc_ip_stats, omcast)
+    STATS_NAME(oc_ip_stats, obytes)
+    STATS_NAME(oc_ip_stats, oerr)
+STATS_NAME_END(oc_ip_stats)
 
 /* sockets to use for coap unicast and multicast */
-static struct mn_socket *ucast;
+static struct mn_socket *oc_ucast;
 
 #if (MYNEWT_VAL(OC_SERVER) == 1)
-static struct mn_socket *mcast;
+static struct mn_socket *oc_mcast;
 #endif
 
 static void
@@ -78,6 +98,7 @@ oc_send_buffer_ip_int(struct os_mbuf *m, int is_mcast)
     to.msin6_scope_id = oe->oe_ip.v6.scope;
     memcpy(&to.msin6_addr, oe->oe_ip.v6.address, sizeof(to.msin6_addr));
 
+    STATS_INCN(oc_ip_stats, obytes, OS_MBUF_PKTLEN(m));
     if (is_mcast) {
         memset(&itf, 0, sizeof(itf));
         memset(&itf2, 0, sizeof(itf2));
@@ -88,7 +109,8 @@ oc_send_buffer_ip_int(struct os_mbuf *m, int is_mcast)
                 break;
             }
 
-            if (0 == (itf.mif_flags & MN_ITF_F_UP)) {
+            if ((itf.mif_flags & (MN_ITF_F_UP | MN_ITF_F_MULTICAST)) !=
+              (MN_ITF_F_UP | MN_ITF_F_MULTICAST)) {
                 continue;
             }
 
@@ -99,46 +121,52 @@ oc_send_buffer_ip_int(struct os_mbuf *m, int is_mcast)
 
             n = os_mbuf_dup(m);
             if (!n) {
+                STATS_INC(oc_ip_stats, oerr);
                 break;
             }
             to.msin6_scope_id = itf2.mif_idx;
-            rc = mn_sendto(ucast, n, (struct mn_sockaddr *) &to);
+            rc = mn_sendto(oc_ucast, n, (struct mn_sockaddr *) &to);
             if (rc != 0) {
                 OC_LOG_ERROR("Failed to send buffer %u on itf %d\n",
                              OS_MBUF_PKTHDR(m)->omp_len, to.msin6_scope_id);
+                STATS_INC(oc_ip_stats, oerr);
                 os_mbuf_free_chain(n);
             }
+            memcpy(&itf2, &itf, sizeof(itf));
         }
         if (itf2.mif_idx) {
             to.msin6_scope_id = itf2.mif_idx;
-            rc = mn_sendto(ucast, m, (struct mn_sockaddr *) &to);
+            rc = mn_sendto(oc_ucast, m, (struct mn_sockaddr *) &to);
             if (rc != 0) {
                 OC_LOG_ERROR("Failed sending buffer %u on itf %d\n",
                              OS_MBUF_PKTHDR(m)->omp_len, to.msin6_scope_id);
+                STATS_INC(oc_ip_stats, oerr);
                 os_mbuf_free_chain(m);
             }
+        } else {
+            os_mbuf_free_chain(m);
         }
     } else {
-        rc = mn_sendto(ucast, m, (struct mn_sockaddr *) &to);
+        rc = mn_sendto(oc_ucast, m, (struct mn_sockaddr *) &to);
         if (rc != 0) {
             OC_LOG_ERROR("Failed to send buffer %u on itf %d\n",
                          OS_MBUF_PKTHDR(m)->omp_len, to.msin6_scope_id);
+            STATS_INC(oc_ip_stats, oerr);
             os_mbuf_free_chain(m);
         }
     }
-    if (rc) {
-        os_mbuf_free_chain(m);
-    }
 }
 
 void
 oc_send_buffer_ip(struct os_mbuf *m)
 {
+    STATS_INC(oc_ip_stats, oucast);
     oc_send_buffer_ip_int(m, 0);
 }
 void
 oc_send_buffer_ip_mcast(struct os_mbuf *m)
 {
+    STATS_INC(oc_ip_stats, omcast);
     oc_send_buffer_ip_int(m, 1);
 }
 
@@ -157,6 +185,8 @@ oc_attempt_rx_ip_sock(struct mn_socket *rxsock)
     }
     assert(OS_MBUF_IS_PKTHDR(n));
 
+    STATS_INC(oc_ip_stats, iframe);
+    STATS_INCN(oc_ip_stats, ibytes, OS_MBUF_PKTLEN(n));
     m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint_ip));
     if (!m) {
         OC_LOG_ERROR("Could not allocate RX buffer\n");
@@ -177,6 +207,7 @@ oc_attempt_rx_ip_sock(struct mn_socket *rxsock)
 
     /* add the addr info to the message */
 rx_attempt_err:
+    STATS_INC(oc_ip_stats, ierr);
     os_mbuf_free_chain(n);
     return NULL;
 }
@@ -186,10 +217,10 @@ oc_attempt_rx_ip(void)
 {
     struct os_mbuf *m;
 
-    m = oc_attempt_rx_ip_sock(ucast);
+    m = oc_attempt_rx_ip_sock(oc_ucast);
 #if (MYNEWT_VAL(OC_SERVER) == 1)
-    if (m == NULL ) {
-        m = oc_attempt_rx_ip_sock(mcast);
+    if (m == NULL) {
+        m = oc_attempt_rx_ip_sock(oc_mcast);
     }
 #endif
     return m;
@@ -211,13 +242,13 @@ oc_socks_readable(void *cb_arg, int err)
 void
 oc_connectivity_shutdown_ip(void)
 {
-    if (ucast) {
-        mn_close(ucast);
+    if (oc_ucast) {
+        mn_close(oc_ucast);
     }
 
 #if (MYNEWT_VAL(OC_SERVER) == 1)
-    if (mcast) {
-        mn_close(mcast);
+    if (oc_mcast) {
+        mn_close(oc_mcast);
     }
 #endif
 
@@ -242,30 +273,31 @@ oc_connectivity_init_ip(void)
 
     memset(&itf, 0, sizeof(itf));
 
-    rc = mn_socket(&ucast, MN_PF_INET6, MN_SOCK_DGRAM, 0);
-    if (rc != 0 || !ucast) {
+    rc = mn_socket(&oc_ucast, MN_PF_INET6, MN_SOCK_DGRAM, 0);
+    if (rc != 0 || !oc_ucast) {
         OC_LOG_ERROR("Could not create oc unicast socket\n");
         return rc;
     }
-    mn_socket_set_cbs(ucast, ucast, &oc_sock_cbs);
+    mn_socket_set_cbs(oc_ucast, oc_ucast, &oc_sock_cbs);
 
 #if (MYNEWT_VAL(OC_SERVER) == 1)
-    rc = mn_socket(&mcast, MN_PF_INET6, MN_SOCK_DGRAM, 0);
-    if (rc != 0 || !mcast) {
-        mn_close(ucast);
+    rc = mn_socket(&oc_mcast, MN_PF_INET6, MN_SOCK_DGRAM, 0);
+    if (rc != 0 || !oc_mcast) {
+        mn_close(oc_ucast);
         OC_LOG_ERROR("Could not create oc multicast socket\n");
         return rc;
     }
-    mn_socket_set_cbs(mcast, mcast, &oc_sock_cbs);
+    mn_socket_set_cbs(oc_mcast, oc_mcast, &oc_sock_cbs);
 #endif
 
     sin.msin6_len = sizeof(sin);
     sin.msin6_family = MN_AF_INET6;
     sin.msin6_port = 0;
     sin.msin6_flowinfo = 0;
+    sin.msin6_scope_id = 0;
     memcpy(&sin.msin6_addr, nm_in6addr_any, sizeof(sin.msin6_addr));
 
-    rc = mn_bind(ucast, (struct mn_sockaddr *)&sin);
+    rc = mn_bind(oc_ucast, (struct mn_sockaddr *)&sin);
     if (rc != 0) {
         OC_LOG_ERROR("Could not bind oc unicast socket\n");
         goto oc_connectivity_init_err;
@@ -281,7 +313,8 @@ oc_connectivity_init_ip(void)
             break;
         }
 
-        if (0 == (itf.mif_flags & MN_ITF_F_UP)) {
+        if ((itf.mif_flags & (MN_ITF_F_UP | MN_ITF_F_MULTICAST)) !=
+          (MN_ITF_F_UP | MN_ITF_F_MULTICAST)) {
             continue;
         }
 
@@ -289,7 +322,7 @@ oc_connectivity_init_ip(void)
         join.mm_idx = itf.mif_idx;
         join.mm_family = MN_AF_INET6;
 
-        rc = mn_setsockopt(mcast, MN_SO_LEVEL, MN_MCAST_JOIN_GROUP, &join);
+        rc = mn_setsockopt(oc_mcast, MN_SO_LEVEL, MN_MCAST_JOIN_GROUP, &join);
         if (rc != 0) {
             continue;
         }
@@ -298,7 +331,7 @@ oc_connectivity_init_ip(void)
     }
 
     sin.msin6_port = htons(COAP_PORT_UNSECURED);
-    rc = mn_bind(mcast, (struct mn_sockaddr *)&sin);
+    rc = mn_bind(oc_mcast, (struct mn_sockaddr *)&sin);
     if (rc != 0) {
         OC_LOG_ERROR("Could not bind oc multicast socket\n");
         goto oc_connectivity_init_err;