net: implemented SO_REUSEPORT support on UDP

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
This commit is contained in:
Takuya ASADA
2015-01-16 00:17:49 +09:00
committed by Avi Kivity
parent ae64fe7d6c
commit bbe4d3b7d6

View File

@@ -221,6 +221,9 @@ public:
auto sa = make_ipv4_address(bind_address);
file_desc fd = file_desc::socket(sa.u.sa.sa_family, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
fd.setsockopt(SOL_IP, IP_PKTINFO, true);
if (engine.posix_reuseport_available()) {
fd.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1);
}
fd.bind(sa.u.sa, sizeof(sa.u.sas));
_address = ipv4_addr(fd.get_address());
_fd = std::make_unique<pollable_fd>(std::move(fd));