Lines Matching refs:nh
64 struct nexthop *nh; member
105 static inline bool nexthop_get(struct nexthop *nh) in nexthop_get() argument
107 return refcount_inc_not_zero(&nh->refcnt); in nexthop_get()
110 static inline void nexthop_put(struct nexthop *nh) in nexthop_put() argument
112 if (refcount_dec_and_test(&nh->refcnt)) in nexthop_put()
113 call_rcu(&nh->rcu, nexthop_free_rcu); in nexthop_put()
122 static inline bool nexthop_is_multipath(const struct nexthop *nh) in nexthop_is_multipath() argument
124 if (nh->is_group) { in nexthop_is_multipath()
127 nh_grp = rcu_dereference_rtnl(nh->nh_grp); in nexthop_is_multipath()
133 struct nexthop *nexthop_select_path(struct nexthop *nh, int hash);
135 static inline unsigned int nexthop_num_path(const struct nexthop *nh) in nexthop_num_path() argument
139 if (nexthop_is_multipath(nh)) { in nexthop_num_path()
142 nh_grp = rcu_dereference_rtnl(nh->nh_grp); in nexthop_num_path()
150 struct nexthop *nexthop_mpath_select(const struct nexthop *nh, int nhsel) in nexthop_mpath_select() argument
152 const struct nh_group *nhg = rcu_dereference_rtnl(nh->nh_grp); in nexthop_mpath_select()
160 return nhg->nh_entries[nhsel].nh; in nexthop_mpath_select()
164 int nexthop_mpath_fill_node(struct sk_buff *skb, struct nexthop *nh, in nexthop_mpath_fill_node() argument
167 struct nh_group *nhg = rtnl_dereference(nh->nh_grp); in nexthop_mpath_fill_node()
171 struct nexthop *nhe = nhg->nh_entries[i].nh; in nexthop_mpath_fill_node()
184 static inline bool nexthop_is_blackhole(const struct nexthop *nh) in nexthop_is_blackhole() argument
188 if (nexthop_is_multipath(nh)) { in nexthop_is_blackhole()
189 if (nexthop_num_path(nh) > 1) in nexthop_is_blackhole()
191 nh = nexthop_mpath_select(nh, 0); in nexthop_is_blackhole()
192 if (!nh) in nexthop_is_blackhole()
196 nhi = rcu_dereference_rtnl(nh->nh_info); in nexthop_is_blackhole()
203 struct nexthop *nh; in nexthop_path_fib_result() local
205 nh = nexthop_select_path(res->fi->nh, hash); in nexthop_path_fib_result()
206 nhi = rcu_dereference(nh->nh_info); in nexthop_path_fib_result()
212 struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel) in nexthop_fib_nhc() argument
219 if (nexthop_is_multipath(nh)) { in nexthop_fib_nhc()
220 nh = nexthop_mpath_select(nh, nhsel); in nexthop_fib_nhc()
221 if (!nh) in nexthop_fib_nhc()
225 nhi = rcu_dereference_rtnl(nh->nh_info); in nexthop_fib_nhc()
231 if (unlikely(fi->nh)) in fib_info_num_path()
232 return nexthop_num_path(fi->nh); in fib_info_num_path()
237 int fib_check_nexthop(struct nexthop *nh, u8 scope,
242 if (unlikely(fi->nh)) in fib_info_nhc()
243 return nexthop_fib_nhc(fi->nh, nhsel); in fib_info_nhc()
251 WARN_ON(fi->nh); in fib_info_nh()
259 int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg,
262 static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) in nexthop_fib6_nh() argument
266 if (nexthop_is_multipath(nh)) { in nexthop_fib6_nh()
267 nh = nexthop_mpath_select(nh, 0); in nexthop_fib6_nh()
268 if (!nh) in nexthop_fib6_nh()
272 nhi = rcu_dereference_rtnl(nh->nh_info); in nexthop_fib6_nh()
283 fib6_nh = f6i->nh ? nexthop_fib6_nh(f6i->nh) : f6i->fib6_nh; in fib6_info_nh_dev()
289 struct nexthop *nh = res->f6i->nh; in nexthop_path_fib6_result() local
292 nh = nexthop_select_path(nh, hash); in nexthop_path_fib6_result()
294 nhi = rcu_dereference_rtnl(nh->nh_info); in nexthop_path_fib6_result()
298 res->nh = nexthop_fib6_nh(nh); in nexthop_path_fib6_result()
300 res->nh = &nhi->fib6_nh; in nexthop_path_fib6_result()
304 int nexthop_for_each_fib6_nh(struct nexthop *nh,
305 int (*cb)(struct fib6_nh *nh, void *arg),