Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vlan.c
Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | |||||
static void vlan_snd_tag_free(struct m_snd_tag *); | static void vlan_snd_tag_free(struct m_snd_tag *); | ||||
#endif | #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 int vlan_output(struct ifnet *ifp, struct mbuf *m, | |||||
const struct sockaddr *dst, struct route *ro); | |||||
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); | ||||
static int vlan_config(struct ifvlan *ifv, struct ifnet *p, uint16_t tag); | static int vlan_config(struct ifvlan *ifv, struct ifnet *p, uint16_t tag); | ||||
static void vlan_link_state(struct ifnet *ifp); | static void vlan_link_state(struct ifnet *ifp); | ||||
static void vlan_capabilities(struct ifvlan *ifv); | static void vlan_capabilities(struct ifvlan *ifv); | ||||
static void vlan_trunk_capabilities(struct ifnet *ifp); | static void vlan_trunk_capabilities(struct ifnet *ifp); | ||||
static struct ifnet *vlan_clone_match_ethervid(const char *, int *); | static struct ifnet *vlan_clone_match_ethervid(const char *, int *); | ||||
▲ Show 20 Lines • Show All 899 Lines • ▼ Show 20 Lines | if (error == 0) { | ||||
if_inc_counter(ifp, IFCOUNTER_OBYTES, len); | if_inc_counter(ifp, IFCOUNTER_OBYTES, len); | ||||
if_inc_counter(ifp, IFCOUNTER_OMCASTS, mcast); | if_inc_counter(ifp, IFCOUNTER_OMCASTS, mcast); | ||||
} else | } else | ||||
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | |||||
vlan_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, | |||||
struct route *ro) | |||||
{ | |||||
struct epoch_tracker et; | |||||
struct ifvlan *ifv; | |||||
struct ifnet *p; | |||||
NET_EPOCH_ENTER(et); | |||||
ifv = ifp->if_softc; | |||||
if (TRUNK(ifv) == NULL) { | |||||
NET_EPOCH_EXIT(et); | |||||
m_freem(m); | |||||
return (ENETDOWN); | |||||
} | |||||
p = PARENT(ifv); | |||||
NET_EPOCH_EXIT(et); | |||||
return p->if_output(ifp, m, dst, ro); | |||||
} | |||||
/* | /* | ||||
* The ifp->if_qflush entry point for vlan(4) is a no-op. | * The ifp->if_qflush entry point for vlan(4) is a no-op. | ||||
*/ | */ | ||||
static void | static void | ||||
vlan_qflush(struct ifnet *ifp __unused) | vlan_qflush(struct ifnet *ifp __unused) | ||||
{ | { | ||||
} | } | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | vlan_config(struct ifvlan *ifv, struct ifnet *p, uint16_t vid) | ||||
ifp = ifv->ifv_ifp; | ifp = ifv->ifv_ifp; | ||||
/* | /* | ||||
* Initialize fields from our parent. This duplicates some | * Initialize fields from our parent. This duplicates some | ||||
* work with ether_ifattach() but allows for non-ethernet | * work with ether_ifattach() but allows for non-ethernet | ||||
* interfaces to also work. | * interfaces to also work. | ||||
*/ | */ | ||||
ifp->if_mtu = p->if_mtu - ifv->ifv_mtufudge; | ifp->if_mtu = p->if_mtu - ifv->ifv_mtufudge; | ||||
ifp->if_baudrate = p->if_baudrate; | ifp->if_baudrate = p->if_baudrate; | ||||
ifp->if_output = p->if_output; | |||||
ifp->if_input = p->if_input; | ifp->if_input = p->if_input; | ||||
ifp->if_resolvemulti = p->if_resolvemulti; | ifp->if_resolvemulti = p->if_resolvemulti; | ||||
ifp->if_addrlen = p->if_addrlen; | ifp->if_addrlen = p->if_addrlen; | ||||
ifp->if_broadcastaddr = p->if_broadcastaddr; | ifp->if_broadcastaddr = p->if_broadcastaddr; | ||||
ifp->if_pcp = ifv->ifv_pcp; | ifp->if_pcp = ifv->ifv_pcp; | ||||
/* | |||||
* We wrap the parent's if_output using vlan_output to ensure that it | |||||
* can't become stale. | |||||
*/ | |||||
ifp->if_output = vlan_output; | |||||
/* | /* | ||||
* Copy only a selected subset of flags from the parent. | * Copy only a selected subset of flags from the parent. | ||||
* Other flags are none of our business. | * Other flags are none of our business. | ||||
*/ | */ | ||||
#define VLAN_COPY_FLAGS (IFF_SIMPLEX) | #define VLAN_COPY_FLAGS (IFF_SIMPLEX) | ||||
ifp->if_flags &= ~VLAN_COPY_FLAGS; | ifp->if_flags &= ~VLAN_COPY_FLAGS; | ||||
ifp->if_flags |= p->if_flags & VLAN_COPY_FLAGS; | ifp->if_flags |= p->if_flags & VLAN_COPY_FLAGS; | ||||
▲ Show 20 Lines • Show All 609 Lines • Show Last 20 Lines |