1
0
mirror of https://github.com/dtaht/ipv4-cleanup.git synced 2024-05-19 06:49:59 +00:00

Initial commit

This commit is contained in:
Dave Taht
2019-01-30 14:08:22 -08:00
parent 7805ebe88c
commit 9363cb2b40
17 changed files with 521 additions and 1 deletions

11
127.md Normal file
View File

@ -0,0 +1,11 @@
# 127.0.0.0/8
Traditionally this address range has been used for "local to the host"
communication, however in surveying the state of the universe, only a few
IP addresses are used
We propose cutting down the "local space" to 127.0.0.0/16 (e.g. 127.0.0.0-
127.0.255.255) and allowing
and even to some extent smarter ones, don't care what appears on the
wire.

4
CLASSE.md Normal file
View File

@ -0,0 +1,4 @@
# Making the former class-e space global unicast
[patches/linux]

27
FAQ.md Normal file
View File

@ -0,0 +1,27 @@
# Frequently Asked Questions
## Focus
## It will take too long
## These addresses will never work
## We could allocate all these addresses
## IPv6
## Class-E is easy
## globally routable
why try to make 0/8 and 240/4 globally routable
any attempt stumbles on the fact that manufacturers, users need to be
incented to - some piece of gear will inevitably not allow ipv4 addresses
in this range unless a standard exists.
Limited use IPv4 address spaces
Making class-e in particular globally routable makes it more possible
to address other long-standing bugs in ipv4 implementations like zeroth
networks,

7
MULTICAST.md Normal file
View File

@ -0,0 +1,7 @@
Thin layer above the MAC that translates a 224/4 address into a multicast
request. Converting the former RESERVED range (232-229) into unicast requests

12
OVERVIEW.md Normal file
View File

@ -0,0 +1,12 @@
carved up the world into into class A, class B,
It seemed an eminently good division at the time
# Timeline
* 1972 Arpanet rolled out
* 1981 TCP/IP rolled out
* 1992 CIDR developed
* 1994 IPv6 started
* 2012 IPv6 rollout started

35
PATCHES.md Normal file
View File

@ -0,0 +1,35 @@
# Patches needed
## 240/4
### Linux
### FreeBSD
### Windows
## 0/8
### Linux
### FreeBSD
### Windows
## 127/8
### Linux
### FreeBSD
### Windows
## 232/8-239/8
### Linux
### FreeBSD
### Windows

View File

@ -1,2 +1,2 @@
# ipv4-cleanup
the IPv4 cleanup project - Making class-e (240/4), 0/, 127/8, 224/4 more usable - adding 419 million new IPs to the world
The IPv4 cleanup project - Making class-e (240/4), 0/, 127/8, 224/4 more usable - adding 419 million new IPs to the world

0
ZERO.md Normal file
View File

20
ZEROTH.md Normal file
View File

@ -0,0 +1,20 @@
# Fixing zeroth addressing
After CIDR rolled out
Is generally restricted to
made in the early 80s, that made 0 the broadcast address in BSD 4.3. BSD
4.3 has long since been retired and we know of no operating system made
in the last 3 decades that uses '0' for broadcast.
finding and eliminating the last remaining vestiges of zeroth
Is generally limited to "ping", where an attempt to ping the zeroth
network address still results in
fixing ping is not a problem: patches
Any rational assessment of IPv4's continued existence stretches out
another 20 years.
That by increasing the range of usable ipv4 addresses

3
patches/README.md Normal file
View File

@ -0,0 +1,3 @@
This directory contains accumulated patches for opening up the
former "class-e" ipv4 address space.

View File

@ -0,0 +1,4 @@
# FreeBSD patches
So far as we know on patch - for ICMP only - is needed for freeBSD
to fully support class e.

View File

@ -0,0 +1,88 @@
From 46bf067870156abd61fe24d14c2486d15b8b502c Mon Sep 17 00:00:00 2001
From: Dave Taht <dave@taht.net>
Date: Fri, 14 Dec 2018 18:38:40 +0000
Subject: [PATCH 1/1] Allow class-e address assignment in ifconfig and early
boot
While the linux kernel became mostly "class-e clean" a decade ago,
and most distributions long ago switched to the iproute2 suite
of utilities, which allow class-e (240.0.0.0/4) address assignment,
distributions relying on busybox, toybox and other forms of
ifconfig cannot assign class-e addresses without this kernel patch.
With this patch, also, a boot command line on these addresses is feasible:
(ip=248.0.1.2::248.0.1.1:255.255.255.0).
While CIDR has been obsolete for 2 decades, and a survey of all the
userspace open source code in the world shows most IN_whatever macros
are also obsolete... rather than obsolete CIDR from this ioctl entirely,
this patch merely enables class-e assignment, sanely.
H/T to Vince Fuller and his original patch here:
https://lkml.org/lkml/2008/1/7/370
Signed-off-by: Dave Taht <dave.taht@gmail.com>
Reviewed-by: John Gilmore <gnu@toad.com>
---
include/uapi/linux/in.h | 8 ++++++--
net/ipv4/devinet.c | 4 +++-
net/ipv4/ipconfig.c | 2 ++
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 48e8a225b985..b27269a2bc95 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -268,8 +268,12 @@ struct sockaddr_in {
#define IN_MULTICAST(a) IN_CLASSD(a)
#define IN_MULTICAST_NET 0xF0000000
-#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
-#define IN_BADCLASS(a) IN_EXPERIMENTAL((a))
+#define IN_BADCLASS(a) ((((long int) (a) ) == 0xffffffff)
+#define IN_EXPERIMENTAL(a) IN_BADCLASS((a))
+
+#define IN_CLASSE(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
+#define IN_CLASSE_NET 0xffffffff
+#define IN_CLASSE_NSHIFT 0
/* Address to accept any incoming messages. */
#define INADDR_ANY ((unsigned long int) 0x00000000)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 5b9b6d497f71..36dac0afcba5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -952,7 +952,7 @@ static int inet_abc_len(__be32 addr)
{
int rc = -1; /* Something else, probably a multicast. */
- if (ipv4_is_zeronet(addr))
+ if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr))
rc = 0;
else {
__u32 haddr = ntohl(addr);
@@ -963,6 +963,8 @@ static int inet_abc_len(__be32 addr)
rc = 16;
else if (IN_CLASSC(haddr))
rc = 24;
+ else if (IN_CLASSE(haddr))
+ rc = 32;
}
return rc;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 55757764c381..86820bcc1b6a 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -429,6 +429,8 @@ static int __init ic_defaults(void)
ic_netmask = htonl(IN_CLASSB_NET);
else if (IN_CLASSC(ntohl(ic_myaddr)))
ic_netmask = htonl(IN_CLASSC_NET);
+ else if (IN_CLASSE(ntohl(ic_myaddr)))
+ ic_netmask = htonl(IN_CLASSE_NET);
else {
pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
&ic_myaddr);
--
2.17.1

View File

