[zeromq-dev] Zyre patch for IPv6 link local

Sathish_Yenna at Dell.com Sathish_Yenna at Dell.com
Wed Dec 16 20:09:46 CET 2015

Hi all,

I need to use IPv6 link local addressing for an application in development. I have applied patches to ZeroMQ and CZMQ and they were accepted into the upstream already. Now, I need to patch Zyre to add interface name to the ipaddress if it's IPv6 address. I have come up with a patch that seemed to work, but not so sure if it's appropriate to be accepted by Zyre owners. Would you please review the following patch (also in the attached file) and let me know what changes you will make.

Thanks in advance for your time.


diff --git a/src/zyre_node.c b/src/zyre_node.c
index 13deb77..e93e4be 100644
--- a/src/zyre_node.c
+++ b/src/zyre_node.c
@@ -164,7 +164,11 @@ zyre_node_start (zyre_node_t *self)
         if (streq (hostname, ""))
             return -1;              //  No UDP broadcast interface available
-        self->port = zsock_bind (self->inbox, "tcp://%s:*", hostname);
+        if (zsys_ipv6 ())
+            self->port = zsock_bind (self->inbox, "tcp://%s%%%s:*", zsys_ipv6_address (), zsys_interface ());
+        else
+            self->port = zsock_bind (self->inbox, "tcp://%s:*", hostname);
         zstr_free (&hostname);
         assert (self->port > 0);    //  Die on bad interface or port exhaustion
         assert (!self->endpoint);   //  If caller set this, we'd be using gossip
@@ -765,8 +769,13 @@ zyre_node_recv_beacon (zyre_node_t *self)
     zuuid_t *uuid = zuuid_new ();
     zuuid_set (uuid, beacon.uuid);
     if (beacon.port) {
-        char endpoint [30];
-        sprintf (endpoint, "tcp://%s:%d", ipaddress, ntohs (beacon.port));
+        char endpoint [100];
+        const char *iface = zsys_interface ();
+        if (iface && !streq (iface, "") && !streq (iface, "*"))
+            sprintf (endpoint, "tcp://%s%%%s:%d", ipaddress, iface, ntohs (beacon.port));
+        else
+            sprintf (endpoint, "tcp://%s:%d", ipaddress, ntohs (beacon.port));
         zyre_peer_t *peer = zyre_node_require_peer (self, uuid, endpoint);
         zyre_peer_refresh (peer);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151216/eebda328/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zyre_node_ipv6_linklocal.patch
Type: application/octet-stream
Size: 1501 bytes
Desc: zyre_node_ipv6_linklocal.patch
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20151216/eebda328/attachment.obj>

More information about the zeromq-dev mailing list