Skip to content

inet:setopts/2 return 'ok' for add_membership and multicast_if even if IfAddress is not avail #7916

Closed
@miaxon

Description

@miaxon

Describe the bug
inet:setpopts/2 return ok when {error, Error} expected.

To Reproduce
In erlang shell try set multicat_if option with unavail address:

1> {ok, S} = gen_udp:open(0).
{ok,#Port<0.4>}
2> inet:setopts(S, [{multicast_if, {1,2,3,4}}]).
ok

Expected behavior
Expected return {error, eaddrnotavail}

Affected versions
26.1.2

Additional context
Debug output:

1> {ok, S} = gen_udp:open(0).
INET-DRV-DBG[10723][-1,<0.86.0>] inet_ctl -> SETOPTS
INET-DRV-DBG[13970][<0.86.0>] packet_inet_ctl -> OPEN
INET-DRV-DBG[10723][19,<0.86.0>] inet_ctl -> SETOPTS
INET-DRV-DBG[6795][19,<0.86.0>] inet_set_opts -> opt: 7
INET-DRV-DBG[7177][19,<0.86.0>] inet_set_opts(rcvbuf) -> 8192
INET-DRV-DBG[7673][19,<0.86.0>] inet_set_opts -> try set opt (1) 8
inet_setopt -> try trick setopt with
   fd:        19
   proto:     1
   type:      8
   sz:        4
   propagate: 0
INET-DRV-DBG[7680][19,<0.86.0>] inet_set_opts -> set opt result: 0
INET-DRV-DBG[6795][19,<0.86.0>] inet_set_opts -> opt: 22
INET-DRV-DBG[6839][19,<0.86.0>] inet_set_opts(active) -> active (ival): active (1)
(drivers/common/inet_drv.c / 7718) sock_select(0x000055f2fe967f60): flags=01, onoff=1, event_mask=01
INET-DRV-DBG[11023][19,<0.86.0>] inet_ctl -> BIND
{ok,#Port<0.4>}

2> inet:setopts(S, [{multicast_if, {1,2,3,4}}]).
INET-DRV-DBG[10723][19,<0.86.0>] inet_ctl -> SETOPTS
INET-DRV-DBG[6795][19,<0.86.0>] inet_set_opts -> opt: 11
INET-DRV-DBG[7376][19,<0.86.0>] inet_set_opts(multicast-if) -> 16909060 (67305985)
inet_set_opts(0x000055f2fe967f60): s=19, IP_MULTICAST_IF = 1020304
INET-DRV-DBG[7673][19,<0.86.0>] inet_set_opts -> try set opt (0) 32
inet_setopt -> try trick setopt with
   fd:        19
   proto:     0
   type:      32
   sz:        4
   propagate: 0
INET-DRV-DBG[7680][19,<0.86.0>] inet_set_opts -> set opt result: -1
ok

inet_set_opts return -1, but inet:setopts/2 return ok.

strace :

[pid 58502] getsockopt(19, SOL_SOCKET, SO_PRIORITY, [0], [4]) = 0
[pid 58502] getsockopt(19, SOL_IP, IP_TOS, [0], [4]) = 0
[pid 58502] setsockopt(19, SOL_SOCKET, SO_RCVBUF, [8192], 4) = 0
[pid 58502] setsockopt(19, SOL_IP, IP_TOS, [0], 4) = 0
[pid 58502] setsockopt(19, SOL_SOCKET, SO_PRIORITY, [0], 4) = 0
[pid 58502] bind(19, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
[pid 58502] getsockname(19, {sa_family=AF_INET, sin_port=htons(42147), sin_addr=inet_addr("0.0.0.0")}, [112 => 16]) = 0
[pid 58502] getsockopt(19, SOL_SOCKET, SO_PRIORITY, [0], [4]) = 0
[pid 58502] getsockopt(19, SOL_IP, IP_TOS, [0], [4]) = 0
[pid 58502] setsockopt(19, SOL_IP, IP_MULTICAST_IF, [67305985], 4) = -1 EADDRNOTAVAIL (Cannot assign requested address)

Metadata

Metadata

Labels

bugIssue is reported as a bugteam:PSAssigned to OTP team PS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions