diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2018-10-25 01:05:20 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2018-10-25 01:05:20 +0000 |
commit | 24076ed67cfdc8085635b68311cecb70bad8e78d (patch) | |
tree | 35592a4165a0625246365a5eaad520143aaaa593 /sys/net | |
parent | 0852556140c8fe666d68b5b69aca2235bc5b8b0d (diff) |
start both the sc_ka_send and sc_ka_hold timeout when
the timeout gets configured instead of gre_up().
this avoids complex gre_ioctl() ordering rules and
enables the sc_ka_hold timeout before the first packet
is received.
from markus@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_gre.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 07ac87e3ef8..30e63eab8e7 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.130 2018/10/18 03:01:18 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.131 2018/10/25 01:05:19 dlg Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -2175,6 +2175,15 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) sc->sc_ka_count = ikar->ikar_cnt; sc->sc_ka_timeo = ikar->ikar_timeo; sc->sc_ka_state = GRE_KA_DOWN; + + arc4random_buf(&sc->sc_ka_key, sizeof(sc->sc_ka_key)); + sc->sc_ka_bias = arc4random(); + sc->sc_ka_holdmax = sc->sc_ka_count; + + sc->sc_ka_recvtm = ticks - hz; + timeout_add(&sc->sc_ka_send, 1); + timeout_add_sec(&sc->sc_ka_hold, + sc->sc_ka_timeo * sc->sc_ka_count); } break; @@ -2747,15 +2756,8 @@ gre_up(struct gre_softc *sc) NET_ASSERT_LOCKED(); SET(sc->sc_if.if_flags, IFF_RUNNING); - if (sc->sc_ka_state != GRE_KA_NONE) { - arc4random_buf(&sc->sc_ka_key, sizeof(sc->sc_ka_key)); - sc->sc_ka_bias = arc4random(); - - sc->sc_ka_recvtm = ticks - hz; - sc->sc_ka_holdmax = sc->sc_ka_count; - + if (sc->sc_ka_state != GRE_KA_NONE) gre_keepalive_send(sc); - } return (0); } |