[dhcp] Remove obsolete dhcp_chaddr() function
As of commit03f0c23
("[ipoib] Expose Ethernet-compatible eIPoIB link-layer addresses and headers"), all link layers have used addresses which fit within the DHCP chaddr field. The dhcp_chaddr() function was therefore made obsolete by this commit, but was accidentally left present (though unused) in the source code. Remove the dhcp_chaddr() function and the only remaining use of it, unnecessarily introduced in commit08bcc0f
("[dhcp] Check for matching chaddr in received DHCP packets"). Reported-by: Wissam Shoukair <wissams@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
08bcc0fe01
commit
6a22170085
|
@ -130,29 +130,6 @@ static inline const char * dhcp_msgtype_name ( unsigned int msgtype ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Transcribe DHCP client hardware address (for debugging)
|
|
||||||
*
|
|
||||||
* @v chaddr Client hardware address
|
|
||||||
* @v hlen Client hardware address length
|
|
||||||
*/
|
|
||||||
static const char * dhcp_chaddr_ntoa ( const void *chaddr, size_t hlen ) {
|
|
||||||
static char buf[ 48 /* 16 x ( "xx" + ":" or NUL ) */ ];
|
|
||||||
const uint8_t *chaddr_bytes = chaddr;
|
|
||||||
char *tmp = buf;
|
|
||||||
|
|
||||||
/* Sanity check */
|
|
||||||
assert ( hlen < ( sizeof ( buf ) / 3 ) );
|
|
||||||
|
|
||||||
/* Transcribe address */
|
|
||||||
while ( hlen-- ) {
|
|
||||||
tmp += sprintf ( tmp, "%s%02x", ( ( tmp == buf ) ? "" : ":" ),
|
|
||||||
*(chaddr_bytes++) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* DHCP session
|
* DHCP session
|
||||||
|
@ -864,53 +841,6 @@ static struct dhcp_session_state dhcp_state_pxebs = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct DHCP client hardware address field and broadcast flag
|
|
||||||
*
|
|
||||||
* @v netdev Network device
|
|
||||||
* @v chaddr Hardware address buffer
|
|
||||||
* @v flags Flags to set (or NULL)
|
|
||||||
* @ret hlen Hardware address length
|
|
||||||
*/
|
|
||||||
unsigned int dhcp_chaddr ( struct net_device *netdev, void *chaddr,
|
|
||||||
uint16_t *flags ) {
|
|
||||||
struct ll_protocol *ll_protocol = netdev->ll_protocol;
|
|
||||||
struct dhcphdr *dhcphdr;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* If the link-layer address cannot fit into the chaddr field
|
|
||||||
* (as is the case for IPoIB) then try using the Ethernet-
|
|
||||||
* compatible link-layer address. If we do this, set the
|
|
||||||
* broadcast flag, since chaddr then does not represent a
|
|
||||||
* valid link-layer address for the return path.
|
|
||||||
*
|
|
||||||
* If we cannot produce an Ethernet-compatible link-layer
|
|
||||||
* address, try using the hardware address.
|
|
||||||
*
|
|
||||||
* If even the hardware address is too large, use an empty
|
|
||||||
* chaddr field and set the broadcast flag.
|
|
||||||
*
|
|
||||||
* This goes against RFC4390, but RFC4390 mandates that we use
|
|
||||||
* a DHCP client identifier that conforms with RFC4361, which
|
|
||||||
* we cannot do without either persistent (NIC-independent)
|
|
||||||
* storage, or by eliminating the hardware address completely
|
|
||||||
* from the DHCP packet, which seems unfriendly to users.
|
|
||||||
*/
|
|
||||||
if ( ll_protocol->ll_addr_len <= sizeof ( dhcphdr->chaddr ) ) {
|
|
||||||
memcpy ( chaddr, netdev->ll_addr, ll_protocol->ll_addr_len );
|
|
||||||
return ll_protocol->ll_addr_len;
|
|
||||||
}
|
|
||||||
if ( flags )
|
|
||||||
*flags |= htons ( BOOTP_FL_BROADCAST );
|
|
||||||
if ( ( rc = ll_protocol->eth_addr ( netdev->ll_addr, chaddr ) ) == 0 )
|
|
||||||
return ETH_ALEN;
|
|
||||||
if ( ll_protocol->hw_addr_len <= sizeof ( dhcphdr->chaddr ) ) {
|
|
||||||
memcpy ( chaddr, netdev->hw_addr, ll_protocol->hw_addr_len );
|
|
||||||
return ll_protocol->hw_addr_len;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a DHCP packet
|
* Create a DHCP packet
|
||||||
*
|
*
|
||||||
|
@ -1176,14 +1106,14 @@ static int dhcp_tx ( struct dhcp_session *dhcp ) {
|
||||||
static int dhcp_deliver ( struct dhcp_session *dhcp,
|
static int dhcp_deliver ( struct dhcp_session *dhcp,
|
||||||
struct io_buffer *iobuf,
|
struct io_buffer *iobuf,
|
||||||
struct xfer_metadata *meta ) {
|
struct xfer_metadata *meta ) {
|
||||||
|
struct net_device *netdev = dhcp->netdev;
|
||||||
|
struct ll_protocol *ll_protocol = netdev->ll_protocol;
|
||||||
struct sockaddr_in *peer;
|
struct sockaddr_in *peer;
|
||||||
size_t data_len;
|
size_t data_len;
|
||||||
struct dhcp_packet *dhcppkt;
|
struct dhcp_packet *dhcppkt;
|
||||||
struct dhcphdr *dhcphdr;
|
struct dhcphdr *dhcphdr;
|
||||||
uint8_t msgtype = 0;
|
uint8_t msgtype = 0;
|
||||||
struct in_addr server_id = { 0 };
|
struct in_addr server_id = { 0 };
|
||||||
uint8_t chaddr[ sizeof ( dhcphdr->chaddr ) ];
|
|
||||||
unsigned int hlen;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
@ -1229,12 +1159,12 @@ static int dhcp_deliver ( struct dhcp_session *dhcp,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Check for matching client hardware address */
|
/* Check for matching client hardware address */
|
||||||
hlen = dhcp_chaddr ( dhcp->netdev, chaddr, NULL );
|
if ( memcmp ( dhcphdr->chaddr, netdev->ll_addr,
|
||||||
if ( memcmp ( dhcphdr->chaddr, chaddr, hlen ) != 0 ) {
|
ll_protocol->ll_addr_len ) != 0 ) {
|
||||||
DBGC ( dhcp, "DHCP %p %s from %s:%d has bad chaddr %s\n",
|
DBGC ( dhcp, "DHCP %p %s from %s:%d has bad chaddr %s\n",
|
||||||
dhcp, dhcp_msgtype_name ( msgtype ),
|
dhcp, dhcp_msgtype_name ( msgtype ),
|
||||||
inet_ntoa ( peer->sin_addr ), ntohs ( peer->sin_port ),
|
inet_ntoa ( peer->sin_addr ), ntohs ( peer->sin_port ),
|
||||||
dhcp_chaddr_ntoa ( dhcphdr->chaddr, hlen ) );
|
ll_protocol->ntoa ( dhcphdr->chaddr ) );
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err_chaddr;
|
goto err_chaddr;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue