diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2023-04-05 13:56:32 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2023-04-05 13:56:32 +0000 |
commit | 62e991f5aacdb08f4a48643ad504931536331575 (patch) | |
tree | 01122f3f053015e02f16d330db26a7e310671455 /sys/netinet6 | |
parent | b0a9f9a430fb7a73ed4d1c575edfd53e81a12591 (diff) |
Call getuptime(9) once for consistency; OK bluhm
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/ip6_forward.c | 17 |
1 files changed, 12 insertions, 5 deletions
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, |