On Mon, Nov 02, 2015 at 13:36 +0100, Gerhard Roth wrote:
> Hi,
>
> snmpd pernanently loses its ARP table information:
>
> # snmpctl walk 127.0.0.1 oid ipNetToMediaPhysAddress
> ipNetToMediaPhysAddress.2.192.168.16.1="xx:xx:xx:xx:xx:xx"
> ipNetToMediaPhysAddress.2.192.168.16.126="xx:xx:xx:xx:xx:xx"
> ipNetToMediaPhysAddress.2.192.168.19.132="xx:xx:xx:xx:xx:xx"
>
> Query the whole tree and this information is gone:
>
> # snmpctl walk 127.0.0.1 oid iso.org>/dev/null
> # snmpctl walk 127.0.0.1 oid ipNetToMediaPhysAddress
> 0=6
>
> The reason is that several OIDs in mib.c call kr_updateif()
> and this function deletes the kif_node and the restores it
> via fetchifs(). But then the ARP information held by the
> old kif_node is gone.
>
> There is no need to delete the kif_node prior to calling
> fetchifs() since it only calls rtmsg_process() which is
> also called during normal processing of messages from the
> routing socket.
>
> And while here, also handle RTM_DESYNC messages.
>
> Gerhard
>
I'm surprised this didn't show up before. Your diff looks
good to me. FWIW, OK mikeb
>
> Index: usr.sbin/snmpd/kroute.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/kroute.c,v
> retrieving revision 1.31
> diff -u -p -u -p -r1.31 kroute.c
> --- usr.sbin/snmpd/kroute.c 18 Jul 2015 00:27:32 -0000 1.31
> +++ usr.sbin/snmpd/kroute.c 2 Nov 2015 11:41:51 -0000
> @@ -365,12 +365,6 @@ kr_iflastchange(void)
> int
> kr_updateif(u_int if_index)
> {
> - struct kif_node *kn;
> -
> - if ((kn = kif_find(if_index)) != NULL)
> - kif_remove(kn);
> -
> - /* Do not update the interface address list */
> return (fetchifs(if_index));
> }
>
> @@ -1380,6 +1374,12 @@ rtmsg_process(char *buf, int len)
> break;
> case RTM_IFANNOUNCE:
> if_announce(next);
> + break;
> + case RTM_DESYNC:
> + kr_shutdown();
> + if (fetchifs(0) == -1)
> + fatalx("rtmsg_process: fetchifs");
> + ktable_init();
> break;
> default:
> /* ignore for now */
>