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@ MFC after: 3 days
This commit is contained in:
parent
861e74ac19
commit
d6e23cf0cf
sys
@ -38,10 +38,9 @@
|
|||||||
|
|
||||||
#include "opt_inet.h"
|
#include "opt_inet.h"
|
||||||
#include "opt_inet6.h"
|
#include "opt_inet6.h"
|
||||||
#include "opt_route.h"
|
|
||||||
#include "opt_sctp.h"
|
|
||||||
#include "opt_mrouting.h"
|
#include "opt_mrouting.h"
|
||||||
#include "opt_mpath.h"
|
#include "opt_mpath.h"
|
||||||
|
#include "opt_route.h"
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -90,13 +89,6 @@
|
|||||||
#define RT_NUMFIBS 1
|
#define RT_NUMFIBS 1
|
||||||
#endif
|
#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.. */
|
/* This is read-only.. */
|
||||||
u_int rt_numfibs = RT_NUMFIBS;
|
u_int rt_numfibs = RT_NUMFIBS;
|
||||||
SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, "");
|
SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, "");
|
||||||
@ -140,6 +132,8 @@ VNET_DEFINE(int, rttrash); /* routes not in table but not freed */
|
|||||||
VNET_DEFINE_STATIC(uma_zone_t, rtzone); /* Routing table UMA zone. */
|
VNET_DEFINE_STATIC(uma_zone_t, rtzone); /* Routing table UMA zone. */
|
||||||
#define V_rtzone VNET(rtzone)
|
#define V_rtzone VNET(rtzone)
|
||||||
|
|
||||||
|
EVENTHANDLER_LIST_DEFINE(rt_addrmsg);
|
||||||
|
|
||||||
static int rtrequest1_fib_change(struct rib_head *, struct rt_addrinfo *,
|
static int rtrequest1_fib_change(struct rib_head *, struct rt_addrinfo *,
|
||||||
struct rtentry **, u_int);
|
struct rtentry **, u_int);
|
||||||
static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
|
static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
|
||||||
@ -2224,20 +2218,10 @@ rt_addrmsg(int cmd, struct ifaddr *ifa, int fibnum)
|
|||||||
|
|
||||||
KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
|
KASSERT(cmd == RTM_ADD || cmd == RTM_DELETE,
|
||||||
("unexpected cmd %d", cmd));
|
("unexpected cmd %d", cmd));
|
||||||
|
|
||||||
KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
|
KASSERT(fibnum == RT_ALL_FIBS || (fibnum >= 0 && fibnum < rt_numfibs),
|
||||||
("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
|
("%s: fib out of range 0 <=%d<%d", __func__, fibnum, rt_numfibs));
|
||||||
|
|
||||||
#if defined(INET) || defined(INET6)
|
EVENTHANDLER_DIRECT_INVOKE(rt_addrmsg, ifa, cmd);
|
||||||
#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
|
|
||||||
return (rtsock_addrmsg(cmd, ifa, fibnum));
|
return (rtsock_addrmsg(cmd, ifa, fibnum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
void
|
||||||
sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add){
|
sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add){
|
||||||
struct ifnet *ifn;
|
struct ifnet *ifn;
|
||||||
|
@ -61,6 +61,8 @@ int sctp_copy_out_packet_log(uint8_t *target, int length);
|
|||||||
|
|
||||||
void sctp_addr_change(struct ifaddr *ifa, int cmd);
|
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);
|
void sctp_add_or_del_interfaces(int (*pred) (struct ifnet *), int add);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <netinet/sctp_auth.h>
|
#include <netinet/sctp_auth.h>
|
||||||
#include <netinet/sctp_bsd_addr.h>
|
#include <netinet/sctp_bsd_addr.h>
|
||||||
#include <netinet/udp.h>
|
#include <netinet/udp.h>
|
||||||
|
#include <sys/eventhandler.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +90,8 @@ sctp_init(void)
|
|||||||
SCTP_BASE_VAR(packet_log_end) = 0;
|
SCTP_BASE_VAR(packet_log_end) = 0;
|
||||||
memset(&SCTP_BASE_VAR(packet_log_buffer), 0, SCTP_PACKET_LOG_SIZE);
|
memset(&SCTP_BASE_VAR(packet_log_buffer), 0, SCTP_PACKET_LOG_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
EVENTHANDLER_REGISTER(rt_addrmsg, sctp_addr_change_event_handler,
|
||||||
|
NULL, EVENTHANDLER_PRI_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VIMAGE
|
#ifdef VIMAGE
|
||||||
|
@ -312,4 +312,9 @@ typedef void (*device_detach_fn)(void *, device_t, enum evhdev_detach);
|
|||||||
EVENTHANDLER_DECLARE(device_attach, device_attach_fn);
|
EVENTHANDLER_DECLARE(device_attach, device_attach_fn);
|
||||||
EVENTHANDLER_DECLARE(device_detach, device_detach_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_ */
|
#endif /* _SYS_EVENTHANDLER_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user