Skip to contentSkip to conversation

A VLAN tagged DHCP request/discover is 4 bytes short

PATCH New Norbert van Bolhuis 2 participants 2 messages Jun 4, 2009 – Jun 15, 2009 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 A VLAN tagged DHCP request/discover is 4 bytes short

The problem is that BOOTP_SIZE uses ETHER_HDR_SIZE which is 14 bytes. If sending a VLAN tagged frame (when env variable vlan is set) this should be VLAN_ETHER_HDR_SIZE=18 which is what NetSetEther returns.

net/bootp.c +2 -2
index 3dea70a..77057c6 100644
@@ -687,7 +687,7 @@ BootpRequest (void)
 	 * Calculate proper packet lengths taking into account the
 	 * variable size of the options field
 	 */
-	pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
+	pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
 	iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
 	NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 	NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);
@@ -860,7 +860,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
 	NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
 
-	pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
+	pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
 	iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
 	NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 
Signature · 3 lines
1.5.2.2

Signed-off-by: Norbert van Bolhuis <[email protected]>
Applied
#1 lore raw

PATCH 1/1 A VLAN tagged DHCP request/discover is 4 bytes short

Quoted 19 lines · Norbert van Bolhuis

The problem is that BOOTP_SIZE uses ETHER_HDR_SIZE which is 14 bytes. If sending a VLAN tagged frame (when env variable vlan is set) this should be VLAN_ETHER_HDR_SIZE=18 which is what NetSetEther returns.

net/bootp.c +1 -1
index 3dea70a..77057c6 100644
@@ -687,7 +687,7 @@ BootpRequest (void)
 	 * Calculate proper packet lengths taking into account the
 	 * variable size of the options field
 	 */
-	pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
+	pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
 	iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
 	NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 	NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);

net/bootp.c static void DhcpSendRequestPkt(Bootp_t *bp_offer) · line 866

Quoted 8 lines
net/bootp.c +1 -1
@@ -860,7 +860,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
 	NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
 	extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
 
-	pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
+	pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
 	iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
 	NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 

Applied to net repo.

thanks,
Ben