[riot-notifications] [RIOT-OS/RIOT] sys/net/dhcpv6: Add IA_NA support to the DHCPv6 client (#16228)

Martine Lenders notifications at github.com
Wed Aug 11 10:56:40 CEST 2021


@miri64 commented on this pull request.



> +
+def check_ia_pd_addr(ia_pd_addr, global_pfx):
+    """Check if the expected IA_PD address has been assigned"""
+    return ia_pd_addr.startswith(global_pfx)
+
+
+def check_global_addrs(ia_na_addr, ia_pd_addr, global_pfx):
+    """Perform IA_NA check for the first and IA_PD for the second address"""
+    return check_ia_na_addr(ia_na_addr) and check_ia_pd_addr(ia_pd_addr, global_pfx)
+
+
+def test_global_addrs(global_addr_1, global_addr_2, global_pfx):
+    """Assert that one global address is the IA_NA and the other one is the IA_PD address"""
+    result_1 = check_global_addrs(global_addr_1, global_addr_2, global_pfx)
+    result_2 = check_global_addrs(global_addr_2, global_addr_1, global_pfx)
+    assert result_1 != result_2

Ahh now I get what you are trying to do

>From my testing with

<details><summary>this patch applied</summary>

```diff
diff --git a/tests/gnrc_dhcpv6_client/kea-dhcp6.conf b/tests/gnrc_dhcpv6_client/kea-dhcp6.conf
index 593edcb9d8..a2a8ab429c 100644
--- a/tests/gnrc_dhcpv6_client/kea-dhcp6.conf
+++ b/tests/gnrc_dhcpv6_client/kea-dhcp6.conf
@@ -23,24 +23,9 @@
     {    "interface": "tapbr0",
          "subnet": "2001:db8::/32",
          "pools": [ { "pool": "2001:db8:1::/64" } ],
-         "pd-pools": [ { "prefix": "2001:db8::",
-                         "prefix-len": 32,
+         "pd-pools": [ { "prefix": "2001:db8:8000::",
+                         "prefix-len": 33,
                          "delegated-len": 64 } ] }
     ]
-  },
-"Logging":
-{
-  "loggers": [
-    {
-      "name": "kea-dhcp6",
-      "output_options": [
-          {
-            "output": "stderr"
-          }
-      ],
-      "severity": "INFO",
-      "debuglevel": 0
-    }
-  ]
-}
+  }
 }
diff --git a/tests/gnrc_dhcpv6_client/tests-as-root/01-run.py b/tests/gnrc_dhcpv6_client/tests-as-root/01-run.py
index 8dec38935c..4177708463 100755
--- a/tests/gnrc_dhcpv6_client/tests-as-root/01-run.py
+++ b/tests/gnrc_dhcpv6_client/tests-as-root/01-run.py
@@ -57,12 +57,16 @@ def extract_global_addresses(child):
 
 def check_ia_na_addr(ia_na_addr):
     """Check if the expected IA_NA address has been assigned"""
-    return IPv6Address(ia_na_addr) in IPv6Network("{}/64".format(IA_NA_ADDRESS_POOL_PREFIX))
+    res = IPv6Address(ia_na_addr) in IPv6Network("{}/64".format(IA_NA_ADDRESS_POOL_PREFIX))
+    print("check_ia_na_addr", ia_na_addr, res)
+    return res
 
 
 def check_ia_pd_addr(ia_pd_addr, global_pfx):
     """Check if the expected IA_PD address has been assigned"""
-    return ia_pd_addr.startswith(global_pfx)
+    res = ia_pd_addr.startswith(global_pfx)
+    print("check_ia_pd_addr", ia_pd_addr, global_pfx, res)
+    return res
 
 
 def check_global_addrs(ia_na_addr, ia_pd_addr, global_pfx):
@@ -72,7 +76,9 @@ def check_global_addrs(ia_na_addr, ia_pd_addr, global_pfx):
 
 def test_global_addrs(global_addr_1, global_addr_2, global_pfx):
     """Assert that one global address is the IA_NA and the other one is the IA_PD address"""
+    print("result_1")
     result_1 = check_global_addrs(global_addr_1, global_addr_2, global_pfx)
+    print("result_2")
     result_2 = check_global_addrs(global_addr_2, global_addr_1, global_pfx)
     assert result_1 != result_2
```

(ignore the logging part removal that is because my kea is quite new and not understood by that version anymore)

</details>

I see, that the results could be

```
assert {"ia_na_check": True, "ia_pd_check": True} != {"ia_na_check": False, "ia_pd_check": False}
```

(which makes more sense than `ia_pd_check` always being `False`), so the final check actually should be

```py
assert result_1["ia_na_check"] or result_2["ia_na_check"]
assert result_1["ia_pd_check"] or result_2["ia_pd_check"]
```

I really recommend changing the prefix for PD (and maybe adopting the check to be similar to the PD one, as the IA_NA's prefix also ends up in the prefix list.


-- 
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/16228#discussion_r686636138
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210811/59f8ab5d/attachment.htm>


More information about the notifications mailing list