v4.0.x - DHCP - incomplete decoding of IPv4 attribute
I know Arran is working on the DHCP code, so maybe it's already known. Just in case... In function fr_dhcpv4_packet_decode: https://github.com/FreeRADIUS/freeradius-server/blob/ce6c2c641194a49b70d6c6e... case FR_TYPE_IPV4_ADDR: memcpy(&vp->vp_ipv4addr, p, 4); break; I had to add the following two lines after the memcpy: vp->data.vb_ip.af = AF_INET; vp->data.vb_ip.prefix = 32; Otherwise an assertion fails later, e.g.: CONSISTENCY CHECK FAILED src/lib/util/pair_cursor.c[361]: VALUE_PAIR "DHCP-Gateway-IP-Address" address family is not set correctly for IPv4 address. Expected 2 got 0 CONSISTENCY CHECK FAILED src/lib/util/pair_cursor.c[361]: VALUE_PAIR "DHCP-Client-IP-Address" address prefix set correctly for IPv4 address. Expected 32 got 0 Regards, Nicolas. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
On Feb 19, 2018, at 6:16 PM, Chaigneau, Nicolas <nicolas.chaigneau@capgemini.com> wrote:
I know Arran is working on the DHCP code, so maybe it's already known. Just in case...
In function fr_dhcpv4_packet_decode:
https://github.com/FreeRADIUS/freeradius-server/blob/ce6c2c641194a49b70d6c6e...
case FR_TYPE_IPV4_ADDR: memcpy(&vp->vp_ipv4addr, p, 4); break;
I had to add the following two lines after the memcpy:
vp->data.vb_ip.af = AF_INET; vp->data.vb_ip.prefix = 32;
Nah that's the DHCPv4 code, haven't touched that. I'm working on v6. Just swapped out most of that switch statement for a call to fr_value_box_from_network... woo code reuse. -Arran
In function fr_dhcpv4_packet_decode:
https://github.com/FreeRADIUS/freeradius-server/blob/ce6c2c641194a49b70d6c6e...
case FR_TYPE_IPV4_ADDR: memcpy(&vp->vp_ipv4addr, p, 4); break;
I had to add the following two lines after the memcpy:
vp->data.vb_ip.af = AF_INET; vp->data.vb_ip.prefix = 32;
Nah that's the DHCPv4 code, haven't touched that. I'm working on v6. Just swapped out most of that switch statement for a call to fr_value_box_from_network... woo code reuse.
Ooh new shiny code. :) You've broken something though, now decoding the response fails: dhcpclient: Failed decoding packet: Found trailing garbage parsing type "ether". Expected length <= 6 bytes, got 16 bytes Although an ethernet address is indeed on 6 bytes, the DHCP field "chaddr" is padded to 16 characters with zeroes. I've fixed this by restoring these lines here: https://github.com/FreeRADIUS/freeradius-server/blob/05e6c40d9319e6fec179101... case FR_TYPE_ETHERNET: memcpy(vp->vp_ether, p, sizeof(vp->vp_ether)); break; Regards, Nicolas. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
On Feb 21, 2018, at 7:01 PM, Chaigneau, Nicolas <nicolas.chaigneau@capgemini.com> wrote:
Although an ethernet address is indeed on 6 bytes, the DHCP field "chaddr" is padded to 16 characters with zeroes. I've fixed this by restoring these lines here:
https://github.com/FreeRADIUS/freeradius-server/blob/05e6c40d9319e6fec179101...
case FR_TYPE_ETHERNET: memcpy(vp->vp_ether, p, sizeof(vp->vp_ether)); break;
I've pushed a fix, thanks. Alan DeKok.
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Chaigneau, Nicolas