naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

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

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