1
0
mirror of https://github.com/dtaht/unicast-extensions.git synced 2024-05-11 05:55:07 +00:00

BIRD patch in useful-patches

This commit is contained in:
Seth Schoen
2023-02-03 23:02:03 -08:00
parent ceb830d6c9
commit 94d97c4f6f
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,69 @@
From 2f223855782a312108019074e3365e29e51c10ce Mon Sep 17 00:00:00 2001
From: Seth Schoen <schoen@loyalty.org>
Date: Fri, 18 Nov 2022 15:33:28 -0800
Subject: [PATCH] Don't treat 0/8 and 240/4 specially in IPv4 classification
With the exception of 0.0.0.0 and 255.255.255.255, which have additional
special meanings, treat 0/8 and 240/4 as normal unicast addresses by
default. This is because some people are experimenting with using these
addresses as regular unicast (either for private addresses or for potential
future public addresses).
On the public Internet, they would still currently be regarded as bogons and
one could make (maybe by default) a bogon-filtering rule in bird.conf that
would not permit these addresses to be routed, e.g. with a pair of static
routes
route 0.0.0.0/8 prohibit;
route 240.0.0.0/4 prohibit;
Dave Taht, who wrote a prior version of this patch, suggested that in
any case it is better to have bogons defined in a configuration file
than hard-coded in software.
---
lib/ip.c | 7 +++++--
lib/ip.h | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/ip.c b/lib/ip.c
index 4c5fa47f..e13bbce0 100644
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -87,8 +87,10 @@ ip4_classify(ip4_addr ad)
if (b < 0xe0)
{
- if (b == 0x00) /* 0.0.0.0/8 This network */
+ if (a == 0x00000000) /* 0.0.0.0/32 Unset address */
return IADDR_INVALID;
+ /* 0.0.0.0/8 is otherwise reserved, but
+ * some people are using it or trying to */
if (b == 0x7f) /* 127.0.0.0/8 Loopback address */
return IADDR_HOST | SCOPE_HOST;
@@ -107,7 +109,8 @@ ip4_classify(ip4_addr ad)
if (a == 0xffffffff) /* 255.255.255.255 Broadcast address */
return IADDR_BROADCAST | SCOPE_LINK;
- return IADDR_HOST | SCOPE_SITE; /* 240.0.0.0/4 Reserved / private */
+ return IADDR_HOST | SCOPE_UNIVERSE; /* 240.0.0.0/4 Reserved / private, but
+ * some people are using it or trying to */
}
int
diff --git a/lib/ip.h b/lib/ip.h
index 9eef2e16..875b9f5e 100644
--- a/lib/ip.h
+++ b/lib/ip.h
@@ -245,7 +245,7 @@ static inline int ip6_is_v4mapped(ip6_addr a)
#define ipa_is_link_local(x) ip6_is_link_local(x)
static inline int ip4_is_unicast(ip4_addr a)
-{ return _I(a) < 0xe0000000; }
+{ return _I(a) < 0xe0000000 || (_I(a) >= 0xf0000000 && _I(a) != 0xffffffff); }
/* XXXX remove */
static inline int ipa_classify_net(ip_addr a)
--
2.25.1

View File

@ -9,3 +9,8 @@ This patch is included with Linux 5.14 and later, and makes the lowest
address on an IPv4 segment non-broadcast. You can apply this version
to a Linux 5.10 LTS kernel (or likely to other kernel versions prior
to 5.14).
* 0001-Don-t-treat-0-8-and-240-4-specially-in-IPv4-classifi.patch
This patch is for use with the BIRD routing daemon, and increases the
extent to which it can support Internet routes within 0/8 and 240/4.