[Xorp-users] OLSR on Linux?

Ben Greear greearb at candelatech.com
Wed Jul 1 11:47:45 PDT 2009


Has anyone ever used OLSR on Linux with more than one interface?  I couldn't get it to work without
the patch below, but maybe that's because of other patches I've added
to xorp?

With the below it starts, at least...not sure if it actually works yet.

Thanks,
Ben



diff --git a/fea/data_plane/io/io_tcpudp_socket.cc b/fea/data_plane/io/io_tcpudp_socket.cc
index bfa23bd..1dcefa1 100644
--- a/fea/data_plane/io/io_tcpudp_socket.cc
+++ b/fea/data_plane/io/io_tcpudp_socket.cc
@@ -777,6 +777,29 @@ IoTcpUdpSocket::udp_open_bind_broadcast(const string& ifname,
      //    INADDR_ANY is used.
      struct in_addr local_in_addr;
      local_in_addr.s_addr = INADDR_ANY;
+#if defined(HOST_OS_LINUX)
+    // Linux handles binding to local IP, and that allows more than one OLSR
+    // to run at a time.  Try to bind to first useful IP address.
+    bool found_lip = false;
+    for (IfTreeVif::IPv4Map::const_iterator ai = vifp->ipv4addrs().begin();
+        ai != vifp->ipv4addrs().end();
+        ++ai) {
+       IfTreeAddr4& ar = *(ai->second);
+       if (ar.enabled() && ar.multicast()) {
+           //XLOG_WARNING("Binding to local IP: %s in udp_open_bind_broadcast on vif: %s/%s\n",
+           //   ar.str().c_str(), ifname.c_str(), vifname.c_str());
+           ar.addr().copy_out(local_in_addr);
+           found_lip = true;
+           break;
+        }
+       //else {
+       //    XLOG_WARNING("Ignoring ip: %s\n", ar.str().c_str());
+       //}
+    }
+    if (!found_lip) {
+       XLOG_WARNING("ERROR:  Couldn't find local IP for vif: %s/%s\n", ifname.c_str(), vifname.c_str());
+    }
+#endif
      ret_value = comm_sock_bind4(_socket_fd, &local_in_addr,
                                 htons(local_port));
      if (ret_value != XORP_OK) {

-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com



More information about the Xorp-users mailing list