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