Commit Graph

5813 Commits

Author SHA1 Message Date
Luca Boccassi
a34adbf474 Merge pull request #2640 from brianbalerno/vrf
Add socket option BINDTODEVICE
2017-07-31 15:58:56 +01:00
Brian Russell
b963542e8f 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.
2017-07-31 15:31:47 +01:00
Constantin Rack
4a37ce9aeb Merge pull request #2636 from bluca/tweetnacl_fd
Problem: tweetnacl on *nix use of /dev/urandom is not thread safe
2017-07-28 17:04:54 +02:00
Luca Boccassi
fbb6bbdcb8 Problem: reading from /dev/urandom is clunky
Solution: if available use the getrandom function as it doesn't
require any synchronization, state or cleanup
2017-07-28 11:28:19 +01:00
Luca Boccassi
2626fdfa23 Problem: tweetnacl leaks file descriptor on fork+exec
Solution: open with O_CLOEXEC if available or set FD_CLOEXEC if not
2017-07-28 11:27:55 +01:00
Luca Boccassi
e015a0f8b9 Problem: fd leak in tweetnacl with one ctx per thread
Solution: add a crypto [de-]initialiser, refcounted and serialised
through critical sections.
This is necessary as utility APIs such as zmq_curve_keypair also
call into the sodium/tweetnacl libraries and need the initialisation
outside of the zmq context.
Also the libsodium documentation explicitly says that sodium_init
must not be called concurrently from multiple threads, which could
have happened until now. Also the randombytes_close function does
not appear to be thread safe either.
This change guarantees that the library is initialised only once at
any given time across the whole program.
Fixes #2632
2017-07-28 11:27:53 +01:00
Luca Boccassi
a7bf010ee2 Problem: misleading indentation in tweetnacl.c
Solution: fix it
2017-07-27 21:04:43 +01:00
Luca Boccassi
2991e6f602 Merge pull request #2633 from pavel-pimenov/fix-C4324
Suppress C4324 (VC++2017)
2017-07-27 10:10:03 +01:00
pavel.pimenov
dfd9d48496 Suppress C4324 (VC++2017)
'zmq::command_t': structure was padded due to alignment specifier
https://msdn.microsoft.com/en-us/library/92fdk6xx.aspx
2017-07-27 07:06:19 +03:00
Constantin Rack
a537ace084 Merge pull request #2631 from ecoughlan/skip_invalid_setsockopt
Don't try to set IPV6_V6ONLY on OpenBSD
2017-07-22 23:16:28 +02:00
Eamonn Coughlan
cfb59dde21 Problem: can't set IPV6_V6ONLY on OpenBSD
Solution: skip setsockopt call resulting in EINVAL
2017-07-22 22:53:12 +02:00
Constantin Rack
b2c4dad46e Merge pull request #2626 from minrk/relicense
RELICENSE: minrk
2017-07-17 14:01:26 +02:00
Min RK
01f29ed8b9 add license grant for minrk 2017-07-17 13:57:53 +02:00
Constantin Rack
e1dfb2e337 Merge pull request #2625 from trofi/master
configure.ac: allow user to disable libunwind discovery via --disable-libunwind
2017-07-14 23:14:54 +02:00
Sergei Trofimovich
88487e7da3 configure.ac: allow user to disable libunwind discovery via --disable-libunwind
on ia64 architecture libunwind comes with gcc. Unfortunately
libunwind is not directly usable as-is and fails at link time:

```
    ia64-unknown-linux-gnu-g++ -o perf/.libs/local_lat perf/local_lat.o src/.libs/libzmq.so -lsodium -lrt -lpthread -ldl
    src/.libs/libzmq.so: undefined reference to `_ULia64_step'
```

The change adds --{enable,disable}-libunwind flag to control
automatic dependency. The default is unchanged: use if available.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2017-07-14 21:44:30 +01:00
Luca Boccassi
dfcf396ded Merge pull request #2624 from msune/master
Problem: adapt, clarify docs ZMQ_ROUTER_MANDATORY
2017-07-14 17:53:55 +01:00
Marc Sune
609c131249 Problem: adapt, clarify docs ZMQ_ROUTER_MANDATORY
Solution:

* Document the new behaviour when generating 'ZMQ_POLLOUT' events
  for ZMQ_ROUTER sockets with 'ZMQ_ROUTER_MANDATORY' set to `1`
* Add clarifications for 'ZMQ_ROUTER' socket when
  'ZMQ_ROUTER_MANDATORY' is set to `1`
2017-07-14 18:49:14 +02:00
Luca Boccassi
bba4a93727 Merge pull request #2622 from msune/master
Fix ROUTER's xhas_out() in MANDATORY mode
2017-07-14 15:48:37 +01:00
Marc Sune
b7b89a8f60 Fix ROUTER's xhas_out() in MANDATORY mode
Before this commit, xhas_out() was returning true regardless. This
was correct before the ZMQ_ROUTER_MANDATORY flag as introduced.
However, ZMQ_POLLOUT.

With this commit, _if_ ZMQ_ROUTER_MANDATORY is set, xhas_out() will
return false if ALL peer's outgoing pipes are full.

There is an outstanding high-level design question:

If ZMQ_ROUTER_MANDATORY is set, and zmq_poll() waits for ZMQ_POLLOUT
events, zmq_poll() will immediately wake up if only 1 pipe has
room to send, regardless of the peer, creating a busy loop of
zmq_poll() wake-up, zmq_send() (EAGAIN). There is no way for
the application to selectively wait for ZMQ_POLLOUT for specific
peer(s), which seems somehow necessary in ZMQ_ROUTER_MANDATORY.

This discussion will be addressed in a separate issue.

Signed-off-by: Marc Sune <marc@voltanet.io>
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2017-07-14 15:55:58 +02:00
Doron Somech
30ab0ed897 Merge pull request #2615 from bluca/curve_server_reconnect
Problem: CURVE server (connect) fails when client rebinds
2017-07-01 20:54:32 +03:00
Luca Boccassi
d04065b778 Problem: CURVE server (connect) fails when client rebinds
Solution: if a CURVE server is using zmq_connect, the same session
will be used for any client "reconnect" (actual binds). This is
acceptable, so do not assert if zap_pipe already exists during the
handshake, but simply reuse it.
Fixes #2608
2017-07-01 17:37:07 +01:00
Constantin Rack
4e6c89e3cd Merge pull request #2613 from mattconnolly/relicense
RELICENSE: Matt Connolly
2017-06-29 08:04:24 +02:00
Matt Connolly
1d17182799 RELICENSE: Matt Connolly
Refs #2376
2017-06-28 22:51:24 -07:00
Luca Boccassi
35cd0245c9 Merge pull request #2610 from bjovke/my_work_2
Problem: When using print_backtrace() on Linux with libunwind, printout of stack traces from multiple threads are interleaved. Solution: added static mutex to serialize printing of stack traces.
2017-06-27 21:05:48 +01:00
Luca Boccassi
33038da522 Merge pull request #2609 from bjovke/my_work
Problem: intermittent memory leak for req/rep send/recv. #2602 Solution: memory leak fixed.
2017-06-27 20:13:28 +01:00
bjovke
9ef34addb8 Problem: When using print_backtrace() on Linux with libunwind, printout of stack traces from multiple threads are interleaved. Solution: added static mutex to serialize printing of stack traces. 2017-06-27 20:29:08 +02:00
bjovke
69355730a4 Problem: intermittent memory leak for req/rep send/recv. #2602 Solution: memory leak fixed. 2017-06-27 20:15:08 +02:00
Constantin Rack
a3550e6104 Merge pull request #2605 from emanuelkoczwara/master
Update zmq.txt
2017-06-23 19:02:09 +02:00
Emanuel Koczwara
cb54a6b24a Update zmq.txt
Fixed minor typo.
2017-06-23 18:57:33 +02:00
Doron Somech
f5da4b1c6c Merge pull request #2603 from bluca/xpub_manual_subs
Problem: XPUB_MANUAL subscriptions not removed on peer term
2017-06-22 11:46:31 +03:00
Luca Boccassi
3536c4b9c4 Problem: XPUB_MANUAL subscriptions not removed on peer term
Solution: remove the pipe from the real trie when a peer disconnects.
Also add a unit test that exercises the behaviour by reconnecting
a different socket and sending a message that matches.
Fixes #2601 and introduced by #2042
2017-06-22 01:02:08 +01:00
Luca Boccassi
8e2027983a Problem: XPUB_MANUAL takes effect for the next bind
Solution: fix unit test to bind after setting the option.
2017-06-22 00:58:44 +01:00
Joe Eli McIlvain
2d83acceff Merge pull request #2596 from bluca/zap_curve
Problems: ZAP can be set up incorrectly, CURVE and GSSAPI can be used only with ZAP
2017-06-15 11:51:43 -07:00
Luca Boccassi
35fce88fee Merge pull request #2599 from ibancg/master
Problem: cannot cross-compile with Mingw-w64
2017-06-14 15:28:02 +01:00
Iban Cereijo
d040dc18b5 Problem: CMake evaluation fails with Mingw-w64
Solution: we can use 'CMAKE_SYSTEM_VERSION' instead of
'${CMAKE_SYSTEM_VERSION}' for the 'if' clauses.

CMake fails to evaluate condition when CMAKE_SYSTEM_VERSION is
empty, which can happen with a default installation of Mingw-w64
in Linux.
2017-06-14 15:55:29 +02:00
Iban Cereijo
2c4e5364aa Problem: missing Ws2_32.lib when cross compiling
Solution: use lower case ws2_32.lib to enable cross compilation
from platforms with case-sensitive filesystems.

When cross compiling the tests with Mingw-w64, CMake cannot
locate Ws2_32.lib
2017-06-14 15:54:03 +02:00
Luca Boccassi
6ad0b08da9 Problem: GSSAPI can no longer be used without ZAP
Solution: do not fail if ZAP is not enabled.
GSSAPI already provides authentication and can be used separately,
so it is a valid use case.
2017-06-13 22:56:49 +01:00
Luca Boccassi
0ce18eac25 Problem: CURVE can no longer be used without ZAP
Solution: revert change that made ZAP mandatory.
The "Stonehouse" pattern, where CURVE is used only for encryption and
without authentication, is a valid use case so we should still
support it.
Also restore CURVE testing in the test_heartbeat.

Fixes #2594
2017-06-13 22:56:32 +01:00
Luca Boccassi
33695d1da8 Problem: ZAP is allowed to be configured incorrectly or not to work
Solution: if inproc://zeromq.zap.01 exists, which means ZAP is
enabled, abort immediately if it cannot be used (eg: out of memory)
or it is configured incorrectly (eg: wrong socket type).
Otherwise authentication failures will simply be ignored and
unauthorised peers will be allowed to slip in.
2017-06-13 22:56:31 +01:00
Doron Somech
10a9ba0926 Merge pull request #2593 from ilovexyz/dev
fix bug: #2592 dish client does not resend subscriptions to radio server after radio server restart
2017-06-12 07:34:28 +03:00
sunddy
af598f2e1c fix bug: dish client does not resend subscriptions to radio server after radio server restart
problem: for zmq radio/dish pattern, if the radio process restarts, the dish will not resend subscriptions to radio. And the result is that the dish will never receive any more messages.

solution: in session_base_t::reconnect (), take ZMQ_DISH into consideration when invoking hiccup method.
2017-06-12 12:26:21 +08:00
BJovke
99805931e4 Merge pull request #2591 from laplaceyang/pr_cancel_timer_in_reconnect
fix bug: coredump if set linger and immediate together
2017-06-02 10:25:18 +02:00
laplaceyang
67a6594fc0 fix bug: coredump if set linger and immediate together
In function session_base_t::reconnect, if we set immediate to 1 and set linger, we will get into first block of reconnect function, and set pipe to NULL, but we forget to cancel timer of linger. Once timer tiggered, we will get coredump. Solution: cancel timer in the end of set pipe to NULL
2017-06-02 11:36:41 +08:00
Constantin Rack
bcc30f2ab0 Merge pull request #2584 from GreatFruitOmsk/master
RELICENSE: Ilya Kulakov
2017-05-23 19:40:34 +02:00
Ilya Kulakov
545135fb8d RELICENSE: Ilya Kulakov
Refs #2376
2017-05-23 10:38:13 -07:00
Constantin Rack
ec56eaaeb6 Merge pull request #2583 from timou/wincmake
Suppress linker warning 4221 for MSVC
2017-05-20 21:08:58 +02:00
Tim Ebringer
293a18257a Suppress linker warning 4221 for MSVC
Some #define switches cause the body of entire files to be omitted. This
causes a linker warning on Visual Studio 2017, for example

    warning LNK4221: This object file does not define any previously
    undefined public symbols, so it will not be used by any link
    operation that consumes this library

Since this is warning us about something that shouldn't be
earth-shattering news, we add a linker flag to suppress this warning on
MSVC builds.
2017-05-20 14:29:58 -04:00
Doron Somech
92339a4d9d Merge pull request #2582 from bluca/test_poller_use_after_free
Problem: use-after-free in test_poller
2017-05-18 15:37:31 +03:00
Luca Boccassi
17637536b8 Problem: use-after-free in test_poller
Solution: remove server socket from poller before closing it
Fixes #2581
2017-05-18 13:10:19 +01:00
Luca Boccassi
bc8ad8860b Merge pull request #2580 from diorcety/ninja
Use OBJECT_DEPENDS and OBJECT_OUTPUTS for precompiled.hpp
2017-05-18 11:33:05 +01:00