aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/dnsmasq/patches/0015-Handle-some-corner-cases-in-RA-contructed-interfaces.patch
blob: ce9ce4af5ab6d791e238e9299cde7b6c88179a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From db0f488ea8f5ded7c57400c9108ec3c9367d75c5 Mon Sep 17 00:00:00 2001
From: Simon Kelley <simon@thekelleys.org.uk>
Date: Thu, 7 Jun 2018 21:37:02 +0100
Subject: [PATCH 15/17] Handle some corner cases in RA contructed interfaces
 with addresses changing interface.

Thanks to Vladislav Grishenko for work on this.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
 src/dhcp6.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -640,7 +640,7 @@ static int construct_worker(struct in6_a
     return 0;
   
   for (template = daemon->dhcp6; template; template = template->next)
-    if (!(template->flags & CONTEXT_TEMPLATE))
+    if (!(template->flags & (CONTEXT_TEMPLATE | CONTEXT_CONSTRUCTED)))
       {
 	/* non-template entries, just fill in interface and local addresses */
 	if (prefix <= template->prefix &&
@@ -667,20 +667,23 @@ static int construct_worker(struct in6_a
 	end6 = *local;
 	setaddr6part(&end6, addr6part(&template->end6));
 	
-	/* If there's an absolute address context covering this address
-	   then don't contruct one as well. */
 	for (context = daemon->dhcp6; context; context = context->next)
 	  if (!(context->flags & CONTEXT_TEMPLATE) &&
 	      IN6_ARE_ADDR_EQUAL(&start6, &context->start6) &&
 	      IN6_ARE_ADDR_EQUAL(&end6, &context->end6))
 	    {
-	      if (context->flags & CONTEXT_CONSTRUCTED)
+	      /* If there's an absolute address context covering this address
+		 then don't construct one as well. */
+	      if (!(context->flags & CONTEXT_CONSTRUCTED))
+		break;
+	      
+	      if (context->if_index == if_index)
 		{
 		  int cflags = context->flags;
 		  context->flags &= ~(CONTEXT_GC | CONTEXT_OLD);
 		  if (cflags & CONTEXT_OLD)
 		    {
-		      /* address went, now it's back */
+		      /* address went, now it's back, and on the same interface */
 		      log_context(AF_INET6, context); 
 		      /* fast RAs for a while */
 		      ra_start_unsolicited(param->now, context);
@@ -688,9 +691,10 @@ static int construct_worker(struct in6_a
 		      /* Add address to name again */
 		      if (context->flags & CONTEXT_RA_NAME)
 			param->newname = 1;
+		    
+		      break;
 		    }
 		}
-	      break;
 	    }
 	
 	if (!context && (context = whine_malloc(sizeof (struct dhcp_context))))