From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address
Date: Tue, 20 Oct 2020 17:09:57 -0400 [thread overview]
Message-ID: <20201020210957.1009638-4-aahringo@redhat.com> (raw)
In-Reply-To: <20201020210957.1009638-1-aahringo@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
next prev parent reply other threads:[~2020-10-20 21:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-10-20 23:04 ` [Cluster-devel] [PATCH dlm/next 3/3] fs: dlm: check on existing node address Alexander Ahring Oder Aring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201020210957.1009638-4-aahringo@redhat.com \
--to=aahringo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).