mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-12-18 06:13:30 +08:00
RFC 5942 Section 5 states DHCPv6 address should not create prefixes
based on the assigned address.
This commit is contained in:
parent
8a06b57ddc
commit
6204b80e3f
25
dhcp6.c
25
dhcp6.c
@ -1295,7 +1295,6 @@ dhcp6_findna(struct interface *ifp, const uint8_t *iaid,
|
||||
const uint8_t *p;
|
||||
struct in6_addr in6;
|
||||
struct ipv6_addr *a;
|
||||
const struct ipv6_addr *pa;
|
||||
char iabuf[INET6_ADDRSTRLEN];
|
||||
const char *ia;
|
||||
int i;
|
||||
@ -1332,18 +1331,18 @@ dhcp6_findna(struct interface *ifp, const uint8_t *iaid,
|
||||
memcpy(&a->addr.s6_addr, &in6.s6_addr,
|
||||
sizeof(in6.s6_addr));
|
||||
}
|
||||
pa = ipv6nd_findprefix(a);
|
||||
if (pa) {
|
||||
memcpy(&a->prefix, &pa->prefix,
|
||||
sizeof(a->prefix));
|
||||
a->prefix_len = pa->prefix_len;
|
||||
} else {
|
||||
a->prefix_len = 64;
|
||||
if (ipv6_makeprefix(&a->prefix, &a->addr, 64) == -1) {
|
||||
syslog(LOG_ERR, "%s: %m", __func__);
|
||||
free(a);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* RFC 5942 Section 5
|
||||
* We cannot assume any prefix length, nor tie the address
|
||||
* to an existing one as it could expire before the address.
|
||||
* As such we just give it a 128 prefix.
|
||||
*/
|
||||
a->prefix_len = 128;
|
||||
if (ipv6_makeprefix(&a->prefix, &a->addr, a->prefix_len) == -1)
|
||||
{
|
||||
syslog(LOG_ERR, "%s: %m", __func__);
|
||||
free(a);
|
||||
continue;
|
||||
}
|
||||
memcpy(&u32, p, sizeof(u32));
|
||||
a->prefix_pltime = ntohl(u32);
|
||||
|
@ -624,7 +624,7 @@ running on the
|
||||
RFC\ 951 RFC\ 1534 RFC\ 2131, RFC\ 2132, RFC\ 2855, RFC\ 3004, RFC\ 3315,
|
||||
RFC\ 3361, RFC\ 3633, RFC\ 3396, RFC\ 3397, RFC\ 3442, RFC\ 3927, RFC\ 4039
|
||||
RFC\ 4075, RFC\ 4361, RFC\ 4390, RFC\ 4702, RFC\ 4704, RFC\ 4861, RFC\ 4833,
|
||||
RFC\ 5227, RFC\ 5969, RFC\ 6106.
|
||||
RFC\ 5227, RFC\ 5942, RFC\ 5969, RFC\ 6106.
|
||||
.Sh AUTHORS
|
||||
.An Roy Marples Aq Mt roy@marples.name
|
||||
.Sh BUGS
|
||||
|
28
ipv6nd.c
28
ipv6nd.c
@ -1121,34 +1121,6 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
|
||||
return l;
|
||||
}
|
||||
|
||||
const struct ipv6_addr *
|
||||
ipv6nd_findprefix(const struct ipv6_addr *a)
|
||||
{
|
||||
const struct ra *rap;
|
||||
const struct ipv6_addr *ap;
|
||||
const struct in6_addr *p1, *p2;
|
||||
int bytelen, bitlen;
|
||||
|
||||
p1 = &a->addr;
|
||||
TAILQ_FOREACH(rap, &ipv6_routers, next) {
|
||||
TAILQ_FOREACH(ap, &rap->addrs, next) {
|
||||
p2 = & ap->prefix;
|
||||
bytelen = ap->prefix_len / NBBY;
|
||||
bitlen = ap->prefix_len % NBBY;
|
||||
if (memcmp(&p1->s6_addr, &p2->s6_addr, bytelen))
|
||||
continue;
|
||||
if (bitlen != 0) {
|
||||
bitlen = NBBY - bitlen;
|
||||
if (p1->s6_addr[bytelen] >> bitlen !=
|
||||
p2->s6_addr[bytelen] >> bitlen)
|
||||
continue;
|
||||
}
|
||||
return ap;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ipv6nd_handleifa(int cmd, const char *ifname,
|
||||
const struct in6_addr *addr, int flags)
|
||||
|
1
ipv6nd.h
1
ipv6nd.h
@ -83,7 +83,6 @@ struct rs_state {
|
||||
#ifdef INET6
|
||||
int ipv6nd_startrs(struct interface *);
|
||||
ssize_t ipv6nd_env(char **, const char *, const struct interface *);
|
||||
const struct ipv6_addr * ipv6nd_findprefix(const struct ipv6_addr *);
|
||||
int ipv6nd_addrexists(const struct ipv6_addr *);
|
||||
void ipv6nd_freedrop_ra(struct ra *, int);
|
||||
#define ipv6nd_free_ra(ra) ipv6nd_freedrop_ra((ra), 0)
|
||||
|
Loading…
Reference in New Issue
Block a user