]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
VSA types are decoded as groups
authorAlan T. DeKok <aland@freeradius.org>
Wed, 6 Sep 2023 12:22:51 +0000 (08:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 6 Sep 2023 12:40:39 +0000 (08:40 -0400)
src/protocols/dhcpv6/decode.c
src/tests/unit/protocols/dhcpv6/microsoft.txt
src/tests/unit/protocols/dhcpv6/relay_forward.txt
src/tests/unit/protocols/dhcpv6/vendor.txt

index 7111af6bc40042d3b35c851017e6923babdc4363..5998a10a79965f83b4225e248e175b34f2264015 100644 (file)
@@ -365,7 +365,25 @@ static ssize_t decode_option(TALLOC_CTX *ctx, fr_pair_list_t *out,
                slen = fr_pair_array_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_value);
 
        } else if (da->type == FR_TYPE_VSA) {
-               slen = decode_vsa(ctx, out, da, data + 4, len, decode_ctx);
+               bool append = false;
+               fr_pair_t *vp;
+
+               vp = fr_pair_find_by_da(out, NULL, da);
+               if (!vp) {
+                       vp = fr_pair_afrom_da(ctx, da);
+                       if (!vp) return PAIR_DECODE_FATAL_ERROR;
+
+                       append = true;
+               }
+
+               slen = decode_vsa(vp, &vp->vp_group, da, data + 4, len, decode_ctx);
+               if (append) {
+                       if (slen < 0) {
+                               TALLOC_FREE(vp);
+                       } else {
+                               fr_pair_append(out, vp);
+                       }
+               }
 
        } else if (da->type == FR_TYPE_TLV) {
                slen = fr_pair_tlvs_from_network(ctx, out, da, data + 4, len, decode_ctx, decode_option, NULL, true);
index a612b2fd7a5b25d41e1f04d1e8fb47035a4656ca..6208ec48b80169b56efaaa6911d11a790e9bc78f 100644 (file)
@@ -16,7 +16,10 @@ encode-pair Vendor-Opts.Microsoft.Rogue-Detection-Request = 0x00
 match 00 11 00 09 00 00 01 37 00 5e 00 01 00
 
 decode-pair -
-match Vendor-Opts.Microsoft = { Rogue-Detection-Request = 0x00 }
+match Vendor-Opts = { Microsoft = { Rogue-Detection-Request = 0x00 } }
+
+encode-pair -
+match 00 11 00 09 00 00 01 37 00 5e 00 01 00
 
 count
-match 7
+match 9
index 1cd242eb76e4af7db18b8363b5e0e5a14ccf2f6c..ae1e29094968e999eafaf9998880375e23108d0b 100644 (file)
@@ -16,10 +16,10 @@ fuzzer-out dhcpv6
 #
 
 decode-proto 0c 01 26 05 86 00 00 06 80 00 00 00 00 00 00 00 00 00 fe 80 00 00 00 00 00 00 02 50 56 ff fe a3 53 fe 00 09 00 c4 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fe 80 00 00 00 00 00 00 02 50 56 ff fe a3 53 fe 00 12 00 1c 4c 41 42 4f 4c 54 32 20 65 74 68 20 31 2f 31 2f 30 35 2f 30 31 2f 32 38 2f 31 2f 31 00 09 00 7e 01 11 41 d7 00 01 00 0e 00 01 00 01 26 b1 b7 f1 00 50 56 a3 53 fe 00 12 00 1c 4c 41 42 4f 4c 54 32 20 65 74 68 20 31 2f 31 2f 30 35 2f 30 31 2f 32 38 2f 31 2f 31 00 06 00 02 00 18 00 08 00 02 00 00 00 03 00 28 56 a3 53 fe 00 00 0e 10 00 00 15 18 00 05 00 18 26 05 86 00 00 06 40 00 00 00 00 00 00 00 00 01 00 00 1c 20 00 00 2a 30 00 19 00 0c 56 a3 53 fe 00 00 0e 10 00 00 15 18 00 25 00 12 00 00 19 7f 00 01 00 01 26 b1 b7 f1 00 50 56 a3 53 fe 00 11 00 2a 00 00 19 7f 00 01 00 0a 4c 41 42 4f 4c 54 32 2d 6e 61 00 02 00 0a 4c 41 42 4f 4c 54 32 2d 70 64 00 03 00 01 3f 00 04 00 01 40
-match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 }
+match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts = { Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 } }
 
 decode-proto 0c 01 26 05 86 00 00 06 80 00 00 00 00 00 00 00 00 00 fe 80 00 00 00 00 00 00 02 50 56 ff fe a3 53 fe 00 09 00 c4 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fe 80 00 00 00 00 00 00 02 50 56 ff fe a3 53 fe 00 12 00 1c 4c 41 42 4f 4c 54 32 20 65 74 68 20 31 2f 31 2f 30 35 2f 30 31 2f 32 38 2f 31 2f 31 00 09 00 7e 01 11 41 d7 00 01 00 0e 00 01 00 01 26 b1 b7 f1 00 50 56 a3 53 fe 00 12 00 1c 4c 41 42 4f 4c 54 32 20 65 74 68 20 31 2f 31 2f 30 35 2f 30 31 2f 32 38 2f 31 2f 31 00 06 00 02 00 18 00 08 00 02 00 00 00 03 00 28 56 a3 53 fe 00 00 0e 10 00 00 15 18 00 05 00 18 26 05 86 00 00 06 40 00 00 00 00 00 00 00 00 01 00 00 1c 20 00 00 2a 30 00 19 00 0c 56 a3 53 fe 00 00 0e 10 00 00 15 18 00 25 00 12 00 00 19 7f 00 01 00 01 26 b1 b7 f1 00 50 56 a3 53 fe 00 11 00 12 00 00 19 7f 00 01 00 0a 4c 41 42 4f 4c 54 32 2d 6e 61 00 11 00 12 00 00 19 7f 00 02 00 0a 4c 41 42 4f 4c 54 32 2d 70 64 00 11 00 09 00 00 19 7f 00 03 00 01 3f 00 11 00 09 00 00 19 7f 00 04 00 01 40
