Date: Wed, 1 Jul 2020 18:03:38 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362848 - in stable/12/sys: net netinet sys Message-ID: <202007011803.061I3cTs089322@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Wed Jul 1 18:03:38 2020 New Revision: 362848 URL: https://svnweb.freebsd.org/changeset/base/362848 Log: MFC r353480: Use event handler in SCTP 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. Submitted by: markj Modified: stable/12/sys/net/route.c stable/12/sys/netinet/sctp_bsd_addr.c stable/12/sys/netinet/sctp_bsd_addr.h stable/12/sys/netinet/sctp_usrreq.c stable/12/sys/sys/eventhandler.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/route.c ============================================================================== --- stable/12/sys/net/route.c Wed Jul 1 17:40:11 2020 (r362847) +++ stable/12/sys/net/route.c Wed Jul 1 18:03:38 2020 (r362848) @@ -38,10 +38,9 @@ #include "opt_inet.h" #include "opt_inet6.h" -#include "opt_route.h" -#include "opt_sctp.h" #include "opt_mrouting.h" #include "opt_mpath.h" +#include "opt_route.h" #include <sys/param.h> #include <sys/systm.h> @@ -90,13 +89,6 @@ #define RT_NUMFIBS 1 #endif -#if defined(INET) || defined(INET6) -#ifdef SCTP -extern void sctp_addr_change(struct ifaddr *ifa, int cmd); -#endif /* SCTP */ -#endif - - /* This is read-only.. */ u_int rt_numfibs = RT_NUMFIBS; SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); @@ -140,6 +132,8 @@ VNET_DEFINE(int, rttrash); /* routes not in table but VNET_DEFINE_STATIC(uma_zone_t, rtzone); /* Routing table UMA zone. */ #define V_rtzone VNET(rtzone) +EVENTHANDLER_LIST_DEFINE(rt_addrmsg); + static int rtrequest1_fib_change(struct rib_head *, struct rt_addrinfo *, struct rtentry **, u_int); static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *); @@ -2192,20 +2186,10 @@ rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum) KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE, ("unexpected cmd %d", cmd)); - KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs), ("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs)); -#if defined(INET) || defined(INET6) -#ifdef SCTP - /* - * notify the SCTP stack - * this will only get called when an address is added/deleted - * XXX pass the ifaddr struct instead if ifa->ifa_addr... - */ - sctp_addr_change(ifa, cmd); -#endif /* SCTP */ -#endif + EVENTHANDLER_DIRECT_INVOKE(rt_addrmsg, ifa, cmd); return (rtsock_addrmsg(cmd, ifa, fibnum)); } Modified: stable/12/sys/netinet/sctp_bsd_addr.c ============================================================================== --- stable/12/sys/netinet/sctp_bsd_addr.c Wed Jul 1 17:40:11 2020 (r362847) +++ stable/12/sys/netinet/sctp_bsd_addr.c Wed Jul 1 18:03:38 2020 (r362848) @@ -357,6 +357,12 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) } 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; struct ifaddr *ifa; Modified: stable/12/sys/netinet/sctp_bsd_addr.h ============================================================================== --- stable/12/sys/netinet/sctp_bsd_addr.h Wed Jul 1 17:40:11 2020 (r362847) +++ stable/12/sys/netinet/sctp_bsd_addr.h Wed Jul 1 18:03:38 2020 (r362848) @@ -61,6 +61,8 @@ int sctp_copy_out_packet_log(uint8_t *target, int leng void sctp_addr_change(struct ifaddr *ifa, int cmd); +void sctp_addr_change_event_handler(void *, struct ifaddr *, int); + void sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add); #endif Modified: stable/12/sys/netinet/sctp_usrreq.c ============================================================================== --- stable/12/sys/netinet/sctp_usrreq.c Wed Jul 1 17:40:11 2020 (r362847) +++ stable/12/sys/netinet/sctp_usrreq.c Wed Jul 1 18:03:38 2020 (r362848) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/sctp_auth.h> #include <netinet/sctp_bsd_addr.h> #include <netinet/udp.h> +#include <sys/eventhandler.h> @@ -89,6 +90,8 @@ sctp_init(void) SCTP_BASE_VAR(packet_log_end) = 0; memset(&SCTP_BASE_VAR(packet_log_buffer), 0, SCTP_PACKET_LOG_SIZE); #endif + EVENTHANDLER_REGISTER(rt_addrmsg, sctp_addr_change_event_handler, + NULL, EVENTHANDLER_PRI_FIRST); } #ifdef VIMAGE Modified: stable/12/sys/sys/eventhandler.h ============================================================================== --- stable/12/sys/sys/eventhandler.h Wed Jul 1 17:40:11 2020 (r362847) +++ stable/12/sys/sys/eventhandler.h Wed Jul 1 18:03:38 2020 (r362848) @@ -335,4 +335,9 @@ typedef void (*device_detach_fn)(void *, device_t, enu EVENTHANDLER_DECLARE(device_attach, device_attach_fn); EVENTHANDLER_DECLARE(device_detach, device_detach_fn); +/* Interface address addition and removal event */ +struct ifaddr; +typedef void (*rt_addrmsg_fn)(void *, struct ifaddr *, int); +EVENTHANDLER_DECLARE(rt_addrmsg, rt_addrmsg_fn); + #endif /* _SYS_EVENTHANDLER_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007011803.061I3cTs089322>