DHCP Option 82, subotion 2 - "DHCP-Relay-Remote-Id" ignored #812

Closed
orcuspl opened this Issue Oct 17, 2014 · 4 comments

Projects

None yet

3 participants

@orcuspl
orcuspl commented Oct 17, 2014

DHCP Option 82, subotion 2 - "DHCP-Relay-Remote-Id" is not parsed by dhcp module in freeradius 3.0.4.

Same config was working fine with 3.0.2.

Part of debug:

        Received DHCP-Discover of Id 481f3a61 from 10.26.17.254:67 to xxx:67
  0: 01 01 06 01 48 1f 3a 61 00 00 00 00 00 00 00 00
  16: 00 00 00 00 00 00 00 00 0a 1a 11 fe d4 be d9 68
  32: 5d 97 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  48: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  64: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  96: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  128: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  144: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  176: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  192: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  208: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  224: 00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
  240: 35 01 01 32 04 0a 1a 11 01 0c 0a 6f 72 63 75 73
  256: 2d 64 65 6c 6c 37 17 01 1c 03 79 1a 0c 0f 77 06
  272: 28 29 57 55 56 2c 2d 2e 2f 2a 79 f9 fc 2a 52 2f
  288: 01 0d 67 65 2d 31 2f 30 2f 31 2e 30 3a 34 33 02
  304: 1e 63 63 3a 65 31 3a 37 66 3a 38 37 3a 62 32 3a
  320: 30 30 3a 31 37 32 2e 31 37 2e 32 31 2e 31 33 ff 

        DHCP-Opcode = Client-Message
        DHCP-Hardware-Type = Ethernet
        DHCP-Hardware-Address-Length = 6
        DHCP-Hop-Count = 1
        DHCP-Transaction-Id = 1210006113
        DHCP-Number-of-Seconds = 0
        DHCP-Flags = 0
        DHCP-Client-IP-Address = 0.0.0.0
        DHCP-Your-IP-Address = 0.0.0.0
        DHCP-Server-IP-Address = 0.0.0.0
        DHCP-Gateway-IP-Address = 10.26.17.254
        DHCP-Client-Hardware-Address = d4:be:d9:68:5d:97
        DHCP-Message-Type += DHCP-Discover
        DHCP-Requested-IP-Address += 10.26.17.1
        DHCP-Hostname += 'orcus-dell'
        DHCP-Parameter-Request-List += DHCP-Subnet-Mask
        DHCP-Parameter-Request-List += DHCP-Broadcast-Address
        DHCP-Parameter-Request-List += DHCP-Router-Address
        DHCP-Parameter-Request-List += DHCP-Classless-Static-Route
        DHCP-Parameter-Request-List += DHCP-Interface-MTU-Size
        DHCP-Parameter-Request-List += DHCP-Hostname
        DHCP-Parameter-Request-List += DHCP-Domain-Name
        DHCP-Parameter-Request-List += DHCP-Domain-Search
        DHCP-Parameter-Request-List += DHCP-Domain-Name-Server
        DHCP-Parameter-Request-List += DHCP-NIS-Domain-Name
        DHCP-Parameter-Request-List += DHCP-NIS-Servers
        DHCP-Parameter-Request-List += DHCP-NDS-Context
        DHCP-Parameter-Request-List += DHCP-NDS-Servers
        DHCP-Parameter-Request-List += DHCP-NDS-Tree-Name
        DHCP-Parameter-Request-List += DHCP-NETBIOS-Name-Servers
        DHCP-Parameter-Request-List += DHCP-NETBIOS-Dgm-Dist-Servers
        DHCP-Parameter-Request-List += DHCP-NETBIOS-Node-Type
        DHCP-Parameter-Request-List += DHCP-NETBIOS
        DHCP-Parameter-Request-List += DHCP-NTP-Servers
        DHCP-Parameter-Request-List += DHCP-Classless-Static-Route
        DHCP-Parameter-Request-List += DHCP-Site-specific-25
        DHCP-Parameter-Request-List += DHCP-Site-specific-28
        DHCP-Parameter-Request-List += DHCP-NTP-Servers
        DHCP-Relay-Circuit-Id += 0x67652d312f302f312e303a3433
  Fri Oct 17 14:46:27 2014 : Debug: (10) Received packet from host 10.26.17.254 port 67  code=1025, id=1210006113, length=336
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Opcode = Client-Message
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Hardware-Type = Ethernet
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Hardware-Address-Length = 6
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Hop-Count = 1
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Transaction-Id = 1210006113
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Number-of-Seconds = 0
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Flags = 0
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Client-IP-Address = 0.0.0.0
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Your-IP-Address = 0.0.0.0
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Server-IP-Address = 0.0.0.0
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Gateway-IP-Address = 10.26.17.254
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Client-Hardware-Address = d4:be:d9:68:5d:97
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Message-Type += DHCP-Discover
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Requested-IP-Address += 10.26.17.1
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Hostname += 'orcus-dell'
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Subnet-Mask
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Broadcast-Address
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Router-Address
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Classless-Static-Route
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Interface-MTU-Size
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Hostname
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Domain-Name
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Domain-Search
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Domain-Name-Server
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NIS-Domain-Name
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NIS-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NDS-Context
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NDS-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NDS-Tree-Name
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NETBIOS-Name-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NETBIOS-Dgm-Dist-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NETBIOS-Node-Type
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NETBIOS
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NTP-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Classless-Static-Route
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Site-specific-25
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-Site-specific-28
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Parameter-Request-List += DHCP-NTP-Servers
  Fri Oct 17 14:46:27 2014 : Debug: (10)  DHCP-Relay-Circuit-Id += 0x67652d312f302f312e303a3433
  Fri Oct 17 14:46:27 2014 : Debug: Trying sub-section dhcp DHCP-Discover {...}
  [...]

