routing: refactor private KPI
* Make nhgrp_get_nhops() return const struct weightened_nhop to indicate that the list is immutable * Make nhgrp_get_group() return the actual group, instead of group+weight. MFC after: 2 weeks
This commit is contained in:
parent
f28532a0f3
commit
ae6bfd12c8
@ -598,7 +598,7 @@ append_nhops(struct nh_control *ctl, const struct nhgrp_object *gr_orig,
|
||||
*/
|
||||
int
|
||||
nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, int num_nhops,
|
||||
struct route_nhop_data *rnd)
|
||||
struct nhgrp_object **pnhg)
|
||||
{
|
||||
struct nh_control *ctl = rh->nh_control;
|
||||
struct nhgrp_priv *nhg_priv;
|
||||
@ -606,8 +606,7 @@ nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, int num_nhops,
|
||||
|
||||
nhg_priv = get_nhgrp(ctl, wn, num_nhops, &error);
|
||||
if (nhg_priv != NULL)
|
||||
rnd->rnd_nhgrp = nhg_priv->nhg;
|
||||
rnd->rnd_weight = 0;
|
||||
*pnhg = nhg_priv->nhg;
|
||||
|
||||
return (error);
|
||||
}
|
||||
@ -718,14 +717,14 @@ nhgrp_get_addition_group(struct rib_head *rh, struct route_nhop_data *rnd_orig,
|
||||
* Returns pointer to array of nexthops with weights for
|
||||
* given @nhg. Stores number of items in the array into @pnum_nhops.
|
||||
*/
|
||||
struct weightened_nhop *
|
||||
nhgrp_get_nhops(struct nhgrp_object *nhg, uint32_t *pnum_nhops)
|
||||
const struct weightened_nhop *
|
||||
nhgrp_get_nhops(const struct nhgrp_object *nhg, uint32_t *pnum_nhops)
|
||||
{
|
||||
struct nhgrp_priv *nhg_priv;
|
||||
const struct nhgrp_priv *nhg_priv;
|
||||
|
||||
KASSERT(((nhg->nhg_flags & MPF_MULTIPATH) != 0), ("nhop is not mpath"));
|
||||
|
||||
nhg_priv = NHGRP_PRIV(nhg);
|
||||
nhg_priv = NHGRP_PRIV_CONST(nhg);
|
||||
*pnum_nhops = nhg_priv->nhg_nh_count;
|
||||
|
||||
return (nhg_priv->nhg_nh_weights);
|
||||
|
@ -155,7 +155,7 @@ destroy_rtentry(struct rtentry *rt)
|
||||
*/
|
||||
#ifdef ROUTE_MPATH
|
||||
if (NH_IS_NHGRP(nh)) {
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
|
||||
nh = wn[0].nh;
|
||||
@ -1010,8 +1010,9 @@ change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info,
|
||||
{
|
||||
int error = 0, found_idx = 0;
|
||||
struct nhop_object *nh_orig = NULL, *nh_new;
|
||||
struct route_nhop_data rnd_new;
|
||||
struct weightened_nhop *wn = NULL, *wn_new;
|
||||
struct route_nhop_data rnd_new = {};
|
||||
const struct weightened_nhop *wn = NULL;
|
||||
struct weightened_nhop *wn_new;
|
||||
uint32_t num_nhops;
|
||||
|
||||
wn = nhgrp_get_nhops(rnd_orig->rnd_nhgrp, &num_nhops);
|
||||
@ -1041,7 +1042,7 @@ change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info,
|
||||
wn_new[found_idx].nh = nh_new;
|
||||
wn_new[found_idx].weight = get_info_weight(info, wn[found_idx].weight);
|
||||
|
||||
error = nhgrp_get_group(rnh, wn_new, num_nhops, &rnd_new);
|
||||
error = nhgrp_get_group(rnh, wn_new, num_nhops, &rnd_new.rnd_nhgrp);
|
||||
nhop_free(nh_new);
|
||||
free(wn_new, M_TEMP);
|
||||
|
||||
@ -1375,7 +1376,7 @@ rib_walk_del(u_int fibnum, int family, rib_filter_f_t *filter_f, void *arg, bool
|
||||
if (report) {
|
||||
#ifdef ROUTE_MPATH
|
||||
struct nhgrp_object *nhg;
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
if (NH_IS_NHGRP(nh)) {
|
||||
nhg = (struct nhgrp_object *)nh;
|
||||
|
@ -135,7 +135,7 @@ uint32_t nhops_get_count(struct rib_head *rh);
|
||||
/* Multipath */
|
||||
struct weightened_nhop;
|
||||
|
||||
struct weightened_nhop *nhgrp_get_nhops(struct nhgrp_object *nhg,
|
||||
const struct weightened_nhop *nhgrp_get_nhops(const struct nhgrp_object *nhg,
|
||||
uint32_t *pnum_nhops);
|
||||
uint32_t nhgrp_get_count(struct rib_head *rh);
|
||||
|
||||
|
@ -290,7 +290,7 @@ decompose_change_notification(struct rib_cmd_info *rc, route_notification_t *cb,
|
||||
void *cbdata)
|
||||
{
|
||||
uint32_t num_old, num_new;
|
||||
struct weightened_nhop *wn_old, *wn_new;
|
||||
const struct weightened_nhop *wn_old, *wn_new;
|
||||
struct weightened_nhop tmp = { NULL, 0 };
|
||||
uint32_t idx_old = 0, idx_new = 0;
|
||||
|
||||
@ -378,7 +378,7 @@ void
|
||||
rib_decompose_notification(struct rib_cmd_info *rc, route_notification_t *cb,
|
||||
void *cbdata)
|
||||
{
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
struct rib_cmd_info rc_new;
|
||||
|
||||
|
@ -295,7 +295,7 @@ void nhgrp_ctl_unlink_all(struct nh_control *ctl);
|
||||
int nhgrp_dump_sysctl(struct rib_head *rh, struct sysctl_req *w);
|
||||
|
||||
int nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn,
|
||||
int num_nhops, struct route_nhop_data *rnd);
|
||||
int num_nhops, struct nhgrp_object **pnhg);
|
||||
typedef bool nhgrp_filter_cb_t(const struct nhop_object *nh, void *data);
|
||||
int nhgrp_get_filtered_group(struct rib_head *rh, const struct nhgrp_object *src,
|
||||
nhgrp_filter_cb_t flt_func, void *flt_data, struct route_nhop_data *rnd);
|
||||
|
@ -718,7 +718,7 @@ select_nhop(struct nhop_object *nh, const struct sockaddr *gw)
|
||||
if (!NH_IS_NHGRP(nh))
|
||||
return (nh);
|
||||
#ifdef ROUTE_MPATH
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
|
||||
if (gw == NULL)
|
||||
@ -2243,7 +2243,7 @@ sysctl_dumpentry(struct rtentry *rt, void *vw)
|
||||
nh = rt_get_raw_nhop(rt);
|
||||
#ifdef ROUTE_MPATH
|
||||
if (NH_IS_NHGRP(nh)) {
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
int error;
|
||||
wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
|
||||
|
@ -196,7 +196,7 @@ check_urpf(struct nhop_object *nh, uint32_t flags,
|
||||
{
|
||||
#ifdef ROUTE_MPATH
|
||||
if (NH_IS_NHGRP(nh)) {
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
|
||||
for (int i = 0; i < num_nhops; i++) {
|
||||
|
@ -205,7 +205,7 @@ check_urpf(struct nhop_object *nh, uint32_t flags,
|
||||
{
|
||||
#ifdef ROUTE_MPATH
|
||||
if (NH_IS_NHGRP(nh)) {
|
||||
struct weightened_nhop *wn;
|
||||
const struct weightened_nhop *wn;
|
||||
uint32_t num_nhops;
|
||||
wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops);
|
||||
for (int i = 0; i < num_nhops; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user