From 3317d2586d130c6c91e063a4253e18e2186a7796ee22d771f9aaa04f12a61f81 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Thu, 23 Aug 2018 09:48:24 +0000 Subject: [PATCH 1/2] - Replace If-connect-fails-let-other-side-accept-connection-and-come-back.patch by: Reset-delay-for-unixsock-connect-from-inotify.patch: Upstream chose to fix bsc#1101647 slightly differently. OBS-URL: https://build.opensuse.org/package/show/network:cluster/conman?expand=0&rev=29 --- ...side-accept-connection-and-come-back.patch | 100 ------------- ...ay-for-unixsock-connect-from-inotify.patch | 135 ++++++++++++++++++ conman.changes | 9 ++ conman.spec | 2 +- 4 files changed, 145 insertions(+), 101 deletions(-) delete mode 100644 If-connect-fails-let-other-side-accept-connection-and-come-back.patch create mode 100644 Reset-delay-for-unixsock-connect-from-inotify.patch diff --git a/If-connect-fails-let-other-side-accept-connection-and-come-back.patch b/If-connect-fails-let-other-side-accept-connection-and-come-back.patch deleted file mode 100644 index bf1d79c..0000000 --- a/If-connect-fails-let-other-side-accept-connection-and-come-back.patch +++ /dev/null @@ -1,100 +0,0 @@ -From: Egbert Eich -Date: Wed Jul 18 11:26:07 2018 +0200 -Subject: If connect fails let other side accept connection and come back -Patch-mainline: Not yet -Git-commit: 1fc96affadb267bb03058293e9d31af95cfd6f2d -References: bsc# - -The UNIX socket code uses inotify to get notified when a socket -it monitors appears. The inotify is triggered when the other side -does bind(). However, we are not able to connect until the other -side calls listen(). Therefore, we need to let the other side continue -if the connect fails and should come back at the earliest time to -attempt a connect() again. -For this we just reset the poll() delay. - -Signed-off-by: Egbert Eich ---- - server-unixsock.c | 22 ++++++++++++++++++---- - 1 file changed, 18 insertions(+), 4 deletions(-) -diff --git a/server-unixsock.c b/server-unixsock.c -index 152bd31..7302acf 100644 ---- a/server-unixsock.c -+++ b/server-unixsock.c -@@ -46,8 +46,10 @@ - - - static size_t max_unixsock_dev_strlen(void); -+static int connect_unixsock_obj_int(obj_t *unixsock, int reset_delay); - static int connect_unixsock_obj(obj_t *unixsock); - static int disconnect_unixsock_obj(obj_t *unixsock); -+static int open_unixsock_obj_reset_delay(obj_t *unixsock); - static void reset_unixsock_delay(obj_t *unixsock); - - extern tpoll_t tp_global; /* defined in server.c */ -@@ -147,7 +149,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, - list_append(conf->objs, unixsock); - - rv = inevent_add(unixsock->aux.unixsock.dev, -- (inevent_cb_f) open_unixsock_obj, unixsock); -+ (inevent_cb_f) open_unixsock_obj_reset_delay, unixsock); - if (rv < 0) { - log_msg(LOG_INFO, - "Console [%s] unable to register device \"%s\" for inotify events", -@@ -157,7 +159,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, - } - - --int open_unixsock_obj(obj_t *unixsock) -+static int open_unixsock_obj_int(obj_t *unixsock, int reset_delay) - { - /* (Re)opens the specified 'unixsock' obj. - * Returns 0 if the console is successfully opened; o/w, returns -1. -@@ -171,11 +173,18 @@ int open_unixsock_obj(obj_t *unixsock) - rc = disconnect_unixsock_obj(unixsock); - } - else { -- rc = connect_unixsock_obj(unixsock); -+ rc = connect_unixsock_obj_int(unixsock, reset_delay); - } - return(rc); - } - -+int open_unixsock_obj(obj_t *unixsock) { -+ return open_unixsock_obj_int(unixsock, 0); -+} -+ -+int open_unixsock_obj_reset_delay(obj_t *unixsock) { -+ return open_unixsock_obj_int(unixsock, 1); -+} - - static size_t max_unixsock_dev_strlen(void) - { -@@ -193,7 +202,7 @@ static size_t max_unixsock_dev_strlen(void) - } - - --static int connect_unixsock_obj(obj_t *unixsock) -+static int connect_unixsock_obj_int(obj_t *unixsock, int reset_delay) - { - /* Opens a connection to the specified (unixsock) obj. - * Returns 0 if the connection is successfully completed; o/w, returns -1. -@@ -257,6 +266,8 @@ static int connect_unixsock_obj(obj_t *unixsock) - (struct sockaddr *) &saddr, sizeof(saddr)) < 0) { - log_msg(LOG_INFO, "Console [%s] cannot connect to device \"%s\": %s", - unixsock->name, auxp->dev, strerror(errno)); -+ if (reset_delay) -+ reset_unixsock_delay(unixsock); - return(disconnect_unixsock_obj(unixsock)); - } - /* Write-locking the unix domain socket appears ineffective. But since -@@ -284,6 +295,9 @@ static int connect_unixsock_obj(obj_t *unixsock) - return(0); - } - -+static int connect_unixsock_obj(obj_t *unixsock) { -+ return connect_unixsock_obj_int(unixsock, 0); -+} - - static int disconnect_unixsock_obj(obj_t *unixsock) - { diff --git a/Reset-delay-for-unixsock-connect-from-inotify.patch b/Reset-delay-for-unixsock-connect-from-inotify.patch new file mode 100644 index 0000000..a4b2ada --- /dev/null +++ b/Reset-delay-for-unixsock-connect-from-inotify.patch @@ -0,0 +1,135 @@ +From: Egbert Eich +Date: Wed Jul 18 11:26:07 2018 +0200 +Subject: Reset delay for unixsock connect from inotify +Patch-mainline: Not yet +Git-repo: https://github.com/dun/conman +Git-commit: 8f5bd09162307a23efb8532a95c4e4a562ce30fe +References: bsc#1101647 + +Consoles over UNIX domain sockets use inotify to detect when their +socket appears in the filesystem. This inotify event is triggered +when the remote has successfully called bind(). However, the remote +may not have called listen() before the inotify event is serviced +by conmand. In such a case, connect() will fail with ECONNREFUSED, +after which the connection delay will be increased before the next +connection attempt. This can result in connection establishment +taking up to UNIXSOCK_MAX_TIMEOUT seconds once the socket appears. + +To handle this case, reset the connection delay to UNIXSOCK_MIN_TIMEOUT +when a connection attempt triggered by inotify fails. + +[cdunlap@llnl.gov: Restructured to use isViaInotify flag] +Signed-off-by: Egbert Eich +Signed-off-by: Chris Dunlap +Closes #28 +Closes #29 +Signed-off-by: Egbert Eich +--- + server-unixsock.c | 36 ++++++++++++++++++++++++++++++++++-- + server.h | 1 + + 2 files changed, 35 insertions(+), 2 deletions(-) +diff --git a/server-unixsock.c b/server-unixsock.c +index e683ec7..b44adb4 100644 +--- a/server-unixsock.c ++++ b/server-unixsock.c +@@ -45,6 +45,7 @@ + #include "util-str.h" + + ++static int open_unixsock_obj_via_inotify(obj_t *unixsock); + static size_t max_unixsock_dev_strlen(void); + static int connect_unixsock_obj(obj_t *unixsock); + static int disconnect_unixsock_obj(obj_t *unixsock); +@@ -140,6 +141,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, + unixsock->aux.unixsock.logfile = NULL; + unixsock->aux.unixsock.timer = -1; + unixsock->aux.unixsock.state = CONMAN_UNIXSOCK_DOWN; ++ unixsock->aux.unixsock.isViaInotify = 0; + unixsock->aux.unixsock.delay = UNIXSOCK_MIN_TIMEOUT; + /* + * Add obj to the master conf->objs list. +@@ -147,7 +149,7 @@ obj_t * create_unixsock_obj(server_conf_t *conf, char *name, char *dev, + list_append(conf->objs, unixsock); + + rv = inevent_add(unixsock->aux.unixsock.dev, +- (inevent_cb_f) open_unixsock_obj, unixsock); ++ (inevent_cb_f) open_unixsock_obj_via_inotify, unixsock); + if (rv < 0) { + log_msg(LOG_INFO, + "Console [%s] unable to register device \"%s\" for inotify events", +@@ -177,6 +179,23 @@ int open_unixsock_obj(obj_t *unixsock) + } + + ++static int open_unixsock_obj_via_inotify(obj_t *unixsock) ++{ ++/* Opens the specified 'unixsock' obj via an inotify callback. ++ * Returns 0 if the console is successfully opened; o/w, returns -1. ++ */ ++ unixsock_obj_t *auxp; ++ ++ assert(unixsock != NULL); ++ assert(is_unixsock_obj(unixsock)); ++ ++ auxp = &(unixsock->aux.unixsock); ++ auxp->isViaInotify = 1; ++ ++ return(open_unixsock_obj(unixsock)); ++} ++ ++ + static size_t max_unixsock_dev_strlen(void) + { + /* Returns the maximum string length allowed for a unix domain device. +@@ -199,6 +218,7 @@ static int connect_unixsock_obj(obj_t *unixsock) + * Returns 0 if the connection is successfully completed; o/w, returns -1. + */ + unixsock_obj_t *auxp; ++ int isViaInotify; + struct stat st; + struct sockaddr_un saddr; + size_t n; +@@ -210,6 +230,9 @@ static int connect_unixsock_obj(obj_t *unixsock) + + auxp = &(unixsock->aux.unixsock); + ++ isViaInotify = auxp->isViaInotify; ++ auxp->isViaInotify = 0; ++ + if (auxp->timer >= 0) { + (void) tpoll_timeout_cancel(tp_global, auxp->timer); + auxp->timer = -1; +@@ -250,11 +273,20 @@ static int connect_unixsock_obj(obj_t *unixsock) + set_fd_nonblocking(unixsock->fd); + set_fd_closed_on_exec(unixsock->fd); + +- /* FIXME: Check to see if connect() on a nonblocking unix domain socket ++ /* If a connect() triggered via an inotify event fails, reset the ++ * reconnect delay to its minimum to quickly re-attempt the connection. ++ * This handles the case where the remote has successfully called bind() ++ * (triggering the inotify event) but has not yet called listen(). ++ * FIXME: Check to see if connect() on a nonblocking unix domain socket + * can return EINPROGRESS. I don't think it can. + */ + if (connect(unixsock->fd, + (struct sockaddr *) &saddr, sizeof(saddr)) < 0) { ++ if (isViaInotify) { ++ auxp->delay = UNIXSOCK_MIN_TIMEOUT; ++ DPRINTF((15, "Reset [%s] reconnect delay due to inotify event\n", ++ unixsock->name)); ++ } + log_msg(LOG_INFO, "Console [%s] cannot connect to device \"%s\": %s", + unixsock->name, auxp->dev, strerror(errno)); + return(disconnect_unixsock_obj(unixsock)); +diff --git a/server.h b/server.h +index 8ccbcf9..6cc7c1b 100644 +--- a/server.h ++++ b/server.h +@@ -180,6 +180,7 @@ typedef struct unixsock_obj { /* UNIXSOCK AUX OBJ DATA: */ + int timer; /* timer id for reconnects */ + int delay; /* secs 'til next reconnect attempt */ + unsigned state:1; /* unixsock_state_t conn state */ ++ unsigned isViaInotify:1; /* true if triggered via inotify */ + } unixsock_obj_t; + + /* Refer to struct ipmiconsole_ipmi_config in . diff --git a/conman.changes b/conman.changes index 420bb4c..e868048 100644 --- a/conman.changes +++ b/conman.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Aug 23 09:48:06 UTC 2018 - eich@suse.com + +- Replace + If-connect-fails-let-other-side-accept-connection-and-come-back.patch + by: + Reset-delay-for-unixsock-connect-from-inotify.patch: + Upstream chose to fix bsc#1101647 slightly differently. + ------------------------------------------------------------------- Wed Jul 18 13:08:03 UTC 2018 - eich@suse.com diff --git a/conman.spec b/conman.spec index ca90bbc..f064539 100644 --- a/conman.spec +++ b/conman.spec @@ -69,7 +69,7 @@ Requires(pre): shadow %endif Patch1: conman-suse-fix-expect-scripts.patch -Patch2: If-connect-fails-let-other-side-accept-connection-and-come-back.patch +Patch2: Reset-delay-for-unixsock-connect-from-inotify.patch # 8/15/14 karl.w.schulz@intel.com - include prereq %if 0%{?sles_version} || 0%{?suse_version} From 033dc54768f024ece46380546cd4901955bde0e10a99a13265542b05eebc48b8 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Thu, 23 Aug 2018 10:26:18 +0000 Subject: [PATCH 2/2] - Update to version 0.2.9: - Allowed IPMI defaults to be overridden via libipmiconsole.conf. (#27) - Updated recognized strings for IPMI workaround-flags (FATE#326641). OBS-URL: https://build.opensuse.org/package/show/network:cluster/conman?expand=0&rev=30 --- conman-0.2.8.tar.gz | 3 --- conman-0.2.9.tar.gz | 3 +++ conman.changes | 7 +++++++ conman.spec | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) delete mode 100644 conman-0.2.8.tar.gz create mode 100644 conman-0.2.9.tar.gz diff --git a/conman-0.2.8.tar.gz b/conman-0.2.8.tar.gz deleted file mode 100644 index e8ac1f3..0000000 --- a/conman-0.2.8.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7e2a4b6a48e09afd51e451729a48217e6b5b55d2087b7fcb545ee4b755dba224 -size 239757 diff --git a/conman-0.2.9.tar.gz b/conman-0.2.9.tar.gz new file mode 100644 index 0000000..8f345c2 --- /dev/null +++ b/conman-0.2.9.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f9a3dbd628eb6642a3907e448147180488898e0b0acf6b7d6daec000ccc76b5 +size 240521 diff --git a/conman.changes b/conman.changes index e868048..0d4d759 100644 --- a/conman.changes +++ b/conman.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Aug 23 10:01:18 UTC 2018 - eich@suse.com + +- Update to version 0.2.9: + - Allowed IPMI defaults to be overridden via libipmiconsole.conf. (#27) + - Updated recognized strings for IPMI workaround-flags (FATE#326641). + ------------------------------------------------------------------- Thu Aug 23 09:48:06 UTC 2018 - eich@suse.com diff --git a/conman.spec b/conman.spec index f064539..a3a4d0e 100644 --- a/conman.spec +++ b/conman.spec @@ -44,7 +44,7 @@ %endif Name: conman -Version: 0.2.8 +Version: 0.2.9 Release: 0 Summary: The Console Manager