* [Cluster-devel] [PATCHv2 dlm/next 0/3] fs: dlm: node address configuration fixes
@ 2020-10-21 0:17 Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Aring @ 2020-10-21 0:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
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
changes since v2:
- remove deadlock situation in 3/3
- fix grammar in 1/3 commit msg
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 | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCHv2 dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly
2020-10-21 0:17 [Cluster-devel] [PATCHv2 dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
@ 2020-10-21 0:17 ` Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2020-10-21 0:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
This patch assigns the dlm_local_addr entries to NULL after we freeing
the memory of the entry. This is 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.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lowcomms.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 11e5e92148fda..9973293bfddcd 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -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
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCHv2 dlm/next 2/3] fs: dlm: constify addr_compare
2020-10-21 0:17 [Cluster-devel] [PATCHv2 dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
@ 2020-10-21 0:17 ` Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2020-10-21 0:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
This patch just constify some function parameter which should be have a
read access only.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/lowcomms.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 9973293bfddcd..c23d794e82910 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -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: {
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCHv2 dlm/next 3/3] fs: dlm: check on existing node address
2020-10-21 0:17 [Cluster-devel] [PATCHv2 dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
@ 2020-10-21 0:17 ` Alexander Aring
2 siblings, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2020-10-21 0:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
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>
---
fs/dlm/lowcomms.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index c23d794e82910..8122eb5f2afb8 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -370,10 +370,25 @@ static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid)
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)
{
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 +413,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);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-21 0:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-21 0:17 [Cluster-devel] [PATCHv2 dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
2020-10-21 0:17 ` [Cluster-devel] [PATCHv2 dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).