aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2022-05-25 10:39:56 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2022-06-07 10:54:42 +0000
commit892eded5b8b0723043577b971ac7be7edeb8df7a (patch)
treeb4962640cf5cdb983c82de1c666b58b9ad9b6b85
parent1967e313795f40c8c5076af66a914132af71b85d (diff)
downloadsrc-892eded5b8b0723043577b971ac7be7edeb8df7a.tar.gz
src-892eded5b8b0723043577b971ac7be7edeb8df7a.zip
vlan(4): Add support for allocating TLS receive tags.
The TLS receive tags are allocated directly from the receiving interface, because mbufs are flowing in the opposite direction and then route change checks are not useful, because they only work for outgoing traffic. Differential revision: https://reviews.freebsd.org/D32356 Sponsored by: NVIDIA Networking
-rw-r--r--sys/net/if_vlan.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index dc7a5fcb0c73..f8af0fd3d915 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -2204,8 +2204,12 @@ vlan_snd_tag_alloc(struct ifnet *ifp,
struct vlan_snd_tag *vst;
struct ifvlan *ifv;
struct ifnet *parent;
+ struct m_snd_tag *mst;
int error;
+ NET_EPOCH_ENTER(et);
+ ifv = ifp->if_softc;
+
switch (params->hdr.type) {
#ifdef RATELIMIT
case IF_SND_TAG_TYPE_UNLIMITED:
@@ -2219,6 +2223,12 @@ vlan_snd_tag_alloc(struct ifnet *ifp,
case IF_SND_TAG_TYPE_TLS:
sw = &vlan_snd_tag_tls_sw;
break;
+ case IF_SND_TAG_TYPE_TLS_RX:
+ sw = NULL;
+ if (params->tls_rx.vlan_id != 0)
+ goto failure;
+ params->tls_rx.vlan_id = ifv->ifv_vid;
+ break;
#ifdef RATELIMIT
case IF_SND_TAG_TYPE_TLS_RATE_LIMIT:
sw = &vlan_snd_tag_tls_rl_sw;
@@ -2226,39 +2236,46 @@ vlan_snd_tag_alloc(struct ifnet *ifp,
#endif
#endif
default:
- return (EOPNOTSUPP);
+ goto failure;
}
- NET_EPOCH_ENTER(et);
- ifv = ifp->if_softc;
if (ifv->ifv_trunk != NULL)
parent = PARENT(ifv);
else
parent = NULL;
- if (parent == NULL) {
- NET_EPOCH_EXIT(et);
- return (EOPNOTSUPP);
- }
+ if (parent == NULL)
+ goto failure;
if_ref(parent);
NET_EPOCH_EXIT(et);
- vst = malloc(sizeof(*vst), M_VLAN, M_NOWAIT);
- if (vst == NULL) {
- if_rele(parent);
- return (ENOMEM);
- }
+ if (sw != NULL) {
+ vst = malloc(sizeof(*vst), M_VLAN, M_NOWAIT);
+ if (vst == NULL) {
+ if_rele(parent);
+ return (ENOMEM);
+ }
+ } else
+ vst = NULL;
- error = m_snd_tag_alloc(parent, params, &vst->tag);
+ error = m_snd_tag_alloc(parent, params, &mst);
if_rele(parent);
if (error) {
free(vst, M_VLAN);
return (error);
}
- m_snd_tag_init(&vst->com, ifp, sw);
+ if (sw != NULL) {
+ m_snd_tag_init(&vst->com, ifp, sw);
+ vst->tag = mst;
+
+ *ppmt = &vst->com;
+ } else
+ *ppmt = mst;
- *ppmt = &vst->com;
return (0);
+failure:
+ NET_EPOCH_EXIT(et);
+ return (EOPNOTSUPP);
}
static struct m_snd_tag *