Fixes problem with RIP on multiple ifaces on BSD.
RIP sockets for multiple ifaces collided, because we cannot bind to a specific iface on BSD. Workarounded by SO_REUSEPORT. Thanks to Eugene M. Zheganin for the bugreport.
This commit is contained in:
parent
548c329cde
commit
8931425d02
3 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
#define CONFIG_MULTIPLE_TABLES
|
#define CONFIG_MULTIPLE_TABLES
|
||||||
|
|
||||||
#define CONFIG_SKIP_MC_BIND
|
#define CONFIG_SKIP_MC_BIND
|
||||||
|
#define CONFIG_NO_IFACE_BIND
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Link: sysdep/unix
|
Link: sysdep/unix
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define CONFIG_MULTIPLE_TABLES
|
#define CONFIG_MULTIPLE_TABLES
|
||||||
|
|
||||||
#define CONFIG_SKIP_MC_BIND
|
#define CONFIG_SKIP_MC_BIND
|
||||||
|
#define CONFIG_NO_IFACE_BIND
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Link: sysdep/unix
|
Link: sysdep/unix
|
||||||
|
|
|
@ -1181,6 +1181,15 @@ sk_open(sock *s)
|
||||||
port = s->sport;
|
port = s->sport;
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
|
||||||
ERR("SO_REUSEADDR");
|
ERR("SO_REUSEADDR");
|
||||||
|
|
||||||
|
#ifdef CONFIG_NO_IFACE_BIND
|
||||||
|
/* Workaround missing ability to bind to an iface */
|
||||||
|
if ((type == SK_UDP) && s->iface && ipa_zero(s->saddr))
|
||||||
|
{
|
||||||
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
|
||||||
|
ERR("SO_REUSEPORT");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
fill_in_sockaddr(&sa, s->saddr, s->iface, port);
|
fill_in_sockaddr(&sa, s->saddr, s->iface, port);
|
||||||
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0)
|
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0)
|
||||||
|
|
Loading…
Reference in a new issue