[klibc] PATCH: ipconfig may accept DHCPOFFER as DHCPACK
Άλκης Γεωργόπουλος
alkisg at gmail.com
Fri Jun 13 17:24:18 PDT 2008
Hello,
I found a bug in ipconfig and I'm sending a proposed patch for it.
I've only seen it happen in 2 dhcp-server environments. Scenario:
ipconfig sends a DHCP_DISCOVER,
server A answers with a DHCP_OFFER,
server B answers with a DHCP_OFFER,
ipconfig sends a DHCP_REQUEST for server A,
ipconfig accepts the DHCP_OFFER from server B instead of DHCP_ACK from
server A. <== BUG
The reason for this was that in dhcp_parse(), DHCPOFFER and DHCPACK
returned the same value (=1). So I had to modify the return values,
and I thought it would be better to return the constants DHCPOFFER,
DHCPACK etc instead of 1,2,3... I tried to keep the changes as minimal
as possible.
I'm not experienced with the diff program, so please excuse the way
I'm sending the patch: it's the result from the "diff main.c
../ipconfig.old/main.c" and "diff dhcp_proto.c
../ipconfig.old/dhcp_proto.c" commands. The version I used was klibc
1.5.10, Release: 1.
Kind regards,
Alkis
diff main.c ../ipconfig.old/main.c:
195c195
< case DHCPOFFER: /* Offer received */
---
> case 1: /* Offer received */
208c208
< case DHCPACK: /* ACK received */
---
> case 1: /* ACK received */
211c211
< case DHCPNAK: /* NAK received */
---
> case 2: /* NAK received */
diff dhcp_proto.c ../ipconfig.old/dhcp_proto.c:
74,78d73
< * Returns:
< * 0 = Not handled
< * 2 = DHCPOFFER (from dhcp_proto.h)
< * 5 = DHCPACK
< * 6 = DHCPNACK
109,110c104,105
< ret = bootp_parse(dev, hdr, exts, extlen) ? DHCPOFFER : 0;
< if (ret == DHCPOFFER && serverid != INADDR_NONE)
---
> ret = bootp_parse(dev, hdr, exts, extlen);
> if (ret == 1 && serverid != INADDR_NONE)
116c111
< ret = bootp_parse(dev, hdr, exts, extlen) ? DHCPACK : 0;
---
> ret = bootp_parse(dev, hdr, exts, extlen);
121c116
< ret = DHCPNAK;
---
> ret = 2;
130,135d124
< * Returns:
< *-1 = Error in packet_recv
< * 0 = Not handled
< * 2 = DHCPOFFER (from dhcp_proto.h)
< * 5 = DHCPACK
< * 6 = DHCPNACK
More information about the klibc
mailing list