Same packet in tcpdump:

    10.26.17.254.bootps > xxx.bootps: [udp sum ok] BOOTP/DHCP, Request from d4:be:d9:68:5d:97 (oui Unknown), length 336, hops 1, xid 0x481f3a61, secs 3, Flags [none] (0x0000)
          Gateway-IP 10.26.17.254
          Client-Ethernet-Address d4:be:d9:68:5d:97 (oui Unknown)
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Discover
            Requested-IP Option 50, length 4: 10.26.17.1
            Hostname Option 12, length 10: "orcus-dell"
            Parameter-Request Option 55, length 23:
              Subnet-Mask, BR, Default-Gateway, Classless-Static-Route
              MTU, Hostname, Domain-Name, Option 119
              Domain-Name-Server, YD, YS, Option 87
              Option 85, Option 86, Netbios-Name-Server, WDD
              Netbios-Node, Netbios-Scope, NTP, Classless-Static-Route
              Classless-Static-Route-Microsoft, Option 252, NTP
            Agent-Information Option 82, length 47:
              Circuit-ID SubOption 1, length 13: ge-1/0/1.0:43
              Remote-ID SubOption 2, length 30: cc:e1:7f:87:b2:00:172.17.21.13
            END Option 255, length 0
@alandekok
Member

What output does 3.0.2 produce?

@orcuspl
orcuspl commented Oct 17, 2014

I have no remote access to previous dhcp client machine. Dumps from 3.0.4 and 3.0.2 for another client:
3.0.4:

Received DHCP-Discover of Id 7986a672 from 10.26.17.254:67 to XXX:67
0: 01 01 06 01 79 86 a6 72 00 00 00 00 00 00 00 00
16: 00 00 00 00 00 00 00 00 0a 1a 11 fe 00 24 1d c4
32: a7 b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00
48: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
64: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
96: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
128: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
144: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
176: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
192: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
208: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
224: 00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
240: 35 01 01 3d 07 01 00 24 1d c4 a7 b8 3c 0c 64 68
256: 63 70 63 64 20 33 2e 32 2e 33 0c 05 6f 72 63 75
272: 73 37 01 06 52 2f 01 0d 67 65 2d 31 2f 30 2f 32
288: 2e 30 3a 34 33 02 1e 63 63 3a 65 31 3a 37 66 3a
304: 38 37 3a 62 32 3a 30 30 3a 31 37 32 2e 31 37 2e
320: 32 31 2e 31 33 ff
        DHCP-Opcode = Client-Message
        DHCP-Hardware-Type = Ethernet
        DHCP-Hardware-Address-Length = 6
        DHCP-Hop-Count = 1
        DHCP-Transaction-Id = 2038867570
        DHCP-Number-of-Seconds = 0
        DHCP-Flags = 0
        DHCP-Client-IP-Address = 0.0.0.0
        DHCP-Your-IP-Address = 0.0.0.0
        DHCP-Server-IP-Address = 0.0.0.0
        DHCP-Gateway-IP-Address = 10.26.17.254
        DHCP-Client-Hardware-Address = 00:24:1d:c4:a7:b8
        DHCP-Message-Type += DHCP-Discover
        DHCP-Client-Identifier += 0x0100241dc4a7b8
        DHCP-Vendor-Class-Identifier += 0x64686370636420332e322e33
        DHCP-Hostname += 'orcus'
        DHCP-Parameter-Request-List += DHCP-Domain-Name-Server
        DHCP-Relay-Circuit-Id += 0x67652d312f302f322e303a3433
