Cleanup opportunity - mode6 processing
Hal Murray
hmurray at megapathdsl.net
Thu Jun 7 03:45:23 UTC 2018
ctl_putsys in ntpd/ntp_control.c is full of things like:
case CS_MRU_MAXDEPTH:
ctl_putuint(sys_var[varid].text, mon_data.mru_maxdepth);
break;
CS_MRU_MAXDEPTH comes from a big line of things like:
#define CS_MRU_MAXDEPTH 30
It is also used in a big table:
{ CS_MRU_MAXDEPTH, RO, "mru_maxdepth" }, /* 30 */
I think those 3 can be combined into one table.
There are a few non-trivial examples like this:
case CS_MRU_MAXMEM: {
uint64_t u;
u = mon_data.mru_maxdepth * sizeof(mon_entry);
u = (u+512)/1024;
ctl_putuint(sys_var[varid].text, u);
break;
}
So the table entry needs a wrapper function rather than directly calling
ctl_putuint. We may need another wrapper for things like int vs long int.
CS_ROOTDELAY and friends are also used in def_sys_var, a list of variables to
be returned for some magic name. I think that can be implemented with a
flags word.
The above is for system variables. There is a similar structure for peer
variables and another for clock variables.
There should be one for auth counters. I assume the list is in ntpq. We
should move it and any similar lists to ntpd so ntpq can print the right
stuff when talking to a newer or older version of ntpd that has updated the
set of appropriate counters.
--
These are my opinions. I hate spam.
More information about the devel
mailing list