udp: Use the bind to device socket option.
Without this Linux specific option, multicast packets arrive on one interface are delivered by the kernel to all others. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
95d5c36c0f
commit
347b42b7d5
4
udp.c
4
udp.c
|
@ -195,6 +195,10 @@ static int open_socket(char *name, struct in_addr *mc_addr, short port)
|
|||
pr_err("bind failed: %m");
|
||||
goto no_option;
|
||||
}
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name))) {
|
||||
pr_err("setsockopt SO_BINDTODEVICE failed: %m");
|
||||
goto no_option;
|
||||
}
|
||||
addr.sin_addr = *mc_addr;
|
||||
if (mcast_join(fd, index, (struct sockaddr *) &addr, sizeof(addr))) {
|
||||
pr_err("mcast_join failed");
|
||||
|
|
Loading…
Reference in New Issue