All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH dlm/next 0/3] fs: dlm: node address configuration fixes
@ 2020-10-20 21:09 Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexander Aring @ 2020-10-20 21:09 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

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(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly
  2020-10-20 21:09 [Cluster-devel] [PATCH dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
@ 2020-10-20 21:09 ` Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
  2 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2020-10-20 21:09 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 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] 5+ messages in thread

* [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: constify addr_compare
  2020-10-20 21:09 [Cluster-devel] [PATCH dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
@ 2020-10-20 21:09 ` Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
  2 siblings, 0 replies; 5+ messages in thread
From: Alexander Aring @ 2020-10-20 21:09 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] 5+ messages in thread

* [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address
  2020-10-20 21:09 [Cluster-devel] [PATCH dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
@ 2020-10-20 21:09 ` Alexander Aring
  2020-10-20 23:04   ` Alexander Ahring Oder Aring
  2 siblings, 1 reply; 5+ messages in thread
From: Alexander Aring @ 2020-10-20 21:09 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 | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index c23d794e82910..0dc651676dfa1 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -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);
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address
  2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
@ 2020-10-20 23:04   ` Alexander Ahring Oder Aring
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Ahring Oder Aring @ 2020-10-20 23:04 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Tue, Oct 20, 2020 at 5:10 PM Alexander Aring <aahringo@redhat.com> wrote:
>
> 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 | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
> index c23d794e82910..0dc651676dfa1 100644
> --- a/fs/dlm/lowcomms.c
> +++ b/fs/dlm/lowcomms.c
> @@ -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);

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-20 23:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20 21:09 [Cluster-devel] [PATCH dlm/next 0/3] fs: dlm: node address configuration fixes Alexander Aring
2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 1/3] fs: dlm: cleanup dlm_local_addr properly Alexander Aring
2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 2/3] fs: dlm: constify addr_compare Alexander Aring
2020-10-20 21:09 ` [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address Alexander Aring
2020-10-20 23:04   ` Alexander Ahring Oder Aring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.