Hello Klemens, Thanks for the curiosity, effort and the patch :), i have just applied the patches and it works:
dev$ doas ospf6ctl show interface Interface Address State HelloTimer Linkstate Uptime lo1 2001:db8::1 LOOP - unknown 00:00:06 On Wed, Nov 23, 2022 at 2:21 PM Klemens Nanni <k...@openbsd.org> wrote: > > On Sat, Nov 19, 2022 at 01:40:14PM +0000, Wouter Prins wrote: > > hello, > > > > Using OpenBSD 7.2 (and previous versions), i noticed when running > > ospf6d on a loopback interface, the output of 'doas ospf6ctl show > > interface' HelloTimer field contains a weird value: > > > > dev$ doas ospf6ctl show interface > > Interface Address State HelloTimer Linkstate > > Uptime > > lo1 2001:db8::1 LOOP 7101w3d0 unknown > > 00:00:02 > > > > Using ospfd (v4), the output of the HelloTimer field for a loopback > > interface defaults to '-'. > > -- > > Wouter Prins > > w...@null0.nl > > This misc@ repot made me curious. > > I don't use OSPF and can't test this, but the relevant code was similar > enough to spot a difference. > > dlg's "implement support for fast hello packets." commit to ospfd(8) > in 2010 retyped ospfd.h struct ctl_iface's hello_timer member to > struct timeval. > > ospf6d.h struct ctl_iface's hello_timer member is still a time_t since > import in 2007. > > Making the v6 version match v4 the version in this regard compiles and > keeps regress/usr.sbin/ospf6d passing. > > Does this fix the HelloTimer output? > > > Index: usr.sbin/ospf6ctl/ospf6ctl.c > =================================================================== > RCS file: /cvs/src/usr.sbin/ospf6ctl/ospf6ctl.c,v > retrieving revision 1.52 > diff -u -p -r1.52 ospf6ctl.c > --- usr.sbin/ospf6ctl/ospf6ctl.c 20 Jan 2022 14:12:55 -0000 1.52 > +++ usr.sbin/ospf6ctl/ospf6ctl.c 23 Nov 2022 12:25:37 -0000 > @@ -388,7 +388,8 @@ show_interface_msg(struct imsg *imsg) > err(1, NULL); > printf("%-11s %-29s %-6s %-10s %-10s %s\n", > iface->name, netid, if_state_name(iface->state), > - fmt_timeframe_core(iface->hello_timer), > + iface->hello_timer.tv_sec < 0 ? "-" : > + fmt_timeframe_core(iface->hello_timer.tv_sec), > get_linkstate(iface->if_type, iface->linkstate), > fmt_timeframe_core(iface->uptime)); > free(netid); > @@ -446,11 +447,12 @@ show_interface_detail_msg(struct imsg *i > iface->dead_interval, iface->rxmt_interval); > if (iface->passive) > printf(" Passive interface (No Hellos)\n"); > - else if (iface->hello_timer < 0) > + else if (iface->hello_timer.tv_sec < 0) > printf(" Hello timer not running\n"); > else > - printf(" Hello timer due in %s\n", > - fmt_timeframe_core(iface->hello_timer)); > + printf(" Hello timer due in %s+%ldmsec\n", > + fmt_timeframe_core(iface->hello_timer.tv_sec), > + iface->hello_timer.tv_usec / 1000); > printf(" Uptime %s\n", fmt_timeframe_core(iface->uptime)); > printf(" Neighbor count is %d, adjacent neighbor count is " > "%d\n", iface->nbr_cnt, iface->adj_cnt); > Index: usr.sbin/ospf6d/interface.c > =================================================================== > RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v > retrieving revision 1.29 > diff -u -p -r1.29 interface.c > --- usr.sbin/ospf6d/interface.c 27 May 2020 09:03:56 -0000 1.29 > +++ usr.sbin/ospf6d/interface.c 23 Nov 2022 12:01:41 -0000 > @@ -686,9 +686,9 @@ if_to_ctl(struct iface *iface) > gettimeofday(&now, NULL); > if (evtimer_pending(&iface->hello_timer, &tv)) { > timersub(&tv, &now, &res); > - ictl.hello_timer = res.tv_sec; > + ictl.hello_timer = res; > } else > - ictl.hello_timer = -1; > + ictl.hello_timer.tv_sec = -1; > > if (iface->state != IF_STA_DOWN) { > ictl.uptime = now.tv_sec - iface->uptime; > Index: usr.sbin/ospf6d/ospf6d.h > =================================================================== > RCS file: /cvs/src/usr.sbin/ospf6d/ospf6d.h,v > retrieving revision 1.50 > diff -u -p -r1.50 ospf6d.h > --- usr.sbin/ospf6d/ospf6d.h 19 Jan 2021 09:46:51 -0000 1.50 > +++ usr.sbin/ospf6d/ospf6d.h 23 Nov 2022 11:59:55 -0000 > @@ -428,7 +428,7 @@ struct ctl_iface { > struct in6_addr dr_addr; > struct in_addr bdr_id; > struct in6_addr bdr_addr; > - time_t hello_timer; > + struct timeval hello_timer; > time_t uptime; > u_int64_t baudrate; > u_int32_t dead_interval; -- Wouter Prins w...@null0.nl