summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-11-13 00:00:44 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-11-13 00:00:44 +0000
commitc4ed575eaea5b82c91ce289df4dc5b84755b29cc (patch)
tree49cd4d9c7f8a6b4ee5caf41c1135ae718029d8d5
parent216ef8c507cd89c2d76415bf7ce58709619d40a2 (diff)
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;