diff mbox

[ovs-dev,v2,4/5] osx: handle differences between OS X and other BSDs

Message ID 1458057179-27633-5-git-send-email-lrichard@redhat.com
State Accepted
Headers show

Commit Message

Lance Richardson March 15, 2016, 3:52 p.m. UTC
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>
---
Changes from v1:
  - Combined patches 4 and 5 into patch number 4
  - Added implementation of RT_ROUNDUP() for OS X

 lib/netdev-bsd.c      | 2 ++
 lib/route-table-bsd.c | 7 +++++++
 lib/rtbsd.c           | 4 ++++
 3 files changed, 13 insertions(+)

Comments

Ben Pfaff March 23, 2016, 1:44 a.m. UTC | #1
On Tue, Mar 15, 2016 at 11:52:58AM -0400, Lance Richardson wrote:
> 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>
> ---
> Changes from v1:
>   - Combined patches 4 and 5 into patch number 4
>   - Added implementation of RT_ROUNDUP() for OS X

Hmm.  Commenting out a whole file is not exactly what I expected...
Anyway, it's progress, thank you.  Applied.
diff mbox

Patch

diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
index edf04bf..72dca5f 100644
--- a/lib/netdev-bsd.c
+++ b/lib/netdev-bsd.c
@@ -15,6 +15,7 @@ 
  * limitations under the License.
  */
 
+#if !defined(__MACH__)
 #include <config.h>
 
 #include "netdev-provider.h"
@@ -1825,3 +1826,4 @@  af_link_ioctl(unsigned long command, const void *arg)
             : 0);
 }
 #endif
+#endif /* !defined(__MACH__) */
diff --git a/lib/route-table-bsd.c b/lib/route-table-bsd.c
index b5ff3cc..76a8d3d 100644
--- a/lib/route-table-bsd.c
+++ b/lib/route-table-bsd.c
@@ -38,6 +38,11 @@ 
 
 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
diff --git a/lib/rtbsd.c b/lib/rtbsd.c
index 33fb9fd..fe4c55c 100644
--- a/lib/rtbsd.c
+++ b/lib/rtbsd.c
@@ -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) {