mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 07:56:09 +00:00
Make ZMQ_TOS work with IPv6 sockets
Summary: To set `Type Of Service` for IP layer packets ZMQ provides `ZMQ_TOS` socket option. However this only works for v4 sockets. Considering things are moving to IPv6 heavily (especially within enterprise networks), ZMQ should support setting `traffic class` for v6 based on `ZMQ_TOS`. There is a subtle difference between v4 and v6 in terms of the positioning of field but TOS has same meaning in both v4 and v6. Linux provides following APIs for v4/v6 to set TOS field value. ``` // For v4 setsockopt(fd, IPPROTO_IP, IP_TOS, tos, sizeof(tos)); // For v6 setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, tos, sizeof(tos)); ``` Test Plan: Make sure Cmake works fine and all tests passes. Imported this change to `OpenR` project and tested on our local testbed. Captured some packets exchanged between PUB/SUB and ROUTER/ROUTER sockets pairs. Verify that `TCLASS` value is set as per expectation. Tasks: #2208
This commit is contained in:
parent
8ac7500f9d
commit
fc8007e896
13
src/ip.cpp
13
src/ip.cpp
@ -167,6 +167,19 @@ void zmq::set_ip_type_of_service (fd_t s_, int iptos)
|
|||||||
{
|
{
|
||||||
int rc = setsockopt(s_, IPPROTO_IP, IP_TOS, reinterpret_cast<const char*>(&iptos), sizeof(iptos));
|
int rc = setsockopt(s_, IPPROTO_IP, IP_TOS, reinterpret_cast<const char*>(&iptos), sizeof(iptos));
|
||||||
|
|
||||||
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
|
#else
|
||||||
|
errno_assert (rc == 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rc = setsockopt(
|
||||||
|
s_,
|
||||||
|
IPPROTO_IPV6,
|
||||||
|
IPV6_TCLASS,
|
||||||
|
reinterpret_cast<const char*>(&iptos),
|
||||||
|
sizeof(iptos));
|
||||||
|
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user