dnsmasq/bugfix-deal-with-CONFRIM-when-binding-mac-with-ipv6.patch

68 lines
2.0 KiB
Diff
Raw Normal View History

2024-02-21 06:55:48 +00:00
From 068fe05737fe86185b5d55da7de6ea6b2668c911 Mon Sep 17 00:00:00 2001
From: liaichun <liaichun@huawei.com>
Date: Mon, 20 Apr 2020 16:17:24 +0800
Subject: [PATCH] bugfix-deal-with-CONFRIM-when-binding-mac-with-ipv6
2019-12-25 15:44:46 +08:00
---
2024-02-21 06:55:48 +00:00
src/rfc3315.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
2019-12-25 15:44:46 +08:00
diff --git a/src/rfc3315.c b/src/rfc3315.c
2024-02-21 06:55:48 +00:00
index 004ebb8..8c22ded 100644
2019-12-25 15:44:46 +08:00
--- a/src/rfc3315.c
+++ b/src/rfc3315.c
2024-02-21 06:55:48 +00:00
@@ -1077,12 +1077,32 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
2019-12-25 15:44:46 +08:00
case DHCP6CONFIRM:
{
2024-02-21 06:55:48 +00:00
int good_addr = 0, bad_addr = 0;
+ int find_bind = 0;
+ struct dhcp_config *find_config = NULL;
2019-12-25 15:44:46 +08:00
/* set reply message type */
2023-02-02 20:08:26 +08:00
outmsgtype = DHCP6REPLY;
2019-12-25 15:44:46 +08:00
log6_quiet(state, "DHCPCONFIRM", NULL, NULL);
2023-02-02 20:08:26 +08:00
-
2019-12-25 15:44:46 +08:00
+
+ if(daemon->bind_mac_with_ip6) {
+ if(state->mac) {
+ for (find_config = daemon->dhcp_conf; find_config; find_config = find_config->next)
+ if (config_has_mac(find_config, state->mac, state->mac_len, state->mac_type) && have_config(find_config, CONFIG_ADDR6)) {
+ find_bind = 1;
+ break;
+ }
+ }
2024-02-21 06:55:48 +00:00
+ /* requires all mac has binding ipv6 address. */
+ if (find_bind == 0) {
+ o1 = new_opt6(OPTION6_STATUS_CODE);
+ put_opt6_short(DHCP6NOTONLINK);
+ put_opt6_string(_("confirm failed, no binding found"));
+ end_opt6(o1);
+ return 1;
+ }
+ }
2023-02-02 20:08:26 +08:00
+
2019-12-25 15:44:46 +08:00
for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end))
{
2023-02-02 20:08:26 +08:00
void *ia_option, *ia_end;
2024-02-21 06:55:48 +00:00
@@ -1106,6 +1126,16 @@ static int dhcp6_no_relay(struct state *state, int msg_type, unsigned char *inbu
good_addr = 1;
log6_quiet(state, "DHCPREPLY", &req_addr, state->hostname);
2019-12-25 15:44:46 +08:00
}
2024-02-21 06:55:48 +00:00
+
+ if(daemon->bind_mac_with_ip6) {
+ if (!is_same_net6(&req_addr, &find_config->addr6, 128)) {
2019-12-25 15:44:46 +08:00
+ o1 = new_opt6(OPTION6_STATUS_CODE);
+ put_opt6_short(DHCP6NOTONLINK);
+ put_opt6_string(_("confirm failed, not binding to this address"));
2019-12-25 15:44:46 +08:00
+ end_opt6(o1);
+ return 1;
+ }
2020-07-28 16:39:08 +08:00
+ }
}
2024-02-21 06:55:48 +00:00
}
2019-12-25 15:44:46 +08:00
--
2024-02-21 06:55:48 +00:00
2.33.0
2023-02-02 20:08:26 +08:00