diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-10-16 09:21:25 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-11-19 16:40:17 (GMT) |
commit | 3fedee55b8965a7496762fcef2f73455644f67f5 (patch) | |
tree | a94e6f527cdc3a76ebab043b2ef9e61d236e377e /lib/route | |
parent | 3f231213c7c586b5a5e8ce6b1ea9c1d3b24d74c0 (diff) | |
download | libnl-3fedee55b8965a7496762fcef2f73455644f67f5.zip libnl-3fedee55b8965a7496762fcef2f73455644f67f5.tar.gz libnl-3fedee55b8965a7496762fcef2f73455644f67f5.tar.bz2 |
route/link: fix dump of parent link for some link types
Some link types incorrectly dump their own interface name as parent
link; fix this.
Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/link.c | 11 | ||||
-rw-r--r-- | lib/route/link/ip6tnl.c | 8 | ||||
-rw-r--r-- | lib/route/link/ipgre.c | 8 | ||||
-rw-r--r-- | lib/route/link/ipip.c | 8 | ||||
-rw-r--r-- | lib/route/link/ipvti.c | 8 | ||||
-rw-r--r-- | lib/route/link/sit.c | 8 | ||||
-rw-r--r-- | lib/route/link/vxlan.c | 8 |
7 files changed, 53 insertions, 6 deletions
diff --git a/lib/route/link.c b/lib/route/link.c index 6dc416b..8ef43b5 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -67,6 +67,17 @@ static struct nl_cache_ops rtnl_link_ops; static struct nl_object_ops link_obj_ops; /** @endcond */ +struct rtnl_link *link_lookup(struct nl_cache *cache, int ifindex) +{ + if (!cache) { + cache = __nl_cache_mngt_require("route/link"); + if (!cache) + return NULL; + } + + return rtnl_link_get(cache, ifindex); +} + static struct rtnl_link_af_ops *af_lookup_and_alloc(struct rtnl_link *link, int family) { diff --git a/lib/route/link/ip6tnl.c b/lib/route/link/ip6tnl.c index 59b06b7..085bf66 100644 --- a/lib/route/link/ip6tnl.c +++ b/lib/route/link/ip6tnl.c @@ -218,10 +218,16 @@ static void ip6_tnl_dump_details(struct rtnl_link *link, struct nl_dump_params * { struct ip6_tnl_info *ip6_tnl = link->l_info; char *name, addr[INET6_ADDRSTRLEN]; + struct rtnl_link *parent; if (ip6_tnl->ip6_tnl_mask & IP6_TNL_ATTR_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, ip6_tnl->link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else diff --git a/lib/route/link/ipgre.c b/lib/route/link/ipgre.c index c39a5e7..7889d11 100644 --- a/lib/route/link/ipgre.c +++ b/lib/route/link/ipgre.c @@ -226,10 +226,16 @@ static void ipgre_dump_details(struct rtnl_link *link, struct nl_dump_params *p) { struct ipgre_info *ipgre = link->l_info; char *name, addr[INET_ADDRSTRLEN]; + struct rtnl_link *parent; if (ipgre->ipgre_mask & IPGRE_ATTR_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, ipgre->link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else diff --git a/lib/route/link/ipip.c b/lib/route/link/ipip.c index 5ded380..593d409 100644 --- a/lib/route/link/ipip.c +++ b/lib/route/link/ipip.c @@ -180,10 +180,16 @@ static void ipip_dump_details(struct rtnl_link *link, struct nl_dump_params *p) { struct ipip_info *ipip = link->l_info; char *name, addr[INET_ADDRSTRLEN]; + struct rtnl_link *parent; if (ipip->ipip_mask & IPIP_ATTR_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, ipip->link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else diff --git a/lib/route/link/ipvti.c b/lib/route/link/ipvti.c index d627a8e..7021a94 100644 --- a/lib/route/link/ipvti.c +++ b/lib/route/link/ipvti.c @@ -170,10 +170,16 @@ static void ipvti_dump_details(struct rtnl_link *link, struct nl_dump_params *p) { struct ipvti_info *ipvti = link->l_info; char *name, addr[INET_ADDRSTRLEN]; + struct rtnl_link *parent; if (ipvti->ipvti_mask & IPVTI_ATTR_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, ipvti->link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else diff --git a/lib/route/link/sit.c b/lib/route/link/sit.c index 75987b9..6e6a09a 100644 --- a/lib/route/link/sit.c +++ b/lib/route/link/sit.c @@ -204,10 +204,16 @@ static void sit_dump_details(struct rtnl_link *link, struct nl_dump_params *p) { struct sit_info *sit = link->l_info; char *name, addr[INET_ADDRSTRLEN]; + struct rtnl_link *parent; if (sit->sit_mask & SIT_ATTR_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, sit->link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c index 127d2dd..8eb6db1 100644 --- a/lib/route/link/vxlan.c +++ b/lib/route/link/vxlan.c @@ -218,6 +218,7 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) { struct vxlan_info *vxi = link->l_info; char *name, addr[INET_ADDRSTRLEN]; + struct rtnl_link *parent; nl_dump_line(p, " vxlan-id %u\n", vxi->vxi_id); @@ -231,7 +232,12 @@ static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p) if (vxi->vxi_mask & VXLAN_HAS_LINK) { nl_dump(p, " link "); - name = rtnl_link_get_name(link); + + name = NULL; + parent = link_lookup(link->ce_cache, vxi->vxi_link); + if (parent) + name = rtnl_link_get_name(parent); + if (name) nl_dump_line(p, "%s\n", name); else |