summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2018-11-13 00:00:43 +0000
committerdlg <dlg@openbsd.org>2018-11-13 00:00:43 +0000
commit5d08e67f6b9171d2313ed928e164f33918735605 (patch)
tree027ce9622be20fc62e56246c73b764a7adbe6e09
parentadd txprio support (diff)
downloadwireguard-openbsd-5d08e67f6b9171d2313ed928e164f33918735605.tar.xz
wireguard-openbsd-5d08e67f6b9171d2313ed928e164f33918735605.zip
add txprio setting support
gif encaps l3, so it can get a prio from the payload, as well as from the mbuf itself, or a hardcoded value. ok claudio@
-rw-r--r--sys/net/if_gif.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 3758d4bbcbd..2e8152989c1 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.117 2018/11/11 12:47:04 dlg Exp $ */
+/* $OpenBSD: if_gif.c,v 1.118 2018/11/13 00:00:43 dlg Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -106,6 +106,7 @@ struct gif_softc {
struct ifnet sc_if;
uint16_t sc_df;
int sc_ttl;
+ int sc_txhprio;
};
struct gif_list gif_list = TAILQ_HEAD_INITIALIZER(gif_list);
@@ -153,6 +154,7 @@ gif_clone_create(struct if_clone *ifc, int unit)
sc->sc_df = htons(0);
sc->sc_ttl = ip_defttl;
+ sc->sc_txhprio = IF_HDRPRIO_PAYLOAD;
snprintf(ifp->if_xname, sizeof(ifp->if_xname),
"%s%d", ifc->ifc_name, unit);
@@ -282,6 +284,18 @@ gif_start(struct ifnet *ifp)
} else
ttl = tttl;
+ switch (sc->sc_txhprio) {
+ case IF_HDRPRIO_PAYLOAD:
+ /* tos is already set */
+ break;
+ case IF_HDRPRIO_PACKET:
+ tos = IFQ_PRIO2TOS(m->m_pkthdr.pf.prio);
+ break;
+ default:
+ tos = IFQ_PRIO2TOS(sc->sc_txhprio);
+ break;
+ }
+
gif_send(sc, m, proto, ttl, tos);
}
}
@@ -529,6 +543,22 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
ifr->ifr_df = sc->sc_df ? 1 : 0;
break;
+ case SIOCSTXHPRIO:
+ if (ifr->ifr_hdrprio == IF_HDRPRIO_PAYLOAD ||
+ ifr->ifr_hdrprio == IF_HDRPRIO_PACKET)
+ ; /* ok, fall through */
+ else if (ifr->ifr_hdrprio < IF_HDRPRIO_MIN ||
+ ifr->ifr_hdrprio > IF_HDRPRIO_MAX) {
+ error = EINVAL;
+ break;
+ }
+
+ sc->sc_txhprio = ifr->ifr_hdrprio;
+ break;
+ case SIOCGTXHPRIO:
+ ifr->ifr_hdrprio = sc->sc_txhprio;
+ break;
+
default:
error = ENOTTY;
break;