Lines Matching refs:nhg

74 	struct nh_group *nhg;  in nexthop_free_mpath()  local
77 nhg = rcu_dereference_raw(nh->nh_grp); in nexthop_free_mpath()
78 for (i = 0; i < nhg->num_nh; ++i) { in nexthop_free_mpath()
79 struct nh_grp_entry *nhge = &nhg->nh_entries[i]; in nexthop_free_mpath()
85 WARN_ON(nhg->spare == nhg); in nexthop_free_mpath()
87 kfree(nhg->spare); in nexthop_free_mpath()
88 kfree(nhg); in nexthop_free_mpath()
136 struct nh_group *nhg; in nexthop_grp_alloc() local
138 nhg = kzalloc(struct_size(nhg, nh_entries, num_nh), GFP_KERNEL); in nexthop_grp_alloc()
139 if (nhg) in nexthop_grp_alloc()
140 nhg->num_nh = num_nh; in nexthop_grp_alloc()
142 return nhg; in nexthop_grp_alloc()
193 static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg) in nla_put_nh_group() argument
196 size_t len = nhg->num_nh * sizeof(*p); in nla_put_nh_group()
201 if (nhg->mpath) in nla_put_nh_group()
212 for (i = 0; i < nhg->num_nh; ++i) { in nla_put_nh_group()
213 p->id = nhg->nh_entries[i].nh->id; in nla_put_nh_group()
214 p->weight = nhg->nh_entries[i].weight - 1; in nla_put_nh_group()
248 struct nh_group *nhg = rtnl_dereference(nh->nh_grp); in nh_fill_node() local
250 if (nhg->fdb_nh && nla_put_flag(skb, NHA_FDB)) in nh_fill_node()
252 if (nla_put_nh_group(skb, nhg)) in nh_fill_node()
307 struct nh_group *nhg = rtnl_dereference(nh->nh_grp); in nh_nlmsg_size_grp() local
308 size_t sz = sizeof(struct nexthop_grp) * nhg->num_nh; in nh_nlmsg_size_grp()
390 struct nh_group *nhg = rtnl_dereference(nh->nh_grp); in valid_group_nh() local
395 if (nhg->mpath) { in valid_group_nh()
400 *is_fdb = nhg->fdb_nh; in valid_group_nh()
442 struct nexthop_grp *nhg; in nh_check_attr_group() local
453 len /= sizeof(*nhg); in nh_check_attr_group()
455 nhg = nla_data(tb[NHA_GROUP]); in nh_check_attr_group()
457 if (nhg[i].resvd1 || nhg[i].resvd2) { in nh_check_attr_group()
461 if (nhg[i].weight > 254) { in nh_check_attr_group()
466 if (nhg[i].id == nhg[j].id) { in nh_check_attr_group()
475 nhg = nla_data(tb[NHA_GROUP]); in nh_check_attr_group()
480 nh = nexthop_find_by_id(net, nhg[i].id); in nh_check_attr_group()
545 struct nh_group *nhg; in nexthop_select_path() local
551 nhg = rcu_dereference(nh->nh_grp); in nexthop_select_path()
552 for (i = 0; i < nhg->num_nh; ++i) { in nexthop_select_path()
553 struct nh_grp_entry *nhge = &nhg->nh_entries[i]; in nexthop_select_path()
593 struct nh_group *nhg; in nexthop_for_each_fib6_nh() local
596 nhg = rcu_dereference_rtnl(nh->nh_grp); in nexthop_for_each_fib6_nh()
597 for (i = 0; i < nhg->num_nh; i++) { in nexthop_for_each_fib6_nh()
598 struct nh_grp_entry *nhge = &nhg->nh_entries[i]; in nexthop_for_each_fib6_nh()
642 struct nh_group *nhg; in fib6_check_nexthop() local
644 nhg = rtnl_dereference(nh->nh_grp); in fib6_check_nexthop()
645 if (nhg->has_v4) in fib6_check_nexthop()
647 is_fdb_nh = nhg->fdb_nh; in fib6_check_nexthop()
714 struct nh_group *nhg; in fib_check_nexthop() local
716 nhg = rtnl_dereference(nh->nh_grp); in fib_check_nexthop()
717 if (nhg->fdb_nh) { in fib_check_nexthop()
730 nhi = rtnl_dereference(nhg->nh_entries[0].nh->nh_info); in fib_check_nexthop()
761 static void nh_group_rebalance(struct nh_group *nhg) in nh_group_rebalance() argument
767 for (i = 0; i < nhg->num_nh; ++i) in nh_group_rebalance()
768 total += nhg->nh_entries[i].weight; in nh_group_rebalance()
770 for (i = 0; i < nhg->num_nh; ++i) { in nh_group_rebalance()
771 struct nh_grp_entry *nhge = &nhg->nh_entries[i]; in nh_group_rebalance()
786 struct nh_group *nhg, *newg; in remove_nh_grp_entry() local
791 nhg = rtnl_dereference(nhp->nh_grp); in remove_nh_grp_entry()
792 newg = nhg->spare; in remove_nh_grp_entry()
795 if (nhg->num_nh == 1) { in remove_nh_grp_entry()
801 newg->mpath = nhg->mpath; in remove_nh_grp_entry()
802 newg->fdb_nh = nhg->fdb_nh; in remove_nh_grp_entry()
803 newg->num_nh = nhg->num_nh; in remove_nh_grp_entry()
806 nhges = nhg->nh_entries; in remove_nh_grp_entry()
808 for (i = 0, j = 0; i < nhg->num_nh; ++i) { in remove_nh_grp_entry()
812 if (nhg->nh_entries[i].nh == nh) { in remove_nh_grp_entry()
853 struct nh_group *nhg = rcu_dereference_rtnl(nh->nh_grp); in remove_nexthop_group() local
854 int i, num_nh = nhg->num_nh; in remove_nexthop_group()
857 struct nh_grp_entry *nhge = &nhg->nh_entries[i]; in remove_nexthop_group()
967 static void nh_group_v4_update(struct nh_group *nhg) in nh_group_v4_update() argument
973 nhges = nhg->nh_entries; in nh_group_v4_update()
974 for (i = 0; i < nhg->num_nh; i++) { in nh_group_v4_update()
981 nhg->has_v4 = has_v4; in nh_group_v4_update()
1015 struct nh_group *nhg; in replace_nexthop_single() local
1017 nhg = rtnl_dereference(nhp->nh_grp); in replace_nexthop_single()
1018 nh_group_v4_update(nhg); in replace_nexthop_single()
1226 struct nh_group *nhg; in nexthop_create_group() local
1239 nhg = nexthop_grp_alloc(num_nh); in nexthop_create_group()
1240 if (!nhg) { in nexthop_create_group()
1246 nhg->spare = nexthop_grp_alloc(num_nh); in nexthop_create_group()
1247 if (!nhg->spare) { in nexthop_create_group()
1248 kfree(nhg); in nexthop_create_group()
1252 nhg->spare->spare = nhg; in nexthop_create_group()
1254 for (i = 0; i < nhg->num_nh; ++i) { in nexthop_create_group()
1264 nhg->has_v4 = true; in nexthop_create_group()
1266 nhg->nh_entries[i].nh = nhe; in nexthop_create_group()
1267 nhg->nh_entries[i].weight = entry[i].weight + 1; in nexthop_create_group()
1268 list_add(&nhg->nh_entries[i].nh_list, &nhe->grp_list); in nexthop_create_group()
1269 nhg->nh_entries[i].nh_parent = nh; in nexthop_create_group()
1273 nhg->mpath = 1; in nexthop_create_group()
1274 nh_group_rebalance(nhg); in nexthop_create_group()
1278 nhg->fdb_nh = 1; in nexthop_create_group()
1280 rcu_assign_pointer(nh->nh_grp, nhg); in nexthop_create_group()
1286 list_del(&nhg->nh_entries[i].nh_list); in nexthop_create_group()
1287 nexthop_put(nhg->nh_entries[i].nh); in nexthop_create_group()
1290 kfree(nhg->spare); in nexthop_create_group()
1291 kfree(nhg); in nexthop_create_group()