mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-15 07:14:49 +02:00
Add socket option BINDTODEVICE
Linux now supports Virtual Routing and Forwarding (VRF) as per: https://www.kernel.org/doc/Documentation/networking/vrf.txt In order for an application to bind or connect to a socket with an address in a VRF, they need to first bind the socket to the VRF device: setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1); Note "dev" is the VRF device, eg. VRF "blue", rather than an interface enslaved to the VRF. Add a new socket option, ZMQ_BINDTODEVICE, to bind a socket to a device. In general, if a socket is bound to a device, eg. an interface, only packets received from that particular device are processed by the socket. If device is a VRF device, then subsequent binds/connects to that socket use addresses in the VRF routing table.
This commit is contained in:
@@ -305,6 +305,10 @@ int zmq::tcp_connecter_t::open ()
|
||||
if (options.tos != 0)
|
||||
set_ip_type_of_service (s, options.tos);
|
||||
|
||||
// Bind the socket to a device if applicable
|
||||
if (!options.bound_device.empty ())
|
||||
bind_to_device (s, options.bound_device);
|
||||
|
||||
// Set the socket to non-blocking mode so that we get async connect().
|
||||
unblock_socket (s);
|
||||
|
||||
|
Reference in New Issue
Block a user