fs: dlm: node address configuration fixes
Alexander Aring
maintainercover fs: dlm: node address configuration fixes
Hi,
I got reports of:
kernel: dlm: TCP protocol can't handle multi-homed hosts, try SCTP
there was some reconfiguration involed and my guess it that we left some dlm_local_addr array pointers in some dangled state. The first patch should fix the observed behaviour. The other patches is something what I thought can also happen, it just checks if we setup a node address twice, if this is the case we return -EEXIST.
This is based on dlm/next with the previous submitted patch series.
- Alex
Alexander Aring (3):
fs: dlm: cleanup dlm_local_addr properly
fs: dlm: constify addr_compare
fs: dlm: check on existing node address
fs/dlm/lowcomms.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
Alexander Aring
maintainerPATCH 1/3 fs: dlm: cleanup dlm_local_addr properly
This patch assigns the dlm_local_addr entries to NULL after we freeing the memory of the entry. This required because the user can changed some settings with less addresses than before and a NULL check on start functionality will check on a dangled pointer.
--- fs/dlm/lowcomms.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/dlm/lowcomms.c +3 -1
@@ -1248,8 +1248,10 @@ static void deinit_local(void) {int i; -for (i =0 ; i < dlm_local_count; i++) +for (i =0 ; i < dlm_local_count; i++) {kfree (dlm_local_addr[i]); + dlm_local_addr[i] =NULL ; + } }/* Initialise SCTP socket and bind to all interfaces
Signature · 1 line
2.26.2
Alexander Aring
maintainerPATCH 2/3 fs: dlm: constify addr_compare
In reply to Alexander AringThis patch just constify some function parameter which should be have a read access only.
--- fs/dlm/lowcomms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/dlm/lowcomms.c +2 -1
@@ -270,7 +270,8 @@ static struct dlm_node_addr *find_node_addr(int nodeid)return NULL ; } -static int addr_compare (struct sockaddr_storage *x,struct sockaddr_storage *y) +static int addr_compare (const struct sockaddr_storage *x, +const struct sockaddr_storage *y) {switch (x->ss_family) {case AF_INET : {
Signature · 1 line
2.26.2
Alexander Aring
maintainerPATCH 3/3 fs: dlm: check on existing node address
In reply to Alexander AringThis 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.
--- fs/dlm/lowcomms.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
fs/dlm/lowcomms.c +26 -0
@@ -370,10 +370,28 @@ static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid)return rv; } +static bool dlm_lowcomms_na_has_addr (const struct dlm_node_addr *na, +const struct sockaddr_storage *addr) +{ +int i; + +spin_lock (&dlm_node_addrs_spin); +for (i =0 ; i < na->addr_count; i++) { +if (addr_compare (na->addr[i], addr)) { +spin_unlock (&dlm_node_addrs_spin); +return true; + } + } +spin_unlock (&dlm_node_addrs_spin); + +return false; +} +int dlm_lowcomms_addr (int nodeid,struct sockaddr_storage *addr,int len) {struct sockaddr_storage *new_addr;struct dlm_node_addr *new_node, *na; +bool ret; new_node =kzalloc (sizeof (struct dlm_node_addr ),GFP_NOFS );if (!new_node)
@@ -398,6 +416,14 @@ int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)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 ) {spin_unlock (&dlm_node_addrs_spin);kfree (new_addr);
Signature · 1 line
2.26.2
Alexander Ahring Oder Aring
maintainerPATCH 3/3 fs: dlm: check on existing node address
Hi,
Quoted 21 lines · Alexander Aring
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
-EEXISTto the user space.Signed-off-by Alexander Aring <[email protected]>--- fs/dlm/lowcomms.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)fs/dlm/lowcomms.c +3
-0@@ -370,10 +370,28 @@ static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid)return rv; } +static bool dlm_lowcomms_na_has_addr (const struct dlm_node_addr *na, +const struct sockaddr_storage *addr) +{
fs/dlm/lowcomms.c static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid) · line 385
Quoted 10 lines
fs/dlm/lowcomms.c +10
-0+int i; + +spin_lock (&dlm_node_addrs_spin); +for (i =0 ; i < na->addr_count; i++) { +if (addr_compare (na->addr[i], addr)) { +spin_unlock (&dlm_node_addrs_spin); +return true; + } + } +spin_unlock (&dlm_node_addrs_spin);
grml, this lock is already held when calling that function, I need to remove the lock and make some comment that this lock needs to be held when the user calls it.
Sorry, I will send a v2.
- Alex