Use an event handler to notify the SCTP about IP address changes
instead of calling an SCTP specific function from the IP code.
This is a requirement of supporting SCTP as a kernel loadable module.
This patch was developed by markj@, I tweaked a bit the SCTP related
code.
This change applies only to the FreeBSD kernel implementation.
diff --git a/usrsctplib/netinet/sctp_bsd_addr.c b/usrsctplib/netinet/sctp_bsd_addr.c
index 2cb2ac8..8547f44 100755
--- a/usrsctplib/netinet/sctp_bsd_addr.c
+++ b/usrsctplib/netinet/sctp_bsd_addr.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 353292 2019-10-07 22:40:05Z glebius $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 353480 2019-10-13 18:17:08Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -742,6 +742,11 @@
#if defined(__FreeBSD__)
void
+sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
+ sctp_addr_change(ifa, cmd);
+}
+
+void
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
{
struct ifnet *ifn;
diff --git a/usrsctplib/netinet/sctp_bsd_addr.h b/usrsctplib/netinet/sctp_bsd_addr.h
index a83c0ec..c43823c 100755
--- a/usrsctplib/netinet/sctp_bsd_addr.h
+++ b/usrsctplib/netinet/sctp_bsd_addr.h
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 310590 2016-12-26 11:06:41Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z tuexen $");
#endif
#ifndef _NETINET_SCTP_BSD_ADDR_H_
@@ -64,6 +64,10 @@
#if !defined(__Panda__)
void sctp_addr_change(struct ifaddr *ifa, int cmd);
#endif
+#if defined(__FreeBSD__)
+
+void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
+#endif
void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add);
diff --git a/usrsctplib/netinet/sctp_usrreq.c b/usrsctplib/netinet/sctp_usrreq.c
index d378904..81e28e6 100755
--- a/usrsctplib/netinet/sctp_usrreq.c
+++ b/usrsctplib/netinet/sctp_usrreq.c
@@ -34,7 +34,7 @@
#ifdef __FreeBSD__
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 350626 2019-08-06 10:29:19Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 353480 2019-10-13 18:17:08Z tuexen $");
#endif
#include <netinet/sctp_os.h>
@@ -61,6 +61,9 @@
#else
#include <netinet/udp.h>
#endif
+#if defined(__FreeBSD__)
+#include <sys/eventhandler.h>
+#endif
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
#include <netinet/sctp_peeloff.h>
@@ -176,6 +179,10 @@
sctp_start_main_timer();
timeout(sctp_delayed_startup, NULL, 1);
#endif
+#if defined(__FreeBSD__)
+ EVENTHANDLER_REGISTER(rt_addrmsg, sctp_addr_change_event_handler,
+ NULL, EVENTHANDLER_PRI_FIRST);
+#endif
}
#if defined(__FreeBSD__)