DHCPv6 IAID should be of unsigned type. It is derived from strtoul() in lease.c:read_leases() and already now interpreted as unsigned in helper.c:276 and outpacket.c:put_opt6_long(). RFC3315 (section 22.4) shows that the IAID is 4 bytes long so we do not need to go up to unsigned long.

Signed-off-by: Dominik DL6ER <dl6er@dl6er.de>
This commit is contained in:
Dominik DL6ER
2019-10-20 18:51:52 +02:00
committed by Simon Kelley
parent 157d8cfd6a
commit 456a319775
5 changed files with 17 additions and 12 deletions

View File

@@ -423,7 +423,7 @@ struct dhcp_config *config_find_by_address6(struct dhcp_config *configs, struct
}
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)
unsigned int iaid, int serial, struct dhcp_netid *netids, int plain_range, struct in6_addr *ans)
{
/* Find a free address: exclude anything in use and anything allocated to
a particular hwaddr/clientid/hostname in our configuration.

View File

@@ -723,7 +723,7 @@ struct dhcp_lease {
int new_prefixlen; /* and its prefix length */
#ifdef HAVE_DHCP6
struct in6_addr addr6;
int iaid;
unsigned int iaid;
struct slaac_address {
struct in6_addr addr;
time_t ping_time;
@@ -1395,14 +1395,15 @@ struct dhcp_lease *lease4_allocate(struct in_addr addr);
#ifdef HAVE_DHCP6
struct dhcp_lease *lease6_allocate(struct in6_addr *addrp, int lease_type);
struct dhcp_lease *lease6_find(unsigned char *clid, int clid_len,
int lease_type, int iaid, struct in6_addr *addr);
int lease_type, unsigned int iaid, struct in6_addr *addr);
void lease6_reset(void);
struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_type, unsigned char *clid, int clid_len, int iaid);
struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_type,
unsigned char *clid, int clid_len, unsigned int iaid);
struct dhcp_lease *lease6_find_by_addr(struct in6_addr *net, int prefix, u64 addr);
u64 lease_find_max_addr6(struct dhcp_context *context);
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface);
void lease_update_slaac(time_t now);
void lease_set_iaid(struct dhcp_lease *lease, int iaid);
void lease_set_iaid(struct dhcp_lease *lease, unsigned int iaid);
void lease_make_duid(time_t now);
#endif
void lease_set_hwaddr(struct dhcp_lease *lease, const unsigned char *hwaddr,
@@ -1520,7 +1521,7 @@ int get_incoming_mark(union mysockaddr *peer_addr, union all_addr *local_addr,
void dhcp6_init(void);
void dhcp6_packet(time_t now);
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);
unsigned 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);
struct dhcp_context *address6_available(struct dhcp_context *context,
struct in6_addr *taddr,

View File

@@ -66,7 +66,8 @@ struct script_data
#endif
struct in6_addr addr6;
#ifdef HAVE_DHCP6
int iaid, vendorclass_count;
int vendorclass_count;
unsigned int iaid;
#endif
unsigned char hwaddr[DHCP_CHADDR_MAX];
char interface[IF_NAMESIZE];

View File

@@ -635,7 +635,8 @@ struct dhcp_lease *lease_find_by_addr(struct in_addr addr)
#ifdef HAVE_DHCP6
/* find address for {CLID, IAID, address} */
struct dhcp_lease *lease6_find(unsigned char *clid, int clid_len,
int lease_type, int iaid, struct in6_addr *addr)
int lease_type, unsigned int iaid,
struct in6_addr *addr)
{
struct dhcp_lease *lease;
@@ -667,7 +668,9 @@ void lease6_reset(void)
}
/* enumerate all leases belonging to {CLID, IAID} */
struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_type, unsigned char *clid, int clid_len, int iaid)
struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_type,
unsigned char *clid, int clid_len,
unsigned int iaid)
{
struct dhcp_lease *lease;
@@ -849,7 +852,7 @@ void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now)
}
#ifdef HAVE_DHCP6
void lease_set_iaid(struct dhcp_lease *lease, int iaid)
void lease_set_iaid(struct dhcp_lease *lease, unsigned int iaid)
{
if (lease->iaid != iaid)
{

View File

@@ -21,11 +21,11 @@
struct state {
unsigned char *clid;
int clid_len, iaid, ia_type, interface, hostname_auth, lease_allocate;
int clid_len, ia_type, interface, hostname_auth, lease_allocate;
char *client_hostname, *hostname, *domain, *send_domain;
struct dhcp_context *context;
struct in6_addr *link_address, *fallback, *ll_addr, *ula_addr;
unsigned int xid, fqdn_flags;
unsigned int xid, fqdn_flags, iaid;
char *iface_name;
void *packet_options, *end;
struct dhcp_netid *tags, *context_tags;