[riot-notifications] [RIOT-OS/RIOT] gnrc_ipv6_ext_frag: Initial import of IPv6 reassembly (#11596)

benpicco notifications at github.com
Fri Sep 13 21:06:42 CEST 2019


benpicco commented on this pull request.

This looks very good!
I only have a few minor comments, but I must also say that I'm not familiar with the GNRC internals, so I might not know what to look out for.

The default settings seem a bit confusing though - did I get it right that it will only support one fragment by default?

> @@ -38,6 +39,40 @@
 extern "C" {
 #endif
 
+/**
+ * @defgroup    net_gnrc_ipv6_ext_conf IPv6 extension header compile configurations
+ * @ingroup     net_gnrc_ipv6_ext
+ * @ingroup     config
+ * @{
+ */
+/**
+ * @brief   IPv6 fragmentation reassembly buffer size
+ *
+ * @note    Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
+ */
+#ifndef GNRC_IPV6_EXT_FRAG_RBUF_SIZE
+#define GNRC_IPV6_EXT_FRAG_RBUF_SIZE        (1U)

So only one fragment is supported as a default?
If I do `USEMODULE += gnrc_ipv6_ext_frag`, I'd expect my node to receive larger packets than before 😉 

> +/**
+ * @brief   IPv6 fragmentation reassembly buffer size
+ *
+ * @note    Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
+ */
+#ifndef GNRC_IPV6_EXT_FRAG_RBUF_SIZE
+#define GNRC_IPV6_EXT_FRAG_RBUF_SIZE        (1U)
+#endif
+
+/**
+ * @brief   The number of total allocatable @ref gnrc_ipv6_ext_frag_limits_t objects
+ *
+ * @note    Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module
+ */
+#ifndef GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE
+#define GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE (GNRC_IPV6_EXT_FRAG_RBUF_SIZE * 2U)

Why is it twice the size of `GNRC_IPV6_EXT_FRAG_RBUF_SIZE`?

Since these are both user-configurable it would be good to have a comment about the relationship between them.

> +        /* first fragment */
+        uint16_t ipv6_len = byteorder_ntohs(ipv6->len);
+
+        /* not divisible by 8*/
+        if ((pkt->size & 0x7)) {
+            DEBUG("ipv6_ext_frag: fragment length not divisible by 8");
+            goto error_exit;
+        }
+        _set_nh(fh_snip->next, nh);
+        gnrc_pktbuf_remove_snip(pkt, fh_snip);
+        /* TODO: RFC 8200 says "- 8"; determine if `sizeof(ipv6_ext_frag_t)` is
+         * really needed*/
+        rbuf->pkt_len += ipv6_len - pkt->size - sizeof(ipv6_ext_frag_t);
+        if (rbuf->pkt != NULL) {
+            /* first fragment but not first arriving */
+            memcpy(rbuf->pkt->data, pkt->data, pkt->size);

Are we sure there will always be enough space in `rbuf->pkt->data`?
I've seen checks for the other cases, but not here - maybe I missed it?

> +        return _completed(rbuf);
+    }
+    else if (!ipv6_ext_frag_more(fh)) {
+        /* first fragment but actually not fragmented */
+        _set_nh(fh_snip->next, nh);
+        gnrc_pktbuf_remove_snip(pkt, fh_snip);
+        gnrc_ipv6_ext_frag_rbuf_del(rbuf);
+        ipv6->len = byteorder_htons(byteorder_ntohs(ipv6->len) -
+                                    sizeof(ipv6_ext_frag_t));
+        return pkt;
+    }
+    else {
+        /* first fragment */
+        uint16_t ipv6_len = byteorder_ntohs(ipv6->len);
+
+        /* not divisible by 8*/

minor nit: space missing

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11596#pullrequestreview-288175003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190913/c7916b07/attachment.htm>


More information about the notifications mailing list