Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ipv6 address check for dhcpconfirm #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/dhcp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,34 @@ struct dhcp_config *config_find_by_address6(struct dhcp_config *configs, struct
return NULL;
}

int is_invalid_address_from_static_range(struct dhcp_context *context, struct in6_addr *taddr)
{
struct dhcp_context *c;
struct dhcp_config *config;
int range_matched = 0;
for (c = context; c; c = c->current) {
if (!is_same_net6(&c->start6, taddr, c->prefix)) {
continue;
}

range_matched = 1;
if (c->flags & (CONTEXT_STATIC)) {
config = config_find_by_address6(daemon->dhcp_conf, &c->start6, c->prefix, addr6part(taddr));
if (config) {
return 1;
}
}
}

/* return fail only when target address match static dhcp range, but it's not static configed */
if (range_matched) {
return 0;
} else {
return 1;
}
}


struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned char *clid, int clid_len, int temp_addr,
int iaid, int serial, struct dhcp_netid *netids, int plain_range, struct in6_addr *ans)
{
Expand Down
1 change: 1 addition & 0 deletions src/dnsmasq.h
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ int get_incoming_mark(union mysockaddr *peer_addr, struct all_addr *local_addr,
#ifdef HAVE_DHCP6
void dhcp6_init(void);
void dhcp6_packet(time_t now);
int is_invalid_address_from_static_range(struct dhcp_context *context, struct in6_addr *taddr);
struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned char *clid, int clid_len, int temp_addr,
int iaid, int serial, struct dhcp_netid *netids, int plain_range, struct in6_addr *ans);
int config_valid(struct dhcp_config *config, struct dhcp_context *context, struct in6_addr *addr);
Expand Down
8 changes: 8 additions & 0 deletions src/rfc3315.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,14 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
return 1;
}

if (!is_invalid_address_from_static_range(state->context, req_addr)) {
o1 = new_opt6(OPTION6_STATUS_CODE);
put_opt6_short(DHCP6NOTONLINK);
put_opt6_string(_("confirm failed"));
end_opt6(o1);
return 1;
}

good_addr = 1;
log6_quiet(state, "DHCPREPLY", req_addr, state->hostname);
}
Expand Down