[ad_1]
I’m trying to open several sockets to listen on the same IPv4 multicast IP+port, but incoming datagrams seem to always be delivered to the first one rather than to the one for the appropriate interface.
strace -e bind,recvfrom,setsockopt
:
setsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(6, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(6, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
setsockopt(6, SOL_IP, IP_ADD_MEMBERSHIP, {imr_multiaddr=inet_addr("224.0.0.251"), imr_interface=inet_addr("10.7.5.80")}, 8) = 0
setsockopt(8, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(8, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(8, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
setsockopt(8, SOL_IP, IP_ADD_MEMBERSHIP, {imr_multiaddr=inet_addr("224.0.0.251"), imr_interface=inet_addr("192.168.0.2")}, 8) = 0
recvfrom(6, "\0\0\0\0\0\1\0\0\0\0\0\0\v_googlecast\4_tcp\5lo"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 40
recvfrom(6, "\0\0\0\0\0\1\0\0\0\0\0\0001google-home-mini-e3"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 90
recvfrom(6, "\0\0\204\0\0\0\0\1\0\0\0\3\v_googlecast\4_tcp\5lo"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 379
recvfrom(6, "\0\0\204\0\0\0\0\1\0\0\0\0011Google-Home-Mini-e3"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 157
recvfrom(6, "\0\0\0\0\0\1\0\0\0\0\0\0\v_googlezone\4_tcp\5lo"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 40
recvfrom(6, "\0\0\0\0\0\1\0\0\0\0\0\0$e35c8e4c-ca53-508e-"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 77
recvfrom(6, "\0\0\204\0\0\0\0\1\0\0\0\3\v_googlezone\4_tcp\5lo"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 214
recvfrom(6, "\0\0\204\0\0\0\0\1\0\0\0\1$e35c8e4c-ca53-508e-"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.137")}, [128 => 16]) = 144
recvfrom(6, "\0\0\204\0\0\0\0\2\0\0\0\0\t_services\7_dns-sd\4_"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.9")}, [128 => 16]) = 88
recvfrom(6, "\0\0\204\0\0\0\0\f\0\0\0\0\3t60\5local\0\0\34\200\1\0\0\0\0\0"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.204")}, [128 => 16]) = 360
recvfrom(6, "\0\0\0\0\0\1\0\0\0\0\0\0\r_water-cooler\4_tcp\5"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(5353), sin_addr=inet_addr("192.168.0.204")}, [128 => 16]) = 42
+++ exited with 1 +++
Note how the packets are from the 192.168.0.0/24
network, but delivered on the socket with an imr_interface
on the 10.10.0.0/16
network.
Is there something else that I’m supposed to do to ensure that packets only arrive on the appropriate socket?
[ad_2]