summaryrefslogtreecommitdiffstats
path: root/src/net/udp
diff options
context:
space:
mode:
authorMichael Brown2014-09-22 17:41:10 +0200
committerMichael Brown2014-09-22 17:48:50 +0200
commit6a221700850b648183279f0a6e565f78fc72d57c (patch)
tree07fe5f969edd081359357c32411014e030f13b4f /src/net/udp
parent[dhcp] Check for matching chaddr in received DHCP packets (diff)
downloadipxe-6a221700850b648183279f0a6e565f78fc72d57c.tar.gz
ipxe-6a221700850b648183279f0a6e565f78fc72d57c.tar.xz
ipxe-6a221700850b648183279f0a6e565f78fc72d57c.zip
[dhcp] Remove obsolete dhcp_chaddr() function
As of commit 03f0c23 ("[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 commit 08bcc0f ("[dhcp] Check for matching chaddr in received DHCP packets"). Reported-by: Wissam Shoukair <wissams@mellanox.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/udp')
-rw-r--r--src/net/udp/dhcp.c80
1 files changed, 5 insertions, 75 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index cacbf5a8..04fad04c 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -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
@@ -865,53 +842,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
*
* @v dhcppkt DHCP packet structure to fill in
@@ -1176,14 +1106,14 @@ static int dhcp_tx ( struct dhcp_session *dhcp ) {
static int dhcp_deliver ( struct dhcp_session *dhcp,
struct io_buffer *iobuf,
struct xfer_metadata *meta ) {
+ struct net_device *netdev = dhcp->netdev;
+ struct ll_protocol *ll_protocol = netdev->ll_protocol;
struct sockaddr_in *peer;
size_t data_len;
struct dhcp_packet *dhcppkt;
struct dhcphdr *dhcphdr;
uint8_t msgtype = 0;
struct in_addr server_id = { 0 };
- uint8_t chaddr[ sizeof ( dhcphdr->chaddr ) ];
- unsigned int hlen;
int rc = 0;
/* Sanity checks */
@@ -1229,12 +1159,12 @@ static int dhcp_deliver ( struct dhcp_session *dhcp,
};
/* Check for matching client hardware address */
- hlen = dhcp_chaddr ( dhcp->netdev, chaddr, NULL );
- if ( memcmp ( dhcphdr->chaddr, chaddr, hlen ) != 0 ) {
+ if ( memcmp ( dhcphdr->chaddr, netdev->ll_addr,
+ ll_protocol->ll_addr_len ) != 0 ) {
DBGC ( dhcp, "DHCP %p %s from %s:%d has bad chaddr %s\n",
dhcp, dhcp_msgtype_name ( msgtype ),
inet_ntoa ( peer->sin_addr ), ntohs ( peer->sin_port ),
- dhcp_chaddr_ntoa ( dhcphdr->chaddr, hlen ) );
+ ll_protocol->ntoa ( dhcphdr->chaddr ) );
rc = -EINVAL;
goto err_chaddr;
}