diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-06-21 16:36:29 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2018-06-21 17:33:30 +0200 |
commit | 62a1b09c5fb018b8ee223e0ccea5a9e084918570 (patch) | |
tree | f92c44370939aa321da2defdcc8b064aa353b1c7 /src/dhcpv4.c | |
parent | d5726ff3edc32222baa7a7aea9df47f1afc53724 (diff) |
dhcpv4: fix DHCP address space logic
Don't use an IPv4 address which belongs to the force renew IP address
list as candidate for the DHCP address space calculation logic as
such addresses are installed by the forced renew logic to safeguard
IP connectivity during the forced renew message exchanges and thus
cannot be used to calculate the DHCP address space
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 9b8186f..8c9e9ba 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -38,6 +38,7 @@ static void dhcpv4_netevent_cb(unsigned long event, struct netevent_handler_info *info); static int setup_dhcpv4_addresses(struct interface *iface); static void update_static_assignments(struct interface *iface); +static bool addr_is_fr_ip(struct interface *iface, struct in_addr *addr); static void valid_until_cb(struct uloop_timeout *event); static void handle_addrlist_change(struct interface *iface); static void free_dhcpv4_assignment(struct dhcpv4_assignment *a); @@ -243,6 +244,9 @@ static int setup_dhcpv4_addresses(struct interface *iface) struct in_addr *addr = &iface->addr4[i].addr.in; struct in_addr mask; + if (addr_is_fr_ip(iface, addr)) + continue; + odhcpd_bitlen2netmask(false, iface->addr4[i].prefix, &mask); if ((start & ntohl(~mask.s_addr)) == start && (end & ntohl(~mask.s_addr)) == end) { @@ -369,6 +373,18 @@ static void decr_ref_cnt_ip(struct odhcpd_ref_ip **ptr, struct interface *iface) *ptr = NULL; } +static bool addr_is_fr_ip(struct interface *iface, struct in_addr *addr) +{ + struct odhcpd_ref_ip *p; + + list_for_each_entry(p, &iface->dhcpv4_fr_ips, head) { + if (addr->s_addr == p->addr.addr.in.s_addr) + return true; + } + + return false; +} + static bool leases_require_fr(struct interface *iface, struct odhcpd_ipaddr *addr, uint32_t mask) { |