Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_lagg.c
Show All 17 Lines | |||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_kern_tls.h" | |||||
#include "opt_ratelimit.h" | #include "opt_ratelimit.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); | static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); | ||||
#ifdef LAGG_PORT_STACKING | #ifdef LAGG_PORT_STACKING | ||||
static int lagg_port_checkstacking(struct lagg_softc *); | static int lagg_port_checkstacking(struct lagg_softc *); | ||||
#endif | #endif | ||||
static void lagg_port2req(struct lagg_port *, struct lagg_reqport *); | static void lagg_port2req(struct lagg_port *, struct lagg_reqport *); | ||||
static void lagg_init(void *); | static void lagg_init(void *); | ||||
static void lagg_stop(struct lagg_softc *); | static void lagg_stop(struct lagg_softc *); | ||||
static int lagg_ioctl(struct ifnet *, u_long, caddr_t); | static int lagg_ioctl(struct ifnet *, u_long, caddr_t); | ||||
#ifdef RATELIMIT | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
static int lagg_snd_tag_alloc(struct ifnet *, | static int lagg_snd_tag_alloc(struct ifnet *, | ||||
union if_snd_tag_alloc_params *, | union if_snd_tag_alloc_params *, | ||||
struct m_snd_tag **); | struct m_snd_tag **); | ||||
static int lagg_snd_tag_modify(struct m_snd_tag *, | static int lagg_snd_tag_modify(struct m_snd_tag *, | ||||
union if_snd_tag_modify_params *); | union if_snd_tag_modify_params *); | ||||
static int lagg_snd_tag_query(struct m_snd_tag *, | static int lagg_snd_tag_query(struct m_snd_tag *, | ||||
union if_snd_tag_query_params *); | union if_snd_tag_query_params *); | ||||
static void lagg_snd_tag_free(struct m_snd_tag *); | static void lagg_snd_tag_free(struct m_snd_tag *); | ||||
▲ Show 20 Lines • Show All 380 Lines • ▼ Show 20 Lines | lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) | ||||
if_initname(ifp, laggname, unit); | if_initname(ifp, laggname, unit); | ||||
ifp->if_softc = sc; | ifp->if_softc = sc; | ||||
ifp->if_transmit = lagg_transmit; | ifp->if_transmit = lagg_transmit; | ||||
ifp->if_qflush = lagg_qflush; | ifp->if_qflush = lagg_qflush; | ||||
ifp->if_init = lagg_init; | ifp->if_init = lagg_init; | ||||
ifp->if_ioctl = lagg_ioctl; | ifp->if_ioctl = lagg_ioctl; | ||||
ifp->if_get_counter = lagg_get_counter; | ifp->if_get_counter = lagg_get_counter; | ||||
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; | ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; | ||||
#ifdef RATELIMIT | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
ifp->if_snd_tag_alloc = lagg_snd_tag_alloc; | ifp->if_snd_tag_alloc = lagg_snd_tag_alloc; | ||||
ifp->if_snd_tag_modify = lagg_snd_tag_modify; | ifp->if_snd_tag_modify = lagg_snd_tag_modify; | ||||
ifp->if_snd_tag_query = lagg_snd_tag_query; | ifp->if_snd_tag_query = lagg_snd_tag_query; | ||||
ifp->if_snd_tag_free = lagg_snd_tag_free; | ifp->if_snd_tag_free = lagg_snd_tag_free; | ||||
#endif | #endif | ||||
ifp->if_capenable = ifp->if_capabilities = IFCAP_HWSTATS; | ifp->if_capenable = ifp->if_capabilities = IFCAP_HWSTATS; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 998 Lines • ▼ Show 20 Lines | #endif | ||||
default: | default: | ||||
error = ether_ioctl(ifp, cmd, data); | error = ether_ioctl(ifp, cmd, data); | ||||
break; | break; | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef RATELIMIT | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
static inline struct lagg_snd_tag * | static inline struct lagg_snd_tag * | ||||
mst_to_lst(struct m_snd_tag *mst) | mst_to_lst(struct m_snd_tag *mst) | ||||
{ | { | ||||
return (__containerof(mst, struct lagg_snd_tag, com)); | return (__containerof(mst, struct lagg_snd_tag, com)); | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
lagg_transmit(struct ifnet *ifp, struct mbuf *m) | lagg_transmit(struct ifnet *ifp, struct mbuf *m) | ||||
{ | { | ||||
struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc; | struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc; | ||||
int error; | int error; | ||||
#ifdef RATELIMIT | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) | if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) | ||||
MPASS(m->m_pkthdr.snd_tag->ifp == ifp); | MPASS(m->m_pkthdr.snd_tag->ifp == ifp); | ||||
#endif | #endif | ||||
LAGG_RLOCK(); | LAGG_RLOCK(); | ||||
/* We need a Tx algorithm and at least one port */ | /* We need a Tx algorithm and at least one port */ | ||||
if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) { | if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) { | ||||
LAGG_RUNLOCK(); | LAGG_RUNLOCK(); | ||||
m_freem(m); | m_freem(m); | ||||
▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | |||||
found: | found: | ||||
return (rval); | return (rval); | ||||
} | } | ||||
int | int | ||||
lagg_enqueue(struct ifnet *ifp, struct mbuf *m) | lagg_enqueue(struct ifnet *ifp, struct mbuf *m) | ||||
{ | { | ||||
#ifdef RATELIMIT | #if defined(KERN_TLS) || defined(RATELIMIT) | ||||
if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { | if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) { | ||||
struct lagg_snd_tag *lst; | struct lagg_snd_tag *lst; | ||||
struct m_snd_tag *mst; | struct m_snd_tag *mst; | ||||
mst = m->m_pkthdr.snd_tag; | mst = m->m_pkthdr.snd_tag; | ||||
lst = mst_to_lst(mst); | lst = mst_to_lst(mst); | ||||
if (lst->tag->ifp != ifp) { | if (lst->tag->ifp != ifp) { | ||||
m_freem(m); | m_freem(m); | ||||
▲ Show 20 Lines • Show All 372 Lines • Show Last 20 Lines |