-/* $OpenBSD: if.c,v 1.683 2022/11/23 16:57:37 kn Exp $ */
+/* $OpenBSD: if.c,v 1.684 2023/02/27 09:35:32 jan Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
ifr->ifr_flags &= ~IFXF_WOL;
error = ENOTSUP;
}
+#endif
if (ISSET(ifp->if_capabilities, IFCAP_TSO) &&
ISSET(ifr->ifr_flags, IFXF_TSO) !=
ISSET(ifp->if_xflags, IFXF_TSO)) {
- struct ifreq ifrq;
-
- s = splnet();
-
if (ISSET(ifr->ifr_flags, IFXF_TSO))
- ifp->if_xflags |= IFXF_TSO;
+ ifsettso(ifp, 1);
else
- ifp->if_xflags &= ~IFXF_TSO;
-
- NET_ASSERT_LOCKED(); /* for ioctl */
- KERNEL_ASSERT_LOCKED(); /* for if_flags */
-
- if (ISSET(ifp->if_flags, IFF_UP)) {
- /* go down for a moment... */
- ifp->if_flags &= ~IFF_UP;
- ifrq.ifr_flags = ifp->if_flags;
- (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS,
- (caddr_t)&ifrq);
-
- /* ... and up again */
- ifp->if_flags |= IFF_UP;
- ifrq.ifr_flags = ifp->if_flags;
- (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS,
- (caddr_t)&ifrq);
- }
-
- splx(s);
+ ifsettso(ifp, 0);
} else if (!ISSET(ifp->if_capabilities, IFCAP_TSO) &&
ISSET(ifr->ifr_flags, IFXF_TSO)) {
ifr->ifr_flags &= ~IFXF_TSO;
error = ENOTSUP;
}
-#endif
if (error == 0)
ifp->if_xflags = (ifp->if_xflags & IFXF_CANTCHANGE) |
return (error);
}
+/* Set/clear TSO flag and restart interface if needed. */
+void
+ifsettso(struct ifnet *ifp, int on)
+{
+ struct ifreq ifrq;
+ int s = splnet();
+
+ NET_ASSERT_LOCKED(); /* for ioctl */
+ KERNEL_ASSERT_LOCKED(); /* for if_flags */
+
+ if (on && !ISSET(ifp->if_xflags, IFXF_TSO))
+ SET(ifp->if_xflags, IFXF_TSO);
+ else if (!on && ISSET(ifp->if_xflags, IFXF_TSO))
+ CLR(ifp->if_xflags, IFXF_TSO);
+ else
+ goto out;
+
+ if (ISSET(ifp->if_flags, IFF_UP)) {
+ /* go down for a moment... */
+ CLR(ifp->if_flags, IFF_UP);
+ ifrq.ifr_flags = ifp->if_flags;
+ (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
+
+ /* ... and up again */
+ SET(ifp->if_flags, IFF_UP);
+ ifrq.ifr_flags = ifp->if_flags;
+ (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifrq);
+ }
+ out:
+ splx(s);
+}
+
void
ifa_add(struct ifnet *ifp, struct ifaddr *ifa)
{
-/* $OpenBSD: if.h,v 1.209 2022/06/27 15:11:23 jan Exp $ */
+/* $OpenBSD: if.h,v 1.210 2023/02/27 09:35:32 jan Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
void ifinit(void);
int ifioctl(struct socket *, u_long, caddr_t, struct proc *);
int ifpromisc(struct ifnet *, int);
+void ifsettso(struct ifnet *, int);
struct ifg_group *if_creategroup(const char *);
int if_addgroup(struct ifnet *, const char *);
int if_delgroup(struct ifnet *, const char *);