Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 4/5] swim: allow to omit host in URI
Date: Wed,  1 May 2019 01:31:26 +0300	[thread overview]
Message-ID: <6dcbe9a1f1efbc07092109336427520109f1e3a3.1556663421.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1556663421.git.v.shpilevoy@tarantool.org>

Before the patch swim.cfg() was returning an error on an attempt
to use URI like 'port', without a host. But it would be useful,
easy, and short to allow that, and use '127.0.0.1' host by
default. Compare:

    swim:cfg({uri = 1234})
            vs
    swim:cfg({uri = '127.0.0.1:1234'})

It is remarkable that box.cfg{listen} also allows to omit host.

Note, that use '0.0.0.0' (INADDR_ANY) is forbidden. Otherwise

    1) Different instances interacting with this one via not the
       same interfaces would see different source IP addresses.
       It would mess member tables;

    2) This instance would not be able to encode its IP address
       in the meta section, because it has no a fixed IP. At the
       same time omission of it and usage of UDP header source
       address is not possible as well, because UDP header is not
       encrypted and therefore is not safe to look at.

Part of #3234
---
 src/lib/swim/swim.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index 22dfc3d2a..b2b4901b1 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -1696,7 +1696,9 @@ swim_uri_to_addr(const char *uri, struct sockaddr_in *addr,
 		return -1;
 	}
 	*addr = *((struct sockaddr_in *) &storage);
-	if (addr->sin_addr.s_addr == 0) {
+	if (is_host_empty) {
+		addr->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+	} else if (addr->sin_addr.s_addr == 0) {
 		diag_set(IllegalParams, "%s INADDR_ANY is not supported",
 			 prefix);
 		return -1;
-- 
2.20.1 (Apple Git-117)

  parent reply	other threads:[~2019-04-30 22:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 22:31 [tarantool-patches] [PATCH 0/5] swim lua preparation Vladislav Shpilevoy
2019-04-30 22:31 ` [tarantool-patches] [PATCH 1/5] swim: do not use ev_timer_start Vladislav Shpilevoy
2019-05-01  5:09   ` [tarantool-patches] " Konstantin Osipov
2019-04-30 22:31 ` [tarantool-patches] [PATCH 2/5] swim: introduce member reference API Vladislav Shpilevoy
2019-05-01  5:15   ` [tarantool-patches] " Konstantin Osipov
2019-05-02 15:10     ` Vladislav Shpilevoy
2019-05-02 15:46       ` Konstantin Osipov
2019-05-02 17:32         ` Vladislav Shpilevoy
2019-04-30 22:31 ` [tarantool-patches] [PATCH 3/5] sio: return 'no host' flag from sio_uri_to_addr() Vladislav Shpilevoy
2019-05-01  5:18   ` [tarantool-patches] " Konstantin Osipov
2019-04-30 22:31 ` Vladislav Shpilevoy [this message]
2019-05-01  5:20   ` [tarantool-patches] Re: [PATCH 4/5] swim: allow to omit host in URI Konstantin Osipov
2019-05-02 15:10     ` Vladislav Shpilevoy
2019-04-30 22:31 ` [tarantool-patches] [PATCH 5/5] swim: explicitly stop old ev_io input/output on rebind Vladislav Shpilevoy
2019-05-01  5:21   ` [tarantool-patches] " Konstantin Osipov
2019-05-02 17:32 ` [tarantool-patches] Re: [PATCH 0/5] swim lua preparation Vladislav Shpilevoy

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=6dcbe9a1f1efbc07092109336427520109f1e3a3.1556663421.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 4/5] swim: allow to omit host in URI' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox