From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1246100-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 901FE1382C5
	for <garchives@archives.gentoo.org>; Wed, 27 Jan 2021 16:55:43 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 57B15E0BF6;
	Wed, 27 Jan 2021 16:55:41 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 3748EE0BF6
	for <gentoo-commits@lists.gentoo.org>; Wed, 27 Jan 2021 16:55:41 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 739E3340D9B
	for <gentoo-commits@lists.gentoo.org>; Wed, 27 Jan 2021 16:55:37 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 6F53F49
	for <gentoo-commits@lists.gentoo.org>; Wed, 27 Jan 2021 16:55:35 +0000 (UTC)
From: "Lars Wendler" <polynomial-c@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Lars Wendler" <polynomial-c@gentoo.org>
Message-ID: <1611766521.e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a.polynomial-c@OpenRC>
Subject: [gentoo-commits] proj/netifrc:master commit in: net/
X-VCS-Repository: proj/netifrc
X-VCS-Files: net/apipa.sh
X-VCS-Directories: net/
X-VCS-Committer: polynomial-c
X-VCS-Committer-Name: Lars Wendler
X-VCS-Revision: e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a
X-VCS-Branch: master
Date: Wed, 27 Jan 2021 16:55:35 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: f5e7eb17-2f92-4294-a064-01cf6209c4a4
X-Archives-Hash: 3ddbd04580ce6fe65ce7119dfa571688

commit:     e5c3bb95ed454a270cf1796bc123fb0c8f34ab5a
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Jan 27 16:25:05 2021 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Wed Jan 27 16:55:21 2021 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e5c3bb95

net/apipa.sh: Account for the first and last /24 being reserved

While the 169.254/16 prefix is used to define IPv4 link-local addresses,
RFC 3927 states that the first 256 and last 256 addresses are reserved for
future use. Therefore, the number of available addresses amounts to neither
64516 nor 65534, but actually 65024.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>

 net/apipa.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/apipa.sh b/net/apipa.sh
index f3ec534..41274fa 100644
--- a/net/apipa.sh
+++ b/net/apipa.sh
@@ -36,11 +36,11 @@ _random_apipa_octets()
 	seed=$(_random_bytes_as_int 2)
 
 	# For APIPA (RFC 3927), the 169.254.0.0/16 address block is
-	# reserved. This provides 65534 addresses, having accounted for the
-	# network and broadcast address. Note that we must count from 1.
+	# reserved. This provides 65024 addresses, having accounted for the
+	# fact that the first and last /24 are reserved for future use.
 	awk "BEGIN {
 		srand($seed)
-		for (i=1; i<65535; i++) print rand() \" \" i
+		for (i=256; i<65280; i++) print rand() \" \" i
 	}" |
 	sort -k 1,1 -n |
 	POSIXLY_CORRECT=1 awk '{