[ovs-dev] [PATCH] ovsdb-server: Add limitation for ovsdb-server remotes

wangyunjian wangyunjian at huawei.com
Tue Dec 22 11:31:16 UTC 2020


From: Yunjian Wang <wangyunjian at huawei.com>

Currently there is no limit to add ovsdb-server remotes,
which will cause all FDs maybe be consumed when we always
call ovsdb_server_add_remote() function. And as a result,
other connections cannot be created. To fix this issue,
we can add limitation for ovsdb-server remotes. It's
limited to 64, witch is just an empirical value.

Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
---
 ovsdb/ovsdb-server.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 0e60e2b87..fc94dcf75 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -62,6 +62,8 @@
 
 VLOG_DEFINE_THIS_MODULE(ovsdb_server);
 
+#define MAX_NUM_DB_REMOTES 64
+
 struct db {
     char *filename;
     struct ovsdb *db;
@@ -1578,6 +1580,12 @@ ovsdb_server_add_remote(struct unixctl_conn *conn, int argc OVS_UNUSED,
     const struct db *db;
     char *retval;
 
+    if (sset_count(config->remotes) > MAX_NUM_DB_REMOTES) {
+        unixctl_command_reply_error(conn,
+            "exceed the maximum number of db remotes");
+        return;
+    }
+
     retval = (strncmp("db:", remote, 3)
               ? NULL
               : parse_db_column(config->all_dbs, remote,
-- 
2.23.0



More information about the dev mailing list