Install virtual IPs via interface name, and use an interface lookup where required
This commit is contained in:
@@ -313,13 +313,13 @@ METHOD(kernel_interface_t, create_address_enumerator, enumerator_t*,
|
||||
|
||||
METHOD(kernel_interface_t, add_ip, status_t,
|
||||
private_kernel_interface_t *this, host_t *virtual_ip, int prefix,
|
||||
host_t *iface_ip)
|
||||
char *iface)
|
||||
{
|
||||
if (!this->net)
|
||||
{
|
||||
return NOT_SUPPORTED;
|
||||
}
|
||||
return this->net->add_ip(this->net, virtual_ip, prefix, iface_ip);
|
||||
return this->net->add_ip(this->net, virtual_ip, prefix, iface);
|
||||
}
|
||||
|
||||
METHOD(kernel_interface_t, del_ip, status_t,
|
||||
|
||||
@@ -333,15 +333,14 @@ struct kernel_interface_t {
|
||||
* Virtual IPs are attached to an interface. If an IP is added multiple
|
||||
* times, the IP is refcounted and not removed until del_ip() was called
|
||||
* as many times as add_ip().
|
||||
* The virtual IP is attached to the interface where the iface_ip is found.
|
||||
*
|
||||
* @param virtual_ip virtual ip address to assign
|
||||
* @param prefix prefix length to install IP with, -1 for auto
|
||||
* @param iface_ip IP of an interface to attach virtual IP
|
||||
* @param iface interface to install virtual IP on
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_ip) (kernel_interface_t *this, host_t *virtual_ip, int prefix,
|
||||
host_t *iface_ip);
|
||||
char *iface);
|
||||
|
||||
/**
|
||||
* Remove a virtual IP from an interface.
|
||||
|
||||
@@ -112,15 +112,14 @@ struct kernel_net_t {
|
||||
* Virtual IPs are attached to an interface. If an IP is added multiple
|
||||
* times, the IP is refcounted and not removed until del_ip() was called
|
||||
* as many times as add_ip().
|
||||
* The virtual IP is attached to the interface where the iface_ip is found.
|
||||
*
|
||||
* @param virtual_ip virtual ip address to assign
|
||||
* @param prefix prefix length to install with IP address, -1 for auto
|
||||
* @param iface_ip IP of an interface to attach virtual IP
|
||||
* @param iface interface to install virtual IP on
|
||||
* @return SUCCESS if operation completed
|
||||
*/
|
||||
status_t (*add_ip) (kernel_net_t *this, host_t *virtual_ip, int prefix,
|
||||
host_t *iface_ip);
|
||||
char *iface);
|
||||
|
||||
/**
|
||||
* Remove a virtual IP from an interface.
|
||||
|
||||
@@ -1664,7 +1664,7 @@ static status_t manage_ipaddr(private_kernel_netlink_net_t *this, int nlmsg_type
|
||||
|
||||
METHOD(kernel_net_t, add_ip, status_t,
|
||||
private_kernel_netlink_net_t *this, host_t *virtual_ip, int prefix,
|
||||
host_t *iface_ip)
|
||||
char *iface_name)
|
||||
{
|
||||
addr_map_entry_t *entry, lookup = {
|
||||
.ip = virtual_ip,
|
||||
@@ -1715,17 +1715,11 @@ METHOD(kernel_net_t, add_ip, status_t,
|
||||
this->ifaces->find_first(this->ifaces, (void*)iface_entry_by_name,
|
||||
(void**)&iface, this->install_virtual_ip_on) != SUCCESS)
|
||||
{
|
||||
lookup.ip = iface_ip;
|
||||
entry = this->addrs->get_match(this->addrs, &lookup,
|
||||
(void*)addr_map_entry_match);
|
||||
if (!entry)
|
||||
if (this->ifaces->find_first(this->ifaces, (void*)iface_entry_by_name,
|
||||
(void**)&iface, iface_name) != SUCCESS)
|
||||
{ /* if we don't find the requested interface we just use the first */
|
||||
this->ifaces->get_first(this->ifaces, (void**)&iface);
|
||||
}
|
||||
else
|
||||
{
|
||||
iface = entry->iface;
|
||||
}
|
||||
}
|
||||
if (iface)
|
||||
{
|
||||
|
||||
@@ -641,7 +641,7 @@ METHOD(kernel_net_t, get_nexthop, host_t*,
|
||||
|
||||
METHOD(kernel_net_t, add_ip, status_t,
|
||||
private_kernel_pfroute_net_t *this, host_t *virtual_ip, int prefix,
|
||||
host_t *iface_ip)
|
||||
char *iface)
|
||||
{
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user