Skip to content

Commit

Permalink
Disallow configuring scope on IPv4 sockets
Browse files Browse the repository at this point in the history
The new 'tconnect' module failed to maintain legacy semantics in
regards to scope usage configuration on IPv4 sockets.

Signed-off-by: Mattias Rönnblom <[email protected]>
  • Loading branch information
m-ronnblom committed Jul 31, 2023
1 parent fb78c1c commit f7a6c2c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libxcm/tp/tcp/tconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ static int tconnect_connect_happy(struct tconnect *tconnect,
struct track *track4 = NULL;

if (has_ipv4) {
track4 = track_create(tconnect->fd4, -1, local_ip, local_port, scope,
track4 = track_create(tconnect->fd4, -1, local_ip, local_port, -1,
tcp_connect_timeout, tcp_opts, remote_ips,
num_remote_ips, remote_port, initial_ipv4_delay,
tconnect->timer_mgr, tconnect->xpoll,
Expand Down Expand Up @@ -497,6 +497,18 @@ static int tconnect_connect_sequential(struct tconnect *tconnect,
return 0;
}

/* For historical reasons, disallow link-local scope configuration in
cases where a single IPv4 address is provided */
static int check_scope_conf(int64_t scope, const struct xcm_addr_ip *remote_ips,
size_t num_remote_ips)
{
if (scope >= 0 && num_remote_ips == 1 && remote_ips[0].family == AF_INET) {
errno = EINVAL;
return -1;
}
return 0;
}

int tconnect_connect(struct tconnect *tconnect,
const struct xcm_addr_ip *local_ip,
uint16_t local_port, int64_t scope,
Expand All @@ -507,6 +519,9 @@ int tconnect_connect(struct tconnect *tconnect,
{
ut_assert(num_remote_ips > 0);

if (check_scope_conf(scope, remote_ips, num_remote_ips) < 0)
return -1;

switch (tconnect->algorithm) {
case tconnect_algorithm_single:
return tconnect_connect_sequential(tconnect, local_ip, local_port,
Expand Down

0 comments on commit f7a6c2c

Please sign in to comment.