diff options
author | glebius <glebius@FreeBSD.org> | 2013-04-25 16:23:22 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-04-25 16:23:22 +0000 |
commit | 994710f1ae309334ef368e7af0f919fbb1b44592 (patch) | |
tree | be4559f022f2ac134fca52793009575df5504985 /contrib/bsnmp/snmp_mibII/mibII.c | |
parent | 2f83e51ae7e4463d05a7666abbff4f7f9f9779b4 (diff) | |
download | FreeBSD-src-994710f1ae309334ef368e7af0f919fbb1b44592.zip FreeBSD-src-994710f1ae309334ef368e7af0f919fbb1b44592.tar.gz |
Restore the ipNetToMedia MIB, that was broken with new ARP commit
in the r186119.
Submitted by: Konstantin Kukushkin <dark rambler-co.ru>
Diffstat (limited to 'contrib/bsnmp/snmp_mibII/mibII.c')
-rw-r--r-- | contrib/bsnmp/snmp_mibII/mibII.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c index 27ebede..d3fe27a 100644 --- a/contrib/bsnmp/snmp_mibII/mibII.c +++ b/contrib/bsnmp/snmp_mibII/mibII.c @@ -934,6 +934,34 @@ mib_find_ifa(struct in_addr addr) } /* + * Process a new ARP entry + */ +static void +process_arp(const struct rt_msghdr *rtm, const struct sockaddr_dl *sdl, + const struct sockaddr_in *sa) +{ + struct mibif *ifp; + struct mibarp *at; + + /* IP arp table entry */ + if (sdl->sdl_alen == 0) + return; + if ((ifp = mib_find_if_sys(sdl->sdl_index)) == NULL) + return; + /* have a valid entry */ + if ((at = mib_find_arp(ifp, sa->sin_addr)) == NULL && + (at = mib_arp_create(ifp, sa->sin_addr, + sdl->sdl_data + sdl->sdl_nlen, sdl->sdl_alen)) == NULL) + return; + + if (rtm->rtm_rmx.rmx_expire == 0) + at->flags |= MIBARP_PERM; + else + at->flags &= ~MIBARP_PERM; + at->flags |= MIBARP_FOUND; +} + +/* * Handle a routing socket message. */ static void @@ -1075,6 +1103,23 @@ handle_rtmsg(struct rt_msghdr *rtm) #endif case RTM_GET: case RTM_ADD: + mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs); + if (rtm->rtm_flags & RTF_LLINFO) { + if (addrs[RTAX_DST] == NULL || + addrs[RTAX_GATEWAY] == NULL || + addrs[RTAX_DST]->sa_family != AF_INET || + addrs[RTAX_GATEWAY]->sa_family != AF_LINK) + break; + process_arp(rtm, + (struct sockaddr_dl *)(void *)addrs[RTAX_GATEWAY], + (struct sockaddr_in *)(void *)addrs[RTAX_DST]); + } else { + if (rtm->rtm_errno == 0 && (rtm->rtm_flags & RTF_UP)) + mib_sroute_process(rtm, addrs[RTAX_GATEWAY], + addrs[RTAX_DST], addrs[RTAX_NETMASK]); + } + break; + case RTM_DELETE: mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs); |