mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-21 14:44:06 +00:00
fs: dlm: check on existing node address
This patch checks if we add twice the same address to a per node address array. This should never be the case and we report -EEXIST to the user space. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
This commit is contained in:
parent
40c6b83e5a
commit
4f19d071f9
1 changed files with 23 additions and 0 deletions
|
@ -374,10 +374,25 @@ unlock:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* caller need to held dlm_node_addrs_spin lock */
|
||||||
|
static bool dlm_lowcomms_na_has_addr(const struct dlm_node_addr *na,
|
||||||
|
const struct sockaddr_storage *addr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < na->addr_count; i++) {
|
||||||
|
if (addr_compare(na->addr[i], addr))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
|
int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage *new_addr;
|
struct sockaddr_storage *new_addr;
|
||||||
struct dlm_node_addr *new_node, *na;
|
struct dlm_node_addr *new_node, *na;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
new_node = kzalloc(sizeof(struct dlm_node_addr), GFP_NOFS);
|
new_node = kzalloc(sizeof(struct dlm_node_addr), GFP_NOFS);
|
||||||
if (!new_node)
|
if (!new_node)
|
||||||
|
@ -402,6 +417,14 @@ int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = dlm_lowcomms_na_has_addr(na, addr);
|
||||||
|
if (ret) {
|
||||||
|
spin_unlock(&dlm_node_addrs_spin);
|
||||||
|
kfree(new_addr);
|
||||||
|
kfree(new_node);
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
|
|
||||||
if (na->addr_count >= DLM_MAX_ADDR_COUNT) {
|
if (na->addr_count >= DLM_MAX_ADDR_COUNT) {
|
||||||
spin_unlock(&dlm_node_addrs_spin);
|
spin_unlock(&dlm_node_addrs_spin);
|
||||||
kfree(new_addr);
|
kfree(new_addr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue