|
|
d62593 |
From f2cb0f1570ca603c5d92d6a7d87596d07fdb01cd Mon Sep 17 00:00:00 2001
|
|
|
d62593 |
Message-Id: <f2cb0f1570ca603c5d92d6a7d87596d07fdb01cd.1612868485.git.aclaudi@redhat.com>
|
|
|
d62593 |
In-Reply-To: <cb7ce51cc1abd7b98370b903ec96205ebfe48661.1612868485.git.aclaudi@redhat.com>
|
|
|
d62593 |
References: <cb7ce51cc1abd7b98370b903ec96205ebfe48661.1612868485.git.aclaudi@redhat.com>
|
|
|
d62593 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
d62593 |
Date: Tue, 9 Feb 2021 12:00:58 +0100
|
|
|
d62593 |
Subject: [PATCH] iproute: force rtm_dst_len to 32/128
|
|
|
d62593 |
MIME-Version: 1.0
|
|
|
d62593 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d62593 |
Content-Transfer-Encoding: 8bit
|
|
|
d62593 |
|
|
|
d62593 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1852038
|
|
|
d62593 |
Upstream Status: unknown commit 5a37254b
|
|
|
d62593 |
|
|
|
d62593 |
commit 5a37254b71249bfb73d44d6278d767a6b127a2f9
|
|
|
d62593 |
Author: Luca Boccassi <bluca@debian.org>
|
|
|
d62593 |
Date: Sun Jan 24 17:36:58 2021 +0000
|
|
|
d62593 |
|
|
|
d62593 |
iproute: force rtm_dst_len to 32/128
|
|
|
d62593 |
|
|
|
d62593 |
Since NETLINK_GET_STRICT_CHK was enabled, the kernel rejects commands
|
|
|
d62593 |
that pass a prefix length, eg:
|
|
|
d62593 |
|
|
|
d62593 |
ip route get `1.0.0.0/1
|
|
|
d62593 |
Error: ipv4: Invalid values in header for route get request.
|
|
|
d62593 |
ip route get 0.0.0.0/0
|
|
|
d62593 |
Error: ipv4: rtm_src_len and rtm_dst_len must be 32 for IPv4
|
|
|
d62593 |
|
|
|
d62593 |
Since there's no point in setting a rtm_dst_len that we know is going
|
|
|
d62593 |
to be rejected, just force it to the right value if it's passed on
|
|
|
d62593 |
the command line. Print a warning to stderr to notify users.
|
|
|
d62593 |
|
|
|
d62593 |
Bug-Debian: https://bugs.debian.org/944730
|
|
|
d62593 |
Reported-By: Clément 'wxcafé' Hertling <wxcafe@wxcafe.net>
|
|
|
d62593 |
Signed-off-by: Luca Boccassi <bluca@debian.org>
|
|
|
d62593 |
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
|
|
d62593 |
---
|
|
|
d62593 |
ip/iproute.c | 13 ++++++++++++-
|
|
|
d62593 |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
d62593 |
|
|
|
d62593 |
diff --git a/ip/iproute.c b/ip/iproute.c
|
|
|
d62593 |
index 05ec2c29..1f3c347e 100644
|
|
|
d62593 |
--- a/ip/iproute.c
|
|
|
d62593 |
+++ b/ip/iproute.c
|
|
|
d62593 |
@@ -2067,7 +2067,18 @@ static int iproute_get(int argc, char **argv)
|
|
|
d62593 |
if (addr.bytelen)
|
|
|
d62593 |
addattr_l(&req.n, sizeof(req),
|
|
|
d62593 |
RTA_DST, &addr.data, addr.bytelen);
|
|
|
d62593 |
- req.r.rtm_dst_len = addr.bitlen;
|
|
|
d62593 |
+ if (req.r.rtm_family == AF_INET && addr.bitlen != 32) {
|
|
|
d62593 |
+ fprintf(stderr,
|
|
|
d62593 |
+ "Warning: /%u as prefix is invalid, only /32 (or none) is supported.\n",
|
|
|
d62593 |
+ addr.bitlen);
|
|
|
d62593 |
+ req.r.rtm_dst_len = 32;
|
|
|
d62593 |
+ } else if (req.r.rtm_family == AF_INET6 && addr.bitlen != 128) {
|
|
|
d62593 |
+ fprintf(stderr,
|
|
|
d62593 |
+ "Warning: /%u as prefix is invalid, only /128 (or none) is supported.\n",
|
|
|
d62593 |
+ addr.bitlen);
|
|
|
d62593 |
+ req.r.rtm_dst_len = 128;
|
|
|
d62593 |
+ } else
|
|
|
d62593 |
+ req.r.rtm_dst_len = addr.bitlen;
|
|
|
d62593 |
address_found = true;
|
|
|
d62593 |
}
|
|
|
d62593 |
argc--; argv++;
|
|
|
d62593 |
--
|
|
|
d62593 |
2.29.2
|
|
|
d62593 |
|