summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorJan Klemkow <jan@cvs.openbsd.org>2023-04-21 14:31:42 +0000
committerJan Klemkow <jan@cvs.openbsd.org>2023-04-21 14:31:42 +0000
commit8760e7246e9cb733bd71d46b6c87fbb573d7bf2d (patch)
tree9457b608100db07ae6828f970ed8012ebfce9b13 /sys/net
parent868b12117f4dbcbe6004159b3b889642e5ae2e5c (diff)
vlan(4) inherits TSO flags
tested by Hrvoje Popovski with tweaks from bluhm and claudio encouraged from deraadt ok bluhm
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c7
-rw-r--r--sys/net/if_vlan.c32
-rw-r--r--sys/net/if_vlan_var.h3
3 files changed, 39 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index e25fe1c03ac..b53416655e9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.690 2023/04/18 22:01:24 mvs Exp $ */
+/* $OpenBSD: if.c,v 1.691 2023/04/21 14:31:41 jan Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -92,6 +92,7 @@
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
+#include <net/if_vlan_var.h>
#include <net/route.h>
#include <net/netisr.h>
@@ -3149,6 +3150,10 @@ ifsettso(struct ifnet *ifp, int on)
else
goto out;
+ /* Change TSO flag also on attached vlan(4)/svlan(4) interfaces. */
+ vlan_flags_from_parent(ifp, IFXF_TSO);
+
+ /* restart interface */
if (ISSET(ifp->if_flags, IFF_UP)) {
/* go down for a moment... */
CLR(ifp->if_flags, IFF_UP);
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 07a302b3832..7d3bef9a548 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vlan.c,v 1.211 2023/02/02 13:28:31 claudio Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.212 2023/04/21 14:31:41 jan Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
@@ -941,6 +941,9 @@ vlan_set_parent(struct vlan_softc *sc, const char *parent)
if (!ISSET(sc->sc_flags, IFVF_LLADDR))
if_setlladdr(ifp, LLADDR(ifp0->if_sadl));
+ /* Inherit flags from parent interface. */
+ vlan_flags_from_parent(ifp0, IFXF_TSO);
+
put:
if_put(ifp0);
return (error);
@@ -962,6 +965,33 @@ vlan_del_parent(struct vlan_softc *sc)
return (0);
}
+void
+vlan_flags_from_parent(struct ifnet *ifp0, int flags)
+{
+ struct ifnet *ifp;
+ struct vlan_softc *sc;
+
+ TAILQ_FOREACH(ifp, &ifnetlist, if_list) {
+ if ((sc = ifp->if_softc) == NULL)
+ continue;
+
+ if (sc->sc_type != ETHERTYPE_VLAN &&
+ sc->sc_type != ETHERTYPE_QINQ)
+ continue;
+
+ /* vlan and tso only works with hw tagging */
+ if (!ISSET(ifp0->if_capabilities, IFCAP_VLAN_HWTAGGING))
+ CLR(flags, IFXF_TSO);
+
+ if (sc->sc_ifidx0 == ifp0->if_index) {
+ if (ISSET(ifp0->if_xflags, flags))
+ SET(ifp->if_xflags, flags);
+ else
+ CLR(ifp->if_xflags, flags);
+ }
+ }
+}
+
int
vlan_set_compat(struct ifnet *ifp, struct ifreq *ifr)
{
diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h
index 401701ea055..1e4e57bc7bf 100644
--- a/sys/net/if_vlan_var.h
+++ b/sys/net/if_vlan_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vlan_var.h,v 1.43 2021/08/19 10:22:00 dlg Exp $ */
+/* $OpenBSD: if_vlan_var.h,v 1.44 2023/04/21 14:31:41 jan Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
@@ -49,6 +49,7 @@ struct vlanreq {
#ifdef _KERNEL
struct mbuf *vlan_input(struct ifnet *, struct mbuf *, unsigned int *);
struct mbuf *vlan_inject(struct mbuf *, uint16_t, uint16_t);
+void vlan_flags_from_parent(struct ifnet *, int);
#endif /* _KERNEL */
#endif /* _NET_IF_VLAN_VAR_H_ */