ip route: restore_handler should check tb[RTA_PREFSRC] for local networks

Prior to this patch, If one route entry's RTA_PREFSRC and RTA_GATEWAY
both were NULL, it was supposed to be restored ONLY as a local address.

But as it didn't check tb[RTA_PREFSRC] when restoring local networks,
rtattr_cmp would return a success if it was NULL, this route entry would
be restored again as a local network.

This patch is to add tb[RTA_PREFSRC] check when restoring local networks.

Fixes: 74af8dd962 ("ip route: restore route entries in correct order")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Tested-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
Xin Long 2016-08-07 17:12:30 +08:00 committed by Stephen Hemminger
parent 9423a324bf
commit c85703bb9f
1 changed files with 1 additions and 1 deletions

View File

@ -1813,7 +1813,7 @@ static int restore_handler(const struct sockaddr_nl *nl,
if (!prio && !tb[RTA_GATEWAY] && (!tb[RTA_PREFSRC] ||
!rtattr_cmp(tb[RTA_PREFSRC], tb[RTA_DST])))
goto restore;
else if (prio == 1 && !tb[RTA_GATEWAY] &&
else if (prio == 1 && !tb[RTA_GATEWAY] && tb[RTA_PREFSRC] &&
rtattr_cmp(tb[RTA_PREFSRC], tb[RTA_DST]))
goto restore;
else if (prio == 2 && tb[RTA_GATEWAY])