mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-common: Reimplement ctdb_sys_have_ip() using new infrastructure
It can now be used when net.ipv4.ip_nonlocal_bind=1. This makes the recovery daemon's local IP verification inefficient. It can be optimised in a subsequent commit. Fall back to bind() if unable to fetch IPs. Signed-off-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Anoop C S <anoopcs@samba.org>
This commit is contained in:
parent
a489b6699d
commit
0536d7a98b
@ -160,10 +160,7 @@ bool ctdb_sys_local_ip_check(const struct ctdb_sys_local_ips_context *ips_ctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the given IP is currently on an interface
|
||||
*/
|
||||
bool ctdb_sys_have_ip(const ctdb_sock_addr *_addr)
|
||||
bool ctdb_sys_bind_ip_check(const ctdb_sock_addr *_addr)
|
||||
{
|
||||
int s;
|
||||
int ret;
|
||||
@ -193,6 +190,28 @@ bool ctdb_sys_have_ip(const ctdb_sock_addr *_addr)
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the given IP is currently on an interface
|
||||
*/
|
||||
bool ctdb_sys_have_ip(const ctdb_sock_addr *addr)
|
||||
{
|
||||
struct ctdb_sys_local_ips_context *ips_ctx = NULL;
|
||||
bool have_ip;
|
||||
int ret;
|
||||
|
||||
ret = ctdb_sys_local_ips_init(NULL, &ips_ctx);
|
||||
if (ret != 0) {
|
||||
DBG_DEBUG("Failed to get local addresses, depending on bind\n");
|
||||
have_ip = ctdb_sys_bind_ip_check(addr);
|
||||
return have_ip;
|
||||
}
|
||||
|
||||
have_ip = ctdb_sys_local_ip_check(ips_ctx, addr);
|
||||
talloc_free(ips_ctx);
|
||||
|
||||
return have_ip;
|
||||
}
|
||||
|
||||
/*
|
||||
* simple TCP checksum - assumes data is multiple of 2 bytes long
|
||||
*/
|
||||
|
@ -30,6 +30,7 @@ int ctdb_sys_local_ips_init(TALLOC_CTX *ctx,
|
||||
struct ctdb_sys_local_ips_context **ips_ctx);
|
||||
bool ctdb_sys_local_ip_check(const struct ctdb_sys_local_ips_context *ips_ctx,
|
||||
const ctdb_sock_addr *addr);
|
||||
bool ctdb_sys_bind_ip_check(const ctdb_sock_addr *addr);
|
||||
bool ctdb_sys_have_ip(const ctdb_sock_addr *addr);
|
||||
|
||||
int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
|
||||
|
Loading…
Reference in New Issue
Block a user