Blame SOURCES/0164-Use-xid-to-match-DHCP-replies.patch

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