Thanks for looking into the patches.

On 1/17/19 11:48 PM, Simon Kelley wrote:

On 14/01/2019 15:56, libor.buk...@oracle.com wrote:
Hello,

patches resolve the build failures, functionality, and performance
issues on Solaris. A brief description is included in each patch.

Please let me know whether these patches could be merged and which
changes are necessary.

Very happy in principle to merge. After a quick look though, I have the
following observations.


Patch 0 - I think this may be out of date WRT the current code, which
removed the HAVE_IPV6 conditional compilation for IPv6 support.

You are right, I updated the patch WRT to the current code.



Patch 1 - Looks fine. I wonder why I couldn't get SIOCSXARP
to work, as detailed in my comment?

Based on your comment, you got ENXIO as a return value. It indicates that there is not ARP table entry for IP address on the device, so, arp lookup failed.



Patch 2 - There is a Makefile included in the contrib/lease-tools
directory. I'd rather work on that than include it in the main Makefile.
This is a nasty , unsupported hack, and I'd really like OpenStack to use
the RemoveDhcpLease DBus method instead, but that's not your problem.
Happy to take conditional compilation patches or even a Solaris forked
version as another source file, but it all has to stay in contrib/

Thank you for your feedback. When we move the hack to contrib/lease-tools directory, we will send an updated patch.


Patch 3 - Nasty, but Not My Problem. will take as is.
Thanks.

Patch 4 - This adds loads of conditional code in src/dnsmasq.c because
Linux deals in terms of interface names, and Solaris in interface
indexes. Much better to make whichdevice() and bindtodevice() return and
take struct irec *, then the Linux version can use the name from that,
and Solaris version the index. The only OS-specific code becomes
bindtodevice()

You are right, there is lots of conditional code. When we have an updated patch, we will send it.

Could it be possible to merge the following patches in git am format?
0001-Fix-build-failures-on-Solaris.patch
0002-Use-SIOCSXARP-ioctl-to-specify-the-exact-datalink.patch
0003-Get-the-client-MAC-address-from-the-link-local-address-on-Solaris.patch

Thanks,
Libor


Cheers,

Simon.


>From 2fde21a0c068f3cbf3f2f04e670e0ed04edab1b3 Mon Sep 17 00:00:00 2001
From: Libor Bukata <libor.buk...@oracle.com>
Date: Fri, 18 Jan 2019 09:50:36 +0100
Subject: [PATCH 1/3] Fix build failures on Solaris.

Patch created by Laszlo Peter and Stacey Marshall.
---
 src/bpf.c     |  2 ++
 src/config.h  |  3 ++-
 src/dnsmasq.h |  2 +-
 src/ip6addr.h | 35 ++++++++++++++++++++++++++++++++++-
 4 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/bpf.c b/src/bpf.c
index 982318d..84ae1ec 100644
--- a/src/bpf.c
+++ b/src/bpf.c
@@ -31,7 +31,9 @@
 #  include <net/if_var.h> 
 #endif
 #include <netinet/in_var.h>
+#ifndef HAVE_SOLARIS_NETWORK
 #include <netinet6/in6_var.h>
+#endif
 
 #ifndef SA_SIZE
 #define SA_SIZE(sa)                                             \
diff --git a/src/config.h b/src/config.h
index 203d69e..cdf2180 100644
--- a/src/config.h
+++ b/src/config.h
@@ -290,7 +290,8 @@ HAVE_SOCKADDR_SA_LEN
 #define HAVE_GETOPT_LONG
 #undef HAVE_SOCKADDR_SA_LEN
 #define ETHER_ADDR_LEN 6 
