From: jan Date: Wed, 26 Apr 2023 00:14:21 +0000 (+0000) Subject: Also set TSO flag on vlan interfaces. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=96e5c5e58d566d6e025bbd313fe94580836c55e5;p=openbsd Also set TSO flag on vlan interfaces. with tweaks from bluhm, claudio and dlg I fine with it from claudio looks good to me from dlg ok bluhm --- diff --git a/sys/net/if.c b/sys/net/if.c index e06e8e8b769..58db412810d 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.692 2023/04/22 04:39:46 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.693 2023/04/26 00:14:21 jan Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -95,6 +95,11 @@ #include #include +#include "vlan.h" +#if NVLAN > 0 +#include +#endif + #include #include #include @@ -3149,6 +3154,12 @@ ifsettso(struct ifnet *ifp, int on) else goto out; +#if NVLAN > 0 + /* Change TSO flag also on attached vlan(4) interfaces. */ + vlan_flags_from_parent(ifp, IFXF_TSO); +#endif + + /* 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 8958233348b..86bb5a757c9 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.213 2023/04/22 04:39:46 dlg Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.214 2023/04/26 00:14:21 jan Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -560,6 +560,9 @@ vlan_up(struct vlan_softc *sc) /* configure the parent to handle packets for this vlan */ vlan_multi_apply(sc, ifp0, SIOCADDMULTI); + /* Inherit flags from parent interface. */ + vlan_flags_from_parent(ifp0, IFXF_TSO); + /* we're running now */ SET(ifp->if_flags, IFF_RUNNING); vlan_link_state(sc, ifp0->if_link_state, ifp0->if_baudrate); @@ -962,6 +965,28 @@ vlan_del_parent(struct vlan_softc *sc) return (0); } +void +vlan_flags_from_parent(struct ifnet *ifp0, int flags) +{ + struct vlan_softc *sc; + int i; + + for (i = 0; i < TAG_HASH_SIZE; i++) { + SMR_SLIST_FOREACH_LOCKED(sc, &vlan_tagh[i], sc_list) { + /* 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(sc->sc_if.if_xflags, flags); + else + CLR(sc->sc_if.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 9e408cd71ef..df51cc186f0 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.45 2023/04/22 04:39:46 dlg Exp $ */ +/* $OpenBSD: if_vlan_var.h,v 1.46 2023/04/26 00:14:21 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_ */