mosers
/
eaas-vde-proxy
Archiviert
1
0
Fork 0

Handle DHCP edge case [Fix #9]

main
Simon Moser vor 3 Jahren
Ursprung 0fe254b866
Commit 3108669ecd
Signiert von: mosers
GPG-Schlüssel-ID: 96B3365A234B500C

@ -315,9 +315,15 @@ func handleDHCP(content []byte, dstMAC net.HardwareAddr, srcMAC net.HardwareAddr
switch reqType { switch reqType {
case dhcp4.Discover: case dhcp4.Discover:
if OldIP == nil { if OldIP == nil {
log.Fatal(prefix, "DHCPDISCOVER but not previous address is known") if NewIP == nil || !NewIP.IsGlobalUnicast() {
log.Warning(prefix, "DHCP request, but neither OldIP nor NewIP known")
sendDHCPRequest(dhcp4.Discover, net.IPv4zero)
return
} }
sendDHCPReply(req, dhcp4.Offer, NewIP, options, dstMAC)
} else {
sendDHCPReply(req, dhcp4.Offer, OldIP, options, dstMAC) sendDHCPReply(req, dhcp4.Offer, OldIP, options, dstMAC)
}
case dhcp4.Inform: case dhcp4.Inform:
fallthrough fallthrough
case dhcp4.Request: case dhcp4.Request: