diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2018-11-11 05:55:11 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2018-11-11 05:55:11 +0000 |
commit | 947ea27b7001429498c52ac4a91fefe33b367e6c (patch) | |
tree | cc9e497ccb6f2f10a72c1271d63771dc9ef138fd /sys/net | |
parent | b7a02204b882b363ec2891365e07af048d8474c6 (diff) |
use the llprio on gre(4) and eoip(4) interfaces for the keepalive tos
llprios are valued 0 to 7, while the ip tos/dscp/tclass is an 8 bit
value. fortunately the high 3 bits map nicely to the llprio values,
so we shift the llprio into place when generating the keepalive
frames. the llprio is defaulted to the value that cisco uses for
their gre keepalives.
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.h | 4 | ||||
-rw-r--r-- | sys/net/if_gre.c | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/sys/net/if.h b/sys/net/if.h index 4f2e9f7bd7a..0d28a126605 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.195 2018/09/12 09:20:34 krw Exp $ */ +/* $OpenBSD: if.h,v 1.196 2018/11/11 05:55:10 dlg Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -129,6 +129,8 @@ struct if_data { #define IFQ_MINPRIO 0 #define IFQ_MAXPRIO IFQ_NQUEUES - 1 #define IFQ_DEFPRIO 3 +#define IFQ_PRIO2TOS(_p) ((_p) << 5) +#define IFQ_TOS2PRIO(_t) ((_t) >> 5) /* * Values for if_link_state. diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 30e63eab8e7..0fa59041cbf 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.131 2018/10/25 01:05:19 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.132 2018/11/11 05:55:10 dlg Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -589,6 +589,8 @@ gre_clone_create(struct if_clone *ifc, int unit) bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(uint32_t)); #endif + ifp->if_llprio = IFQ_TOS2PRIO(IPTOS_PREC_INTERNETCONTROL); + NET_LOCK(); TAILQ_INSERT_TAIL(&gre_list, sc, sc_entry); NET_UNLOCK(); @@ -2817,6 +2819,7 @@ gre_keepalive_send(void *arg) int linkhdr, len; uint16_t proto; uint8_t ttl; + uint8_t tos; /* * re-schedule immediately, so we deal with incomplete configuation @@ -2869,6 +2872,7 @@ gre_keepalive_send(void *arg) SipHash24_Final(gk->gk_digest, &ctx); ttl = sc->sc_tunnel.t_ttl == -1 ? ip_defttl : sc->sc_tunnel.t_ttl; + tos = IFQ_PRIO2TOS(sc->sc_if.if_llprio); t.t_af = sc->sc_tunnel.t_af; t.t_df = sc->sc_tunnel.t_df; @@ -2877,7 +2881,7 @@ gre_keepalive_send(void *arg) t.t_key = sc->sc_tunnel.t_key; t.t_key_mask = sc->sc_tunnel.t_key_mask; - m = gre_encap(&t, m, htons(0), ttl, IPTOS_PREC_INTERNETCONTROL); + m = gre_encap(&t, m, htons(0), ttl, tos); if (m == NULL) return; @@ -2906,8 +2910,7 @@ gre_keepalive_send(void *arg) /* * put it in the tunnel */ - m = gre_encap(&sc->sc_tunnel, m, proto, ttl, - IPTOS_PREC_INTERNETCONTROL); + m = gre_encap(&sc->sc_tunnel, m, proto, ttl, tos); if (m == NULL) return; @@ -3751,10 +3754,11 @@ static void eoip_keepalive_send(void *arg) { struct eoip_softc *sc = arg; + struct ifnet *ifp = &sc->sc_ac.ac_if; struct mbuf *m; int linkhdr; - if (!ISSET(sc->sc_ac.ac_if.if_flags, IFF_RUNNING)) + if (!ISSET(ifp->if_flags, IFF_RUNNING)) return; /* this is really conservative */ @@ -3780,7 +3784,7 @@ eoip_keepalive_send(void *arg) m->m_pkthdr.len = m->m_len = linkhdr; m_adj(m, linkhdr); - m = eoip_encap(sc, m, IPTOS_PREC_INTERNETCONTROL); + m = eoip_encap(sc, m, IFQ_PRIO2TOS(ifp->if_llprio)); if (m == NULL) return; |