- 
+#undef HAVE_IPSET
+
 #endif
 
 /* rules to implement compile-time option dependencies and 
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 0dc1de9..6a2d370 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -1343,7 +1343,7 @@ int set_ipv6pktinfo(int fd);
 #ifdef HAVE_DHCP6
 void join_multicast(int dienow);
 #endif
-#if defined(HAVE_LINUX_NETWORK) || defined(HAVE_BSD_NETWORK)
+#if defined(HAVE_LINUX_NETWORK) || defined(HAVE_BSD_NETWORK) || defined(HAVE_SOLARIS_NETWORK)
 void newaddress(time_t now);
 #endif
 
diff --git a/src/ip6addr.h b/src/ip6addr.h
index 6f6dff7..6a71858 100644
--- a/src/ip6addr.h
+++ b/src/ip6addr.h
@@ -14,8 +14,41 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef HAVE_SOLARIS_NETWORK
+#ifdef _BIG_ENDIAN
+#define IN6_IS_ADDR_ULA(a) \
+	(((a)->_S6_un._S6_u32[0] & htonl (0x000000ff))                        \
+	 == htonl (0x000000fd))
 
+#define IN6_IS_ADDR_ULA_ZERO(a) \
+	(((a)->_S6_un._S6_u32[0] == htonl (0x000000fd))                              \
+	 && ((a)->_S6_un._S6_u32[1] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[2] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[3] == 0))
 
+#define IN6_IS_ADDR_LINK_LOCAL_ZERO(a) \
+	(((a)->_S6_un._S6_u32[0] == htonl (0x000080fe))                        \
+	 && ((a)->_S6_un._S6_u32[1] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[2] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[3] == 0))
+#else /* _BIG_ENDIAN */
+#define IN6_IS_ADDR_ULA(a) \
+	(((a)->_S6_un._S6_u32[0] & htonl (0xff000000))                        \
+	 == htonl (0xfd000000))
+
+#define IN6_IS_ADDR_ULA_ZERO(a) \
+	(((a)->_S6_un._S6_u32[0] == htonl (0xfd000000))                              \
+	 && ((a)->_S6_un._S6_u32[1] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[2] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[3] == 0))
+
+#define IN6_IS_ADDR_LINK_LOCAL_ZERO(a) \
+	(((a)->_S6_un._S6_u32[0] == htonl (0xfe800000))                        \
+	 && ((a)->_S6_un._S6_u32[1] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[2] == 0)                                     \
+	 && ((a)->_S6_un._S6_u32[3] == 0))
+#endif /* _BIG_ENDIAN */
+#else /* HAVE_SOLARIS_NETWORK */
 #define IN6_IS_ADDR_ULA(a) \
         ((((__const uint32_t *) (a))[0] & htonl (0xff000000))                 \
          == htonl (0xfd000000))
@@ -31,4 +64,4 @@
          && ((__const uint32_t *) (a))[1] == 0                                \
          && ((__const uint32_t *) (a))[2] == 0                                \
          && ((__const uint32_t *) (a))[3] == 0)
-
+#endif /* HAVE_SOLARIS_NETWORK */
-- 
1.8.3.1

>From 6c4c879651d097f1eb80cdb651a79fe7f6226262 Mon Sep 17 00:00:00 2001
From: Libor Bukata <libor.buk...@oracle.com>
Date: Fri, 18 Jan 2019 09:51:53 +0100
Subject: [PATCH 2/3] Use SIOCSXARP ioctl to specify the exact datalink.

If there are multiple datalinks configured with IP addresses from the
same subnet, then the datalink to which an on-link device's ARP entry
will be associated depends on the order in which these datalinks were
plumbed with IP addresses. In that, the datalink that was plumbed for
IP last will have the ARP entry associated against it. To avoid this,
we need to use SIOCSXARP ioctl to specify the exact datalink.

