Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_ratelimit.c
Show First 20 Lines • Show All 1,022 Lines • ▼ Show 20 Lines | #endif | ||||
err = ifp->if_snd_tag_alloc(ifp, ¶ms, &tag); | err = ifp->if_snd_tag_alloc(ifp, ¶ms, &tag); | ||||
if (err) { | if (err) { | ||||
/* Failed to setup a tag? */ | /* Failed to setup a tag? */ | ||||
if (error) | if (error) | ||||
*error = err; | *error = err; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
tifp = tag->ifp; | tifp = tag->ifp; | ||||
tifp->if_snd_tag_free(tag); | m_snd_tag_rele(tag); | ||||
return (tifp); | return (tifp); | ||||
} | } | ||||
static const struct tcp_hwrate_limit_table * | static const struct tcp_hwrate_limit_table * | ||||
rt_setup_rate(struct inpcb *inp, struct ifnet *ifp, uint64_t bytes_per_sec, | rt_setup_rate(struct inpcb *inp, struct ifnet *ifp, uint64_t bytes_per_sec, | ||||
uint32_t flags, int *error) | uint32_t flags, int *error) | ||||
{ | { | ||||
/* First lets find the interface if it exists */ | /* First lets find the interface if it exists */ | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | tcp_rl_ifnet_link(void *arg __unused, struct ifnet *ifp, int link_state) | ||||
mtx_unlock(&rs_mtx); | mtx_unlock(&rs_mtx); | ||||
rt_setup_new_rs(ifp, &error); | rt_setup_new_rs(ifp, &error); | ||||
} | } | ||||
static void | static void | ||||
tcp_rl_ifnet_departure(void *arg __unused, struct ifnet *ifp) | tcp_rl_ifnet_departure(void *arg __unused, struct ifnet *ifp) | ||||
{ | { | ||||
struct tcp_rate_set *rs, *nrs; | struct tcp_rate_set *rs, *nrs; | ||||
struct ifnet *tifp; | |||||
int i; | int i; | ||||
mtx_lock(&rs_mtx); | mtx_lock(&rs_mtx); | ||||
CK_LIST_FOREACH_SAFE(rs, &int_rs, next, nrs) { | CK_LIST_FOREACH_SAFE(rs, &int_rs, next, nrs) { | ||||
if ((rs->rs_ifp == ifp) && | if ((rs->rs_ifp == ifp) && | ||||
(rs->rs_if_dunit == ifp->if_dunit)) { | (rs->rs_if_dunit == ifp->if_dunit)) { | ||||
CK_LIST_REMOVE(rs, next); | CK_LIST_REMOVE(rs, next); | ||||
rs_number_alive--; | rs_number_alive--; | ||||
rs->rs_flags |= RS_IS_DEAD; | rs->rs_flags |= RS_IS_DEAD; | ||||
for (i = 0; i < rs->rs_rate_cnt; i++) { | for (i = 0; i < rs->rs_rate_cnt; i++) { | ||||
if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) { | if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) { | ||||
tifp = rs->rs_rlt[i].tag->ifp; | in_pcbdetach_tag(rs->rs_rlt[i].tag); | ||||
in_pcbdetach_tag(tifp, rs->rs_rlt[i].tag); | |||||
rs->rs_rlt[i].tag = NULL; | rs->rs_rlt[i].tag = NULL; | ||||
} | } | ||||
rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED; | rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED; | ||||
} | } | ||||
if (rs->rs_flows_using == 0) | if (rs->rs_flows_using == 0) | ||||
rs_defer_destroy(rs); | rs_defer_destroy(rs); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
mtx_unlock(&rs_mtx); | mtx_unlock(&rs_mtx); | ||||
} | } | ||||
static void | static void | ||||
tcp_rl_shutdown(void *arg __unused, int howto __unused) | tcp_rl_shutdown(void *arg __unused, int howto __unused) | ||||
{ | { | ||||
struct tcp_rate_set *rs, *nrs; | struct tcp_rate_set *rs, *nrs; | ||||
struct ifnet *tifp; | |||||
int i; | int i; | ||||
mtx_lock(&rs_mtx); | mtx_lock(&rs_mtx); | ||||
CK_LIST_FOREACH_SAFE(rs, &int_rs, next, nrs) { | CK_LIST_FOREACH_SAFE(rs, &int_rs, next, nrs) { | ||||
CK_LIST_REMOVE(rs, next); | CK_LIST_REMOVE(rs, next); | ||||
rs_number_alive--; | rs_number_alive--; | ||||
rs->rs_flags |= RS_IS_DEAD; | rs->rs_flags |= RS_IS_DEAD; | ||||
for (i = 0; i < rs->rs_rate_cnt; i++) { | for (i = 0; i < rs->rs_rate_cnt; i++) { | ||||
if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) { | if (rs->rs_rlt[i].flags & HDWRPACE_TAGPRESENT) { | ||||
tifp = rs->rs_rlt[i].tag->ifp; | in_pcbdetach_tag(rs->rs_rlt[i].tag); | ||||
in_pcbdetach_tag(tifp, rs->rs_rlt[i].tag); | |||||
rs->rs_rlt[i].tag = NULL; | rs->rs_rlt[i].tag = NULL; | ||||
} | } | ||||
rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED; | rs->rs_rlt[i].flags = HDWRPACE_IFPDEPARTED; | ||||
} | } | ||||
if (rs->rs_flows_using == 0) | if (rs->rs_flows_using == 0) | ||||
rs_defer_destroy(rs); | rs_defer_destroy(rs); | ||||
} | } | ||||
mtx_unlock(&rs_mtx); | mtx_unlock(&rs_mtx); | ||||
▲ Show 20 Lines • Show All 348 Lines • Show Last 20 Lines |