Skip to content

Replication and net box interface bind#11984

Merged
locker merged 4 commits intotarantool:masterfrom
mkostoevr:m.kostoev/gh-11803-replication-and-net-box-interface-bind
Nov 18, 2025
Merged

Replication and net box interface bind#11984
locker merged 4 commits intotarantool:masterfrom
mkostoevr:m.kostoev/gh-11803-replication-and-net-box-interface-bind

Conversation

@mkostoevr
Copy link
Contributor

Closes #11803

@mkostoevr mkostoevr changed the title M.kostoev/gh 11803 replication and net box interface bind Replication and net box interface bind Oct 27, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch from a804682 to 9eb25b3 Compare October 27, 2025 08:50
@mkostoevr mkostoevr self-assigned this Oct 27, 2025
@coveralls
Copy link

coveralls commented Oct 27, 2025

Coverage Status

coverage: 87.643% (+0.003%) from 87.64%
when pulling ed205fc on mkostoevr:m.kostoev/gh-11803-replication-and-net-box-interface-bind
into cc77a6e
on tarantool:master
.

It's been used by the applier originally, but in commit 0486a48
("replication: add remote peer connection timeout"), the function is
only used in the coio test. Let's drop it completely and rename the
`coio_connect_timeout` to `coio_connect`.

Follows-up tarantool#8380

NO_DOC=refactoring
NO_CHANGELOG=refactoring
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch 6 times, most recently from 0122c9f to 1f015be Compare November 11, 2025 16:42
@mkostoevr mkostoevr added the asan-ci Enables asan build tests for a pull request label Nov 11, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch from 1f015be to 20763b4 Compare November 12, 2025 07:16
@mkostoevr mkostoevr removed the asan-ci Enables asan build tests for a pull request label Nov 12, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch 6 times, most recently from 3aac458 to 58d0185 Compare November 12, 2025 12:21
@mkostoevr mkostoevr marked this pull request as ready for review November 12, 2025 12:23
@mkostoevr mkostoevr requested a review from a team as a code owner November 12, 2025 12:23
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch 2 times, most recently from b7f818e to 1568bf4 Compare November 12, 2025 15:27
@mkostoevr mkostoevr requested a review from locker November 12, 2025 16:21
@mkostoevr mkostoevr assigned locker and unassigned mkostoevr Nov 13, 2025
@locker locker assigned mkostoevr and unassigned locker Nov 13, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch from 1568bf4 to 89c82ba Compare November 17, 2025 06:57
@mkostoevr mkostoevr assigned locker and unassigned mkostoevr Nov 17, 2025
@locker locker assigned mkostoevr and unassigned locker Nov 17, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch from 89c82ba to 883beff Compare November 17, 2025 14:32
@mkostoevr mkostoevr assigned locker and unassigned mkostoevr Nov 17, 2025
@locker locker assigned mkostoevr and unassigned locker Nov 17, 2025
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch 2 times, most recently from c0636e7 to 5fab610 Compare November 17, 2025 16:24
@mkostoevr mkostoevr added the full-ci Enables all tests for a pull request label Nov 17, 2025
The parameter allows to specify the `src` field of packets sent using
the connection.

Needed for tarantool#11803

NO_DOC=internal
NO_CHANGELOG=internal
Part of tarantool#11803

@TarantoolBot document
Title: introduced the `interface` URI param support in `replication`

Now a URI passed to the `box.cfg.replication` can contain `interface`
parameter specifying the name of the interface to bind the connection
to the URI to.

Examples of the `box.cfg.replication` value:
- `{uri1, params = {interface = 'enp0s31f6'}}`
- `{uri1, uri2, default_params = {interface = 'enp0s31f6'}}`
- ```
  {
    uri1, {uri2, params = {interface = 'wlp0s20f3'}}, uri3,
    default_params = {interface = 'enp0s31f6'}
  }
  ```
Closes tarantool#11803

@TarantoolBot document
Title: `interface` URI parameter support in `net.box.connect`

Now a URI passed to the `net.box.connect` can contain the `interface`
param specifying the name of the interface to bind the connection to.
Example: `net_box.connect({3301, params = {interface = 'lo'}})`.
@mkostoevr mkostoevr force-pushed the m.kostoev/gh-11803-replication-and-net-box-interface-bind branch from 5fab610 to ed205fc Compare November 17, 2025 16:31
@mkostoevr
Copy link
Contributor Author

Updated the changelogs, actualized the coio_bind_iface function comment and moved a variable.

diff
diff --git a/changelogs/unreleased/gh-11803-uri-interface-option-in-box-cfg-replication.md b/changelogs/unreleased/gh-11803-uri-interface-option-in-box-cfg-replication.md
index 5b23121e98..8520d5c790 100644
--- a/changelogs/unreleased/gh-11803-uri-interface-option-in-box-cfg-replication.md
+++ b/changelogs/unreleased/gh-11803-uri-interface-option-in-box-cfg-replication.md
@@ -1,5 +1,5 @@
 ## feature/box
 
-* Now the `interface` parameter can be used in `box.cfg.replication` URIs.
-  It allows to specify the interface to bind the connections to a URI to
+* The `interface` parameter can now be used in `box.cfg.replication` URIs.
+  It allows specifying the network interface to bind to for URI connections
   (gh-11803).
diff --git a/src/lib/core/coio.c b/src/lib/core/coio.c
index 3729bbb0db..446bcf629d 100644
--- a/src/lib/core/coio.c
+++ b/src/lib/core/coio.c
@@ -81,7 +81,8 @@ ipv6_scope(const struct sockaddr *addr)
 
 /**
  * Bind the given socket fd stream to the given interface (by name). The
- * bind parameters are selected based on the given destination address.
+ * interface IP is selected based on the given address family and IPv6
+ * scope (if the address family is IPv6).
  *
  * @retval 0 success
  * @retval -1 error
@@ -115,8 +116,6 @@ coio_bind_iface(int fd, const char *ifname, int remote_af,
                        sin->sin_port = htons(0); /* Bind to any port. */
                } else {
                        assert(remote_af == AF_INET6);
-                       struct sockaddr_in6 *sin6 =
-                               (struct sockaddr_in6 *)iface->ifa_addr;
                        /*
                         * We are interested only in interface addresses whose
                         * scope matches the remote address we want to connect
@@ -133,6 +132,8 @@ coio_bind_iface(int fd, const char *ifname, int remote_af,
                         * to specify an IPv6 address with a zone ID specified
                         * in Tarantool (see the URI parser in src/lib/uri).
                         */
+                       struct sockaddr_in6 *sin6 =
+                               (struct sockaddr_in6 *)iface->ifa_addr;
                        bind_addr_len = sizeof(*sin6);
                        bind_addr = iface->ifa_addr;
                        sin6->sin6_port = htons(0); /* Bind to any port. */

@mkostoevr mkostoevr assigned locker and unassigned mkostoevr Nov 18, 2025
@locker locker merged commit 5528ca2 into tarantool:master Nov 18, 2025
44 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Enables all tests for a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to set a specific interface for outgoing replication/net.box connections

4 participants