Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

With your bare hands?!?


devel / comp.protocols.time.ntp / bug in "discard monitor N"?

SubjectAuthor
* bug in "discard monitor N"?Edward McGuire
+- Re: bug in "discard monitor N"?Edward McGuire
`* Re: [questions] bug in "discard monitor N"?David Hart
 `- Re: [questions] bug in "discard monitor N"?Edward McGuire

1
bug in "discard monitor N"?

<abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=455&group=comp.protocols.time.ntp#455

  copy link   Newsgroups: comp.protocols.time.ntp
X-Received: by 2002:a05:620a:16d1:b0:6fa:156e:44c0 with SMTP id a17-20020a05620a16d100b006fa156e44c0mr3011766qkn.293.1668206711764;
Fri, 11 Nov 2022 14:45:11 -0800 (PST)
X-Received: by 2002:a0c:f951:0:b0:4bb:b2b1:c10f with SMTP id
i17-20020a0cf951000000b004bbb2b1c10fmr3946376qvo.64.1668206711577; Fri, 11
Nov 2022 14:45:11 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.protocols.time.ntp
Date: Fri, 11 Nov 2022 14:45:11 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=70.117.52.110; posting-account=99-szAoAAABeqjQXkwq9U3xS8fVveYhv
NNTP-Posting-Host: 70.117.52.110
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>
Subject: bug in "discard monitor N"?
From: metaed@gmail.com (Edward McGuire)
Injection-Date: Fri, 11 Nov 2022 22:45:11 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3996
 by: Edward McGuire - Fri, 11 Nov 2022 22:45 UTC

I was trying to understand how "discard monitor N" works in ntpd 4.2.8p15. I don't have a high-volume server -- this was purely academic interest. In the process I think I ran across a bug in how it works. Please correct me where I'm wrong.

The academic question was: what are the valid range and units of N?

The documentation says "discard monitor N" determines the "probability of being recorded for packets that overflow the MRU list size limit". Similarly Dr Mills described it as the "probability that a packet that overflows the internal LRU list is discarded". Naively I would have expected a probability to be expressed as [0..1) or [0..100), but actually it is expressed in seconds. Internally it is mon_age, and the default is 3000.

ntp_monitor.c:
int mon_age = 3000; /* preemption limit */

When a packet comes in from a new client that would overflow the MRU list, that means ntpd has already checked that the MRU list is full, can't be extended, and all the entries are too young to age out (mru maxage). In this "dire" situation, the new information can be discarded, or it can be recorded over the oldest list entry. The choice is made by chance. The probability that the oldest entry will be recorded over depends on the age of the oldest entry, and is calculated as:

oldest_age / mon_age

This means the probability of being recorded over is very low when the oldest entry is only 1 second old, and very high when the oldest entry is nearly 3000 seconds old. And an oldest entry older than the threshold will always be recorded over.

The relevant code is:

ntp_monitor.c:
/* Preempt from the MRU list if old enough. */
} else if (ntp_random() / (2. * FRAC) >
(double)oldest_age / mon_age) {
return ~(RES_LIMITED | RES_KOD) & flags;
} else {
mon_reclaim_entry(oldest);

Now here ntpd is generating a random real number by:

ntp_random() / (2. * FRAC)

This looks like an arithmetic error to me. It returns a [0..0.25) random number where you would expect a [0..1) random number. To get a [0..1) random number, you would want

ntp_random() * 2. / FRAC

and you do find that elsewhere in the code. FRAC represents 2^32. But ntp_random() returns a random integer in the range 0 .. 2^31 - 1, and this must be doubled (not halved) to get a [0..1) random number. So contrary to what I believe is the intent, "discard monitor 3000" currently sets the age threshold to 3000 รท 4 = 750 s, beyond which the oldest MRU list entry is always recorded over in case of overflow.

Related Bugzilla bug 3640: ntp.conf: missing documentation for "discard monitor" default value <https://bugs.ntp.org/show_bug.cgi?id=3640>. I did not find a bug describing wrong behavior.

Cheers!
Edward

Re: bug in "discard monitor N"?

<1d9624ca-efec-4c47-a98d-218810f2ae32n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=456&group=comp.protocols.time.ntp#456

  copy link   Newsgroups: comp.protocols.time.ntp
X-Received: by 2002:a05:6214:18ec:b0:4bb:7ad8:deae with SMTP id ep12-20020a05621418ec00b004bb7ad8deaemr4068127qvb.92.1668209519235;
Fri, 11 Nov 2022 15:31:59 -0800 (PST)
X-Received: by 2002:ac8:4c9e:0:b0:3a5:a44:ab6e with SMTP id
j30-20020ac84c9e000000b003a50a44ab6emr3502551qtv.522.1668209519035; Fri, 11
Nov 2022 15:31:59 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.protocols.time.ntp
Date: Fri, 11 Nov 2022 15:31:58 -0800 (PST)
In-Reply-To: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=70.117.52.110; posting-account=99-szAoAAABeqjQXkwq9U3xS8fVveYhv
NNTP-Posting-Host: 70.117.52.110
References: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d9624ca-efec-4c47-a98d-218810f2ae32n@googlegroups.com>
Subject: Re: bug in "discard monitor N"?
From: metaed@gmail.com (Edward McGuire)
Injection-Date: Fri, 11 Nov 2022 23:31:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1231
 by: Edward McGuire - Fri, 11 Nov 2022 23:31 UTC

Or you could say that for NTP 4.2.8p15, the unit of measure for "discard monitor N" is 0.25 second.

Re: [questions] bug in "discard monitor N"?

<CAMbSiYCGUUuMLNe6tijnWNcHb_1oe_R35mTxz_bFyk1j1qiXpg@mail.gmail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=457&group=comp.protocols.time.ntp#457

  copy link   Newsgroups: comp.protocols.time.ntp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: davehart@gmail.com (David Hart)
Newsgroups: comp.protocols.time.ntp
Subject: Re: [questions] bug in "discard monitor N"?
Date: Wed, 16 Nov 2022 12:33:00 -0000 (UTC)
Organization: Taughannock Networks, Trumansburg NY
Message-ID: <CAMbSiYCGUUuMLNe6tijnWNcHb_1oe_R35mTxz_bFyk1j1qiXpg@mail.gmail.com>
References: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>
Reply-To: questions@lists.ntp.org
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Wed, 16 Nov 2022 12:33:00 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="1454"; mail-complaints-to="abuse@iecc.com"
To: questions@lists.ntp.org
Return-Path: <questions+bounces-125-ntpquestions=iecc.com@lists.ntp.org>
Delivered-To: ntpquestions@iecc.com
Delivered-To: questions@lists.ntp.org
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gal.iecc.com
X-Spam-Status: No, score=1.4 required=4.4 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6
Authentication-Results: iecc.com; spf=pass spf.mailfrom=questions+bounces-125-ntpquestions=iecc.com@lists.ntp.org spf.helo=mail0.chi1.ntfo.org smtp.remote-ip="204.93.207.17"; dkim=fail (bad signature) header.d=gmail.com header.s=20210112 header.a=rsa-sha256 header.b="lbjUdGiM"; dmarc=none header.from=gmail.com polrec.p=none polrec.pct=100
X-Original-To: questions@lists.ntp.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=LOPurWN8TQK5EWKRf/49k2O4zQ70L6RTNP+fuNlWbvk=; b=lbjUdGiMCDeJ8+CDHZPXtYSiWFF06/Kqn3AzKnUK+jqIlX/H3iwtgs0BNMSynPcpLc Sn6nXTnyrmrpkbpr7psu/ZcYvcmqhmjrFz/TQWATyCTRLcpz5xGl4S9XMrFMjZ0ZmnO8 jWBJx7x230p5aIYBcVhlameMot3ce6JrIF1nU/4+9YT4fH8+mtgE84VIiggKKfbvpMmT nZ+qhSdee+JmdNwuEGWN6JZJOraFyMFFOerddlXQb5OcCEr38
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LOPurWN8TQK5EWKRf/49k2O4zQ70L6RTNP+fuNlWbvk=; b=NQf8IkoNJWN2X+lafdFgaw3aTmwLwbYg992Cbm4cZ0sIfNjhuVje0ziwEOViyIIsMK /BWYdaTNh3j/GTWJL1HLFhsBkQMr6BvHXzSSYlVohrBItQIJ2HGUx3PXstpWV+oG0c4e j1WGD3pTyKn/O6IOCm9fkvPbUHxPWVqac+7YlYIXMm/IXD5wWHnovX3XuNK+BuF+koZb zS9UuKDYp58j37BEGMOPF
X-Gm-Message-State: ANoB5pnztx2HHejILw560YJVY5SFRXTk53e6kkIR0olfa3WAyGaV19XI cFnyZXLDPv4siGH4Bvpg5MjF343aIhczzP5R0FNh6nZctBs=
X-Google-Smtp-Source: AA0mqf6sVZyDxV/Kpzc5IK6a4R5y3q3Vx7wpBxxX49sTdp8pKw8kz9eBfwmsHEYi7Dl1h3MK4CUBED2KYQIOiDi2Y7s=
List-unsubscribe: mailto: questions+unsubscribe@lists.ntp.org
X-BeenThere: questions@lists.ntp.org
List-Id: questions.lists.ntp.org
Precedence: list
In-Reply-To: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com>
X-DCC-iecc-Metrics: gal.iecc.com 1107; Body=1 Fuz1=1 Fuz2=1
Mail-to-news: iecc.com
 by: David Hart - Wed, 16 Nov 2022 12:33 UTC

On Fri, Nov 11, 2022 at 5:45 PM Edward McGuire <metaed@gmail.com> wrote:
>
> I was trying to understand how "discard monitor N" works in ntpd 4.2.8p15. I don't have a high-volume server -- this was purely academic interest. In the process I think I ran across a bug in how it works. Please correct me where I'm wrong.

I agree with your analysis.

> Related Bugzilla bug 3640: ntp.conf: missing documentation for "discard monitor" default value <https://bugs.ntp.org/show_bug.cgi?id=3640>. I did not find a bug describing wrong behavior.

Please take another look at that bug for a proposed fix for the
ntp.conf manpage as well as the bug you identified in ntp_monitor.c.

Cheers,
Dave Hart
--
This is questions@lists.ntp.org
Subscribe: questions+subscribe@lists.ntp.org
Unsubscribe: questions+unsubscribe@lists.ntp.org

Re: [questions] bug in "discard monitor N"?

<f7562b9f-4459-4920-8d9a-65c2e12daf8en@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=458&group=comp.protocols.time.ntp#458

  copy link   Newsgroups: comp.protocols.time.ntp
X-Received: by 2002:ac8:5484:0:b0:3a5:c6e3:f1b5 with SMTP id h4-20020ac85484000000b003a5c6e3f1b5mr19320945qtq.375.1669064979828;
Mon, 21 Nov 2022 13:09:39 -0800 (PST)
X-Received: by 2002:a05:6214:4401:b0:4c6:b0f4:b0e9 with SMTP id
oj1-20020a056214440100b004c6b0f4b0e9mr3703492qvb.14.1669064979649; Mon, 21
Nov 2022 13:09:39 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.protocols.time.ntp
Date: Mon, 21 Nov 2022 13:09:39 -0800 (PST)
In-Reply-To: <CAMbSiYCGUUuMLNe6tijnWNcHb_1oe_R35mTxz_bFyk1j1qiXpg@mail.gmail.com>
Injection-Info: google-groups.googlegroups.com; posting-host=70.117.52.110; posting-account=99-szAoAAABeqjQXkwq9U3xS8fVveYhv
NNTP-Posting-Host: 70.117.52.110
References: <abc42796-17c7-4af6-af51-3d22677c8d57n@googlegroups.com> <CAMbSiYCGUUuMLNe6tijnWNcHb_1oe_R35mTxz_bFyk1j1qiXpg@mail.gmail.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f7562b9f-4459-4920-8d9a-65c2e12daf8en@googlegroups.com>
Subject: Re: [questions] bug in "discard monitor N"?
From: metaed@gmail.com (Edward McGuire)
Injection-Date: Mon, 21 Nov 2022 21:09:39 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: Edward McGuire - Mon, 21 Nov 2022 21:09 UTC

On Wednesday, November 16, 2022 at 6:33:02 AM UTC-6, dave...@gmail.com wrote:
> Please take another look at that bug for a proposed fix for the
> ntp.conf manpage as well as the bug you identified in ntp_monitor.c

Thank you Dave, the patch looked right.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor