dcavalca / rpms / grub2

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