Com: clear IP_MULTICAST_ALL on Linux
The default, non-compliant, behavior will pass all multicast packets to any socket bound to 0.0.0.0 or the mcast address, regardless of which groups, on which interfaces, that socket has joined.
This commit is contained in:
@@ -99,6 +99,22 @@ LIBCOM_API SOCKET epicsStdCall epicsSocketCreate (
|
||||
close ( sock );
|
||||
sock = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
# ifndef IP_MULTICAST_ALL
|
||||
# define IP_MULTICAST_ALL 49
|
||||
# endif
|
||||
/* Enable compliant filtering of multicasts on Linux. cf. 'man 7 ip' */
|
||||
if(domain==AF_INET && type==SOCK_DGRAM){
|
||||
static int logged;
|
||||
int val = 0;
|
||||
if(setsockopt(sock, IPPROTO_IP, IP_MULTICAST_ALL, (char*)&val, sizeof(val)) && !logged) {
|
||||
logged = 1;
|
||||
errlogPrintf("Warning: Unable to clear IP_MULTICAST_ALL (err=%d). This may cause problems on multi-homed hosts.\n",
|
||||
SOCKERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return sock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user