Blame SOURCES/dnsmasq-2.81-dhcpv6-relay-link-address.patch

2cad81
From f8c77edbdffb8ada7753ea9fa104f0f6da70cfe3 Mon Sep 17 00:00:00 2001
2cad81
From: Simon Kelley <simon@thekelleys.org.uk>
2cad81
Date: Thu, 10 Jan 2019 21:58:18 +0000
2cad81
Subject: [PATCH] Fix removal of DHCP_CLIENT_MAC options from DHCPv6 relay
2cad81
 replies.
2cad81
2cad81
---
2cad81
 src/rfc3315.c | 30 +++++++++++++++++-------------
2cad81
 1 file changed, 17 insertions(+), 13 deletions(-)
2cad81
2cad81
diff --git a/src/rfc3315.c b/src/rfc3315.c
2cad81
index d3c1722..79b2a86 100644
2cad81
--- a/src/rfc3315.c
2cad81
+++ b/src/rfc3315.c
2cad81
@@ -219,21 +219,25 @@ static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz,
2cad81
       if (opt6_ptr(opt, 0) + opt6_len(opt) > end) 
2cad81
         return 0;
2cad81
      
2cad81
-      int o = new_opt6(opt6_type(opt));
2cad81
-      if (opt6_type(opt) == OPTION6_RELAY_MSG)
2cad81
+      /* Don't copy MAC address into reply. */
2cad81
+      if (opt6_type(opt) != OPTION6_CLIENT_MAC)
2cad81
 	{
2cad81
-	  struct in6_addr align;
2cad81
-	  /* the packet data is unaligned, copy to aligned storage */
2cad81
-	  memcpy(&align, inbuff + 2, IN6ADDRSZ); 
2cad81
-	  state->link_address = &align;
2cad81
-	  /* zero is_unicast since that is now known to refer to the 
2cad81
-	     relayed packet, not the original sent by the client */
2cad81
-	  if (!dhcp6_maybe_relay(state, opt6_ptr(opt, 0), opt6_len(opt), client_addr, 0, now))
2cad81
-	    return 0;
2cad81
+	  int o = new_opt6(opt6_type(opt));
2cad81
+	  if (opt6_type(opt) == OPTION6_RELAY_MSG)
2cad81
+	    {
2cad81
+	      struct in6_addr align;
2cad81
+	      /* the packet data is unaligned, copy to aligned storage */
2cad81
+	      memcpy(&align, inbuff + 2, IN6ADDRSZ); 
2cad81
+	      state->link_address = &align;
2cad81
+	      /* zero is_unicast since that is now known to refer to the 
2cad81
+		 relayed packet, not the original sent by the client */
2cad81
+	      if (!dhcp6_maybe_relay(state, opt6_ptr(opt, 0), opt6_len(opt), client_addr, 0, now))
2cad81
+		return 0;
2cad81
+	    }
2cad81
+	  else
2cad81
+	    put_opt6(opt6_ptr(opt, 0), opt6_len(opt));
2cad81
+	  end_opt6(o);
2cad81
 	}
2cad81
-      else if (opt6_type(opt) != OPTION6_CLIENT_MAC)
2cad81
-	put_opt6(opt6_ptr(opt, 0), opt6_len(opt));
2cad81
-      end_opt6(o);	    
2cad81
     }
2cad81
   
2cad81
   return 1;
2cad81
-- 
2cad81
2.39.1
2cad81