فهرست منبع

Use the interface address in netlog and netkexec replies

After DHCP the driver's static default IP is not the address on the wire, so netlog datagrams and netkexec ACKs could carry a source from another subnet and be dropped. Use net_get_ip() for both.
Johannes Zellner 1 هفته پیش
والد
کامیت
4d00ddb05a
2فایلهای تغییر یافته به همراه5 افزوده شده و 16 حذف شده
  1. 1 8
      netkexec.c
  2. 4 8
      netlog.c

+ 1 - 8
netkexec.c

@@ -242,14 +242,7 @@ static void send_ack(unsigned int next_offset, unsigned int status)
 
 	if (!nd)
 		return;
-	if (nd->default_ip) {
-		unsigned int i;
-
-		for (i = 0; i < 4; i++)
-			src[i] = nd->default_ip[i];
-	} else {
-		net_get_ip(src);
-	}
+	net_get_ip(src);
 	wr32(ackbuf, X_MAGIC_ACK);
 	wr32(ackbuf + 4, next_offset);
 	wr32(ackbuf + 8, status);

+ 4 - 8
netlog.c

@@ -86,14 +86,10 @@ static void send_line(const unsigned char *buf, unsigned int len)
 	if (!nd)
 		return;
 	netlog_get_host(dst);
-	if (nd->default_ip) {
-		unsigned int i;
-
-		for (i = 0; i < 4; i++)
-			src[i] = nd->default_ip[i];
-	} else {
-		net_get_ip(src);
-	}
+	/* Use the address the interface actually has: after DHCP the
+	 * driver's static default is no longer what is on the wire, and a
+	 * source address from another subnet is dropped by some paths. */
+	net_get_ip(src);
 	net_udp_send_from_dev(nd, src, bcast_mac, dst,
 			      NETLOG_PORT, NETLOG_PORT, buf, len);
 }