|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From d1c457badfce0dc86b54b2cac2c5eec99d7bc65e Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Tom Gundersen <teg@jklm.no>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Sat, 13 Sep 2014 20:41:35 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] resolved: fall back to hardcoded ifindex when checking if a
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
link is the loopback
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Reported by Philippe De Swert <philippedeswert@gmail.com>.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Coverity CID#1237656
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/resolve/resolved-manager.c | 8 +++++++-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index f97989754d..00aaffe448 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1687,6 +1687,9 @@ fail:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+/* lo having ifindex 1 is hardcoded in the kernel */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#define LOOPBACK_IFINDEX 1
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int manager_ifindex_is_loopback(Manager *m, int ifindex) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Link *l;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(m);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1695,7 +1698,10 @@ int manager_ifindex_is_loopback(Manager *m, int ifindex) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -EINVAL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
l = hashmap_get(m->links, INT_TO_PTR(ifindex));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (l->flags & IFF_LOOPBACK)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (!l)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* in case we don't yet track the link, rely on the hardcoded value */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return ifindex == LOOPBACK_IFINDEX;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ else if (l->flags & IFF_LOOPBACK)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|