Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vlan.c
Show First 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | |||||
static const struct if_snd_tag_sw vlan_snd_tag_tls_sw = { | static const struct if_snd_tag_sw vlan_snd_tag_tls_sw = { | ||||
.snd_tag_modify = vlan_snd_tag_modify, | .snd_tag_modify = vlan_snd_tag_modify, | ||||
.snd_tag_query = vlan_snd_tag_query, | .snd_tag_query = vlan_snd_tag_query, | ||||
.snd_tag_free = vlan_snd_tag_free, | .snd_tag_free = vlan_snd_tag_free, | ||||
.next_snd_tag = vlan_next_snd_tag, | .next_snd_tag = vlan_next_snd_tag, | ||||
.type = IF_SND_TAG_TYPE_TLS | .type = IF_SND_TAG_TYPE_TLS | ||||
}; | }; | ||||
static const struct if_snd_tag_sw vlan_snd_tag_tls_rx_sw = { | |||||
.snd_tag_modify = vlan_snd_tag_modify, | |||||
.snd_tag_query = vlan_snd_tag_query, | |||||
.snd_tag_free = vlan_snd_tag_free, | |||||
.next_snd_tag = vlan_next_snd_tag, | |||||
.type = IF_SND_TAG_TYPE_TLS_RX | |||||
}; | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
static const struct if_snd_tag_sw vlan_snd_tag_tls_rl_sw = { | static const struct if_snd_tag_sw vlan_snd_tag_tls_rl_sw = { | ||||
.snd_tag_modify = vlan_snd_tag_modify, | .snd_tag_modify = vlan_snd_tag_modify, | ||||
.snd_tag_query = vlan_snd_tag_query, | .snd_tag_query = vlan_snd_tag_query, | ||||
.snd_tag_free = vlan_snd_tag_free, | .snd_tag_free = vlan_snd_tag_free, | ||||
.next_snd_tag = vlan_next_snd_tag, | .next_snd_tag = vlan_next_snd_tag, | ||||
.type = IF_SND_TAG_TYPE_TLS_RATE_LIMIT | .type = IF_SND_TAG_TYPE_TLS_RATE_LIMIT | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 1,787 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct epoch_tracker et; | struct epoch_tracker et; | ||||
const struct if_snd_tag_sw *sw; | const struct if_snd_tag_sw *sw; | ||||
struct vlan_snd_tag *vst; | struct vlan_snd_tag *vst; | ||||
struct ifvlan *ifv; | struct ifvlan *ifv; | ||||
struct ifnet *parent; | struct ifnet *parent; | ||||
int error; | int error; | ||||
NET_EPOCH_ENTER(et); | |||||
ifv = ifp->if_softc; | |||||
switch (params->hdr.type) { | switch (params->hdr.type) { | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_UNLIMITED: | case IF_SND_TAG_TYPE_UNLIMITED: | ||||
sw = &vlan_snd_tag_ul_sw; | sw = &vlan_snd_tag_ul_sw; | ||||
break; | break; | ||||
case IF_SND_TAG_TYPE_RATE_LIMIT: | case IF_SND_TAG_TYPE_RATE_LIMIT: | ||||
sw = &vlan_snd_tag_rl_sw; | sw = &vlan_snd_tag_rl_sw; | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
case IF_SND_TAG_TYPE_TLS: | case IF_SND_TAG_TYPE_TLS: | ||||
sw = &vlan_snd_tag_tls_sw; | sw = &vlan_snd_tag_tls_sw; | ||||
break; | break; | ||||
case IF_SND_TAG_TYPE_TLS_RX: | |||||
sw = &vlan_snd_tag_tls_rx_sw; | |||||
if (params->tls_rx.vlan_id != 0) | |||||
goto failure; | |||||
params->tls_rx.vlan_id = ifv->ifv_vid; | |||||
break; | |||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | case IF_SND_TAG_TYPE_TLS_RATE_LIMIT: | ||||
sw = &vlan_snd_tag_tls_rl_sw; | sw = &vlan_snd_tag_tls_rl_sw; | ||||
break; | break; | ||||
#endif | #endif | ||||
#endif | #endif | ||||
default: | default: | ||||
return (EOPNOTSUPP); | goto failure; | ||||
} | } | ||||
NET_EPOCH_ENTER(et); | |||||
ifv = ifp->if_softc; | |||||
if (ifv->ifv_trunk != NULL) | if (ifv->ifv_trunk != NULL) | ||||
parent = PARENT(ifv); | parent = PARENT(ifv); | ||||
else | else | ||||
parent = NULL; | parent = NULL; | ||||
if (parent == NULL) { | if (parent == NULL) | ||||
NET_EPOCH_EXIT(et); | goto failure; | ||||
return (EOPNOTSUPP); | |||||
} | |||||
if_ref(parent); | if_ref(parent); | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
vst = malloc(sizeof(*vst), M_VLAN, M_NOWAIT); | vst = malloc(sizeof(*vst), M_VLAN, M_NOWAIT); | ||||
if (vst == NULL) { | if (vst == NULL) { | ||||
if_rele(parent); | if_rele(parent); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
error = m_snd_tag_alloc(parent, params, &vst->tag); | error = m_snd_tag_alloc(parent, params, &vst->tag); | ||||
if_rele(parent); | if_rele(parent); | ||||
if (error) { | if (error) { | ||||
free(vst, M_VLAN); | free(vst, M_VLAN); | ||||
return (error); | return (error); | ||||
} | } | ||||
m_snd_tag_init(&vst->com, ifp, sw); | m_snd_tag_init(&vst->com, ifp, sw); | ||||
*ppmt = &vst->com; | *ppmt = &vst->com; | ||||
return (0); | return (0); | ||||
failure: | |||||
NET_EPOCH_EXIT(et); | |||||
return (EOPNOTSUPP); | |||||
} | } | ||||
static struct m_snd_tag * | static struct m_snd_tag * | ||||
vlan_next_snd_tag(struct m_snd_tag *mst) | vlan_next_snd_tag(struct m_snd_tag *mst) | ||||
{ | { | ||||
struct vlan_snd_tag *vst; | struct vlan_snd_tag *vst; | ||||
vst = mst_to_vst(mst); | vst = mst_to_vst(mst); | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |