naccyde / rpms / iproute

Forked from rpms/iproute 8 months ago
Clone

Blame SOURCES/0009-iproute-force-rtm_dst_len-to-32-128.patch

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