Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/nhop_ctl.c
| Show First 20 Lines • Show All 1,329 Lines • ▼ Show 20 Lines | nhops_dump_sysctl(struct rib_head *rh, struct sysctl_req *w) | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static void | static void | ||||
| nhops_ifnet_state_changed(struct ifnet *ifp, bool status) | nhops_ifnet_state_changed(struct ifnet *ifp, bool status) | ||||
| { | { | ||||
| struct nhop_object *nh; | struct nhop_object *nh; | ||||
| struct nhop_iter iter = { .fibnum = ifp->if_fib, .wlock = true }; | struct nhop_iter iter = { .fibnum = ifp->if_fib, .wlock = true }; | ||||
| bool nhops_changed; | |||||
| for (iter.family = 1; iter.family <= AF_MAX; iter.family++) { | for (iter.family = 1; iter.family <= AF_MAX; iter.family++) { | ||||
| /* | |||||
| * By tracking nhop changes, we avoid redundant nhgrp | |||||
| * recompilation triggered by multiple events. | |||||
| */ | |||||
| nhops_changed = false; | |||||
| iter.rh = rt_tables_get_rnh_safe(iter.fibnum, iter.family); | iter.rh = rt_tables_get_rnh_safe(iter.fibnum, iter.family); | ||||
| for (nh = nhops_iter_start(&iter); nh != NULL; | for (nh = nhops_iter_start(&iter); nh != NULL; | ||||
| nh = nhops_iter_next(&iter)) { | nh = nhops_iter_next(&iter)) { | ||||
| if (nh->nh_ifp != ifp) | if (nh->nh_ifp != ifp) | ||||
| continue; | continue; | ||||
| if (status) | if (status && !NH_IS_VALID(nh)) { | ||||
| nh->nh_flags &= ~NHF_INVALID; | nh->nh_flags &= ~NHF_INVALID; | ||||
| else | nhops_changed = true; | ||||
| } else if (!status && NH_IS_VALID(nh)) { | |||||
| nh->nh_flags |= NHF_INVALID; | nh->nh_flags |= NHF_INVALID; | ||||
| nhops_changed = true; | |||||
| } | } | ||||
| } | |||||
| if (iter.rh != NULL && nhops_changed) | |||||
| nhgrp_recompile(iter.rh); | |||||
| nhops_iter_stop(&iter); | nhops_iter_stop(&iter); | ||||
| } | } | ||||
| } | } | ||||
| static void | static void | ||||
| nhops_ifnet_event(void *arg __unused, struct ifnet *ifp, int state) | nhops_ifnet_event(void *arg __unused, struct ifnet *ifp, int state) | ||||
| { | { | ||||
| Show All 25 Lines | |||||