kernel-pfroute: Provide name of interfaces on which virtual IPs are installed
This commit is contained in:
@@ -1266,7 +1266,7 @@ METHOD(kernel_net_t, get_interface_name, bool,
|
|||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
*name = strdup(entry->iface->ifname);
|
*name = strdup(entry->iface->ifname);
|
||||||
DBG2(DBG_KNL, "virtual %H is on interface %s", ip, *name);
|
DBG2(DBG_KNL, "virtual IP %H is on interface %s", ip, *name);
|
||||||
}
|
}
|
||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
@@ -173,6 +173,15 @@ static bool addr_map_entry_match_up_and_usable(addr_map_entry_t *a,
|
|||||||
a->ip->ip_equals(a->ip, b->ip);
|
a->ip->ip_equals(a->ip, b->ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used with get_match this finds an address entry if it is installed as virtual
|
||||||
|
* IP address
|
||||||
|
*/
|
||||||
|
static bool addr_map_entry_match_virtual(addr_map_entry_t *a, addr_map_entry_t *b)
|
||||||
|
{
|
||||||
|
return b->addr->virtual && a->ip->ip_equals(a->ip, b->ip);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used with get_match this finds an address entry if it is installed on
|
* Used with get_match this finds an address entry if it is installed on
|
||||||
* any active local interface
|
* any active local interface
|
||||||
@@ -1060,6 +1069,19 @@ METHOD(kernel_net_t, get_interface_name, bool,
|
|||||||
this->lock->unlock(this->lock);
|
this->lock->unlock(this->lock);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
/* check if it is a virtual IP */
|
||||||
|
entry = this->addrs->get_match(this->addrs, &lookup,
|
||||||
|
(void*)addr_map_entry_match_virtual);
|
||||||
|
if (entry)
|
||||||
|
{
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
|
*name = strdup(entry->iface->ifname);
|
||||||
|
DBG2(DBG_KNL, "virtual IP %H is on interface %s", ip, *name);
|
||||||
|
}
|
||||||
|
this->lock->unlock(this->lock);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
/* maybe it is installed on an ignored interface */
|
/* maybe it is installed on an ignored interface */
|
||||||
entry = this->addrs->get_match(this->addrs, &lookup,
|
entry = this->addrs->get_match(this->addrs, &lookup,
|
||||||
(void*)addr_map_entry_match_up);
|
(void*)addr_map_entry_match_up);
|
||||||
|
|||||||
Reference in New Issue
Block a user