Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174536931
D55905.id173830.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D55905.id173830.diff
View Options
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -155,7 +155,10 @@
/* ND6 queue flags */
#define ND6_QUEUE_FLAG_NEWGUA 0x01 /* new global unicast address event */
#define ND6_QUEUE_FLAG_LLADDR 0x02 /* link-layer address change event */
-#define ND6_QUEUE_FLAG_ANYCAST 0x04 /* delay NA for anycast or proxy address */
+#define ND6_QUEUE_FLAG_ANYCAST 0x04 /* delay NA for anycast address */
+
+/* don't count for GRAND */
+#define ND6_QUEUE_PATH_MASK (ND6_QUEUE_FLAG_ANYCAST)
/* protocol constants */
#define MAX_RTR_SOLICITATION_DELAY 1 /* 1sec */
@@ -375,7 +378,6 @@
void nd6_dad_stop(struct ifaddr *);
void nd6_grand_start(struct ifaddr *, uint32_t);
void nd6_queue_stop(struct ifaddr *);
-void nd6_delayed_na_start(struct ifaddr *, struct in6_addr *, u_int, uint32_t);
/* nd6_rtr.c */
void nd6_rs_input(struct mbuf *, int, int);
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -98,6 +98,7 @@
const struct in6_addr *, u_long, int, struct sockaddr *, u_int);
static void nd6_ns_output_fib(struct ifnet *, const struct in6_addr *,
const struct in6_addr *, const struct in6_addr *, uint8_t *, u_int);
+static void nd6_queue_add(struct ifaddr *, struct in6_addr *, int, uint32_t);
static struct ifaddr *nd6_proxy_fill_sdl(struct ifnet *,
const struct in6_addr *, struct sockaddr_dl *);
@@ -365,7 +366,7 @@
nd6_na_output_fib(ifp, &saddr6, &taddr6, rflag, tlladdr,
proxy ? (struct sockaddr *)&proxydl : NULL, M_GETFIB(m));
else
- nd6_delayed_na_start(ifa, &saddr6, arc4random() %
+ nd6_queue_add(ifa, &saddr6, arc4random() %
(MAX_ANYCAST_DELAY_TIME * hz), ND6_QUEUE_FLAG_ANYCAST);
freeit:
if (ifa != NULL)
@@ -1649,21 +1650,32 @@
}
static void
-nd6_queue_rel(void *arg)
+nd6_queue_rel_locked(struct nd_queue *ndq)
{
- struct nd_queue *ndq = arg;
- struct ifaddr *ifa = ndq->ndq_ifa;
+ struct ifaddr *ifa;
+ ifa = ndq->ndq_ifa;
IF_ADDR_WLOCK_ASSERT(ifa->ifa_ifp);
- /* Remove ndq from the nd_queue and free it */
+ /* Remove ndq from the nd_queue list and free it */
TAILQ_REMOVE(&ifa->ifa_ifp->if_inet6->nd_queue, ndq, ndq_list);
free(ndq, M_IP6NDP);
- IF_ADDR_WUNLOCK(ifa->ifa_ifp);
-
ifa_free(ifa);
}
+static void
+nd6_queue_rel(void *arg)
+{
+ struct nd_queue *ndq = arg;
+ struct ifnet *ifp;
+
+ ifp = ndq->ndq_ifa->ifa_ifp;
+ IF_ADDR_WLOCK_ASSERT(ifp);
+
+ nd6_queue_rel_locked(ndq);
+ IF_ADDR_WUNLOCK(ifp);
+}
+
static void
nd6_queue_timer(void *arg)
{
@@ -1712,9 +1724,15 @@
if ((ndq->ndq_flags & ND6_QUEUE_FLAG_ANYCAST) != 0)
flags |= ND_NA_FLAG_SOLICITED;
- /* Wait at least a RetransTimer before removing from queue */
- delay = ext->nd_retrans * hz / 1000;
- callout_reset(&ndq->ndq_callout, delay, nd6_queue_rel, ndq);
+ /*
+ * if NA is not solicited, wait at least a RetransTimer
+ * before removing from queue.
+ */
+ if ((ndq->ndq_flags & ND6_QUEUE_PATH_MASK) == 0) {
+ delay = ext->nd_retrans * hz / 1000;
+ callout_reset(&ndq->ndq_callout, delay, nd6_queue_rel, ndq);
+ } else
+ nd6_queue_rel_locked(ndq);
IF_ADDR_WUNLOCK(ifp);
if (__predict_true(in6_setscope(&daddr, ifp, NULL) == 0))
@@ -1730,36 +1748,48 @@
int delay, uint32_t flags)
{
struct nd_queue *ndq;
- struct ifnet *ifp = ifa->ifa_ifp;
- struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
- struct in6_ifextra *ext = ifp->if_inet6;
+ struct ifnet *ifp;
+ struct in6_ifextra *ext;
char ip6buf[INET6_ADDRSTRLEN];
+ bool on_queue;
NET_EPOCH_ASSERT();
- ndq = malloc(sizeof(*ndq), M_IP6NDP, M_NOWAIT | M_ZERO);
+ on_queue = false;
+ ifp = ifa->ifa_ifp;
+ ext = ifp->if_inet6;
+ IF_ADDR_WLOCK(ifp);
+ /* cancel out previous NA and reuse its ndq */
+ TAILQ_FOREACH(ndq, &ext->nd_queue, ndq_list) {
+ if (ndq->ndq_ifa == ifa) {
+ on_queue = true;
+ break;
+ }
+ }
+ if (ndq == NULL)
+ ndq = malloc(sizeof(*ndq), M_IP6NDP, M_NOWAIT | M_ZERO);
if (ndq == NULL) {
- log(LOG_ERR, "nd6_queue_add: memory allocation failed for "
- "%s(%s)\n",
- ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr),
- ifp ? if_name(ifp) : "???");
+ log(LOG_ERR, "%s: memory allocation failed for %s(%s)\n",
+ __func__, ip6_sprintf(ip6buf, IFA_IN6(ifa)),
+ ifp ? if_name(ifp) : "???");
return;
}
- IF_ADDR_WLOCK(ifa->ifa_ifp);
- callout_init_mtx(&ndq->ndq_callout, &ifp->if_addr_lock,
- CALLOUT_TRYLOCK | CALLOUT_RETURNUNLOCKED);
- nd6log((LOG_DEBUG, "%s: send delayed IPv6 ND for %s\n", if_name(ifp),
- ip6_sprintf(ip6buf, &ia->ia_addr.sin6_addr)));
+ if (!on_queue) {
+ callout_init_mtx(&ndq->ndq_callout, &ifp->if_addr_lock,
+ CALLOUT_TRYLOCK | CALLOUT_RETURNUNLOCKED);
+ ifa_ref(ifa);
+ ndq->ndq_ifa = ifa;
+ TAILQ_INSERT_TAIL(&ext->nd_queue, ndq, ndq_list);
+ }
- ndq->ndq_ifa = ifa;
- ifa_ref(ndq->ndq_ifa);
memcpy(&ndq->ndq_daddr, daddr, sizeof(struct in6_addr));
ndq->ndq_flags = flags;
- TAILQ_INSERT_TAIL(&ext->nd_queue, ndq, ndq_list);
+ nd6log((LOG_DEBUG, "%s: delay IPv6 NA for %s\n", if_name(ifp),
+ ip6_sprintf(ip6buf, IFA_IN6(ifa))));
callout_reset(&ndq->ndq_callout, delay, nd6_queue_timer, ndq);
- IF_ADDR_WUNLOCK(ifa->ifa_ifp);
+ IF_ADDR_WUNLOCK(ifp);
}
/*
@@ -1796,6 +1826,9 @@
* Make sure we don't queue GRAND more than V_ip6_grand_count
* per interface.
*/
+ if ((ndq->ndq_flags & ND6_QUEUE_PATH_MASK) != 0)
+ continue;
+
count++;
if (count >= V_ip6_grand_count)
return;
@@ -1826,28 +1859,17 @@
nd6_queue_stop(struct ifaddr *ifa)
{
struct nd_queue *ndq;
+ struct ifnet *ifp;
- IF_ADDR_WLOCK(ifa->ifa_ifp);
- TAILQ_FOREACH(ndq, &ifa->ifa_ifp->if_inet6->nd_queue, ndq_list) {
+ ifp = ifa->ifa_ifp;
+ IF_ADDR_WLOCK(ifp);
+ TAILQ_FOREACH(ndq, &ifp->if_inet6->nd_queue, ndq_list) {
if (ndq->ndq_ifa != ifa)
continue;
callout_stop(&ndq->ndq_callout);
- nd6_queue_rel(ndq);
- return;
+ nd6_queue_rel_locked(ndq);
+ break;
}
- IF_ADDR_WUNLOCK(ifa->ifa_ifp);
-}
-
-/*
- * Send delayed NA for specified address.
- * Called by nd6_ns_input for anycast or proxy NA
- */
-void
-nd6_delayed_na_start(struct ifaddr *ifa, struct in6_addr *daddr,
- u_int delay, uint32_t flags)
-{
-
- NET_EPOCH_ASSERT();
- nd6_queue_add(ifa, daddr, delay, flags);
+ IF_ADDR_WUNLOCK(ifp);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 5, 12:35 AM (1 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40217217
Default Alt Text
D55905.id173830.diff (6 KB)
Attached To
Mode
D55905: ndp: Accept multiple queued ND for non-GRAND NAs
Attached
Detach File
Event Timeline
Log In to Comment