Lines Matching +full:0 +full:- +full:mon

2  * ntp_monitor - monitor ntpd statistics
27 * Each entry is doubly linked into two lists, a hash table and a most-
28 * recently-used (MRU) list. When a packet arrives it is looked up in
68 * List of free structures structures, and counters of in-use and total
108 * init_mon - initialize monitoring global data
123 * remove_from_hash - removes an entry from the address hash table and
128 mon_entry *mon
134 mru_entries--;
135 hash = MON_HASH(&mon->rmtadr);
136 UNLINK_SLIST(punlinked, mon_hash[hash], mon, hash_next,
138 ENSURE(punlinked == mon);
153 * mon_reclaim_entry - Remove an entry from the MRU list and from the
154 * hash array, then zero-initialize it. Indirectly
175 * mon_getmoremem - get more memory and put it on the free list
183 entries = (0 == mon_mem_increments)
190 for (chunk += entries; entries; entries--)
191 mon_free_entry(--chunk);
199 * mon_start - start up the monitoring software
209 if (MON_OFF == mode) /* MON_OFF is 0 */
215 if (0 == mon_mem_increments)
223 mon_hash_bits = 0;
229 mon_hash = erealloc_zero(mon_hash, octets, 0);
236 * mon_stop - stop the monitoring software
243 mon_entry *mon;
247 if ((mon_enabled & mode) == 0 || mode == MON_OFF)
259 ITER_DLIST_BEGIN(mon_mru_list, mon, mru, mon_entry)
260 mon_free_entry(mon);
264 mru_entries = 0;
271 * mon_clearinterface -- remove mru entries referring to a local address
279 mon_entry *mon;
281 /* iterate mon over mon_mru_list */
282 ITER_DLIST_BEGIN(mon_mru_list, mon, mru, mon_entry)
283 if (mon->lcladr == lcladr) {
285 UNLINK_DLIST(mon, mru);
287 remove_from_hash(mon);
289 mon_free_entry(mon);
296 * ntp_monitor - record stats about this packet
306 * such responses. ntpdc -c reslist lets you see whether RES_LIMITED
318 mon_entry * mon;
335 pkt = &rbufp->recv_pkt;
336 hash = MON_HASH(&rbufp->recv_srcadr);
337 mode = PKT_MODE(pkt->li_vn_mode);
338 version = PKT_VERSION(pkt->li_vn_mode);
339 mon = mon_hash[hash];
346 for (; mon != NULL; mon = mon->hash_next) {
347 if (SOCK_EQ(&mon->rmtadr, &rbufp->recv_srcadr)) {
351 if (mon != NULL) {
352 interval_fp = rbufp->recv_time;
353 L_SUB(&interval_fp, &mon->last);
354 /* add one-half second to round up */
355 L_ADDUF(&interval_fp, 0x80000000);
357 mon->last = rbufp->recv_time;
358 NSRCPORT(&mon->rmtadr) = NSRCPORT(&rbufp->recv_srcadr);
359 mon->count++;
361 mon->vn_mode = VN_MODE(version, mode);
364 UNLINK_DLIST(mon, mru);
365 LINK_DLIST(mon_mru_list, mon, mru);
372 mon->leak -= interval;
373 mon->leak = max(0, mon->leak);
375 leak = mon->leak + head;
385 * that we give a 1-s grace for the minimum threshold
386 * and a 2-s grace for the headway increment. If one or
392 * This rate-limits the KoDs to no more often than the
396 mon->leak = leak - 2;
398 } else if (mon->leak < limit) {
399 mon->leak = limit + head;
403 mon->flags = restrict_mask;
405 return mon->flags;
415 * - mru_mindepth ("mru mindepth") is a floor beneath which
419 * - mru_maxage ("mru maxage") is a ceiling on the age in
424 * - mru_maxdepth ("mru maxdepth") is a hard limit on the
426 * - "mru maxmem" sets mru_maxdepth to the number of entries
429 * - mru_initalloc ("mru initalloc" sets the count of the
431 * - "mru initmem" sets mru_initalloc in units of kilobytes.
433 * - mru_incalloc ("mru incalloc" sets the number of entries to
434 * allocate on-demand each time the free list is empty.
435 * - "mru incmem" sets mru_incalloc in units of kilobytes.
444 UNLINK_HEAD_SLIST(mon, mon_free, hash_next);
447 oldest_age = 0; /* silence uninit warning */
449 interval_fp = rbufp->recv_time;
450 L_SUB(&interval_fp, &oldest->last);
451 /* add one-half second to round up */
452 L_ADDUF(&interval_fp, 0x80000000);
455 /* note -1 is legal for mru_maxage (disables) */
458 mon = oldest;
463 UNLINK_HEAD_SLIST(mon, mon_free, hash_next);
470 mon = oldest;
474 INSIST(mon != NULL);
481 mon->last = rbufp->recv_time;
482 mon->first = mon->last;
483 mon->count = 1;
484 mon->flags = ~(RES_LIMITED | RES_KOD) & flags;
485 mon->leak = 0;
486 memcpy(&mon->rmtadr, &rbufp->recv_srcadr, sizeof(mon->rmtadr));
487 mon->vn_mode = VN_MODE(version, mode);
488 mon->lcladr = rbufp->dstadr;
489 mon->cast_flags = (u_char)(((rbufp->dstadr->flags &
490 INT_MCASTOPEN) && rbufp->fd == mon->lcladr->fd) ? MDF_MCAST
491 : rbufp->fd == mon->lcladr->bfd ? MDF_BCAST : MDF_UCAST);
497 LINK_SLIST(mon_hash[hash], mon, hash_next);
498 LINK_DLIST(mon_mru_list, mon, mru);
500 return mon->flags;