Changeset View
Changeset View
Standalone View
Standalone View
sys/net/rtsock.c
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | |||||
static int update_rtm_from_rc(struct rt_addrinfo *info, | static int update_rtm_from_rc(struct rt_addrinfo *info, | ||||
struct rt_msghdr **prtm, int alloc_len, | struct rt_msghdr **prtm, int alloc_len, | ||||
struct rib_cmd_info *rc, struct nhop_object *nh); | struct rib_cmd_info *rc, struct nhop_object *nh); | ||||
static void send_rtm_reply(struct socket *so, struct rt_msghdr *rtm, | static void send_rtm_reply(struct socket *so, struct rt_msghdr *rtm, | ||||
struct mbuf *m, sa_family_t saf, u_int fibnum, | struct mbuf *m, sa_family_t saf, u_int fibnum, | ||||
int rtm_errno); | int rtm_errno); | ||||
static bool can_export_rte(struct ucred *td_ucred, bool rt_is_host, | static bool can_export_rte(struct ucred *td_ucred, bool rt_is_host, | ||||
const struct sockaddr *rt_dst); | const struct sockaddr *rt_dst); | ||||
static void rtsock_notify_event(uint32_t fibnum, const struct rib_cmd_info *rc); | |||||
static struct netisr_handler rtsock_nh = { | static struct netisr_handler rtsock_nh = { | ||||
.nh_name = "rtsock", | .nh_name = "rtsock", | ||||
.nh_handler = rts_input, | .nh_handler = rts_input, | ||||
.nh_proto = NETISR_ROUTE, | .nh_proto = NETISR_ROUTE, | ||||
.nh_policy = NETISR_POLICY_SOURCE, | .nh_policy = NETISR_POLICY_SOURCE, | ||||
}; | }; | ||||
Show All 40 Lines | vnet_rts_uninit(void) | ||||
netisr_unregister_vnet(&rtsock_nh); | netisr_unregister_vnet(&rtsock_nh); | ||||
} | } | ||||
VNET_SYSUNINIT(vnet_rts_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, | VNET_SYSUNINIT(vnet_rts_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, | ||||
vnet_rts_uninit, 0); | vnet_rts_uninit, 0); | ||||
#endif | #endif | ||||
static void | static void | ||||
report_route_event(const struct rib_cmd_info *rc, void *_cbdata) | |||||
{ | |||||
uint32_t fibnum = (uint32_t)(uintptr_t)_cbdata; | |||||
struct nhop_object *nh; | |||||
nh = rc->rc_cmd == RTM_DELETE ? rc->rc_nh_old : rc->rc_nh_new; | |||||
rt_routemsg(rc->rc_cmd, rc->rc_rt, nh, fibnum); | |||||
} | |||||
static void | |||||
rts_handle_route_event(uint32_t fibnum, const struct rib_cmd_info *rc) | |||||
{ | |||||
#ifdef ROUTE_MPATH | |||||
if ((rc->rc_nh_new && NH_IS_NHGRP(rc->rc_nh_new)) || | |||||
(rc->rc_nh_old && NH_IS_NHGRP(rc->rc_nh_old))) { | |||||
rib_decompose_notification(rc, report_route_event, | |||||
(void *)(uintptr_t)fibnum); | |||||
} else | |||||
#endif | |||||
report_route_event(rc, (void *)(uintptr_t)fibnum); | |||||
} | |||||
glebius: Missing tab. | |||||
static struct rtbridge rtsbridge = { .route_f = rts_handle_route_event }; | |||||
static struct rtbridge *rtsbridge_orig_p; | |||||
static void | |||||
rtsock_notify_event(uint32_t fibnum, const struct rib_cmd_info *rc) | |||||
{ | |||||
netlink_callback_p->route_f(fibnum, rc); | |||||
} | |||||
static void | |||||
rtsock_init(void) | |||||
{ | |||||
rtsbridge_orig_p = rtsock_callback_p; | |||||
rtsock_callback_p = &rtsbridge; | |||||
} | |||||
SYSINIT(rtsock_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, rtsock_init, NULL); | |||||
static void | |||||
rts_handle_ifnet_arrival(void *arg __unused, struct ifnet *ifp) | rts_handle_ifnet_arrival(void *arg __unused, struct ifnet *ifp) | ||||
{ | { | ||||
rt_ifannouncemsg(ifp, IFAN_ARRIVAL); | rt_ifannouncemsg(ifp, IFAN_ARRIVAL); | ||||
} | } | ||||
EVENTHANDLER_DEFINE(ifnet_arrival_event, rts_handle_ifnet_arrival, NULL, 0); | EVENTHANDLER_DEFINE(ifnet_arrival_event, rts_handle_ifnet_arrival, NULL, 0); | ||||
static void | static void | ||||
rts_handle_ifnet_departure(void *arg __unused, struct ifnet *ifp) | rts_handle_ifnet_departure(void *arg __unused, struct ifnet *ifp) | ||||
▲ Show 20 Lines • Show All 783 Lines • ▼ Show 20 Lines | case RTM_CHANGE: | ||||
if (rtm->rtm_type == RTM_ADD) { | if (rtm->rtm_type == RTM_ADD) { | ||||
if (info.rti_info[RTAX_GATEWAY] == NULL) { | if (info.rti_info[RTAX_GATEWAY] == NULL) { | ||||
RTS_PID_LOG(LOG_DEBUG, "RTM_ADD w/o gateway"); | RTS_PID_LOG(LOG_DEBUG, "RTM_ADD w/o gateway"); | ||||
senderr(EINVAL); | senderr(EINVAL); | ||||
} | } | ||||
} | } | ||||
error = rib_action(fibnum, rtm->rtm_type, &info, &rc); | error = rib_action(fibnum, rtm->rtm_type, &info, &rc); | ||||
if (error == 0) { | if (error == 0) { | ||||
rtsock_notify_event(fibnum, &rc); | |||||
#ifdef ROUTE_MPATH | #ifdef ROUTE_MPATH | ||||
if (NH_IS_NHGRP(rc.rc_nh_new) || | if (NH_IS_NHGRP(rc.rc_nh_new) || | ||||
(rc.rc_nh_old && NH_IS_NHGRP(rc.rc_nh_old))) { | (rc.rc_nh_old && NH_IS_NHGRP(rc.rc_nh_old))) { | ||||
struct rib_cmd_info rc_simple = {}; | struct rib_cmd_info rc_simple = {}; | ||||
rib_decompose_notification(&rc, | rib_decompose_notification(&rc, | ||||
save_add_notification, (void *)&rc_simple); | save_add_notification, (void *)&rc_simple); | ||||
rc = rc_simple; | rc = rc_simple; | ||||
} | } | ||||
#endif | #endif | ||||
/* nh MAY be empty if RTM_CHANGE request is no-op */ | /* nh MAY be empty if RTM_CHANGE request is no-op */ | ||||
nh = rc.rc_nh_new; | nh = rc.rc_nh_new; | ||||
if (nh != NULL) { | if (nh != NULL) { | ||||
rtm->rtm_index = nh->nh_ifp->if_index; | rtm->rtm_index = nh->nh_ifp->if_index; | ||||
rtm->rtm_flags = rc.rc_rt->rte_flags | nhop_get_rtflags(nh); | rtm->rtm_flags = rc.rc_rt->rte_flags | nhop_get_rtflags(nh); | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
case RTM_DELETE: | case RTM_DELETE: | ||||
error = rib_action(fibnum, RTM_DELETE, &info, &rc); | error = rib_action(fibnum, RTM_DELETE, &info, &rc); | ||||
if (error == 0) { | if (error == 0) { | ||||
rtsock_notify_event(fibnum, &rc); | |||||
#ifdef ROUTE_MPATH | #ifdef ROUTE_MPATH | ||||
if (NH_IS_NHGRP(rc.rc_nh_old) || | if (NH_IS_NHGRP(rc.rc_nh_old) || | ||||
(rc.rc_nh_new && NH_IS_NHGRP(rc.rc_nh_new))) { | (rc.rc_nh_new && NH_IS_NHGRP(rc.rc_nh_new))) { | ||||
struct rib_cmd_info rc_simple = {}; | struct rib_cmd_info rc_simple = {}; | ||||
rib_decompose_notification(&rc, | rib_decompose_notification(&rc, | ||||
save_del_notification, (void *)&rc_simple); | save_del_notification, (void *)&rc_simple); | ||||
rc = rc_simple; | rc = rc_simple; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,564 Lines • Show Last 20 Lines |
Missing tab.