[PATCH] BSD: macOS Support

Pim van Pelt pim at ipng.nl
Wed Mar 13 16:18:15 CET 2024


Hey Maria, Zhang,

Regarding CI/CD, perhaps I can have a chat with the folks of Flow who have
exactly bare metal mac as a service including a tailored product for CI:
https://flow.swiss/ci-engine

If the expected lifetime of macOS support in Bird is unknown, and there is
no vested interest in it, perhaps that would be less of an appealing
situation.
It kind of depends on the eventual use / longevity. If folks on this list
are enthusiastic about macOS, and the maintainers are OK extending the
builds to include it, I think it would definitely be possible to work with
the flow.swiss team, and I can make introductions.

groet,
Pim

On Wed, Mar 13, 2024 at 11:22 AM Maria Matejka via Bird-users <
bird-users at network.cz> wrote:

> Hello Zhang,
>
> thank you for your contribution. This looks includable, however I'd like
> to ask you about maintainability of this patch. It may quite quickly rot
> away. Is there an easy (and legal) way to have automatic macOS build and
> basic run testing, without a need to maintain a physical Mac?
>
> Thanks,
> Maria
> On 2024-03-13 03:02, Zhang Maiyun via Bird-users wrote:
>
> Dear all,
>
> This patch makes bird build and run on macOS with `sysconfig=bsd`.
> It is mainly modifying preprocessor directives.
>
> I have tested it on macOS 14.3.1 and it is able to establish BGP sessions
> and at least exchange IPv4 routes.
>
> Kind regards,
> Maiyun Zhang
>
> Signed-off-by: Zhang Maiyun <me at maiyun.me> <me at maiyun.me>
> ---
>  sysdep/bsd/krt-sock.c | 6 ++++++
>  sysdep/bsd/sysio.h    | 6 +++++-
>  sysdep/unix/io.c      | 3 +++
>  sysdep/unix/random.c  | 2 +-
>  4 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c
> index d13e20a3..afb66cb3 100644
> --- a/sysdep/bsd/krt-sock.c
> +++ b/sysdep/bsd/krt-sock.c
> @@ -635,6 +635,7 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
>      krt_got_route_async(p, e, new, src);
>  }
>
> +#ifndef __APPLE__
>  static void
>  krt_read_ifannounce(struct ks_msg *msg)
>  {
> @@ -661,6 +662,7 @@ krt_read_ifannounce(struct ks_msg *msg)
>
>    DBG("KRT: IFANNOUNCE what: %d index %d name %s\n", ifam->ifan_what, ifam->ifan_index, ifam->ifan_name);
>  }
> +#endif
>
>  static void
>  krt_read_ifinfo(struct ks_msg *msg, int scan)
> @@ -725,7 +727,9 @@ krt_read_ifinfo(struct ks_msg *msg, int scan)
>
>    if (fl & IFF_UP)
>      f.flags |= IF_ADMIN_UP;
> +#ifndef __APPLE__
>    if (ifm->ifm_data.ifi_link_state != LINK_STATE_DOWN)
> +#endif
>      f.flags |= IF_LINK_UP;          /* up or unknown */
>    if (fl & IFF_LOOPBACK)            /* Loopback */
>      f.flags |= IF_MULTIACCESS | IF_LOOPBACK | IF_IGNORE;
> @@ -873,9 +877,11 @@ krt_read_msg(struct proto *p, struct ks_msg *msg, int scan)
>      case RTM_CHANGE:
>        krt_read_route(msg, (struct krt_proto *)p, scan);
>        break;
> +#ifndef __APPLE__
>      case RTM_IFANNOUNCE:
>        krt_read_ifannounce(msg);
>        break;
> +#endif
>      case RTM_IFINFO:
>        krt_read_ifinfo(msg, scan);
>        break;
> diff --git a/sysdep/bsd/sysio.h b/sysdep/bsd/sysio.h
> index b6b42b1e..85081c07 100644
> --- a/sysdep/bsd/sysio.h
> +++ b/sysdep/bsd/sysio.h
> @@ -32,7 +32,7 @@
>  #endif
>
>
> -#ifdef __NetBSD__
> +#if defined(__NetBSD__) || defined(__APPLE__)
>
>  #ifndef IP_RECVTTL
>  #define IP_RECVTTL 23
> @@ -49,6 +49,10 @@
>  #define TCP_MD5SIG	TCP_SIGNATURE_ENABLE
>  #endif
>
> +#ifdef __APPLE__
> +#define TCP_MD5SIG	TCPOPT_SIGNATURE
> +#endif
> +
>
>  #undef  SA_LEN
>  #define SA_LEN(x) (x).sa.sa_len
> diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
> index 9b499020..81e09888 100644
> --- a/sysdep/unix/io.c
> +++ b/sysdep/unix/io.c
> @@ -12,6 +12,9 @@
>  #ifndef _GNU_SOURCE
>  #define _GNU_SOURCE
>  #endif
> +#ifdef __APPLE__
> +#define __APPLE_USE_RFC_3542
> +#endif
>
>  #include <stdio.h>
>  #include <stdlib.h>
> diff --git a/sysdep/unix/random.c b/sysdep/unix/random.c
> index 4e64e56b..7d68c482 100644
> --- a/sysdep/unix/random.c
> +++ b/sysdep/unix/random.c
> @@ -16,7 +16,7 @@
>  #include "sysdep/config.h"
>  #include "nest/bird.h"
>
> -#ifdef HAVE_GETRANDOM
> +#if defined(HAVE_GETRANDOM) || (defined(__APPLE__) && defined(HAVE_GETENTROPY))
>  #include <sys/random.h>
>  #endif
>
>
> --
> Maria Matejka (she/her) | BIRD Team Leader | CZ.NIC, z.s.p.o.
>
>

-- 
Pim van Pelt <pim at ipng.nl>
PBVP1-RIPE - http://www.ipng.nl/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20240313/c7d9a3a7/attachment.htm>


More information about the Bird-users mailing list