15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
15a2072
Date: Fri, 21 Apr 2017 09:20:38 +0200
15a2072
Subject: [PATCH] Use xid to match DHCP replies
15a2072
15a2072
Transaction identifier (xid) from DHCP request
15a2072
packet is stored in network level interface and used
15a2072
to match request with the responses it generates.
15a2072
15a2072
Resolves: rhbz#1370642
15a2072
15a2072
Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@intel.com>
15a2072
---
15a2072
 grub-core/net/bootp.c | 3 ++-
15a2072
 grub-core/net/ip.c    | 1 +
15a2072
 include/grub/net.h    | 3 ++-
15a2072
 3 files changed, 5 insertions(+), 2 deletions(-)
15a2072
15a2072
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
15a2072
index da3e454466b..2869482fe06 100644
15a2072
--- a/grub-core/net/bootp.c
15a2072
+++ b/grub-core/net/bootp.c
15a2072
@@ -777,7 +777,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
15a2072
 	      grub_errno = GRUB_ERR_NONE;
15a2072
 	      t = 0;
15a2072
 	    }
15a2072
-	  pack->ident = grub_cpu_to_be32 (t);
15a2072
+	  pack->xid = grub_cpu_to_be32 (t);
15a2072
+	  ifaces[j].dhcp_xid = pack->xid;
15a2072
 	  pack->seconds = grub_cpu_to_be16 (t);
15a2072
 
15a2072
 	  grub_memcpy (&pack->mac_addr, &ifaces[j].hwaddress.mac, 6); 
15a2072
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
15a2072
index 7c95cc7464a..8411e0ecca3 100644
15a2072
--- a/grub-core/net/ip.c
15a2072
+++ b/grub-core/net/ip.c
15a2072
@@ -275,6 +275,7 @@ handle_dgram (struct grub_net_buff *nb,
15a2072
 	FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
15a2072
 	  if (inf->card == card
15a2072
 	      && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV
15a2072
+	      && inf->dhcp_xid == bootp->xid
15a2072
 	      && inf->hwaddress.type == GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET
15a2072
 	      && grub_memcmp (inf->hwaddress.mac, &bootp->mac_addr,
15a2072
 			      sizeof (inf->hwaddress.mac)) == 0)
15a2072
diff --git a/include/grub/net.h b/include/grub/net.h
15a2072
index f8f3ec13acc..de51894cbbf 100644
15a2072
--- a/include/grub/net.h
15a2072
+++ b/include/grub/net.h
15a2072
@@ -292,6 +292,7 @@ struct grub_net_network_level_interface
15a2072
   struct grub_net_bootp_packet *dhcp_ack;
15a2072
   grub_size_t dhcp_acklen;
15a2072
   grub_uint16_t vlantag;
15a2072
+  grub_uint32_t dhcp_xid;
15a2072
   void *data;
15a2072
 };
15a2072
 
15a2072
@@ -429,7 +430,7 @@ struct grub_net_bootp_packet
15a2072
   grub_uint8_t hw_type;		/* hardware type.  */
15a2072
   grub_uint8_t hw_len;		/* hardware addr len.  */
15a2072
   grub_uint8_t gate_hops;	/* zero it.  */
15a2072
-  grub_uint32_t ident;		/* random number chosen by client.  */
15a2072
+  grub_uint32_t xid;		/* transaction id chosen by client.  */
15a2072
   grub_uint16_t seconds;	/* seconds since did initial bootstrap.  */
15a2072
   grub_uint16_t flags;
15a2072
   grub_uint32_t	client_ip;