git: 892eded5b8b0 - main - vlan(4): Add support for allocating TLS receive tags.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 07 Jun 2022 10:59:26 UTC
The branch main has been updated by hselasky:
URL: https://cgit.FreeBSD.org/src/commit/?id=892eded5b8b0723043577b971ac7be7edeb8df7a
commit 892eded5b8b0723043577b971ac7be7edeb8df7a
Author: Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-05-25 10:39:56 +0000
Commit: Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-06-07 10:54:42 +0000
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
---
sys/net/if_vlan.c | 47 ++++++++++++++++++++++++++++++++---------------
1 file 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 *