From: kn Date: Wed, 5 Apr 2023 13:56:31 +0000 (+0000) Subject: Call getuptime(9) once for consistency; OK bluhm X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d096889826e7a279acf9477f1df76cdf687ded64;p=openbsd Call getuptime(9) once for consistency; OK bluhm --- diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index 7dd2934a093..56c6dd93b49 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_forward.c,v 1.108 2022/08/09 21:10:02 kn Exp $ */ +/* $OpenBSD: ip6_forward.c,v 1.109 2023/04/05 13:56:31 kn Exp $ */ /* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */ /* @@ -102,9 +102,13 @@ ip6_forward(struct mbuf *m, struct rtentry *rt, int srcrt) if ((m->m_flags & (M_BCAST|M_MCAST)) != 0 || IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) || IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) { + time_t uptime; + ip6stat_inc(ip6s_cantforward); - if (ip6_log_time + ip6_log_interval < getuptime()) { - ip6_log_time = getuptime(); + uptime = getuptime(); + + if (ip6_log_time + ip6_log_interval < uptime) { + ip6_log_time = uptime; inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6)); inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6)); log(LOG_DEBUG, @@ -189,11 +193,14 @@ reroute: */ if (in6_addr2scopeid(m->m_pkthdr.ph_ifidx, &ip6->ip6_src) != in6_addr2scopeid(rt->rt_ifidx, &ip6->ip6_src)) { + time_t uptime; + ip6stat_inc(ip6s_cantforward); ip6stat_inc(ip6s_badscope); + uptime = getuptime(); - if (ip6_log_time + ip6_log_interval < getuptime()) { - ip6_log_time = getuptime(); + if (ip6_log_time + ip6_log_interval < uptime) { + ip6_log_time = uptime; inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6)); inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6)); log(LOG_DEBUG,