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