summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2015-02-19 22:37:01 +0000
committerglebius <glebius@FreeBSD.org>2015-02-19 22:37:01 +0000
commit4ec4d85cb2fe1baffb382462d48924915ab19366 (patch)
tree492cbfc9472b4648e73c023a3b6125f35eaa9b1e
parent6b09d3f1e121bb6b5e29f211220883fe60f99178 (diff)
downloadFreeBSD-src-4ec4d85cb2fe1baffb382462d48924915ab19366.zip
FreeBSD-src-4ec4d85cb2fe1baffb382462d48924915ab19366.tar.gz
- Rename 'struct mld_ifinfo' into 'struct mld_ifsoftc', since it really
represents a context. - Preserve name 'struct mld_ifinfo' for a new structure, that will be stable API between userland and kernel. - Make sysctl_mld_ifinfo() return the new 'struct mld_ifinfo', instead of old one, which had a bunch of internal kernel structures in it. Sponsored by: Netflix Sponsored by: Nginx, Inc.
-rw-r--r--sys/netinet6/in6_var.h6
-rw-r--r--sys/netinet6/mld6.c99
-rw-r--r--sys/netinet6/mld6_var.h65
3 files changed, 96 insertions, 74 deletions
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 51aa466..7da67bb 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -97,7 +97,7 @@ struct in6_addrlifetime {
struct nd_ifinfo;
struct scope6_id;
struct lltable;
-struct mld_ifinfo;
+struct mld_ifsoftc;
struct in6_ifextra {
counter_u64_t *in6_ifstat;
@@ -105,7 +105,7 @@ struct in6_ifextra {
struct nd_ifinfo *nd_ifinfo;
struct scope6_id *scope6_id;
struct lltable *lltable;
- struct mld_ifinfo *mld_ifinfo;
+ struct mld_ifsoftc *mld_ifinfo;
};
#define LLTABLE6(ifp) (((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->lltable)
@@ -646,7 +646,7 @@ struct in6_multi {
u_int in6m_timer; /* MLD6 listener report timer */
/* New fields for MLDv2 follow. */
- struct mld_ifinfo *in6m_mli; /* MLD info */
+ struct mld_ifsoftc *in6m_mli; /* MLD info */
SLIST_ENTRY(in6_multi) in6m_nrele; /* to-be-released by MLD */
struct ip6_msource_tree in6m_srcs; /* tree of sources */
u_long in6m_nsrc; /* # of tree entries */
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 79e68c9..615fb19 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -102,33 +102,33 @@ __FBSDID("$FreeBSD$");
#define KTR_MLD KTR_INET6
#endif
-static struct mld_ifinfo *
+static struct mld_ifsoftc *
mli_alloc_locked(struct ifnet *);
static void mli_delete_locked(const struct ifnet *);
static void mld_dispatch_packet(struct mbuf *);
static void mld_dispatch_queue(struct mbufq *, int);
-static void mld_final_leave(struct in6_multi *, struct mld_ifinfo *);
+static void mld_final_leave(struct in6_multi *, struct mld_ifsoftc *);
static void mld_fasttimo_vnet(void);
static int mld_handle_state_change(struct in6_multi *,
- struct mld_ifinfo *);
-static int mld_initial_join(struct in6_multi *, struct mld_ifinfo *,
+ struct mld_ifsoftc *);
+static int mld_initial_join(struct in6_multi *, struct mld_ifsoftc *,
const int);
#ifdef KTR
static char * mld_rec_type_to_str(const int);
#endif
-static void mld_set_version(struct mld_ifinfo *, const int);
+static void mld_set_version(struct mld_ifsoftc *, const int);
static void mld_slowtimo_vnet(void);
static int mld_v1_input_query(struct ifnet *, const struct ip6_hdr *,
/*const*/ struct mld_hdr *);
static int mld_v1_input_report(struct ifnet *, const struct ip6_hdr *,
/*const*/ struct mld_hdr *);
-static void mld_v1_process_group_timer(struct mld_ifinfo *,
+static void mld_v1_process_group_timer(struct mld_ifsoftc *,
struct in6_multi *);
-static void mld_v1_process_querier_timers(struct mld_ifinfo *);
+static void mld_v1_process_querier_timers(struct mld_ifsoftc *);
static int mld_v1_transmit_report(struct in6_multi *, const int);
static void mld_v1_update_group(struct in6_multi *, const int);
-static void mld_v2_cancel_link_timers(struct mld_ifinfo *);
-static void mld_v2_dispatch_general_query(struct mld_ifinfo *);
+static void mld_v2_cancel_link_timers(struct mld_ifsoftc *);
+static void mld_v2_dispatch_general_query(struct mld_ifsoftc *);
static struct mbuf *
mld_v2_encap_report(struct ifnet *, struct mbuf *);
static int mld_v2_enqueue_filter_change(struct mbufq *,
@@ -140,11 +140,11 @@ static int mld_v2_input_query(struct ifnet *, const struct ip6_hdr *,
struct mbuf *, const int, const int);
static int mld_v2_merge_state_changes(struct in6_multi *,
struct mbufq *);
-static void mld_v2_process_group_timers(struct mld_ifinfo *,
+static void mld_v2_process_group_timers(struct mld_ifsoftc *,
struct mbufq *, struct mbufq *,
struct in6_multi *, const int);
static int mld_v2_process_group_query(struct in6_multi *,
- struct mld_ifinfo *mli, int, struct mbuf *, const int);
+ struct mld_ifsoftc *mli, int, struct mbuf *, const int);
static int sysctl_mld_gsr(SYSCTL_HANDLER_ARGS);
static int sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS);
@@ -206,7 +206,7 @@ static MALLOC_DEFINE(M_MLD, "mld", "mld state");
* VIMAGE-wide globals.
*/
static VNET_DEFINE(struct timeval, mld_gsrdelay) = {10, 0};
-static VNET_DEFINE(LIST_HEAD(, mld_ifinfo), mli_head);
+static VNET_DEFINE(LIST_HEAD(, mld_ifsoftc), mli_head);
static VNET_DEFINE(int, interface_timers_running6);
static VNET_DEFINE(int, state_change_timers_running6);
static VNET_DEFINE(int, current_state_timers_running6);
@@ -344,7 +344,7 @@ out_locked:
}
/*
- * Expose struct mld_ifinfo to userland, keyed by ifindex.
+ * Expose struct mld_ifsoftc to userland, keyed by ifindex.
* For use by ifmcstat(8).
*
* SMPng: NOTE: Does an unlocked ifindex space read.
@@ -358,7 +358,7 @@ sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS)
int error;
u_int namelen;
struct ifnet *ifp;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
name = (int *)arg1;
namelen = arg2;
@@ -389,8 +389,17 @@ sysctl_mld_ifinfo(SYSCTL_HANDLER_ARGS)
LIST_FOREACH(mli, &V_mli_head, mli_link) {
if (ifp == mli->mli_ifp) {
- error = SYSCTL_OUT(req, mli,
- sizeof(struct mld_ifinfo));
+ struct mld_ifinfo info;
+
+ info.mli_version = mli->mli_version;
+ info.mli_v1_timer = mli->mli_v1_timer;
+ info.mli_v2_timer = mli->mli_v2_timer;
+ info.mli_flags = mli->mli_flags;
+ info.mli_rv = mli->mli_rv;
+ info.mli_qi = mli->mli_qi;
+ info.mli_qri = mli->mli_qri;
+ info.mli_uri = mli->mli_uri;
+ error = SYSCTL_OUT(req, &info, sizeof(info));
break;
}
}
@@ -454,10 +463,10 @@ mld_is_addr_reported(const struct in6_addr *addr)
*
* SMPng: Normally called with IF_AFDATA_LOCK held.
*/
-struct mld_ifinfo *
+struct mld_ifsoftc *
mld_domifattach(struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
CTR3(KTR_MLD, "%s: called for ifp %p(%s)",
__func__, ifp, if_name(ifp));
@@ -478,14 +487,14 @@ mld_domifattach(struct ifnet *ifp)
/*
* VIMAGE: assume curvnet set by caller.
*/
-static struct mld_ifinfo *
+static struct mld_ifsoftc *
mli_alloc_locked(/*const*/ struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
MLD_LOCK_ASSERT();
- mli = malloc(sizeof(struct mld_ifinfo), M_MLD, M_NOWAIT|M_ZERO);
+ mli = malloc(sizeof(struct mld_ifsoftc), M_MLD, M_NOWAIT|M_ZERO);
if (mli == NULL)
goto out;
@@ -501,7 +510,7 @@ mli_alloc_locked(/*const*/ struct ifnet *ifp)
LIST_INSERT_HEAD(&V_mli_head, mli, mli_link);
- CTR2(KTR_MLD, "allocate mld_ifinfo for ifp %p(%s)",
+ CTR2(KTR_MLD, "allocate mld_ifsoftc for ifp %p(%s)",
ifp, if_name(ifp));
out:
@@ -522,7 +531,7 @@ out:
void
mld_ifdetach(struct ifnet *ifp)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifmultiaddr *ifma;
struct in6_multi *inm, *tinm;
@@ -578,9 +587,9 @@ mld_domifdetach(struct ifnet *ifp)
static void
mli_delete_locked(const struct ifnet *ifp)
{
- struct mld_ifinfo *mli, *tmli;
+ struct mld_ifsoftc *mli, *tmli;
- CTR3(KTR_MLD, "%s: freeing mld_ifinfo for ifp %p(%s)",
+ CTR3(KTR_MLD, "%s: freeing mld_ifsoftc for ifp %p(%s)",
__func__, ifp, if_name(ifp));
MLD_LOCK_ASSERT();
@@ -603,7 +612,7 @@ mli_delete_locked(const struct ifnet *ifp)
}
}
#ifdef INVARIANTS
- panic("%s: mld_ifinfo not found for ifp %p\n", __func__, ifp);
+ panic("%s: mld_ifsoftc not found for ifp %p\n", __func__, ifp);
#endif
}
@@ -619,7 +628,7 @@ mld_v1_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
/*const*/ struct mld_hdr *mld)
{
struct ifmultiaddr *ifma;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct in6_multi *inm;
int is_general_query;
uint16_t timer;
@@ -678,7 +687,7 @@ mld_v1_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
* Switch to MLDv1 host compatibility mode.
*/
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
mld_set_version(mli, MLD_VERSION_1);
timer = (ntohs(mld->mld_maxdelay) * PR_FASTHZ) / MLD_TIMER_SCALE;
@@ -795,7 +804,7 @@ static int
mld_v2_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
struct mbuf *m, const int off, const int icmp6len)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct mldv2_query *mld;
struct in6_multi *inm;
uint32_t maxdelay, nsrc, qqi;
@@ -877,7 +886,7 @@ mld_v2_input_query(struct ifnet *ifp, const struct ip6_hdr *ip6,
MLD_LOCK();
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
/*
* Discard the v2 query if we're in Compatibility Mode.
@@ -967,7 +976,7 @@ out_locked:
* Return <0 if any error occured. Currently this is ignored.
*/
static int
-mld_v2_process_group_query(struct in6_multi *inm, struct mld_ifinfo *mli,
+mld_v2_process_group_query(struct in6_multi *inm, struct mld_ifsoftc *mli,
int timer, struct mbuf *m0, const int off)
{
struct mldv2_query *mld;
@@ -1171,7 +1180,7 @@ mld_v1_input_report(struct ifnet *ifp, const struct ip6_hdr *ip6,
*/
inm = in6m_lookup_locked(ifp, &mld->mld_addr);
if (inm != NULL) {
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
mli = inm->in6m_mli;
KASSERT(mli != NULL,
@@ -1321,7 +1330,7 @@ mld_fasttimo_vnet(void)
struct mbufq scq; /* State-change packets */
struct mbufq qrq; /* Query response packets */
struct ifnet *ifp;
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifmultiaddr *ifma;
struct in6_multi *inm, *tinm;
int uri_fasthz;
@@ -1446,7 +1455,7 @@ out_locked:
* Will update the global pending timer flags.
*/
static void
-mld_v1_process_group_timer(struct mld_ifinfo *mli, struct in6_multi *inm)
+mld_v1_process_group_timer(struct mld_ifsoftc *mli, struct in6_multi *inm)
{
int report_timer_expired;
@@ -1490,7 +1499,7 @@ mld_v1_process_group_timer(struct mld_ifinfo *mli, struct in6_multi *inm)
* Note: Unlocked read from mli.
*/
static void
-mld_v2_process_group_timers(struct mld_ifinfo *mli,
+mld_v2_process_group_timers(struct mld_ifsoftc *mli,
struct mbufq *qrq, struct mbufq *scq,
struct in6_multi *inm, const int uri_fasthz)
{
@@ -1611,7 +1620,7 @@ mld_v2_process_group_timers(struct mld_ifinfo *mli,
* as per Section 9.12.
*/
static void
-mld_set_version(struct mld_ifinfo *mli, const int version)
+mld_set_version(struct mld_ifsoftc *mli, const int version)
{
int old_version_timer;
@@ -1641,7 +1650,7 @@ mld_set_version(struct mld_ifinfo *mli, const int version)
* joined on it; state-change, general-query, and group-query timers.
*/
static void
-mld_v2_cancel_link_timers(struct mld_ifinfo *mli)
+mld_v2_cancel_link_timers(struct mld_ifsoftc *mli)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
@@ -1734,7 +1743,7 @@ mld_slowtimo(void)
static void
mld_slowtimo_vnet(void)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
MLD_LOCK();
@@ -1750,7 +1759,7 @@ mld_slowtimo_vnet(void)
* See Section 9.12 of RFC 3810.
*/
static void
-mld_v1_process_querier_timers(struct mld_ifinfo *mli)
+mld_v1_process_querier_timers(struct mld_ifsoftc *mli)
{
MLD_LOCK_ASSERT();
@@ -1866,7 +1875,7 @@ mld_v1_transmit_report(struct in6_multi *in6m, const int type)
int
mld_change_state(struct in6_multi *inm, const int delay)
{
- struct mld_ifinfo *mli;
+ struct mld_ifsoftc *mli;
struct ifnet *ifp;
int error;
@@ -1891,7 +1900,7 @@ mld_change_state(struct in6_multi *inm, const int delay)
MLD_LOCK();
mli = MLD_IFINFO(ifp);
- KASSERT(mli != NULL, ("%s: no mld_ifinfo for ifp %p", __func__, ifp));
+ KASSERT(mli != NULL, ("%s: no mld_ifsoftc for ifp %p", __func__, ifp));
/*
* If we detect a state transition to or from MCAST_UNDEFINED
@@ -1934,7 +1943,7 @@ out_locked:
* initial state change for delay ticks (in units of PR_FASTHZ).
*/
static int
-mld_initial_join(struct in6_multi *inm, struct mld_ifinfo *mli,
+mld_initial_join(struct in6_multi *inm, struct mld_ifsoftc *mli,
const int delay)
{
struct ifnet *ifp;
@@ -2083,7 +2092,7 @@ mld_initial_join(struct in6_multi *inm, struct mld_ifinfo *mli,
* Issue an intermediate state change during the life-cycle.
*/
static int
-mld_handle_state_change(struct in6_multi *inm, struct mld_ifinfo *mli)
+mld_handle_state_change(struct in6_multi *inm, struct mld_ifsoftc *mli)
{
struct ifnet *ifp;
int retval;
@@ -2147,7 +2156,7 @@ mld_handle_state_change(struct in6_multi *inm, struct mld_ifinfo *mli)
* to INCLUDE {} for immediate transmission.
*/
static void
-mld_final_leave(struct in6_multi *inm, struct mld_ifinfo *mli)
+mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
{
int syncstates;
#ifdef KTR
@@ -2963,7 +2972,7 @@ mld_v2_merge_state_changes(struct in6_multi *inm, struct mbufq *scq)
* Respond to a pending MLDv2 General Query.
*/
static void
-mld_v2_dispatch_general_query(struct mld_ifinfo *mli)
+mld_v2_dispatch_general_query(struct mld_ifsoftc *mli)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
diff --git a/sys/netinet6/mld6_var.h b/sys/netinet6/mld6_var.h
index a4e001c..be7e903 100644
--- a/sys/netinet6/mld6_var.h
+++ b/sys/netinet6/mld6_var.h
@@ -35,31 +35,6 @@
* implementation-specific definitions.
*/
-#ifdef _KERNEL
-
-/*
- * Per-link MLD state.
- */
-struct mld_ifinfo {
- LIST_ENTRY(mld_ifinfo) mli_link;
- struct ifnet *mli_ifp; /* interface this instance belongs to */
- uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
- uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
- uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
- uint32_t mli_flags; /* MLD per-interface flags */
- uint32_t mli_rv; /* MLDv2 Robustness Variable */
- uint32_t mli_qi; /* MLDv2 Query Interval (s) */
- uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
- uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
- SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */
- struct mbufq mli_gq; /* queue of general query responses */
-};
-#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */
-#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */
-
-#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
-#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */
-
/*
* MLD per-group states.
*/
@@ -129,6 +104,44 @@ struct mld_ifinfo {
sizeof(struct icmp6_hdr))
/*
+ * Structure returned by net.inet6.mld.ifinfo.
+ */
+struct mld_ifinfo {
+ uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
+ uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
+ uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
+ uint32_t mli_flags; /* MLD per-interface flags */
+#define MLIF_SILENT 0x00000001 /* Do not use MLD on this ifp */
+#define MLIF_USEALLOW 0x00000002 /* Use ALLOW/BLOCK for joins/leaves */
+ uint32_t mli_rv; /* MLDv2 Robustness Variable */
+ uint32_t mli_qi; /* MLDv2 Query Interval (s) */
+ uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
+ uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
+};
+
+#ifdef _KERNEL
+/*
+ * Per-link MLD state.
+ */
+struct mld_ifsoftc {
+ LIST_ENTRY(mld_ifsoftc) mli_link;
+ struct ifnet *mli_ifp; /* interface this instance belongs to */
+ uint32_t mli_version; /* MLDv1 Host Compatibility Mode */
+ uint32_t mli_v1_timer; /* MLDv1 Querier Present timer (s) */
+ uint32_t mli_v2_timer; /* MLDv2 General Query (interface) timer (s)*/
+ uint32_t mli_flags; /* MLD per-interface flags */
+ uint32_t mli_rv; /* MLDv2 Robustness Variable */
+ uint32_t mli_qi; /* MLDv2 Query Interval (s) */
+ uint32_t mli_qri; /* MLDv2 Query Response Interval (s) */
+ uint32_t mli_uri; /* MLDv2 Unsolicited Report Interval (s) */
+ SLIST_HEAD(,in6_multi) mli_relinmhead; /* released groups */
+ struct mbufq mli_gq; /* queue of general query responses */
+};
+
+#define MLD_RANDOM_DELAY(X) (arc4random() % (X) + 1)
+#define MLD_MAX_STATE_CHANGES 24 /* Max pending changes per group */
+
+/*
* Subsystem lock macros.
* The MLD lock is only taken with MLD. Currently it is system-wide.
* VIMAGE: The lock could be pushed to per-VIMAGE granularity in future.
@@ -147,7 +160,7 @@ struct mld_ifinfo {
(((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->mld_ifinfo)
int mld_change_state(struct in6_multi *, const int);
-struct mld_ifinfo *
+struct mld_ifsoftc *
mld_domifattach(struct ifnet *);
void mld_domifdetach(struct ifnet *);
void mld_fasttimo(void);
OpenPOWER on IntegriCloud