osx: handle differences between OS X and other BSDs
authorLance Richardson <lrichard@redhat.com>
Tue, 15 Mar 2016 15:52:58 +0000 (11:52 -0400)
committerBen Pfaff <blp@ovn.org>
Wed, 23 Mar 2016 01:42:58 +0000 (18:42 -0700)
Conditional compilation to account for:
  - OS X does not implement RTM_IFANNOUNCE.
  - OS X does not implement tap netdeivces.
  - OS X does not implement RT_ROUNDUP().

Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/netdev-bsd.c
lib/route-table-bsd.c
lib/rtbsd.c

index 273ec8e..3b0ad3e 100644 (file)
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+#if !defined(__MACH__)
 #include <config.h>
 
 #include "netdev-provider.h"
@@ -1826,3 +1827,4 @@ af_link_ioctl(unsigned long command, const void *arg)
             : 0);
 }
 #endif
+#endif /* !defined(__MACH__) */
index b5ff3cc..76a8d3d 100644 (file)
 
 VLOG_DEFINE_THIS_MODULE(route_table_bsd);
 
+/* OS X does not define RT_ROUNDUP() or equivalent macro. */
+#if defined(__MACH__)
+#define RT_ROUNDUP(l) ((l) > 0 ? ROUND_UP((l), sizeof(long)) : sizeof(long))
+#endif
+
 bool
 route_table_fallback_lookup(ovs_be32 ip, char name[], ovs_be32 *gw)
 {
@@ -162,6 +167,8 @@ retry:
             sa = (struct sockaddr *)((char *)sa + SA_SIZE(sa));
 #elif defined(__NetBSD__)
             sa = (struct sockaddr *)((char *)sa + RT_ROUNDUP(sa->sa_len));
+#elif defined(__MACH__)
+            sa = (struct sockaddr *)((char *)sa + RT_ROUNDUP(sa->sa_len));
 #else
 #error unimplemented
 #endif
index 33fb9fd..fe4c55c 100644 (file)
@@ -128,7 +128,9 @@ rtbsd_notifier_run(void)
             case RTM_IFINFO:
             /* Since RTM_IFANNOUNCE messages are smaller than RTM_IFINFO
              * messages, the same buffer may be used. */
+#ifndef __MACH__ /* OS X does not implement RTM_IFANNOUNCE */
             case RTM_IFANNOUNCE:
+#endif
                 rtbsd_report_change(&msg);
                 break;
             default:
@@ -180,11 +182,13 @@ rtbsd_report_change(const struct if_msghdr *msg)
         change.if_index = msg->ifm_index;
         if_indextoname(msg->ifm_index, change.if_name);
         break;
+#ifndef __MACH__ /* OS X does not implement RTM_IFANNOUNCE */
     case RTM_IFANNOUNCE:
         ahdr = (const struct if_announcemsghdr *) msg;
         change.if_index = ahdr->ifan_index;
         strncpy(change.if_name, ahdr->ifan_name, IF_NAMESIZE);
         break;
+#endif
     }
 
     LIST_FOR_EACH (notifier, node, &all_notifiers) {