Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vlan.c
Show All 40 Lines | |||||
* use by the real outgoing interface, and ask it to send them. | * use by the real outgoing interface, and ask it to send them. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_vlan.h" | #include "opt_vlan.h" | ||||
#include "opt_ratelimit.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | |||||
static __inline struct ifvlan * vlan_gethash(struct ifvlantrunk *trunk, | static __inline struct ifvlan * vlan_gethash(struct ifvlantrunk *trunk, | ||||
uint16_t vid); | uint16_t vid); | ||||
#endif | #endif | ||||
static void trunk_destroy(struct ifvlantrunk *trunk); | static void trunk_destroy(struct ifvlantrunk *trunk); | ||||
static void vlan_init(void *foo); | static void vlan_init(void *foo); | ||||
static void vlan_input(struct ifnet *ifp, struct mbuf *m); | static void vlan_input(struct ifnet *ifp, struct mbuf *m); | ||||
static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr); | static int vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr); | ||||
#ifdef RATELIMIT | |||||
static int vlan_snd_tag_alloc(struct ifnet *, | |||||
union if_snd_tag_alloc_params *, struct m_snd_tag **); | |||||
#endif | |||||
static void vlan_qflush(struct ifnet *ifp); | static void vlan_qflush(struct ifnet *ifp); | ||||
static int vlan_setflag(struct ifnet *ifp, int flag, int status, | static int vlan_setflag(struct ifnet *ifp, int flag, int status, | ||||
int (*func)(struct ifnet *, int)); | int (*func)(struct ifnet *, int)); | ||||
static int vlan_setflags(struct ifnet *ifp, int status); | static int vlan_setflags(struct ifnet *ifp, int status); | ||||
static int vlan_setmulti(struct ifnet *ifp); | static int vlan_setmulti(struct ifnet *ifp); | ||||
static int vlan_transmit(struct ifnet *ifp, struct mbuf *m); | static int vlan_transmit(struct ifnet *ifp, struct mbuf *m); | ||||
static void vlan_unconfig(struct ifnet *ifp); | static void vlan_unconfig(struct ifnet *ifp); | ||||
static void vlan_unconfig_locked(struct ifnet *ifp, int departing); | static void vlan_unconfig_locked(struct ifnet *ifp, int departing); | ||||
▲ Show 20 Lines • Show All 743 Lines • ▼ Show 20 Lines | vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) | ||||
ifp->if_linkmib = &ifv->ifv_mib; | ifp->if_linkmib = &ifv->ifv_mib; | ||||
ifp->if_linkmiblen = sizeof(ifv->ifv_mib); | ifp->if_linkmiblen = sizeof(ifv->ifv_mib); | ||||
/* NB: mtu is not set here */ | /* NB: mtu is not set here */ | ||||
ifp->if_init = vlan_init; | ifp->if_init = vlan_init; | ||||
ifp->if_transmit = vlan_transmit; | ifp->if_transmit = vlan_transmit; | ||||
ifp->if_qflush = vlan_qflush; | ifp->if_qflush = vlan_qflush; | ||||
ifp->if_ioctl = vlan_ioctl; | ifp->if_ioctl = vlan_ioctl; | ||||
#ifdef RATELIMIT | |||||
ifp->if_snd_tag_alloc = vlan_snd_tag_alloc; | |||||
#endif | |||||
ifp->if_flags = VLAN_IFFLAGS; | ifp->if_flags = VLAN_IFFLAGS; | ||||
ether_ifattach(ifp, eaddr); | ether_ifattach(ifp, eaddr); | ||||
/* Now undo some of the damage... */ | /* Now undo some of the damage... */ | ||||
ifp->if_baudrate = 0; | ifp->if_baudrate = 0; | ||||
ifp->if_type = IFT_L2VLAN; | ifp->if_type = IFT_L2VLAN; | ||||
ifp->if_hdrlen = ETHER_VLAN_ENCAP_LEN; | ifp->if_hdrlen = ETHER_VLAN_ENCAP_LEN; | ||||
ifa = ifp->if_addr; | ifa = ifp->if_addr; | ||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr; | sdl = (struct sockaddr_dl *)ifa->ifa_addr; | ||||
▲ Show 20 Lines • Show All 604 Lines • ▼ Show 20 Lines | vlan_capabilities(struct ifvlan *ifv) | ||||
*/ | */ | ||||
#define IFCAP_VLAN_TOE IFCAP_TOE | #define IFCAP_VLAN_TOE IFCAP_TOE | ||||
if (p->if_capabilities & IFCAP_VLAN_TOE) | if (p->if_capabilities & IFCAP_VLAN_TOE) | ||||
ifp->if_capabilities |= p->if_capabilities & IFCAP_TOE; | ifp->if_capabilities |= p->if_capabilities & IFCAP_TOE; | ||||
if (p->if_capenable & IFCAP_VLAN_TOE) { | if (p->if_capenable & IFCAP_VLAN_TOE) { | ||||
TOEDEV(ifp) = TOEDEV(p); | TOEDEV(ifp) = TOEDEV(p); | ||||
ifp->if_capenable |= p->if_capenable & IFCAP_TOE; | ifp->if_capenable |= p->if_capenable & IFCAP_TOE; | ||||
} | } | ||||
#ifdef RATELIMIT | |||||
/* | |||||
* If the parent interface supports ratelimiting, so does the | |||||
* VLAN interface. | |||||
*/ | |||||
ifp->if_capabilities |= (p->if_capabilities & IFCAP_TXRTLMT); | |||||
ifp->if_capenable |= (p->if_capenable & IFCAP_TXRTLMT); | |||||
#endif | |||||
} | } | ||||
static void | static void | ||||
vlan_trunk_capabilities(struct ifnet *ifp) | vlan_trunk_capabilities(struct ifnet *ifp) | ||||
{ | { | ||||
struct ifvlantrunk *trunk = ifp->if_vlantrunk; | struct ifvlantrunk *trunk = ifp->if_vlantrunk; | ||||
struct ifvlan *ifv; | struct ifvlan *ifv; | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | #endif | ||||
default: | default: | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef RATELIMIT | |||||
static int | |||||
vlan_snd_tag_alloc(struct ifnet *ifp, | |||||
union if_snd_tag_alloc_params *params, | |||||
struct m_snd_tag **ppmt) | |||||
{ | |||||
/* get trunk device */ | |||||
ifp = vlan_trunkdev(ifp); | |||||
if (ifp == NULL || (ifp->if_capenable & IFCAP_TXRTLMT) == 0) | |||||
return (EOPNOTSUPP); | |||||
/* forward allocation request */ | |||||
return (ifp->if_snd_tag_alloc(ifp, params, ppmt)); | |||||
} | |||||
#endif |