File 2551-erts-Tweaked-the-config-and-usage-of-SCTP-for-NetBSD.patch of Package erlang
From c6a283d573a8a22001f0d3b0ed8b19ed8ce3b276 Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Tue, 3 Mar 2020 15:28:18 +0100
Subject: [PATCH 1/8] [erts] Tweaked the config and usage of SCTP for NetBSD
On NetBSD the type sctp_assoc_value does not exist.
Its used normally when setting, for instance, the
option SCTP_DELAYED_ACK_TIME. This option *does*
exist on NetBSD, but it can only be used to set the
"default value" (which on Linux is done by setting
assoc_id (in assoc_value) to 0).
The way to "properly" handle this on NetBSD would be
to accept this option (for inet:[setopts/getopts]),
but verify that the assoc id is zero (0).
For now we simply test for the type, and if it does
not exist, we do not allow set/get of this option.
---
erts/configure.in | 6 ++++++
erts/emulator/drivers/common/inet_drv.c | 16 +++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/erts/configure.in b/erts/configure.in
index 46c90a152a..1f6a95f794 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -1736,6 +1736,12 @@ if test x"$ac_cv_header_netinet_sctp_h" = x"yes"; then
AS_IF([test "x$enable_sctp" = "xlib"],
AC_CHECK_LIB(sctp, sctp_bindx))
AC_CHECK_FUNCS([sctp_bindx sctp_peeloff sctp_getladdrs sctp_freeladdrs sctp_getpaddrs sctp_freepaddrs])
+ AC_CHECK_MEMBERS([struct sctp_accoc_value.assoc_id], [], [],
+ [#if HAVE_SYS_SOCKET_H
+ #include <sys/socket.h>
+ #endif
+ #include <netinet/sctp.h>
+ ])
AC_CHECK_DECLS([SCTP_UNORDERED, SCTP_ADDR_OVER, SCTP_ABORT,
SCTP_EOF, SCTP_SENDALL, SCTP_ADDR_CONFIRMED,
SCTP_DELAYED_ACK_TIME,
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index c3d2df6008..868a001a36 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -6954,9 +6954,9 @@ static int sctp_set_opts(inet_descriptor* desc, char* ptr, int len)
struct sctp_paddrparams pap;
struct sctp_sndrcvinfo sri;
struct sctp_event_subscribe es;
-# ifdef SCTP_DELAYED_ACK_TIME
+#if defined(HAVE_DECL_SCTP_DELAYED_ACK_TIME) && defined(SCTP_ASSOC_VALUE_ASSOC_ID)
struct sctp_assoc_value av; /* Not in SOLARIS10 */
-# endif
+#endif
# ifdef SO_BINDTODEVICE
char ifname[IFNAMSIZ];
# endif
@@ -7475,8 +7475,9 @@ static int sctp_set_opts(inet_descriptor* desc, char* ptr, int len)
arg_sz = sizeof ( arg.es);
break;
}
- /* The following is not available on Solaris 10: */
-# ifdef SCTP_DELAYED_ACK_TIME
+ /* The following is not available on
+ * Solaris 10 or NetBSD or ... */
+#if defined(HAVE_DECL_SCTP_DELAYED_ACK_TIME) && defined(SCTP_ASSOC_VALUE_ASSOC_ID)
case SCTP_OPT_DELAYED_ACK_TIME:
{
CHKLEN(curr, ASSOC_ID_LEN + 4);
@@ -7489,7 +7490,7 @@ static int sctp_set_opts(inet_descriptor* desc, char* ptr, int len)
arg_sz = sizeof ( arg.av);
break;
}
-# endif
+#endif
default:
/* XXX: No more supported SCTP options. In particular, authentica-
tion options (SCTP_AUTH_CHUNK, SCTP_AUTH_KEY, SCTP_PEER_AUTH_
@@ -8790,8 +8791,9 @@ static ErlDrvSSizeT sctp_fill_opts(inet_descriptor* desc,
i = LOAD_TUPLE (spec, i, 2);
break;
}
- /* The following option is not available in Solaris 10: */
-# if HAVE_DECL_SCTP_DELAYED_ACK_TIME
+ /* The following option is not available on:
+ * Solaris 10 or NetBSD or ... */
+#if defined(HAVE_DECL_SCTP_DELAYED_ACK_TIME) && defined(SCTP_ASSOC_VALUE_ASSOC_ID)
case SCTP_OPT_DELAYED_ACK_TIME:
{
struct sctp_assoc_value av;
--
2.16.4