Patch created by Girish Moodalbail.
---
 src/dhcp.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index ee74f06..687d912 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -439,17 +439,24 @@ void dhcp_packet(time_t now, int pxe_fd)
   else
     {
       /* unicast to unconfigured client. Inject mac address direct into ARP cache. 
-	 Note that this only works for ethernet on solaris, because we use SIOCSARP
-	 and not SIOCSXARP, which would be perfect, except that it returns ENXIO 
-	 mysteriously. Bah. Fall back to broadcast for other net types. */
-      struct arpreq req;
+	 Fall back to broadcast for other net types. */
+      struct xarpreq xreq;
+      int ifnamsz = strlen(ifr.ifr_name);
+
+      dest.sin_family = AF_INET;
       dest.sin_addr = mess->yiaddr;
       dest.sin_port = htons(daemon->dhcp_client_port);
-      *((struct sockaddr_in *)&req.arp_pa) = dest;
-      req.arp_ha.sa_family = AF_UNSPEC;
-      memcpy(req.arp_ha.sa_data, mess->chaddr, mess->hlen);
-      req.arp_flags = ATF_COM;
-      ioctl(daemon->dhcpfd, SIOCSARP, &req);
+      *((struct sockaddr_in *)&xreq.xarp_pa) = dest;
+      xreq.xarp_ha.sdl_nlen = ifnamsz;
+      memcpy(xreq.xarp_ha.sdl_data, ifr.ifr_name, ifnamsz);
+      xreq.xarp_ha.sdl_family = AF_LINK;
+      xreq.xarp_ha.sdl_index = iface_index;
+      /* 6 corresponds to IFT_ETHER */
+      xreq.xarp_ha.sdl_type = 6;
+      xreq.xarp_ha.sdl_alen = ETHER_ADDR_LEN;
+      memcpy(xreq.xarp_ha.sdl_data + ifnamsz, mess->chaddr, mess->hlen);
+      xreq.xarp_flags = ATF_COM;
+      ioctl(daemon->dhcpfd, SIOCSXARP, &xreq);
     }
 #elif defined(HAVE_BSD_NETWORK)
   else 
-- 
1.8.3.1

>From aa0f393ba3a7c7f7aa7f619c9b7e933048edf6b4 Mon Sep 17 00:00:00 2001
From: Libor Bukata <libor.buk...@oracle.com>
Date: Fri, 18 Jan 2019 09:55:07 +0100
Subject: [PATCH 3/3] Get the client MAC address from the link-local address on Solaris.

Solaris doesn't have an easy way to retrieve the MAC address
of the client that is soliciting the DHCPv6 IP address.
This fix uses a simple way to retrieve the client MAC
address from the client's EUI64 link-local address.

Patch created by Stacey Marshall.
---
 src/dhcp6.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/dhcp6.c b/src/dhcp6.c
index 7e6e3df..4c0c1d8 100644
--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -252,6 +252,23 @@ void dhcp6_packet(time_t now)
 
 void get_client_mac(struct in6_addr *client, int iface, unsigned char *mac, unsigned int *maclenp, unsigned int *mactypep, time_t now)
 {
+#ifdef HAVE_SOLARIS_NETWORK
+/* Solaris does not have an easy way to retrieve MAC address for a given IPv6 address from the kernel.
+   For now the following workaround should work for OpenStack's needs. */
+  uint8_t *addr6;
+
+  *maclenp = ETHER_ADDR_LEN;
+  *mactypep = ARPHRD_ETHER;
+  /* Take the EUI64 based client's link-local address and convert it to client's MAC address.
+     For example: from fe80::f816:3eff:fe5c:df43 link-local address we arrive at fa:16:3e:5c:df:43 */
+  addr6 = client->s6_addr;
+  mac[0] = addr6[8] ^ 0x2;
+  mac[1] = addr6[9];
+  mac[2] = addr6[10];
+  mac[3] = addr6[13];
+  mac[4] = addr6[14];
+  mac[5]= addr6[15];
+#else
   /* Receiving a packet from a host does not populate the neighbour
      cache, so we send a neighbour discovery request if we can't 
      find the sender. Repeat a few times in case of packet loss. */
@@ -292,6 +309,7 @@ void get_client_mac(struct in6_addr *client, int iface, unsigned char *mac, unsi
 
   *maclenp = maclen;
   *mactypep = ARPHRD_ETHER;
+#endif /* HAVE_SOLARIS_NETWORK */
 }
     
 static int complete_context6(struct in6_addr *local,  int prefix,
-- 
1.8.3.1

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to