@ -0,0 +1,29 @@
From 12d5d77d4053d7511e14853c24bba7d0a3a71c4e Mon Sep 17 00:00:00 2001
From: Dave Taht <dave@taht.net>
Date: Sun, 9 Dec 2018 04:52:33 +0000
Subject: [PATCH] Support class-e addressing in netifd
---
proto.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/proto.c b/proto.c
index 6047735..2819e30 100644
--- a/proto.c
+++ b/proto.c
@@ -131,11 +131,7 @@ parse_addr(struct interface *iface, const char *str, bool v6, int mask,
if (!parse_ip_and_netmask(af, str, &addr->addr, &addr->mask))
goto error;
- if (!v6) {
- if (IN_EXPERIMENTAL(ntohl(addr->addr.in.s_addr)))
- goto error;
-
- } else if (IN6_IS_ADDR_MULTICAST(&addr->addr.in6))
+ if (!v6 && IN6_IS_ADDR_MULTICAST(&addr->addr.in6))
goto error;
if (broadcast)
--
2.17.1

15
patches/openwrt/README.md Normal file
View File

@ -0,0 +1,15 @@
# OpenWRT patches
For class e support three patches were needed.
* Backport of linux 4.20 ifconfig ioctl. Status: ACCEPTED.
* Removal of IN_EXPERIMENTAL check in netifd. Status: ACCEPTED.
* Removal of 240/4 from bcp38 packge. Status: ACCEPTEDa
OpenWrt 19.01 will be fully class-e capable
# 0/8 support
# 232/8-239/8 Support
# 127/8

View File

@ -0,0 +1,187 @@
From fc3908d7af86acd11198936f23f96e5b990e3de9 Mon Sep 17 00:00:00 2001
From: Dave Taht <dave@taht.net>
Date: Sun, 9 Dec 2018 02:46:20 +0000
Subject: [PATCH] Allow Class E addresses throughout FRR
There is no reason to conflate the multicast and class e address
spaces within FRR.
---
bgpd/bgp_attr.c | 2 +-
bgpd/bgp_packet.c | 3 ++-
bgpd/bgp_route.c | 7 +++++--
lib/prefix.h | 6 ++++--
lib/routemap.c | 5 +++--
pimd/mtracebis.c | 3 ++-
pimd/pim_igmp_mtrace.c | 13 +++++++------
7 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 87ebb9c28..d2833ac2b 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1286,7 +1286,7 @@ static bgp_attr_parse_ret_t bgp_attr_nexthop(struct bgp_attr_parser_args *args)
nexthop_n = stream_get_ipv4(peer->curr);
nexthop_h = ntohl(nexthop_n);
if ((IPV4_NET0(nexthop_h) || IPV4_NET127(nexthop_h)
- || IPV4_CLASS_DE(nexthop_h))
+ || IPV4_CLASS_D(nexthop_h) || IPV4_BROADCAST(nexthop_h))
&& !BGP_DEBUG(
allow_martians,
ALLOW_MARTIANS)) /* loopbacks may be used in testing */
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 73a07c823..a5b34c947 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1149,7 +1149,8 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
}
/* remote router-id check. */
- if (remote_id.s_addr == 0 || IPV4_CLASS_DE(ntohl(remote_id.s_addr))
+ if (remote_id.s_addr == 0 || IPV4_CLASS_D(ntohl(remote_id.s_addr))
+ || IPV4_BROADCAST(remote_id.s_addr)
|| ntohl(peer->local_id.s_addr) == ntohl(remote_id.s_addr)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug("%s bad OPEN, wrong router identifier %s",
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 74e4276c0..612cd6e32 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2864,7 +2864,8 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
/* If NEXT_HOP is present, validate it. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (attr->nexthop.s_addr == 0
- || IPV4_CLASS_DE(ntohl(attr->nexthop.s_addr))
+ || IPV4_CLASS_D(ntohl(attr->nexthop.s_addr))
+ || IPV4_BROADCAST(attr->nexthop.s_addr)
|| bgp_nexthop_self(bgp, attr->nexthop))
return 1;
}
@@ -2879,7 +2880,9 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
case BGP_ATTR_NHLEN_IPV4:
case BGP_ATTR_NHLEN_VPNV4:
ret = (attr->mp_nexthop_global_in.s_addr == 0
- || IPV4_CLASS_DE(ntohl(
+ || IPV4_BROADCAST(
+ attr->mp_nexthop_global_in.s_addr)
+ || IPV4_CLASS_D(ntohl(
attr->mp_nexthop_global_in.s_addr))
|| bgp_nexthop_self(bgp,
attr->mp_nexthop_global_in));
diff --git a/lib/prefix.h b/lib/prefix.h
index 424756913..ce19ee761 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -329,7 +329,8 @@ static inline void ipv4_addr_copy(struct in_addr *dst,
#define IPV4_NET0(a) ((((uint32_t)(a)) & 0xff000000) == 0x00000000)
#define IPV4_NET127(a) ((((uint32_t)(a)) & 0xff000000) == 0x7f000000)
#define IPV4_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffff0000) == 0xa9fe0000)
-#define IPV4_CLASS_DE(a) ((((uint32_t)(a)) & 0xe0000000) == 0xe0000000)
+#define IPV4_CLASS_D(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
+#define IPV4_BROADCAST(a) (((uint32_t)(a)) == 0xffffffff)
#define IPV4_MC_LINKLOCAL(a) ((((uint32_t)(a)) & 0xffffff00) == 0xe0000000)
/* Max bit/byte length of IPv6 address. */
@@ -465,7 +466,8 @@ static inline int ipv4_martian(struct in_addr *addr)
{
in_addr_t ip = ntohl(addr->s_addr);
- if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_DE(ip)) {
+ if (IPV4_NET0(ip) || IPV4_NET127(ip) || IPV4_CLASS_D(ip)
+ || IPV4_BROADCAST(ip)) {
return 1;
}
return 0;
diff --git a/lib/routemap.c b/lib/routemap.c
index 5c6d106d8..f235ddec9 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -2357,9 +2357,10 @@ DEFUN (set_ip_nexthop,
return CMD_WARNING_CONFIG_FAILED;
}
if (su.sin.sin_addr.s_addr == 0
- || IPV4_CLASS_DE(ntohl(su.sin.sin_addr.s_addr))) {
+ || IPV4_BROADCAST(su.sin.sin_addr.s_addr)
+ || IPV4_CLASS_D(ntohl(su.sin.sin_addr.s_addr))) {
vty_out(vty,
- "%% nexthop address cannot be 0.0.0.0, multicast or reserved\n");
+ "%% nexthop address cannot be 0.0.0.0, or multicast\n");
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/pimd/mtracebis.c b/pimd/mtracebis.c
index 65c495eff..e2239ae40 100644
--- a/pimd/mtracebis.c
+++ b/pimd/mtracebis.c
@@ -456,7 +456,8 @@ int main(int argc, char *const argv[])
if (argc == 3) {
if (inet_pton(AF_INET, argv[2], &mc_group) != 1)
not_group = true;
- if (!not_group && !IPV4_CLASS_DE(ntohl(mc_group.s_addr)))
+ if (!not_group && !(IPV4_CLASS_D(ntohl(mc_group.s_addr))
+ || IPV4_BROADCAST(mc_group.s_addr)))
not_group = true;
}
diff --git a/pimd/pim_igmp_mtrace.c b/pimd/pim_igmp_mtrace.c
index 1fb624a6a..ce71557a8 100644
--- a/pimd/pim_igmp_mtrace.c
+++ b/pimd/pim_igmp_mtrace.c
@@ -322,7 +322,7 @@ static int mtrace_send_packet(struct interface *ifp,
goto close_fd;
}
- if (IPV4_CLASS_DE(ntohl(dst_addr.s_addr))) {
+ if (IPV4_CLASS_D(ntohl(dst_addr.s_addr))) {
if (IPV4_MC_LINKLOCAL(ntohl(dst_addr.s_addr))) {
ttl = 1;
} else {
@@ -506,7 +506,7 @@ static int mtrace_mc_forward_packet(struct pim_instance *pim, struct ip *ip_hdr)
static int mtrace_forward_packet(struct pim_instance *pim, struct ip *ip_hdr)
{
- if (IPV4_CLASS_DE(ntohl(ip_hdr->ip_dst.s_addr)))
+ if (IPV4_CLASS_D(ntohl(ip_hdr->ip_dst.s_addr)))
return mtrace_mc_forward_packet(pim, ip_hdr);
else
return mtrace_un_forward_packet(pim, ip_hdr, NULL);
@@ -568,7 +568,7 @@ static int mtrace_send_response(struct pim_instance *pim,
mtracep->checksum = 0;
mtracep->checksum = in_cksum((char *)mtracep, mtrace_len);
- if (IPV4_CLASS_DE(ntohl(mtracep->rsp_addr.s_addr))) {
+ if (IPV4_CLASS_D(ntohl(mtracep->rsp_addr.s_addr))) {
struct pim_rpf *p_rpf;
char grp_str[INET_ADDRSTRLEN];
@@ -639,7 +639,8 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,
* Check if mtrace packet is addressed elsewhere and forward,
* if applicable
*/
- if (!IPV4_CLASS_DE(ntohl(ip_hdr->ip_dst.s_addr)))
+ if (!(IPV4_CLASS_D(ntohl(ip_hdr->ip_dst.s_addr))
+ || IPV4_BROADCAST(ip_hdr->ip_dst.s_addr)))
if (!if_lookup_exact_address(&ip_hdr->ip_dst, AF_INET,
pim->vrf_id))
return mtrace_forward_packet(pim, ip_hdr);
@@ -687,7 +688,7 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,
/* 6.1.1 Packet verification */
if (!pim_if_connected_to_source(ifp, mtracep->dst_addr)) {
- if (IPV4_CLASS_DE(ntohl(ip_hdr->ip_dst.s_addr))) {
+ if (IPV4_CLASS_D(ntohl(ip_hdr->ip_dst.s_addr))) {
if (PIM_DEBUG_MTRACE)
zlog_debug(
"Dropping multicast query "
@@ -730,7 +731,7 @@ int igmp_mtrace_recv_qry_req(struct igmp_sock *igmp, struct ip *ip_hdr,
}
/* 6.2.1 Packet Verification - drop not link-local multicast */
- if (IPV4_CLASS_DE(ntohl(ip_hdr->ip_dst.s_addr))
+ if (IPV4_CLASS_D(ntohl(ip_hdr->ip_dst.s_addr))
&& !IPV4_MC_LINKLOCAL(ntohl(ip_hdr->ip_dst.s_addr))) {
if (PIM_DEBUG_MTRACE)
zlog_warn(
--
2.17.1

View File

@ -0,0 +1,31 @@
From 810e27a7f077acf604efccefaaa9b411daea7bc3 Mon Sep 17 00:00:00 2001
From: Dave Taht <dave@taht.net>
Date: Sun, 9 Dec 2018 03:41:08 +0000
Subject: [PATCH] Relax martians check
Other routing daemons use a bogon list to manage invalid IP
addresses. Babel's martians check was too restrictive.
This patch enables both class-e and multicast IP addresses to be
carried within the babel protocol.
---
util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index 38b834f..6c1ba8c 100644
--- a/util.c
+++ b/util.c
@@ -446,7 +446,8 @@ martian_prefix(const unsigned char *prefix, int plen)
(prefix[15] == 0 || prefix[15] == 1)) ||
(plen >= 96 && v4mapped(prefix) &&
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
- (plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
+ (plen >= 128 && (prefix[12] == 0xFF) && (prefix[13] == 0xFF) &&
+ (prefix[14] == 0xFF) && (prefix[15] == 0xFF))));
}
int
--
2.17.1

View File

@ -0,0 +1,47 @@
From 0b837018b9ec6a0fa719cc7f991887d9cd517022 Mon Sep 17 00:00:00 2001
From: Dave Taht <dave@taht.net>
Date: Sat, 27 Oct 2018 09:09:17 -0700
Subject: [PATCH] bird: treat former classe addresses as valid addresses
There is no reason to disallow the former class e address
space, except in a bogon file.
---
lib/ip.c | 8 ++++++--
lib/ip.h | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/ip.c b/lib/ip.c
index 9497248c..fc570c61 100644
--- a/lib/ip.c
+++ b/lib/ip.c
@@ -100,8 +100,12 @@ ip4_classify(ip4_addr ad)
if (b >= 0xe0 && b <= 0xef)
return IADDR_MULTICAST | SCOPE_UNIVERSE;
- if (a == 0xffffffff)
- return IADDR_BROADCAST | SCOPE_LINK;
+ if (b >= 0xf0)
+ if(a == 0xffffffff) {
+ return IADDR_BROADCAST | SCOPE_LINK;
+ } else {
+ return IADDR_HOST | SCOPE_UNIVERSE;
+ }
return IADDR_INVALID;
}
diff --git a/lib/ip.h b/lib/ip.h
index cc6be384..27d40faf 100644
--- a/lib/ip.h
+++ b/lib/ip.h
@@ -242,7 +242,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.17.1