[dhcp] Use a random DHCP transaction identifier (xid)

iPXE currently uses the last four bytes of the MAC address as the DHCP
transaction identifier.  Reduce the probability of collisions by
generating a random transaction identifier.

Originally-implemented-by: Amos Kong <akong@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2011-09-19 17:30:39 +01:00
parent 8b092f4c50
commit 12767d2202
3 changed files with 36 additions and 29 deletions

View File

@@ -114,7 +114,8 @@ int create_fakedhcpdiscover ( struct net_device *netdev,
int rc;
if ( ( rc = dhcp_create_request ( &dhcppkt, netdev, DHCPDISCOVER,
ciaddr, data, max_len ) ) != 0 ) {
dhcp_last_xid, ciaddr, data,
max_len ) ) != 0 ) {
DBG ( "Could not create DHCPDISCOVER: %s\n",
strerror ( rc ) );
return rc;
@@ -139,7 +140,8 @@ int create_fakedhcpack ( struct net_device *netdev,
int rc;
/* Create base DHCPACK packet */
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK, NULL, 0,
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK,
dhcp_last_xid, NULL, 0,
data, max_len ) ) != 0 ) {
DBG ( "Could not create DHCPACK: %s\n", strerror ( rc ) );
return rc;
@@ -190,7 +192,8 @@ int create_fakepxebsack ( struct net_device *netdev,
}
/* Create base DHCPACK packet */
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK, NULL, 0,
if ( ( rc = dhcp_create_packet ( &dhcppkt, netdev, DHCPACK,
dhcp_last_xid, NULL, 0,
data, max_len ) ) != 0 ) {
DBG ( "Could not create PXE BS ACK: %s\n",
strerror ( rc ) );