sync
This commit is contained in:
parent
ab90ba3a7c
commit
9e5eddc6af
57 changed files with 838 additions and 537 deletions
35
sys/net/if.c
35
sys/net/if.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if.c,v 1.696 2023/05/14 01:46:53 dlg Exp $ */
|
||||
/* $OpenBSD: if.c,v 1.697 2023/05/16 14:32:54 jan Exp $ */
|
||||
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -2109,10 +2109,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
|
|||
error = ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ISSET(ifr->ifr_flags, IFXF_TSO) !=
|
||||
ISSET(ifp->if_xflags, IFXF_TSO))
|
||||
error = ifsettso(ifp, ISSET(ifr->ifr_flags, IFXF_TSO));
|
||||
if (ISSET(ifr->ifr_flags, IFXF_LRO) !=
|
||||
ISSET(ifp->if_xflags, IFXF_LRO))
|
||||
error = ifsetlro(ifp, ISSET(ifr->ifr_flags, IFXF_LRO));
|
||||
|
||||
if (error == 0)
|
||||
ifp->if_xflags = (ifp->if_xflags & IFXF_CANTCHANGE) |
|
||||
|
@ -3153,37 +3152,33 @@ ifpromisc(struct ifnet *ifp, int pswitch)
|
|||
return (error);
|
||||
}
|
||||
|
||||
/* Set/clear TSO flag and restart interface if needed. */
|
||||
/* Set/clear LRO flag and restart interface if needed. */
|
||||
int
|
||||
ifsettso(struct ifnet *ifp, int on)
|
||||
ifsetlro(struct ifnet *ifp, int on)
|
||||
{
|
||||
struct ifreq ifrq;
|
||||
int error = 0;
|
||||
int s = splnet();
|
||||
|
||||
if (!ISSET(ifp->if_capabilities, IFCAP_LRO)) {
|
||||
error = ENOTSUP;
|
||||
goto out;
|
||||
}
|
||||
|
||||
NET_ASSERT_LOCKED(); /* for ioctl */
|
||||
KERNEL_ASSERT_LOCKED(); /* for if_flags */
|
||||
|
||||
if (on && !ISSET(ifp->if_xflags, IFXF_TSO)) {
|
||||
if (!ISSET(ifp->if_capabilities, IFCAP_TSO)) {
|
||||
error = ENOTSUP;
|
||||
goto out;
|
||||
}
|
||||
if (on && !ISSET(ifp->if_xflags, IFXF_LRO)) {
|
||||
if (ether_brport_isset(ifp)) {
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
SET(ifp->if_xflags, IFXF_TSO);
|
||||
} else if (!on && ISSET(ifp->if_xflags, IFXF_TSO))
|
||||
CLR(ifp->if_xflags, IFXF_TSO);
|
||||
SET(ifp->if_xflags, IFXF_LRO);
|
||||
} else if (!on && ISSET(ifp->if_xflags, IFXF_LRO))
|
||||
CLR(ifp->if_xflags, IFXF_LRO);
|
||||
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... */
|
||||
|
|
10
sys/net/if.h
10
sys/net/if.h
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if.h,v 1.211 2023/03/07 20:09:48 jan Exp $ */
|
||||
/* $OpenBSD: if.h,v 1.213 2023/05/16 14:32:54 jan Exp $ */
|
||||
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -231,7 +231,7 @@ struct if_status_description {
|
|||
#define IFXF_INET6_NOSOII 0x40 /* [N] don't do RFC 7217 */
|
||||
#define IFXF_AUTOCONF4 0x80 /* [N] v4 autoconf (aka dhcp) enabled */
|
||||
#define IFXF_MONITOR 0x100 /* [N] only used for bpf */
|
||||
#define IFXF_TSO 0x200 /* [N] TCP segment offloading */
|
||||
#define IFXF_LRO 0x200 /* [N] TCP large recv offload */
|
||||
|
||||
#define IFXF_CANTCHANGE \
|
||||
(IFXF_MPSAFE|IFXF_CLONED)
|
||||
|
@ -251,7 +251,9 @@ struct if_status_description {
|
|||
#define IFCAP_VLAN_HWTAGGING 0x00000020 /* hardware VLAN tag support */
|
||||
#define IFCAP_CSUM_TCPv6 0x00000080 /* can do IPv6/TCP checksums */
|
||||
#define IFCAP_CSUM_UDPv6 0x00000100 /* can do IPv6/UDP checksums */
|
||||
#define IFCAP_TSO 0x00004000 /* TCP segment offloading */
|
||||
#define IFCAP_TSOv4 0x00001000 /* IPv4/TCP segment offload */
|
||||
#define IFCAP_TSOv6 0x00002000 /* IPv6/TCP segment offload */
|
||||
#define IFCAP_LRO 0x00004000 /* TCP large recv offload */
|
||||
#define IFCAP_WOL 0x00008000 /* can do wake on lan */
|
||||
|
||||
#define IFCAP_CSUM_MASK (IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | \
|
||||
|
@ -544,7 +546,7 @@ void if_getdata(struct ifnet *, struct if_data *);
|
|||
void ifinit(void);
|
||||
int ifioctl(struct socket *, u_long, caddr_t, struct proc *);
|
||||
int ifpromisc(struct ifnet *, int);
|
||||
int ifsettso(struct ifnet *, int);
|
||||
int ifsetlro(struct ifnet *, int);
|
||||
struct ifg_group *if_creategroup(const char *);
|
||||
int if_addgroup(struct ifnet *, const char *);
|
||||
int if_delgroup(struct ifnet *, const char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_aggr.c,v 1.39 2022/02/05 03:56:16 dlg Exp $ */
|
||||
/* $OpenBSD: if_aggr.c,v 1.40 2023/05/16 14:32:54 jan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 The University of Queensland
|
||||
|
@ -2618,6 +2618,9 @@ aggr_update_capabilities(struct aggr_softc *sc)
|
|||
uint32_t capabilities = ~0;
|
||||
int set = 0;
|
||||
|
||||
/* Do not inherit LRO capabilities. */
|
||||
CLR(capabilities, IFCAP_LRO);
|
||||
|
||||
rw_enter_read(&sc->sc_lock);
|
||||
TAILQ_FOREACH(p, &sc->sc_ports, p_entry) {
|
||||
struct ifnet *ifp0 = p->p_ifp0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_bridge.c,v 1.367 2023/05/13 13:35:17 bluhm Exp $ */
|
||||
/* $OpenBSD: if_bridge.c,v 1.368 2023/05/16 14:32:54 jan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
|
||||
|
@ -338,7 +338,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||
*/
|
||||
|
||||
NET_LOCK();
|
||||
ifsettso(ifs, 0);
|
||||
ifsetlro(ifs, 0);
|
||||
NET_UNLOCK();
|
||||
|
||||
bif->bridge_sc = sc;
|
||||
|
@ -401,7 +401,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||
}
|
||||
|
||||
NET_LOCK();
|
||||
ifsettso(ifs, 0);
|
||||
ifsetlro(ifs, 0);
|
||||
NET_UNLOCK();
|
||||
|
||||
bif->bridge_sc = sc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_tpmr.c,v 1.32 2023/02/27 09:35:32 jan Exp $ */
|
||||
/* $OpenBSD: if_tpmr.c,v 1.33 2023/05/16 14:32:54 jan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2019 The University of Queensland
|
||||
|
@ -521,7 +521,7 @@ tpmr_add_port(struct tpmr_softc *sc, const struct ifbreq *req)
|
|||
goto put;
|
||||
}
|
||||
|
||||
ifsettso(ifp0, 0);
|
||||
ifsetlro(ifp0, 0);
|
||||
|
||||
p->p_ifp0 = ifp0;
|
||||
p->p_tpmr = sc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_veb.c,v 1.30 2023/02/27 09:35:32 jan Exp $ */
|
||||
/* $OpenBSD: if_veb.c,v 1.31 2023/05/16 14:32:54 jan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021 David Gwynne <dlg@openbsd.org>
|
||||
|
@ -1465,7 +1465,7 @@ veb_add_port(struct veb_softc *sc, const struct ifbreq *req, unsigned int span)
|
|||
goto put;
|
||||
}
|
||||
|
||||
ifsettso(ifp0, 0);
|
||||
ifsetlro(ifp0, 0);
|
||||
|
||||
p->p_ifp0 = ifp0;
|
||||
p->p_veb = sc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_vlan.c,v 1.214 2023/04/26 00:14:21 jan Exp $ */
|
||||
/* $OpenBSD: if_vlan.c,v 1.215 2023/05/16 14:32:54 jan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1998 Massachusetts Institute of Technology
|
||||
|
@ -536,7 +536,8 @@ vlan_up(struct vlan_softc *sc)
|
|||
* Chips that can do hardware-assisted VLAN encapsulation, can
|
||||
* calculate the correct checksum for VLAN tagged packets.
|
||||
*/
|
||||
ifp->if_capabilities = ifp0->if_capabilities & IFCAP_CSUM_MASK;
|
||||
ifp->if_capabilities = ifp0->if_capabilities &
|
||||
(IFCAP_CSUM_MASK | IFCAP_TSOv4 | IFCAP_TSOv6);
|
||||
}
|
||||
|
||||
/* commit the sc */
|
||||
|
@ -560,9 +561,6 @@ 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);
|
||||
|
@ -965,28 +963,6 @@ 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)
|
||||
{
|
||||
|
|
23
sys/net/pf.c
23
sys/net/pf.c
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pf.c,v 1.1179 2023/05/13 13:35:17 bluhm Exp $ */
|
||||
/* $OpenBSD: pf.c,v 1.1180 2023/05/15 16:34:56 bluhm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Hartmeier
|
||||
|
@ -6555,15 +6555,9 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st)
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) &&
|
||||
m0->m_pkthdr.ph_mss <= ifp->if_mtu) {
|
||||
if (tcp_chopper(m0, &ml, ifp, m0->m_pkthdr.ph_mss) ||
|
||||
if_output_ml(ifp, &ml, sintosa(dst), rt))
|
||||
goto done;
|
||||
tcpstat_inc(tcps_outswtso);
|
||||
if (tcp_if_output_tso(ifp, &m0, sintosa(dst), rt,
|
||||
IFCAP_TSOv4, ifp->if_mtu) || m0 == NULL)
|
||||
goto done;
|
||||
}
|
||||
CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO);
|
||||
|
||||
/*
|
||||
* Too large for interface; fragment if possible.
|
||||
|
@ -6598,7 +6592,6 @@ void
|
|||
pf_route6(struct pf_pdesc *pd, struct pf_state *st)
|
||||
{
|
||||
struct mbuf *m0;
|
||||
struct mbuf_list ml;
|
||||
struct sockaddr_in6 *dst, sin6;
|
||||
struct rtentry *rt = NULL;
|
||||
struct ip6_hdr *ip6;
|
||||
|
@ -6696,15 +6689,9 @@ pf_route6(struct pf_pdesc *pd, struct pf_state *st)
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) &&
|
||||
m0->m_pkthdr.ph_mss <= ifp->if_mtu) {
|
||||
if (tcp_chopper(m0, &ml, ifp, m0->m_pkthdr.ph_mss) ||
|
||||
if_output_ml(ifp, &ml, sin6tosa(dst), rt))
|
||||
goto done;
|
||||
tcpstat_inc(tcps_outswtso);
|
||||
if (tcp_if_output_tso(ifp, &m0, sin6tosa(dst), rt,
|
||||
IFCAP_TSOv6, ifp->if_mtu) || m0 == NULL)
|
||||
goto done;
|
||||
}
|
||||
CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO);
|
||||
|
||||
ip6stat_inc(ip6s_cantfrag);
|
||||
if (st->rt != PF_DUPTO)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue