m/t/nanoswitch: fix race in handing out IP addresses

The previous logic only work by accident, with currentIP being
immediately incremented after being handed out, effectively serving the
'next' IP immediately.

Change-Id: I89ca21ea9d3600a268545aab5e79dac53313d294
Reviewed-on: https://review.monogon.dev/c/monogon/+/779
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/test/nanoswitch/nanoswitch.go b/metropolis/test/nanoswitch/nanoswitch.go
index c09d8ec..bfd3323 100644
--- a/metropolis/test/nanoswitch/nanoswitch.go
+++ b/metropolis/test/nanoswitch/nanoswitch.go
@@ -69,7 +69,7 @@
 // hardcoded, a wrapping bump allocator for the IPs, 30 second lease timeout
 // and no support for DHCP collision detection.
 func runDHCPServer(link netlink.Link) supervisor.Runnable {
-	currentIP := net.IP{10, 1, 0, 1}
+	currentIP := net.IP{10, 1, 0, 2}
 
 	// Map from stringified MAC address to IP address, allowing handing out the
 	// same IP to a given MAC on re-discovery.
@@ -101,8 +101,8 @@
 				if ip, ok := leases[hwaddr]; ok {
 					reply.YourIPAddr = ip
 				} else {
-					leases[hwaddr] = currentIP
-					reply.YourIPAddr = currentIP
+					leases[hwaddr] = net.ParseIP(currentIP.String())
+					reply.YourIPAddr = leases[hwaddr]
 					currentIP[3]++ // Works only because it's a /24
 				}
 				supervisor.Logger(ctx).Infof("Replying with DHCP IP %s to %s", reply.YourIPAddr.String(), hwaddr)