2017-11-27 15:23:17 +00:00
|
|
|
/*-
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2008-12-15 06:53:09 +00:00
|
|
|
* Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2008 Qing Li. All rights reserved.
|
|
|
|
* Copyright (c) 2008 Kip Macy. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2010-03-18 09:09:59 +00:00
|
|
|
#include "opt_ddb.h"
|
2008-12-15 06:53:09 +00:00
|
|
|
#include "opt_inet.h"
|
|
|
|
#include "opt_inet6.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.
EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).
As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions. The remainder of the patch addresses
adding appropriate includes to fix those files.
LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).
No functional change (intended). Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
|
|
|
#include <sys/eventhandler.h>
|
2008-12-15 06:53:09 +00:00
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
#include <sys/rwlock.h>
|
|
|
|
|
2010-03-18 09:09:59 +00:00
|
|
|
#ifdef DDB
|
|
|
|
#include <ddb/ddb.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
#include <vm/uma.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <net/if_llatbl.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/if_var.h>
|
|
|
|
#include <net/route.h>
|
2020-06-01 20:49:42 +00:00
|
|
|
#include <net/route/route_ctl.h>
|
2021-12-26 18:42:12 +00:00
|
|
|
#include <net/route/route_debug.h>
|
2009-08-01 19:26:27 +00:00
|
|
|
#include <net/vnet.h>
|
2008-12-15 06:53:09 +00:00
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
#include <netinet6/in6_var.h>
|
|
|
|
#include <netinet6/nd6.h>
|
|
|
|
|
|
|
|
MALLOC_DEFINE(M_LLTABLE, "lltable", "link level address tables");
|
|
|
|
|
2018-07-24 16:35:52 +00:00
|
|
|
VNET_DEFINE_STATIC(SLIST_HEAD(, lltable), lltables) =
|
2015-12-22 14:57:04 +00:00
|
|
|
SLIST_HEAD_INITIALIZER(lltables);
|
2009-09-17 14:52:15 +00:00
|
|
|
#define V_lltables VNET(lltables)
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
static struct rwlock lltable_list_lock;
|
|
|
|
RW_SYSINIT(lltable_list_lock, &lltable_list_lock, "lltable_list_lock");
|
|
|
|
#define LLTABLE_LIST_RLOCK() rw_rlock(&lltable_list_lock)
|
|
|
|
#define LLTABLE_LIST_RUNLOCK() rw_runlock(&lltable_list_lock)
|
|
|
|
#define LLTABLE_LIST_WLOCK() rw_wlock(&lltable_list_lock)
|
|
|
|
#define LLTABLE_LIST_WUNLOCK() rw_wunlock(&lltable_list_lock)
|
|
|
|
#define LLTABLE_LIST_LOCK_ASSERT() rw_assert(&lltable_list_lock, RA_LOCKED)
|
2009-08-25 09:52:38 +00:00
|
|
|
|
2014-12-07 17:32:06 +00:00
|
|
|
static void lltable_unlink(struct lltable *llt);
|
2015-08-10 12:03:59 +00:00
|
|
|
static void llentries_unlink(struct lltable *llt, struct llentries *head);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump lle state for a specific address family.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
lltable_dump_af(struct lltable *llt, struct sysctl_req *wr)
|
|
|
|
{
|
2019-01-09 01:11:19 +00:00
|
|
|
struct epoch_tracker et;
|
2015-08-10 12:03:59 +00:00
|
|
|
int error;
|
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_LOCK_ASSERT();
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
if (llt->llt_ifp->if_flags & IFF_LOOPBACK)
|
|
|
|
return (0);
|
|
|
|
error = 0;
|
|
|
|
|
2019-01-09 01:11:19 +00:00
|
|
|
NET_EPOCH_ENTER(et);
|
2015-08-10 12:03:59 +00:00
|
|
|
error = lltable_foreach_lle(llt,
|
|
|
|
(llt_foreach_cb_t *)llt->llt_dump_entry, wr);
|
2019-01-09 01:11:19 +00:00
|
|
|
NET_EPOCH_EXIT(et);
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
/*
|
|
|
|
* Dump arp state for a specific address family.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lltable_sysctl_dumparp(int af, struct sysctl_req *wr)
|
|
|
|
{
|
|
|
|
struct lltable *llt;
|
|
|
|
int error = 0;
|
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_RLOCK();
|
2009-09-17 14:52:15 +00:00
|
|
|
SLIST_FOREACH(llt, &V_lltables, llt_link) {
|
2008-12-15 06:53:09 +00:00
|
|
|
if (llt->llt_af == af) {
|
2015-08-10 12:03:59 +00:00
|
|
|
error = lltable_dump_af(llt, wr);
|
2008-12-15 06:53:09 +00:00
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_RUNLOCK();
|
2008-12-15 06:53:09 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-08-10 12:03:59 +00:00
|
|
|
* Common function helpers for chained hash table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Runs specified callback for each entry in @llt.
|
|
|
|
* Caller does the locking.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
htable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg)
|
|
|
|
{
|
|
|
|
struct llentry *lle, *next;
|
|
|
|
int i, error;
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
2015-08-11 05:51:00 +00:00
|
|
|
for (i = 0; i < llt->llt_hsize; i++) {
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) {
|
2015-08-10 12:03:59 +00:00
|
|
|
error = f(llt, lle, farg);
|
|
|
|
if (error != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
/*
|
|
|
|
* The htable_[un]link_entry() functions return:
|
|
|
|
* 0 if the entry was (un)linked already and nothing changed,
|
|
|
|
* 1 if the entry was added/removed to/from the table, and
|
|
|
|
* -1 on error (e.g., not being able to add the entry due to limits reached).
|
|
|
|
* While the "unlink" operation should never error, callers of
|
|
|
|
* lltable_link_entry() need to check for errors and handle them.
|
|
|
|
*/
|
|
|
|
static int
|
2015-08-10 12:03:59 +00:00
|
|
|
htable_link_entry(struct lltable *llt, struct llentry *lle)
|
|
|
|
{
|
|
|
|
struct llentries *lleh;
|
|
|
|
uint32_t hashidx;
|
|
|
|
|
|
|
|
if ((lle->la_flags & LLE_LINKED) != 0)
|
2020-03-04 17:17:02 +00:00
|
|
|
return (0);
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
IF_AFDATA_WLOCK_ASSERT(llt->llt_ifp);
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
if (llt->llt_maxentries > 0 &&
|
|
|
|
llt->llt_entries >= llt->llt_maxentries)
|
|
|
|
return (-1);
|
|
|
|
|
2015-01-05 17:23:02 +00:00
|
|
|
hashidx = llt->llt_hash(lle, llt->llt_hsize);
|
2015-08-10 12:03:59 +00:00
|
|
|
lleh = &llt->lle_head[hashidx];
|
|
|
|
|
|
|
|
lle->lle_tbl = llt;
|
|
|
|
lle->lle_head = lleh;
|
|
|
|
lle->la_flags |= LLE_LINKED;
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_INSERT_HEAD(lleh, lle, lle_next);
|
2020-03-04 17:17:02 +00:00
|
|
|
llt->llt_entries++;
|
|
|
|
|
|
|
|
return (1);
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
static int
|
2015-08-10 12:03:59 +00:00
|
|
|
htable_unlink_entry(struct llentry *lle)
|
|
|
|
{
|
2020-03-04 17:17:02 +00:00
|
|
|
struct lltable *llt;
|
2015-08-10 12:03:59 +00:00
|
|
|
|
2019-11-15 23:12:19 +00:00
|
|
|
if ((lle->la_flags & LLE_LINKED) == 0)
|
2020-03-04 17:17:02 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
llt = lle->lle_tbl;
|
|
|
|
IF_AFDATA_WLOCK_ASSERT(llt->llt_ifp);
|
|
|
|
KASSERT(llt->llt_entries > 0, ("%s: lltable %p (%s) entries %d <= 0",
|
|
|
|
__func__, llt, if_name(llt->llt_ifp), llt->llt_entries));
|
2019-11-15 23:12:19 +00:00
|
|
|
|
|
|
|
CK_LIST_REMOVE(lle, lle_next);
|
|
|
|
lle->la_flags &= ~(LLE_VALID | LLE_LINKED);
|
2015-08-10 12:03:59 +00:00
|
|
|
#if 0
|
2019-11-15 23:12:19 +00:00
|
|
|
lle->lle_tbl = NULL;
|
|
|
|
lle->lle_head = NULL;
|
2015-08-10 12:03:59 +00:00
|
|
|
#endif
|
2020-03-04 17:17:02 +00:00
|
|
|
llt->llt_entries--;
|
|
|
|
|
|
|
|
return (1);
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct prefix_match_data {
|
2015-09-14 16:48:19 +00:00
|
|
|
const struct sockaddr *addr;
|
2015-08-10 12:03:59 +00:00
|
|
|
const struct sockaddr *mask;
|
|
|
|
struct llentries dchain;
|
|
|
|
u_int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
htable_prefix_free_cb(struct lltable *llt, struct llentry *lle, void *farg)
|
|
|
|
{
|
|
|
|
struct prefix_match_data *pmd;
|
|
|
|
|
|
|
|
pmd = (struct prefix_match_data *)farg;
|
|
|
|
|
2015-09-14 16:48:19 +00:00
|
|
|
if (llt->llt_match_prefix(pmd->addr, pmd->mask, pmd->flags, lle)) {
|
2015-08-10 12:03:59 +00:00
|
|
|
LLE_WLOCK(lle);
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_LIST_INSERT_HEAD(&pmd->dchain, lle, lle_chain);
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-09-14 16:48:19 +00:00
|
|
|
htable_prefix_free(struct lltable *llt, const struct sockaddr *addr,
|
2015-08-10 12:03:59 +00:00
|
|
|
const struct sockaddr *mask, u_int flags)
|
|
|
|
{
|
|
|
|
struct llentry *lle, *next;
|
|
|
|
struct prefix_match_data pmd;
|
|
|
|
|
|
|
|
bzero(&pmd, sizeof(pmd));
|
2015-09-14 16:48:19 +00:00
|
|
|
pmd.addr = addr;
|
2015-08-10 12:03:59 +00:00
|
|
|
pmd.mask = mask;
|
|
|
|
pmd.flags = flags;
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_INIT(&pmd.dchain);
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
IF_AFDATA_WLOCK(llt->llt_ifp);
|
|
|
|
/* Push matching lles to chain */
|
|
|
|
lltable_foreach_lle(llt, htable_prefix_free_cb, &pmd);
|
|
|
|
|
|
|
|
llentries_unlink(llt, &pmd.dchain);
|
|
|
|
IF_AFDATA_WUNLOCK(llt->llt_ifp);
|
|
|
|
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_LIST_FOREACH_SAFE(lle, &pmd.dchain, lle_chain, next)
|
2015-08-20 12:05:17 +00:00
|
|
|
lltable_free_entry(llt, lle);
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
2015-08-11 05:51:00 +00:00
|
|
|
static void
|
|
|
|
htable_free_tbl(struct lltable *llt)
|
|
|
|
{
|
|
|
|
|
|
|
|
free(llt->lle_head, M_LLTABLE);
|
|
|
|
free(llt, M_LLTABLE);
|
|
|
|
}
|
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
static void
|
|
|
|
llentries_unlink(struct lltable *llt, struct llentries *head)
|
|
|
|
{
|
|
|
|
struct llentry *lle, *next;
|
|
|
|
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_LIST_FOREACH_SAFE(lle, head, lle_chain, next)
|
2015-08-10 12:03:59 +00:00
|
|
|
llt->llt_unlink_entry(lle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper function used to drop all mbufs in hold queue.
|
2010-11-12 22:03:02 +00:00
|
|
|
*
|
|
|
|
* Returns the number of held packets, if any, that were dropped.
|
2008-12-15 06:53:09 +00:00
|
|
|
*/
|
2010-11-12 22:03:02 +00:00
|
|
|
size_t
|
2015-08-10 12:03:59 +00:00
|
|
|
lltable_drop_entry_queue(struct llentry *lle)
|
2008-12-15 06:53:09 +00:00
|
|
|
{
|
2010-11-12 22:03:02 +00:00
|
|
|
size_t pkts_dropped;
|
|
|
|
struct mbuf *next;
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
LLE_WLOCK_ASSERT(lle);
|
2012-08-02 13:57:49 +00:00
|
|
|
|
|
|
|
pkts_dropped = 0;
|
2010-11-12 22:03:02 +00:00
|
|
|
while ((lle->la_numheld > 0) && (lle->la_hold != NULL)) {
|
|
|
|
next = lle->la_hold->m_nextpkt;
|
2008-12-15 06:53:09 +00:00
|
|
|
m_freem(lle->la_hold);
|
2010-11-12 22:03:02 +00:00
|
|
|
lle->la_hold = next;
|
|
|
|
lle->la_numheld--;
|
|
|
|
pkts_dropped++;
|
|
|
|
}
|
|
|
|
|
2012-07-31 11:31:12 +00:00
|
|
|
KASSERT(lle->la_numheld == 0,
|
|
|
|
("%s: la_numheld %d > 0, pkts_droped %zd", __func__,
|
2010-11-12 22:03:02 +00:00
|
|
|
lle->la_numheld, pkts_dropped));
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
return (pkts_dropped);
|
|
|
|
}
|
|
|
|
|
2015-11-07 11:12:00 +00:00
|
|
|
void
|
|
|
|
lltable_set_entry_addr(struct ifnet *ifp, struct llentry *lle,
|
2015-12-31 05:03:27 +00:00
|
|
|
const char *linkhdr, size_t linkhdrsize, int lladdr_off)
|
2015-11-07 11:12:00 +00:00
|
|
|
{
|
|
|
|
|
2015-12-31 05:03:27 +00:00
|
|
|
memcpy(lle->r_linkdata, linkhdr, linkhdrsize);
|
|
|
|
lle->r_hdrlen = linkhdrsize;
|
|
|
|
lle->ll_addr = &lle->r_linkdata[lladdr_off];
|
2015-11-07 11:12:00 +00:00
|
|
|
lle->la_flags |= LLE_VALID;
|
2015-12-05 09:50:37 +00:00
|
|
|
lle->r_flags |= RLLE_VALID;
|
2015-11-07 11:12:00 +00:00
|
|
|
}
|
|
|
|
|
2015-12-13 07:39:49 +00:00
|
|
|
/*
|
2021-08-06 08:27:22 +00:00
|
|
|
* Acquires lltable write lock.
|
2015-12-13 07:39:49 +00:00
|
|
|
*
|
2021-08-06 08:27:22 +00:00
|
|
|
* Returns true on success, with both lltable and lle lock held.
|
|
|
|
* On failure, false is returned and lle wlock is still held.
|
2015-12-13 07:39:49 +00:00
|
|
|
*/
|
2021-08-06 08:27:22 +00:00
|
|
|
bool
|
|
|
|
lltable_acquire_wlock(struct ifnet *ifp, struct llentry *lle)
|
2015-12-13 07:39:49 +00:00
|
|
|
{
|
2021-08-06 08:27:22 +00:00
|
|
|
NET_EPOCH_ASSERT();
|
2015-12-13 07:39:49 +00:00
|
|
|
|
|
|
|
/* Perform real LLE update */
|
|
|
|
/* use afdata WLOCK to update fields */
|
|
|
|
LLE_WUNLOCK(lle);
|
|
|
|
IF_AFDATA_WLOCK(ifp);
|
|
|
|
LLE_WLOCK(lle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since we droppped LLE lock, other thread might have deleted
|
|
|
|
* this lle. Check and return
|
|
|
|
*/
|
|
|
|
if ((lle->la_flags & LLE_DELETED) != 0) {
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
2021-08-06 08:27:22 +00:00
|
|
|
return (false);
|
2015-12-13 07:39:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-06 08:27:22 +00:00
|
|
|
return (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tries to update @lle link-level address.
|
|
|
|
* Since update requires AFDATA WLOCK, function
|
|
|
|
* drops @lle lock, acquires AFDATA lock and then acquires
|
|
|
|
* @lle lock to maintain lock order.
|
|
|
|
*
|
|
|
|
* Returns 1 on success.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lltable_try_set_entry_addr(struct ifnet *ifp, struct llentry *lle,
|
|
|
|
const char *linkhdr, size_t linkhdrsize, int lladdr_off)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!lltable_acquire_wlock(ifp, lle))
|
|
|
|
return (0);
|
|
|
|
|
2015-12-13 07:39:49 +00:00
|
|
|
/* Update data */
|
2015-12-31 05:03:27 +00:00
|
|
|
lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize, lladdr_off);
|
2015-12-13 07:39:49 +00:00
|
|
|
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2015-12-31 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* Helper function used to pre-compute full/partial link-layer
|
|
|
|
* header data suitable for feeding into if_output().
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lltable_calc_llheader(struct ifnet *ifp, int family, char *lladdr,
|
|
|
|
char *buf, size_t *bufsize, int *lladdr_off)
|
|
|
|
{
|
|
|
|
struct if_encap_req ereq;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
bzero(buf, *bufsize);
|
|
|
|
bzero(&ereq, sizeof(ereq));
|
|
|
|
ereq.buf = buf;
|
|
|
|
ereq.bufsize = *bufsize;
|
|
|
|
ereq.rtype = IFENCAP_LL;
|
|
|
|
ereq.family = family;
|
|
|
|
ereq.lladdr = lladdr;
|
|
|
|
ereq.lladdr_len = ifp->if_addrlen;
|
|
|
|
error = ifp->if_requestencap(ifp, &ereq);
|
|
|
|
if (error == 0) {
|
|
|
|
*bufsize = ereq.bufsize;
|
|
|
|
*lladdr_off = ereq.lladdr_off;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
/*
|
|
|
|
* Searches for the child entry matching @family inside @lle.
|
|
|
|
* Returns the entry or NULL.
|
|
|
|
*/
|
|
|
|
struct llentry *
|
|
|
|
llentry_lookup_family(struct llentry *lle, int family)
|
|
|
|
{
|
|
|
|
struct llentry *child_lle;
|
|
|
|
|
|
|
|
if (lle == NULL)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
CK_SLIST_FOREACH(child_lle, &lle->lle_children, lle_child_next) {
|
|
|
|
if (child_lle->r_family == family)
|
|
|
|
return (child_lle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2021-12-26 18:42:12 +00:00
|
|
|
/*
|
|
|
|
* Retrieves upper protocol family for the llentry.
|
|
|
|
* By default, all "normal" (e.g. upper_family == transport_family)
|
|
|
|
* llentries have r_family set to 0.
|
|
|
|
* Thus, use @default_family in that regard, otherwise use r_family.
|
|
|
|
*
|
|
|
|
* Returns upper protocol family
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
llentry_get_upper_family(const struct llentry *lle, int default_family)
|
|
|
|
{
|
|
|
|
return (lle->r_family == 0 ? default_family : lle->r_family);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prints llentry @lle data into provided buffer.
|
|
|
|
* Example: lle/inet/valid/em0/1.2.3.4
|
|
|
|
*
|
|
|
|
* Returns @buf.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
llentry_print_buf(const struct llentry *lle, struct ifnet *ifp, int family,
|
|
|
|
char *buf, size_t bufsize)
|
|
|
|
{
|
|
|
|
char abuf[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
const char *valid = (lle->r_flags & RLLE_VALID) ? "valid" : "no_l2";
|
|
|
|
const char *upper_str = rib_print_family(llentry_get_upper_family(lle, family));
|
|
|
|
|
|
|
|
switch (family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
inet_ntop(AF_INET, &lle->r_l3addr.addr4, abuf, sizeof(abuf));
|
|
|
|
snprintf(buf, bufsize, "lle/%s/%s/%s/%s", upper_str,
|
|
|
|
valid, if_name(ifp), abuf);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
inet_ntop(AF_INET6, &lle->r_l3addr.addr6, abuf, sizeof(abuf));
|
|
|
|
snprintf(buf, bufsize, "lle/%s/%s/%s/%s", upper_str,
|
|
|
|
valid, if_name(ifp), abuf);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
snprintf(buf, bufsize, "lle/%s/%s/%s/????", upper_str,
|
|
|
|
valid, if_name(ifp));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
llentry_print_buf_lltable(const struct llentry *lle, char *buf, size_t bufsize)
|
|
|
|
{
|
|
|
|
struct lltable *tbl = lle->lle_tbl;
|
|
|
|
|
|
|
|
return (llentry_print_buf(lle, lltable_get_ifp(tbl), lltable_get_af(tbl), buf, bufsize));
|
|
|
|
}
|
|
|
|
|
2021-08-02 22:39:00 +00:00
|
|
|
/*
|
|
|
|
* Requests feedback from the datapath.
|
|
|
|
* First packet using @lle should result in
|
|
|
|
* setting r_skip_req back to 0 and updating
|
|
|
|
* lle_hittime to the current time_uptime.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
llentry_request_feedback(struct llentry *lle)
|
|
|
|
{
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
struct llentry *child_lle;
|
|
|
|
|
2021-08-02 22:39:00 +00:00
|
|
|
LLE_REQ_LOCK(lle);
|
|
|
|
lle->r_skip_req = 1;
|
|
|
|
LLE_REQ_UNLOCK(lle);
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
|
|
|
|
CK_SLIST_FOREACH(child_lle, &lle->lle_children, lle_child_next) {
|
|
|
|
LLE_REQ_LOCK(child_lle);
|
|
|
|
child_lle->r_skip_req = 1;
|
|
|
|
LLE_REQ_UNLOCK(child_lle);
|
|
|
|
}
|
2021-08-02 22:39:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates the lle state to mark it has been used
|
|
|
|
* and record the time.
|
|
|
|
* Used by the llentry_provide_feedback() wrapper.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
llentry_mark_used(struct llentry *lle)
|
|
|
|
{
|
|
|
|
LLE_REQ_LOCK(lle);
|
|
|
|
lle->r_skip_req = 0;
|
|
|
|
lle->lle_hittime = time_uptime;
|
|
|
|
LLE_REQ_UNLOCK(lle);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetches the time when lle was used.
|
|
|
|
* Return 0 if the entry was not used, relevant time_uptime
|
|
|
|
* otherwise.
|
|
|
|
*/
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
static time_t
|
|
|
|
llentry_get_hittime_raw(struct llentry *lle)
|
2021-08-02 22:39:00 +00:00
|
|
|
{
|
|
|
|
time_t lle_hittime = 0;
|
|
|
|
|
|
|
|
LLE_REQ_LOCK(lle);
|
|
|
|
if ((lle->r_skip_req == 0) && (lle_hittime < lle->lle_hittime))
|
|
|
|
lle_hittime = lle->lle_hittime;
|
|
|
|
LLE_REQ_UNLOCK(lle);
|
|
|
|
|
|
|
|
return (lle_hittime);
|
|
|
|
}
|
|
|
|
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
time_t
|
|
|
|
llentry_get_hittime(struct llentry *lle)
|
|
|
|
{
|
|
|
|
time_t lle_hittime = 0;
|
|
|
|
struct llentry *child_lle;
|
|
|
|
|
|
|
|
lle_hittime = llentry_get_hittime_raw(lle);
|
|
|
|
|
|
|
|
CK_SLIST_FOREACH(child_lle, &lle->lle_children, lle_child_next) {
|
|
|
|
time_t hittime = llentry_get_hittime_raw(child_lle);
|
|
|
|
if (hittime > lle_hittime)
|
|
|
|
lle_hittime = hittime;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (lle_hittime);
|
|
|
|
}
|
|
|
|
|
2015-12-31 05:03:27 +00:00
|
|
|
/*
|
|
|
|
* Update link-layer header for given @lle after
|
|
|
|
* interface lladdr was changed.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
llentry_update_ifaddr(struct lltable *llt, struct llentry *lle, void *farg)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp;
|
|
|
|
u_char linkhdr[LLE_MAX_LINKHDR];
|
|
|
|
size_t linkhdrsize;
|
|
|
|
u_char *lladdr;
|
|
|
|
int lladdr_off;
|
|
|
|
|
|
|
|
ifp = (struct ifnet *)farg;
|
|
|
|
|
|
|
|
lladdr = lle->ll_addr;
|
|
|
|
|
|
|
|
LLE_WLOCK(lle);
|
|
|
|
if ((lle->la_flags & LLE_VALID) == 0) {
|
|
|
|
LLE_WUNLOCK(lle);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lle->la_flags & LLE_IFADDR) != 0)
|
|
|
|
lladdr = IF_LLADDR(ifp);
|
|
|
|
|
|
|
|
linkhdrsize = sizeof(linkhdr);
|
|
|
|
lltable_calc_llheader(ifp, llt->llt_af, lladdr, linkhdr, &linkhdrsize,
|
|
|
|
&lladdr_off);
|
|
|
|
memcpy(lle->r_linkdata, linkhdr, linkhdrsize);
|
|
|
|
LLE_WUNLOCK(lle);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update all calculated headers for given @llt
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lltable_update_ifaddr(struct lltable *llt)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (llt->llt_ifp->if_flags & IFF_LOOPBACK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
IF_AFDATA_WLOCK(llt->llt_ifp);
|
|
|
|
lltable_foreach_lle(llt, llentry_update_ifaddr, llt->llt_ifp);
|
|
|
|
IF_AFDATA_WUNLOCK(llt->llt_ifp);
|
|
|
|
}
|
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
/*
|
2015-08-20 12:05:17 +00:00
|
|
|
*
|
2016-05-03 18:05:43 +00:00
|
|
|
* Performs generic cleanup routines and frees lle.
|
2015-08-20 12:05:17 +00:00
|
|
|
*
|
|
|
|
* Called for non-linked entries, with callouts and
|
|
|
|
* other AF-specific cleanups performed.
|
|
|
|
*
|
|
|
|
* @lle must be passed WLOCK'ed
|
2015-08-10 12:03:59 +00:00
|
|
|
*
|
|
|
|
* Returns the number of held packets, if any, that were dropped.
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
llentry_free(struct llentry *lle)
|
|
|
|
{
|
|
|
|
size_t pkts_dropped;
|
|
|
|
|
|
|
|
LLE_WLOCK_ASSERT(lle);
|
|
|
|
|
2015-09-15 06:48:19 +00:00
|
|
|
KASSERT((lle->la_flags & LLE_LINKED) == 0, ("freeing linked lle"));
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
pkts_dropped = lltable_drop_entry_queue(lle);
|
|
|
|
|
2018-07-17 11:33:23 +00:00
|
|
|
/* cancel timer */
|
|
|
|
if (callout_stop(&lle->lle_timer) > 0)
|
|
|
|
LLE_REMREF(lle);
|
2008-12-15 06:53:09 +00:00
|
|
|
LLE_FREE_LOCKED(lle);
|
2010-11-12 22:03:02 +00:00
|
|
|
|
|
|
|
return (pkts_dropped);
|
2008-12-15 06:53:09 +00:00
|
|
|
}
|
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
/*
|
|
|
|
* Free all entries from given table and free itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
lltable_free_cb(struct lltable *llt, struct llentry *lle, void *farg)
|
|
|
|
{
|
|
|
|
struct llentries *dchain;
|
|
|
|
|
|
|
|
dchain = (struct llentries *)farg;
|
|
|
|
|
|
|
|
LLE_WLOCK(lle);
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_LIST_INSERT_HEAD(dchain, lle, lle_chain);
|
2015-08-10 12:03:59 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
/*
|
|
|
|
* Free all entries from given table and free itself.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
lltable_free(struct lltable *llt)
|
|
|
|
{
|
|
|
|
struct llentry *lle, *next;
|
2015-08-10 12:03:59 +00:00
|
|
|
struct llentries dchain;
|
2008-12-15 06:53:09 +00:00
|
|
|
|
|
|
|
KASSERT(llt != NULL, ("%s: llt is NULL", __func__));
|
|
|
|
|
2014-12-07 17:32:06 +00:00
|
|
|
lltable_unlink(llt);
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_INIT(&dchain);
|
2012-08-02 13:57:49 +00:00
|
|
|
IF_AFDATA_WLOCK(llt->llt_ifp);
|
2015-08-10 12:03:59 +00:00
|
|
|
/* Push all lles to @dchain */
|
|
|
|
lltable_foreach_lle(llt, lltable_free_cb, &dchain);
|
|
|
|
llentries_unlink(llt, &dchain);
|
2012-08-02 13:57:49 +00:00
|
|
|
IF_AFDATA_WUNLOCK(llt->llt_ifp);
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2018-05-24 23:21:23 +00:00
|
|
|
CK_LIST_FOREACH_SAFE(lle, &dchain, lle_chain, next) {
|
2015-08-10 12:03:59 +00:00
|
|
|
llentry_free(lle);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
KASSERT(llt->llt_entries == 0, ("%s: lltable %p (%s) entires not 0: %d",
|
|
|
|
__func__, llt, llt->llt_ifp->if_xname, llt->llt_entries));
|
|
|
|
|
2015-08-11 05:51:00 +00:00
|
|
|
llt->llt_free_tbl(llt);
|
2008-12-15 06:53:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 16:48:19 +00:00
|
|
|
/*
|
|
|
|
* Deletes an address from given lltable.
|
|
|
|
* Used for userland interaction to remove
|
|
|
|
* individual entries. Skips entries added by OS.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
lltable_delete_addr(struct lltable *llt, u_int flags,
|
|
|
|
const struct sockaddr *l3addr)
|
|
|
|
{
|
|
|
|
struct llentry *lle;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
ifp = llt->llt_ifp;
|
|
|
|
IF_AFDATA_WLOCK(ifp);
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
lle = lla_lookup(llt, LLE_SF(l3addr->sa_family, LLE_EXCLUSIVE), l3addr);
|
2015-09-14 16:48:19 +00:00
|
|
|
|
|
|
|
if (lle == NULL) {
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) {
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
|
|
|
LLE_WUNLOCK(lle);
|
|
|
|
return (EPERM);
|
|
|
|
}
|
|
|
|
|
|
|
|
lltable_unlink_entry(llt, lle);
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
|
|
|
|
|
|
|
llt->llt_delete_entry(llt, lle);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2009-05-20 21:07:15 +00:00
|
|
|
void
|
2015-09-14 16:48:19 +00:00
|
|
|
lltable_prefix_free(int af, struct sockaddr *addr, struct sockaddr *mask,
|
2012-07-31 11:31:12 +00:00
|
|
|
u_int flags)
|
2009-05-20 21:07:15 +00:00
|
|
|
{
|
|
|
|
struct lltable *llt;
|
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_RLOCK();
|
2009-09-17 14:52:15 +00:00
|
|
|
SLIST_FOREACH(llt, &V_lltables, llt_link) {
|
2009-05-20 21:07:15 +00:00
|
|
|
if (llt->llt_af != af)
|
|
|
|
continue;
|
|
|
|
|
2015-09-14 16:48:19 +00:00
|
|
|
llt->llt_prefix_free(llt, addr, mask, flags);
|
2009-05-20 21:07:15 +00:00
|
|
|
}
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_RUNLOCK();
|
2009-05-20 21:07:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
struct lltable *
|
2015-08-11 05:51:00 +00:00
|
|
|
lltable_allocate_htbl(uint32_t hsize)
|
2008-12-15 06:53:09 +00:00
|
|
|
{
|
|
|
|
struct lltable *llt;
|
2015-08-11 05:51:00 +00:00
|
|
|
int i;
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2015-08-11 05:51:00 +00:00
|
|
|
llt = malloc(sizeof(struct lltable), M_LLTABLE, M_WAITOK | M_ZERO);
|
|
|
|
llt->llt_hsize = hsize;
|
|
|
|
llt->lle_head = malloc(sizeof(struct llentries) * hsize,
|
|
|
|
M_LLTABLE, M_WAITOK | M_ZERO);
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2015-08-11 05:51:00 +00:00
|
|
|
for (i = 0; i < llt->llt_hsize; i++)
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_INIT(&llt->lle_head[i]);
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
/* Set some default callbacks */
|
|
|
|
llt->llt_link_entry = htable_link_entry;
|
|
|
|
llt->llt_unlink_entry = htable_unlink_entry;
|
|
|
|
llt->llt_prefix_free = htable_prefix_free;
|
|
|
|
llt->llt_foreach_entry = htable_foreach_lle;
|
2015-08-11 05:51:00 +00:00
|
|
|
llt->llt_free_tbl = htable_free_tbl;
|
|
|
|
|
|
|
|
return (llt);
|
|
|
|
}
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
/*
|
2014-12-07 17:32:06 +00:00
|
|
|
* Links lltable to global llt list.
|
2008-12-15 06:53:09 +00:00
|
|
|
*/
|
2014-12-07 17:32:06 +00:00
|
|
|
void
|
|
|
|
lltable_link(struct lltable *llt)
|
2008-12-15 06:53:09 +00:00
|
|
|
{
|
2015-08-10 12:03:59 +00:00
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_WLOCK();
|
2009-09-17 14:52:15 +00:00
|
|
|
SLIST_INSERT_HEAD(&V_lltables, llt, llt_link);
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_WUNLOCK();
|
2014-12-07 17:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
lltable_unlink(struct lltable *llt)
|
|
|
|
{
|
|
|
|
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_WLOCK();
|
2014-12-07 17:32:06 +00:00
|
|
|
SLIST_REMOVE(&V_lltables, llt, lltable, llt_link);
|
2016-10-11 17:41:13 +00:00
|
|
|
LLTABLE_LIST_WUNLOCK();
|
2008-12-15 06:53:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-26 12:39:26 +00:00
|
|
|
/*
|
|
|
|
* Gets interface @ifp lltable for the specified @family
|
|
|
|
*/
|
|
|
|
struct lltable *
|
|
|
|
lltable_get(struct ifnet *ifp, int family)
|
|
|
|
{
|
|
|
|
switch (family) {
|
2021-12-30 21:49:35 +00:00
|
|
|
#ifdef INET
|
2021-12-26 12:39:26 +00:00
|
|
|
case AF_INET:
|
|
|
|
return (in_lltable_get(ifp));
|
2021-12-30 21:49:35 +00:00
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
2021-12-26 12:39:26 +00:00
|
|
|
case AF_INET6:
|
|
|
|
return (in6_lltable_get(ifp));
|
2021-12-30 21:49:35 +00:00
|
|
|
#endif
|
2021-12-26 12:39:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2015-08-10 12:03:59 +00:00
|
|
|
/*
|
|
|
|
* External methods used by lltable consumers
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
lltable_foreach_lle(struct lltable *llt, llt_foreach_cb_t *f, void *farg)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (llt->llt_foreach_entry(llt, f, farg));
|
|
|
|
}
|
|
|
|
|
2015-08-20 12:05:17 +00:00
|
|
|
struct llentry *
|
|
|
|
lltable_alloc_entry(struct lltable *llt, u_int flags,
|
|
|
|
const struct sockaddr *l3addr)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (llt->llt_alloc_entry(llt, flags, l3addr));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lltable_free_entry(struct lltable *llt, struct llentry *lle)
|
|
|
|
{
|
|
|
|
|
|
|
|
llt->llt_free_entry(llt, lle);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
int
|
2015-08-10 12:03:59 +00:00
|
|
|
lltable_link_entry(struct lltable *llt, struct llentry *lle)
|
|
|
|
{
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
return (llt->llt_link_entry(llt, lle));
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
for `if_output` functions. Using these headers allows saving some
CPU cycles/memory accesses on the fast path.
However, this approach makes adding L2 header for IPv4 traffic with IPv6
nexthops more complex, as it is not possible to store multiple
pre-calculated headers inside lle. Additionally, the solution space is
limited by the fact that PCB caching saves LLEs in addition to the nexthop.
Thus, add support for creating special "child" LLEs for the purpose of holding
custom family encaps and store mbufs pending resolution. To simplify handling
of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
to the "parent" LLE - it is not possible to delete "child" when parent is alive.
Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
machine used by the standard LLEs.
nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
allowing to return such child LLEs. This change uses `LLE_SF()` macro which
packs family and flags in a single int field. This is done to simplify merging
back to stable/. Once this code lands, most of the cases will be converted to
use a dedicated `family` parameter.
Differential Revision: https://reviews.freebsd.org/D31379
MFC after: 2 weeks
2021-08-21 14:13:32 +00:00
|
|
|
void
|
|
|
|
lltable_link_child_entry(struct llentry *lle, struct llentry *child_lle)
|
|
|
|
{
|
|
|
|
child_lle->lle_parent = lle;
|
|
|
|
child_lle->lle_tbl = lle->lle_tbl;
|
|
|
|
child_lle->la_flags |= LLE_LINKED;
|
|
|
|
CK_SLIST_INSERT_HEAD(&lle->lle_children, child_lle, lle_child_next);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lltable_unlink_child_entry(struct llentry *child_lle)
|
|
|
|
{
|
|
|
|
struct llentry *lle = child_lle->lle_parent;
|
|
|
|
|
|
|
|
child_lle->la_flags &= ~LLE_LINKED;
|
|
|
|
child_lle->lle_parent = NULL;
|
|
|
|
CK_SLIST_REMOVE(&lle->lle_children, child_lle, llentry, lle_child_next);
|
|
|
|
}
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
int
|
2015-08-10 12:03:59 +00:00
|
|
|
lltable_unlink_entry(struct lltable *llt, struct llentry *lle)
|
|
|
|
{
|
|
|
|
|
2020-03-04 17:17:02 +00:00
|
|
|
return (llt->llt_unlink_entry(lle));
|
2015-08-10 12:03:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
lltable_fill_sa_entry(const struct llentry *lle, struct sockaddr *sa)
|
|
|
|
{
|
|
|
|
struct lltable *llt;
|
|
|
|
|
|
|
|
llt = lle->lle_tbl;
|
|
|
|
llt->llt_fill_sa_entry(lle, sa);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ifnet *
|
|
|
|
lltable_get_ifp(const struct lltable *llt)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (llt->llt_ifp);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lltable_get_af(const struct lltable *llt)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (llt->llt_af);
|
|
|
|
}
|
|
|
|
|
2008-12-15 06:53:09 +00:00
|
|
|
/*
|
2014-11-15 18:54:07 +00:00
|
|
|
* Called in route_output when rtm_flags contains RTF_LLDATA.
|
2008-12-15 06:53:09 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info)
|
|
|
|
{
|
|
|
|
struct sockaddr_dl *dl =
|
|
|
|
(struct sockaddr_dl *)info->rti_info[RTAX_GATEWAY];
|
|
|
|
struct sockaddr *dst = (struct sockaddr *)info->rti_info[RTAX_DST];
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct lltable *llt;
|
2015-08-20 12:05:17 +00:00
|
|
|
struct llentry *lle, *lle_tmp;
|
2015-12-31 05:03:27 +00:00
|
|
|
uint8_t linkhdr[LLE_MAX_LINKHDR];
|
|
|
|
size_t linkhdrsize;
|
|
|
|
int lladdr_off;
|
2014-11-15 18:54:07 +00:00
|
|
|
u_int laflags = 0;
|
|
|
|
int error;
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2019-12-31 17:26:53 +00:00
|
|
|
if (dl == NULL || dl->sdl_family != AF_LINK)
|
|
|
|
return (EINVAL);
|
2013-01-29 21:44:22 +00:00
|
|
|
|
2021-02-20 18:21:52 +00:00
|
|
|
/* XXX: should be ntohs() */
|
2008-12-15 06:53:09 +00:00
|
|
|
ifp = ifnet_byindex(dl->sdl_index);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
log(LOG_INFO, "%s: invalid ifp (sdl_index %d)\n",
|
|
|
|
__func__, dl->sdl_index);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-12-26 12:39:26 +00:00
|
|
|
llt = lltable_get(ifp, dst->sa_family);
|
|
|
|
|
2019-12-31 17:26:53 +00:00
|
|
|
if (llt == NULL)
|
|
|
|
return (ESRCH);
|
2008-12-15 06:53:09 +00:00
|
|
|
|
2014-11-15 18:54:07 +00:00
|
|
|
error = 0;
|
|
|
|
|
|
|
|
switch (rtm->rtm_type) {
|
|
|
|
case RTM_ADD:
|
|
|
|
/* Add static LLE */
|
2015-08-31 05:03:36 +00:00
|
|
|
laflags = 0;
|
|
|
|
if (rtm->rtm_rmx.rmx_expire == 0)
|
|
|
|
laflags = LLE_STATIC;
|
|
|
|
lle = lltable_alloc_entry(llt, laflags, dst);
|
2015-08-20 12:05:17 +00:00
|
|
|
if (lle == NULL)
|
2014-11-15 18:54:07 +00:00
|
|
|
return (ENOMEM);
|
|
|
|
|
2015-12-31 05:03:27 +00:00
|
|
|
linkhdrsize = sizeof(linkhdr);
|
|
|
|
if (lltable_calc_llheader(ifp, dst->sa_family, LLADDR(dl),
|
|
|
|
linkhdr, &linkhdrsize, &lladdr_off) != 0)
|
|
|
|
return (EINVAL);
|
|
|
|
lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize,
|
|
|
|
lladdr_off);
|
2014-11-15 18:54:07 +00:00
|
|
|
if ((rtm->rtm_flags & RTF_ANNOUNCE))
|
|
|
|
lle->la_flags |= LLE_PUB;
|
2015-08-31 05:03:36 +00:00
|
|
|
lle->la_expire = rtm->rtm_rmx.rmx_expire;
|
|
|
|
|
2014-11-15 18:54:07 +00:00
|
|
|
laflags = lle->la_flags;
|
2015-08-20 12:05:17 +00:00
|
|
|
|
|
|
|
/* Try to link new entry */
|
|
|
|
lle_tmp = NULL;
|
|
|
|
IF_AFDATA_WLOCK(ifp);
|
|
|
|
LLE_WLOCK(lle);
|
|
|
|
lle_tmp = lla_lookup(llt, LLE_EXCLUSIVE, dst);
|
|
|
|
if (lle_tmp != NULL) {
|
|
|
|
/* Check if we are trying to replace immutable entry */
|
|
|
|
if ((lle_tmp->la_flags & LLE_IFADDR) != 0) {
|
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
|
|
|
LLE_WUNLOCK(lle_tmp);
|
|
|
|
lltable_free_entry(llt, lle);
|
|
|
|
return (EPERM);
|
|
|
|
}
|
|
|
|
/* Unlink existing entry from table */
|
|
|
|
lltable_unlink_entry(llt, lle_tmp);
|
|
|
|
}
|
|
|
|
lltable_link_entry(llt, lle);
|
2014-11-15 18:54:07 +00:00
|
|
|
IF_AFDATA_WUNLOCK(ifp);
|
2015-08-20 12:05:17 +00:00
|
|
|
|
|
|
|
if (lle_tmp != NULL) {
|
|
|
|
EVENTHANDLER_INVOKE(lle_event, lle_tmp,LLENTRY_EXPIRED);
|
|
|
|
lltable_free_entry(llt, lle_tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* By invoking LLE handler here we might get
|
|
|
|
* two events on static LLE entry insertion
|
|
|
|
* in routing socket. However, since we might have
|
|
|
|
* other subscribers we need to generate this event.
|
|
|
|
*/
|
|
|
|
EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_RESOLVED);
|
|
|
|
LLE_WUNLOCK(lle);
|
2008-12-15 06:53:09 +00:00
|
|
|
#ifdef INET
|
2014-11-15 18:54:07 +00:00
|
|
|
/* gratuitous ARP */
|
|
|
|
if ((laflags & LLE_PUB) && dst->sa_family == AF_INET)
|
|
|
|
arprequest(ifp,
|
|
|
|
&((struct sockaddr_in *)dst)->sin_addr,
|
|
|
|
&((struct sockaddr_in *)dst)->sin_addr,
|
|
|
|
(u_char *)LLADDR(dl));
|
2008-12-15 06:53:09 +00:00
|
|
|
#endif
|
|
|
|
|
2014-11-15 18:54:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RTM_DELETE:
|
2015-09-14 16:48:19 +00:00
|
|
|
return (lltable_delete_addr(llt, 0, dst));
|
2014-11-15 18:54:07 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
}
|
2008-12-15 06:53:09 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
2009-09-17 14:52:15 +00:00
|
|
|
|
2010-03-18 09:09:59 +00:00
|
|
|
#ifdef DDB
|
|
|
|
struct llentry_sa {
|
|
|
|
struct llentry base;
|
|
|
|
struct sockaddr l3_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
llatbl_lle_show(struct llentry_sa *la)
|
|
|
|
{
|
|
|
|
struct llentry *lle;
|
|
|
|
uint8_t octet[6];
|
|
|
|
|
|
|
|
lle = &la->base;
|
|
|
|
db_printf("lle=%p\n", lle);
|
2018-05-24 23:21:23 +00:00
|
|
|
db_printf(" lle_next=%p\n", lle->lle_next.cle_next);
|
2010-03-18 09:09:59 +00:00
|
|
|
db_printf(" lle_lock=%p\n", &lle->lle_lock);
|
|
|
|
db_printf(" lle_tbl=%p\n", lle->lle_tbl);
|
|
|
|
db_printf(" lle_head=%p\n", lle->lle_head);
|
|
|
|
db_printf(" la_hold=%p\n", lle->la_hold);
|
2010-11-12 22:03:02 +00:00
|
|
|
db_printf(" la_numheld=%d\n", lle->la_numheld);
|
2010-03-18 09:09:59 +00:00
|
|
|
db_printf(" la_expire=%ju\n", (uintmax_t)lle->la_expire);
|
|
|
|
db_printf(" la_flags=0x%04x\n", lle->la_flags);
|
|
|
|
db_printf(" la_asked=%u\n", lle->la_asked);
|
|
|
|
db_printf(" la_preempt=%u\n", lle->la_preempt);
|
|
|
|
db_printf(" ln_state=%d\n", lle->ln_state);
|
|
|
|
db_printf(" ln_router=%u\n", lle->ln_router);
|
|
|
|
db_printf(" ln_ntick=%ju\n", (uintmax_t)lle->ln_ntick);
|
|
|
|
db_printf(" lle_refcnt=%d\n", lle->lle_refcnt);
|
2015-12-31 05:03:27 +00:00
|
|
|
bcopy(lle->ll_addr, octet, sizeof(octet));
|
2010-03-18 09:09:59 +00:00
|
|
|
db_printf(" ll_addr=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
|
|
|
octet[0], octet[1], octet[2], octet[3], octet[4], octet[5]);
|
2015-08-11 12:38:54 +00:00
|
|
|
db_printf(" lle_timer=%p\n", &lle->lle_timer);
|
2010-03-18 09:09:59 +00:00
|
|
|
|
|
|
|
switch (la->l3_addr.sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
{
|
|
|
|
struct sockaddr_in *sin;
|
|
|
|
char l3s[INET_ADDRSTRLEN];
|
|
|
|
|
|
|
|
sin = (struct sockaddr_in *)&la->l3_addr;
|
|
|
|
inet_ntoa_r(sin->sin_addr, l3s);
|
2012-08-01 09:00:26 +00:00
|
|
|
db_printf(" l3_addr=%s\n", l3s);
|
2010-03-18 09:09:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
{
|
|
|
|
struct sockaddr_in6 *sin6;
|
|
|
|
char l3s[INET6_ADDRSTRLEN];
|
|
|
|
|
|
|
|
sin6 = (struct sockaddr_in6 *)&la->l3_addr;
|
|
|
|
ip6_sprintf(l3s, &sin6->sin6_addr);
|
2012-08-01 09:00:26 +00:00
|
|
|
db_printf(" l3_addr=%s\n", l3s);
|
2010-03-18 09:09:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
db_printf(" l3_addr=N/A (af=%d)\n", la->l3_addr.sa_family);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DB_SHOW_COMMAND(llentry, db_show_llentry)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!have_addr) {
|
|
|
|
db_printf("usage: show llentry <struct llentry *>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
llatbl_lle_show((struct llentry_sa *)addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
llatbl_llt_show(struct lltable *llt)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct llentry *lle;
|
|
|
|
|
|
|
|
db_printf("llt=%p llt_af=%d llt_ifp=%p\n",
|
|
|
|
llt, llt->llt_af, llt->llt_ifp);
|
|
|
|
|
2015-01-05 17:23:02 +00:00
|
|
|
for (i = 0; i < llt->llt_hsize; i++) {
|
2018-05-23 21:02:14 +00:00
|
|
|
CK_LIST_FOREACH(lle, &llt->lle_head[i], lle_next) {
|
2010-03-18 09:09:59 +00:00
|
|
|
llatbl_lle_show((struct llentry_sa *)lle);
|
|
|
|
if (db_pager_quit)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DB_SHOW_COMMAND(lltable, db_show_lltable)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!have_addr) {
|
|
|
|
db_printf("usage: show lltable <struct lltable *>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
llatbl_llt_show((struct lltable *)addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
DB_SHOW_ALL_COMMAND(lltables, db_show_all_lltables)
|
|
|
|
{
|
|
|
|
VNET_ITERATOR_DECL(vnet_iter);
|
|
|
|
struct lltable *llt;
|
|
|
|
|
|
|
|
VNET_FOREACH(vnet_iter) {
|
|
|
|
CURVNET_SET_QUIET(vnet_iter);
|
|
|
|
#ifdef VIMAGE
|
|
|
|
db_printf("vnet=%p\n", curvnet);
|
|
|
|
#endif
|
|
|
|
SLIST_FOREACH(llt, &V_lltables, llt_link) {
|
|
|
|
db_printf("llt=%p llt_af=%d llt_ifp=%p(%s)\n",
|
|
|
|
llt, llt->llt_af, llt->llt_ifp,
|
|
|
|
(llt->llt_ifp != NULL) ?
|
|
|
|
llt->llt_ifp->if_xname : "?");
|
|
|
|
if (have_addr && addr != 0) /* verbose */
|
|
|
|
llatbl_llt_show(llt);
|
|
|
|
if (db_pager_quit) {
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CURVNET_RESTORE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|