From 779e0d38dc9dbdfb6adab8e543c360bcf2d2756f Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 21 Apr 2023 14:31:41 +0000 Subject: [PATCH] vlan(4) inherits TSO flags tested by Hrvoje Popovski with tweaks from bluhm and claudio encouraged from deraadt ok bluhm --- sys/net/if.c | 7 ++++++- sys/net/if_vlan.c | 32 +++++++++++++++++++++++++++++++- sys/net/if_vlan_var.h | 3 ++- 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 #include #include +#include #include #include @@ -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_ */ -- 2.20.1