naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0241-ip-route-restore_handler-should-check-tb-RTA_PREFSRC.patch

049c96
From 3bcd42253a598fe19892e418e15edea6cb87149e Mon Sep 17 00:00:00 2001
049c96
From: Phil Sutter <psutter@redhat.com>
049c96
Date: Thu, 25 Aug 2016 16:47:35 +0200
049c96
Subject: [PATCH] ip route: restore_handler should check tb[RTA_PREFSRC] for
049c96
 local networks
049c96
049c96
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1362728
049c96
Upstream Status: iproute2.git commit c85703bb9fb77
049c96
049c96
commit c85703bb9fb778ca94a3f84343406a251d23f9ba
049c96
Author: Xin Long <lucien.xin@gmail.com>
049c96
Date:   Sun Aug 7 17:12:30 2016 +0800
049c96
049c96
    ip route: restore_handler should check tb[RTA_PREFSRC] for local networks
049c96
049c96
    Prior to this patch, If one route entry's RTA_PREFSRC and RTA_GATEWAY
049c96
    both were NULL, it was supposed to be restored ONLY as a local address.
049c96
049c96
    But as it didn't check tb[RTA_PREFSRC] when restoring local networks,
049c96
    rtattr_cmp would return a success if it was NULL, this route entry would
049c96
    be restored again as a local network.
049c96
049c96
    This patch is to add tb[RTA_PREFSRC] check when restoring local networks.
049c96
049c96
    Fixes: 74af8dd9620e ("ip route: restore route entries in correct order")
049c96
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
049c96
    Tested-by: Phil Sutter <phil@nwl.cc>
049c96
---
049c96
 ip/iproute.c | 2 +-
049c96
 1 file changed, 1 insertion(+), 1 deletion(-)
049c96
049c96
diff --git a/ip/iproute.c b/ip/iproute.c
049c96
index b7057b3..15e1a51 100644
049c96
--- a/ip/iproute.c
049c96
+++ b/ip/iproute.c
049c96
@@ -1619,7 +1619,7 @@ static int restore_handler(const struct sockaddr_nl *nl,
049c96
 	if (!prio && !tb[RTA_GATEWAY] && (!tb[RTA_PREFSRC] ||
049c96
 	    !rtattr_cmp(tb[RTA_PREFSRC], tb[RTA_DST])))
049c96
 		goto restore;
049c96
-	else if (prio == 1 && !tb[RTA_GATEWAY] &&
049c96
+	else if (prio == 1 && !tb[RTA_GATEWAY] && tb[RTA_PREFSRC] &&
049c96
 		 rtattr_cmp(tb[RTA_PREFSRC], tb[RTA_DST]))
049c96
 		goto restore;
049c96
 	else if (prio == 2 && tb[RTA_GATEWAY])
049c96
-- 
049c96
1.8.3.1
049c96