-match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 }
+match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts = { Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 } }
 
 #
 #  This doesn't encode to the longer string above, as we pack multiple Vendor-Opts into one option
@@ -31,7 +31,7 @@ match  0c 01 26 05 86 00 00 06 80 00 00 00 00 00 00 00 00 00 fe 80 00 00 00 00 0
 #  Yes, this is exactly the same massive text blob as above. :)
 #
 decode-proto -
-match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 }
+match Packet-Type = Relay-Forward, Hop-Count = 1, Relay-Link-Address = 2605:8600:6:8000::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Relay-Message = { Packet-Type = Relay-Forward, Hop-Count = 0, Relay-Link-Address = ::, Relay-Peer-Address = fe80::250:56ff:fea3:53fe, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Relay-Message = { Packet-Type = Solicit, Transaction-ID = 0x1141d7, Client-ID = { DUID = LLT, DUID.LLT = { Hardware-Type = Ethernet, Time = "Jul 27 2020 16:06:09 UTC", Hardware-Type.Ethernet = { Address = 00:50:56:a3:53:fe } } }, Interface-ID = 0x4c41424f4c54322065746820312f312f30352f30312f32382f312f31, Option-Request = Domain-List, Elapsed-Time = 0, IA-NA = { IAID = 1453544446, T1 = 3600, T2 = 5400, Options = { IA-Addr = { IPv6-Address = 2605:8600:6:4000::1, Preferred-Lifetime = 7200, Valid-Lifetime = 10800 } } }, IA-PD = { IAID = 1453544446, T1 = 3600, T2 = 5400 } } }, Relay-Agent-Remote-ID = { Vendor = 6527, Value = 0x0001000126b1b7f1005056a353fe }, Vendor-Opts = { Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 } }
 
 count
 match 11
index 4bfc0626d0f2c6e10c14796c163407093085eddf..58c0db677fbf7a6f2d901fed53e594f2aea412a1 100644 (file)
@@ -15,13 +15,13 @@ encode-pair Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT
 match 00 11 00 2a 00 00 19 7f 00 01 00 0a 4c 41 42 4f 4c 54 32 2d 6e 61 00 02 00 0a 4c 41 42 4f 4c 54 32 2d 70 64 00 03 00 01 3f 00 04 00 01 40
 
 decode-pair -
-match Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 }
+match Vendor-Opts = { Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 } }
 
 encode-pair Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na" }, Vendor-Opts.Nokia-SR = { PFX-Pool = "LABOLT2-pd" }, Vendor-Opts.Nokia-SR = { PFX-Len = 63 }, Vendor-Opts.Nokia-SR = { Reserved-NA-Len = 64 }
 match 00 11 00 12 00 00 19 7f 00 01 00 0a 4c 41 42 4f 4c 54 32 2d 6e 61 00 11 00 12 00 00 19 7f 00 02 00 0a 4c 41 42 4f 4c 54 32 2d 70 64 00 11 00 09 00 00 19 7f 00 03 00 01 3f 00 11 00 09 00 00 19 7f 00 04 00 01 40
 
 decode-pair -
-match Vendor-Opts.Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 }
+match Vendor-Opts = { Nokia-SR = { WAN-Pool = "LABOLT2-na", PFX-Pool = "LABOLT2-pd", PFX-Len = 63, Reserved-NA-Len = 64 } }
 
 count
 match 11