Blame SOURCES/dnsmasq-2.79-mixed-family-failed.patch

7bb5d0
From 4348c43be45d20aba87ee5564ecdde10aff7e5e7 Mon Sep 17 00:00:00 2001
7bb5d0
From: Simon Kelley <simon@thekelleys.org.uk>
7bb5d0
Date: Fri, 22 Jan 2021 16:49:12 +0000
7bb5d0
Subject: [PATCH] Move fd into frec_src, fixes
7bb5d0
 15b60ddf935a531269bb8c68198de012a4967156
7bb5d0
7bb5d0
If identical queries from IPv4 and IPv6 sources are combined by the
7bb5d0
new code added in 15b60ddf935a531269bb8c68198de012a4967156 then replies
7bb5d0
can end up being sent via the wrong family of socket. The ->fd
7bb5d0
should be per query, not per-question.
7bb5d0
7bb5d0
In bind-interfaces mode, this could also result in replies being sent
7bb5d0
via the wrong socket even when IPv4/IPV6 issues are not in play.
7bb5d0
7bb5d0
(cherry picked from commit 04490bf622ac84891aad6f2dd2edf83725decdee)
7bb5d0
7bb5d0
Fix for 12af2b171de0d678d98583e2190789e544440e02
7bb5d0
7bb5d0
(cherry picked from commit 3f535da79e7a42104543ef5c7b5fa2bed819a78b)
7bb5d0
---
7bb5d0
 src/dnsmasq.h | 3 ++-
7bb5d0
 src/forward.c | 5 +++--
7bb5d0
 2 files changed, 5 insertions(+), 3 deletions(-)
7bb5d0
7bb5d0
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
7bb5d0
index f3bbb4e..e7e1693 100644
7bb5d0
--- a/src/dnsmasq.h
7bb5d0
+++ b/src/dnsmasq.h
7bb5d0
@@ -632,6 +632,7 @@ struct frec {
7bb5d0
     union mysockaddr source;
7bb5d0
     struct all_addr dest;
7bb5d0
     unsigned int iface, log_id;
7bb5d0
+    int fd;
7bb5d0
     unsigned short orig_id;
7bb5d0
     struct frec_src *next;
7bb5d0
   } frec_src;
7bb5d0
@@ -641,7 +642,7 @@ struct frec {
7bb5d0
   struct randfd *rfd6;
7bb5d0
 #endif
7bb5d0
   unsigned short new_id;
7bb5d0
-  int fd, forwardall, flags;
7bb5d0
+  int forwardall, flags;
7bb5d0
   time_t time;
7bb5d0
   unsigned char *hash[HASH_SIZE];
7bb5d0
 #ifdef HAVE_DNSSEC 
7bb5d0
diff --git a/src/forward.c b/src/forward.c
7bb5d0
index 9d249c0..82dd850 100644
7bb5d0
--- a/src/forward.c
7bb5d0
+++ b/src/forward.c
7bb5d0
@@ -368,6 +368,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
7bb5d0
 	      new->dest = *dst_addr;
7bb5d0
 	      new->log_id = daemon->log_id;
7bb5d0
 	      new->iface = dst_iface;
7bb5d0
+	      new->fd = udpfd;
7bb5d0
 	    }
7bb5d0
 	  
7bb5d0
 	  return 1;
7bb5d0
@@ -392,8 +393,8 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
7bb5d0
 	  forward->frec_src.dest = *dst_addr;
7bb5d0
 	  forward->frec_src.iface = dst_iface;
7bb5d0
 	  forward->frec_src.next = NULL;
7bb5d0
+	  forward->frec_src.fd = udpfd;
7bb5d0
 	  forward->new_id = get_id();
7bb5d0
-	  forward->fd = udpfd;
7bb5d0
 	  memcpy(forward->hash, hash, HASH_SIZE);
7bb5d0
 	  forward->forwardall = 0;
7bb5d0
 	  forward->flags = fwd_flags;
7bb5d0
@@ -1175,7 +1176,7 @@ void reply_query(int fd, int family, time_t now)
7bb5d0
 	    {
7bb5d0
 	      header->id = htons(src->orig_id);
7bb5d0
 	      
7bb5d0
-	      send_from(forward->fd, option_bool(OPT_NOWILD) || option_bool (OPT_CLEVERBIND), daemon->packet, nn, 
7bb5d0
+	      send_from(src->fd, option_bool(OPT_NOWILD) || option_bool (OPT_CLEVERBIND), daemon->packet, nn, 
7bb5d0
 			&src->source, &src->dest, src->iface);
7bb5d0
 
7bb5d0
 	      if (option_bool(OPT_EXTRALOG) && src != &forward->frec_src)
7bb5d0
-- 
7bb5d0
2.26.2
7bb5d0