dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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