Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F175226465
D60488.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D60488.diff
View Options
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1215,7 +1215,7 @@
struct in6_aliasreq ifra;
struct in6_ifaddr *ia = NULL, *ib = NULL;
int error, plen0;
- struct in6_addr *ifid_addr = NULL, mask, newaddr;
+ struct in6_addr mask, newaddr;
int prefixlen = pr->ndpr_plen;
int updateflags;
char ip6buf[INET6_ADDRSTRLEN];
@@ -1255,47 +1255,39 @@
if(!in6_get_stableifid(ifp, &newaddr, prefixlen))
return NULL;
} else {
+ bool have_ifid = false;
+
ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 0); /* 0 is OK? */
- if (ifa) {
+ if (ifa != NULL) {
ib = (struct in6_ifaddr *)ifa;
- ifid_addr = &ib->ia_addr.sin6_addr;
/* prefixlen + ifidlen must be equal to 128 */
plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL);
- if (prefixlen != plen0) {
- ifa_free(ifa);
- ifid_addr = NULL;
+ if (prefixlen == plen0) {
+ memcpy(&newaddr, &ib->ia_addr.sin6_addr,
+ sizeof(newaddr));
+ have_ifid = true;
+ } else {
nd6log((LOG_DEBUG,
"%s: wrong prefixlen for %s (prefix=%d ifid=%d)\n",
__func__, if_name(ifp), prefixlen, 128 - plen0));
}
+ ifa_free(ifa);
}
- /* No suitable LL address, get the ifid directly */
- if (ifid_addr == NULL) {
- ifa = ifa_alloc(sizeof(struct in6_ifaddr), M_NOWAIT);
- if (ifa != NULL) {
- ib = (struct in6_ifaddr *)ifa;
- ifid_addr = &ib->ia_addr.sin6_addr;
- if(in6_get_ifid(ifp, NULL, ifid_addr) != 0) {
- nd6log((LOG_DEBUG,
- "%s: failed to get ifid for %s\n",
- __func__, if_name(ifp)));
- ifa_free(ifa);
- ifid_addr = NULL;
- }
+ /*
+ * No suitable link-local address, get the ifid directly.
+ * Only the low 64 bits are filled in, zero the rest.
+ */
+ if (!have_ifid) {
+ memset(&newaddr, 0, sizeof(newaddr));
+ if (in6_get_ifid(ifp, NULL, &newaddr) != 0) {
+ nd6log((LOG_INFO,
+ "%s: could not determine ifid for %s\n",
+ __func__, if_name(ifp)));
+ return (NULL);
}
}
-
- if (ifid_addr == NULL) {
- nd6log((LOG_INFO,
- "%s: could not determine ifid for %s\n",
- __func__, if_name(ifp)));
- return NULL;
- }
-
- memcpy(&newaddr, &ib->ia_addr.sin6_addr, sizeof(ib->ia_addr.sin6_addr));
- ifa_free(ifa);
}
IN6_MASK_ADDR(&ifra.ifra_addr.sin6_addr, &mask);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 10, 6:21 AM (19 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40501006
Default Alt Text
D60488.diff (2 KB)
Attached To
Mode
D60488: nd6: Do not allocate an ifaddr for the interface ID in in6_ifadd()
Attached
Detach File
Event Timeline
Log In to Comment