!34 fix dnsmasq --bind-mac-with-ip6 unsupported option error

From: @quanhongfei
Reviewed-by: @zengwefeng
Signed-off-by: @zengwefeng
This commit is contained in:
openeuler-ci-bot 2021-05-08 17:58:47 +08:00 committed by Gitee
commit bcaafae6e5
3 changed files with 93 additions and 2394 deletions

View File

@ -1,40 +1,46 @@
From 5db7b109af8f6967335806b50d628611be7b9cfd Mon Sep 17 00:00:00 2001 From 53e1a09a06e11317bbde0e236837e5daa8d40593 Mon Sep 17 00:00:00 2001
From: xiaoweiwei <xiaoweiwei5@huawei.com> From: liaichun <liaichun@huawei.com>
Date: Tue, 28 Jul 2020 15:22:54 +0800 Date: Mon, 20 Apr 2020 16:06:51 +0800
Subject: [PATCH] bugfix allow binding mac with ipv6 Subject: [PATCH] bugfix-allow-binding-mac-with-ipv6
Conflict: NA
Reference: NA
--- ---
src/dnsmasq.c | 1 + src/dnsmasq.c | 2 +-
src/dnsmasq.h | 2 ++ src/dnsmasq.h | 4 ++-
src/option.c | 3 +++ src/option.c | 5 +++-
src/rfc3315.c | 32 +++++++++++++++++++++++++++++++- src/rfc3315.c | 35 +++++++++++++++++++++++++-
4 files changed, 37 insertions(+), 1 deletion(-) 4 files changed, 46 insertions(+)
diff --git a/src/dnsmasq.c b/src/dnsmasq.c diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index bfad87f..b25e0c9 100644 index fc085eb..e44c360 100644
--- a/src/dnsmasq.c --- a/src/dnsmasq.c
+++ b/src/dnsmasq.c +++ b/src/dnsmasq.c
@@ -261,6 +261,7 @@ int main (int argc, char **argv) @@ -260,7 +260,7 @@ int main (int argc, char **argv)
if (daemon->dhcp6) if (daemon->dhcp6)
{ {
daemon->doing_ra = option_bool(OPT_RA); daemon->doing_ra = option_bool(OPT_RA);
-
+ daemon->bind_mac_with_ip6 = option_bool(OPT_BIND_MAC_IP6); + daemon->bind_mac_with_ip6 = option_bool(OPT_BIND_MAC_IP6);
for (context = daemon->dhcp6; context; context = context->next) for (context = daemon->dhcp6; context; context = context->next)
{ {
if (context->flags & CONTEXT_DHCP)
diff --git a/src/dnsmasq.h b/src/dnsmasq.h diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 4220798..b9054b9 100644 index 68e6287..e7f1a0d 100644
--- a/src/dnsmasq.h --- a/src/dnsmasq.h
+++ b/src/dnsmasq.h +++ b/src/dnsmasq.h
@@ -270,6 +270,7 @@ struct event_desc { @@ -269,7 +269,8 @@ struct event_desc {
#define OPT_IGNORE_CLID 59
#define OPT_SINGLE_PORT 60 #define OPT_SINGLE_PORT 60
#define OPT_LEASE_RENEW 61 #define OPT_LEASE_RENEW 61
#define OPT_LAST 62 -#define OPT_LAST 62
+#define OPT_BIND_MAC_IP6 63 +#define OPT_BIND_MAC_IP6 62
+#define OPT_LAST 63
#define OPTION_BITS (sizeof(unsigned int)*8) #define OPTION_BITS (sizeof(unsigned int)*8)
#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) ) #define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
@@ -1051,6 +1052,7 @@ extern struct daemon { @@ -1049,6 +1050,7 @@ extern struct daemon {
int override; int override;
int enable_pxe; int enable_pxe;
int doing_ra, doing_dhcp6; int doing_ra, doing_dhcp6;
@ -43,22 +49,24 @@ index 4220798..b9054b9 100644
struct dhcp_netid_list *force_broadcast, *bootp_dynamic; struct dhcp_netid_list *force_broadcast, *bootp_dynamic;
struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs; struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs;
diff --git a/src/option.c b/src/option.c diff --git a/src/option.c b/src/option.c
index dbe5f90..f8391d0 100644 index 1f698da..f02d389 100644
--- a/src/option.c --- a/src/option.c
+++ b/src/option.c +++ b/src/option.c
@@ -167,6 +167,7 @@ struct myoption { @@ -167,7 +167,8 @@ struct myoption {
#define LOPT_IGNORE_CLID 358 #define LOPT_IGNORE_CLID 358
#define LOPT_SINGLE_PORT 359 #define LOPT_SINGLE_PORT 359
#define LOPT_SCRIPT_TIME 360 #define LOPT_SCRIPT_TIME 360
-
+#define LOPT_BIND_MAC_IP6 361 +#define LOPT_BIND_MAC_IP6 361
+
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
static const struct option opts[] = static const struct option opts[] =
#else
@@ -339,6 +340,7 @@ static const struct myoption opts[] = @@ -339,6 +340,7 @@ static const struct myoption opts[] =
{ "dumpfile", 1, 0, LOPT_DUMPFILE }, { "dumpfile", 1, 0, LOPT_DUMPFILE },
{ "dumpmask", 1, 0, LOPT_DUMPMASK }, { "dumpmask", 1, 0, LOPT_DUMPMASK },
{ "dhcp-ignore-clid", 0, 0, LOPT_IGNORE_CLID }, { "dhcp-ignore-clid", 0, 0, LOPT_IGNORE_CLID },
+ { "bind-mac-with-ip6",0, 0, LOPT_BIND_MAC_IP6}, + { "bind-mac-with-ip6", 0, 0 , LOPT_BIND_MAC_IP6 },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
@ -71,7 +79,7 @@ index dbe5f90..f8391d0 100644
}; };
diff --git a/src/rfc3315.c b/src/rfc3315.c diff --git a/src/rfc3315.c b/src/rfc3315.c
index b3f0a0a..5781809 100644 index b3f0a0a..a5a092c 100644
--- a/src/rfc3315.c --- a/src/rfc3315.c
+++ b/src/rfc3315.c +++ b/src/rfc3315.c
@@ -49,6 +49,7 @@ static void end_ia(int t1cntr, unsigned int min_time, int do_fuzz); @@ -49,6 +49,7 @@ static void end_ia(int t1cntr, unsigned int min_time, int do_fuzz);
@ -92,11 +100,12 @@ index b3f0a0a..5781809 100644
{ {
mark_config_used(state->context, &addr); mark_config_used(state->context, &addr);
if (have_config(config, CONFIG_TIME)) if (have_config(config, CONFIG_TIME))
@@ -1684,6 +1686,34 @@ static int check_address(struct state *state, struct in6_addr *addr) @@ -1259,6 +1261,37 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
return 1;
} }
+static int check_and_try_preempte_address(struct state *state, struct in6_addr *addr, time_t now, struct dhcp_config *config){ +static int check_and_try_preempte_address(struct state *state, struct in6_addr *addr, time_t now, struct dhcp_config *config)
+{
+ struct dhcp_lease *lease; + struct dhcp_lease *lease;
+ +
+ if (!(lease = lease6_find_by_addr(addr, 128, 0))) + if (!(lease = lease6_find_by_addr(addr, 128, 0)))
@ -104,7 +113,8 @@ index b3f0a0a..5781809 100644
+ return 1; + return 1;
+ } + }
+ +
+ if (daemon->bind_mac_with_ip6) { +
+ if(daemon->bind_mac_with_ip6) {
+ // break rfc3315 here + // break rfc3315 here
+ // bind mac address with a lease + // bind mac address with a lease
+ if ((state->mac) && !(config->flags & CONFIG_CLID) && + if ((state->mac) && !(config->flags & CONFIG_CLID) &&
@ -124,9 +134,9 @@ index b3f0a0a..5781809 100644
+ +
+ return 1; + return 1;
+} +}
+
/* return true of *addr could have been generated from config. */ static struct dhcp_netid *add_options(struct state *state, int do_refresh)
static struct addrlist *config_implies(struct dhcp_config *config, struct dhcp_context *context, struct in6_addr *addr) {
void *oro;
-- --
1.8.3.1 2.23.0

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
Name: dnsmasq Name: dnsmasq
Version: 2.82 Version: 2.82
Release: 7 Release: 8
Summary: Dnsmasq provides network infrastructure for small networks Summary: Dnsmasq provides network infrastructure for small networks
License: GPLv2 or GPLv3 License: GPLv2 or GPLv3
URL: http://www.thekelleys.org.uk/dnsmasq/ URL: http://www.thekelleys.org.uk/dnsmasq/
@ -124,6 +124,12 @@ install -Dpm644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysusersdir}/dnsmasq.conf
%{_mandir}/man8/dnsmasq* %{_mandir}/man8/dnsmasq*
%changelog %changelog
* Sat May 08 2021 quanhongfei <quanhongfei@huawei.com> - 2.82-8
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:fix dnsmasq --bind-mac-with-ip6 unsupported option error
* Wed Apr 21 2021 gaihuiying <gaihuiying1@huawei.com> - 2.82-7 * Wed Apr 21 2021 gaihuiying <gaihuiying1@huawei.com> - 2.82-7
- Type:CVE - Type:CVE
- Id:NA - Id:NA