Fri Oct 17 20:28:13 2014 : Debug: (2) Received packet from host 10.26.17.254 port 67 code=1025, id=2038867570, length=326
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Opcode = Client-Message
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Hardware-Type = Ethernet
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Hardware-Address-Length = 6
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Hop-Count = 1
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Transaction-Id = 2038867570
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Number-of-Seconds = 0
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Flags = 0
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Client-IP-Address = 0.0.0.0
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Your-IP-Address = 0.0.0.0
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Server-IP-Address = 0.0.0.0
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Gateway-IP-Address = 10.26.17.254
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Client-Hardware-Address = 00:24:1d:c4:a7:b8
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Message-Type += DHCP-Discover
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Client-Identifier += 0x0100241dc4a7b8
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Vendor-Class-Identifier += 0x64686370636420332e322e33
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Hostname += 'orcus'
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Parameter-Request-List += DHCP-Domain-Name-Server
Fri Oct 17 20:28:13 2014 : Debug: (2)   DHCP-Relay-Circuit-Id += 0x67652d312f302f322e303a3433
Fri Oct 17 20:28:13 2014 : Debug: Trying sub-section dhcp DHCP-Discover {...}

3.0.2:

Received DHCP-Discover of id 10c75c61 from 10.26.17.254:67 to XXX:67
0: 01 01 06 01 10 c7 5c 61 00 00 00 00 00 00 00 00
16: 00 00 00 00 00 00 00 00 0a 1a 11 fe 00 24 1d c4
32: a7 b8 00 00 00 00 00 00 00 00 00 00 00 00 00 00
48: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
64: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
96: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
112: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
128: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
144: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
176: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
192: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
208: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
224: 00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
240: 35 01 01 3d 07 01 00 24 1d c4 a7 b8 3c 0c 64 68
256: 63 70 63 64 20 33 2e 32 2e 33 0c 05 6f 72 63 75
272: 73 37 01 06 52 2f 01 0d 67 65 2d 31 2f 30 2f 32
288: 2e 30 3a 34 33 02 1e 63 63 3a 65 31 3a 37 66 3a
304: 38 37 3a 62 32 3a 30 30 3a 31 37 32 2e 31 37 2e
320: 32 31 2e 31 33 ff
        DHCP-Opcode = Client-Message
        DHCP-Hardware-Type = Ethernet
        DHCP-Hardware-Address-Length = 6
        DHCP-Hop-Count = 1
        DHCP-Transaction-Id = 281500769
        DHCP-Number-of-Seconds = 0
        DHCP-Flags = 0
        DHCP-Client-IP-Address = 0.0.0.0
        DHCP-Your-IP-Address = 0.0.0.0
        DHCP-Server-IP-Address = 0.0.0.0
        DHCP-Gateway-IP-Address = 10.26.17.254
        DHCP-Client-Hardware-Address = 00:24:1d:c4:a7:b8
        DHCP-Message-Type += DHCP-Discover
        DHCP-Client-Identifier += 0x00241dc4a7b8
        DHCP-Vendor-Class-Identifier += 0x64686370636420332e322e33
        DHCP-Hostname += 'orcus'
        DHCP-Parameter-Request-List += 6
        DHCP-Relay-Circuit-Id = 0x67652d312f302f322e303a3433
        DHCP-Relay-Remote-Id = 0x63633a65313a37663a38373a62323a30303a3137322e31372e32312e3133
Fri Oct 17 20:33:24 2014 : Debug: Trying sub-section dhcp DHCP-Discover {...}

3.0.3 is segfaulting just after parsing configuration (Centos 6.5) so I'm not able to check it.

@orcuspl
orcuspl commented Oct 17, 2014

Above fr_dhcp_attr2vp definition in src/modules/proto_dhcp/dhcp.c there is a comment "Decode ONE value into a VP". Somewhere in docs I've read that you are getting rid of subTLVs in VALUE_PAIR. Currently fr_dhcp_decode_suboption may return more than one VALUE_PAIR and fr_dhcp_decode_options is not prepared for this as it's using fr_cursor_insert instead of fr_cursor_merge.

I never looked into freeradius source code before today so patch is based only on what I've found in docs:

--- freeradius-server-3.0.4/src/modules/proto_dhcp/dhcp.c       2014-09-10 15:57:22.000000000 +0200
+++ freeradius-server-3.0.4_orc/src/modules/proto_dhcp/dhcp.c   2014-10-17 22:25:23.031487200 +0200
@@ -994,7 +994,7 @@
                                pairfree(out);
                                return -1;
                        }
-                       fr_cursor_insert(&cursor, vp);
+                       fr_cursor_merge(&cursor, vp);

                        for (vp = fr_cursor_current(&cursor);
                             vp;
@arr2036
Member
arr2036 commented Oct 18, 2014

Yes, you're correct. The behaviour of fr_cursor_insert changed to only insert single VALUE_PAIRs, fr_cursor_merge is now the correct function to use.

@arr2036 arr2036 closed this in 96e35fc Oct 18, 2014
@pwdng pwdng added a commit to pwdng/freeradius-server that referenced this issue Oct 24, 2014
@arr2036 @pwdng arr2036 + pwdng Need to merge suboptions list, not insert the head of it, closes #812 41fdee5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment