diff options
author | roberto <roberto@FreeBSD.org> | 2008-08-22 15:58:00 +0000 |
---|---|---|
committer | roberto <roberto@FreeBSD.org> | 2008-08-22 15:58:00 +0000 |
commit | b85c7169a740b2edf0106ad59fdaa1b0160f823c (patch) | |
tree | 2b9fb7f64eacb322e95695e412c923e97ba33e88 /contrib/ntp/ntpd/ntp_monitor.c | |
parent | 1d197cfe9feac6bc29537d8e53c30b6435937b95 (diff) | |
parent | 7a6072eb585696f8856cd498c3fd194cf49f14c6 (diff) | |
download | FreeBSD-src-b85c7169a740b2edf0106ad59fdaa1b0160f823c.zip FreeBSD-src-b85c7169a740b2edf0106ad59fdaa1b0160f823c.tar.gz |
Merge ntpd & friends 4.2.4p5 from vendor/ntp/dist into head. Next commit
will update usr.sbin/ntp to match this.
MFC after: 2 weeks
Diffstat (limited to 'contrib/ntp/ntpd/ntp_monitor.c')
-rw-r--r-- | contrib/ntp/ntpd/ntp_monitor.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/contrib/ntp/ntpd/ntp_monitor.c b/contrib/ntp/ntpd/ntp_monitor.c index 6b288fc..753fa76 100644 --- a/contrib/ntp/ntpd/ntp_monitor.c +++ b/contrib/ntp/ntpd/ntp_monitor.c @@ -9,6 +9,7 @@ #include "ntp_io.h" #include "ntp_if.h" #include "ntp_stdlib.h" +#include <ntp_random.h> #include <stdio.h> #include <signal.h> @@ -177,11 +178,31 @@ mon_stop( mon_mru_list.mru_prev = &mon_mru_list; } +void +ntp_monclearinterface(struct interface *interface) +{ + struct mon_data *md; + + for (md = mon_mru_list.mru_next; md != &mon_mru_list; + md = md->mru_next) { + if (md->interface == interface) + { + /* dequeue from mru list and put to free list */ + md->mru_prev->mru_next = md->mru_next; + md->mru_next->mru_prev = md->mru_prev; + remove_from_hash(md); + md->hash_next = mon_free; + mon_free = md; + } + } +} /* * ntp_monitor - record stats about this packet + * + * Returns 1 if the packet is at the head of the list, 0 otherwise. */ -void +int ntp_monitor( struct recvbuf *rbufp ) @@ -193,7 +214,7 @@ ntp_monitor( register int mode; if (mon_enabled == MON_OFF) - return; + return 0; pkt = &rbufp->recv_pkt; memset(&addr, 0, sizeof(addr)); @@ -223,7 +244,7 @@ ntp_monitor( md->mru_prev = &mon_mru_list; mon_mru_list.mru_next->mru_prev = md; mon_mru_list.mru_next = md; - return; + return 1; } md = md->hash_next; } @@ -239,9 +260,10 @@ ntp_monitor( * Preempt from the MRU list if old enough. */ md = mon_mru_list.mru_prev; - if (((u_long)RANDOM & 0xffffffff) / FRAC > + /* We get 31 bits from ntp_random() */ + if (((u_long)ntp_random()) / FRAC > (double)(current_time - md->lasttime) / mon_age) - return; + return 0; md->mru_prev->mru_next = &mon_mru_list; mon_mru_list.mru_prev = md->mru_prev; @@ -266,7 +288,7 @@ ntp_monitor( md->mode = (u_char) mode; md->version = PKT_VERSION(pkt->li_vn_mode); md->interface = rbufp->dstadr; - md->cast_flags = (u_char)(((rbufp->dstadr->flags & INT_MULTICAST) && + md->cast_flags = (u_char)(((rbufp->dstadr->flags & INT_MCASTOPEN) && rbufp->fd == md->interface->fd) ? MDF_MCAST: rbufp->fd == md->interface->bfd ? MDF_BCAST : MDF_UCAST); @@ -280,6 +302,7 @@ ntp_monitor( md->mru_prev = &mon_mru_list; mon_mru_list.mru_next->mru_prev = md; mon_mru_list.mru_next = md; + return 1; } |