David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Generic nexthop implementation |
| 4 | * |
| 5 | * Copyright (c) 2017-19 Cumulus Networks |
| 6 | * Copyright (c) 2017-19 David Ahern <dsa@cumulusnetworks.com> |
| 7 | */ |
| 8 | |
| 9 | #ifndef __LINUX_NEXTHOP_H |
| 10 | #define __LINUX_NEXTHOP_H |
| 11 | |
| 12 | #include <linux/netdevice.h> |
Roopa Prabhu | 8590ceed | 2020-05-21 22:26:15 -0700 | [diff] [blame] | 13 | #include <linux/notifier.h> |
David Ahern | f88d8ea | 2019-06-03 20:19:52 -0700 | [diff] [blame] | 14 | #include <linux/route.h> |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 15 | #include <linux/types.h> |
| 16 | #include <net/ip_fib.h> |
David Ahern | 53010f9 | 2019-05-24 14:43:06 -0700 | [diff] [blame] | 17 | #include <net/ip6_fib.h> |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 18 | #include <net/netlink.h> |
| 19 | |
| 20 | #define NEXTHOP_VALID_USER_FLAGS RTNH_F_ONLINK |
| 21 | |
| 22 | struct nexthop; |
| 23 | |
| 24 | struct nh_config { |
| 25 | u32 nh_id; |
| 26 | |
| 27 | u8 nh_family; |
| 28 | u8 nh_protocol; |
| 29 | u8 nh_blackhole; |
Roopa Prabhu | 38428d6 | 2020-05-21 22:26:13 -0700 | [diff] [blame] | 30 | u8 nh_fdb; |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 31 | u32 nh_flags; |
| 32 | |
| 33 | int nh_ifindex; |
| 34 | struct net_device *dev; |
| 35 | |
David Ahern | 597cfe4f | 2019-05-24 14:43:05 -0700 | [diff] [blame] | 36 | union { |
| 37 | __be32 ipv4; |
David Ahern | 53010f9 | 2019-05-24 14:43:06 -0700 | [diff] [blame] | 38 | struct in6_addr ipv6; |
David Ahern | 597cfe4f | 2019-05-24 14:43:05 -0700 | [diff] [blame] | 39 | } gw; |
| 40 | |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 41 | struct nlattr *nh_grp; |
| 42 | u16 nh_grp_type; |
| 43 | |
David Ahern | b513bd0 | 2019-05-24 14:43:07 -0700 | [diff] [blame] | 44 | struct nlattr *nh_encap; |
| 45 | u16 nh_encap_type; |
| 46 | |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 47 | u32 nlflags; |
| 48 | struct nl_info nlinfo; |
| 49 | }; |
| 50 | |
| 51 | struct nh_info { |
| 52 | struct hlist_node dev_hash; /* entry on netns devhash */ |
| 53 | struct nexthop *nh_parent; |
| 54 | |
| 55 | u8 family; |
| 56 | bool reject_nh; |
Roopa Prabhu | 38428d6 | 2020-05-21 22:26:13 -0700 | [diff] [blame] | 57 | bool fdb_nh; |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 58 | |
| 59 | union { |
| 60 | struct fib_nh_common fib_nhc; |
David Ahern | 597cfe4f | 2019-05-24 14:43:05 -0700 | [diff] [blame] | 61 | struct fib_nh fib_nh; |
David Ahern | 53010f9 | 2019-05-24 14:43:06 -0700 | [diff] [blame] | 62 | struct fib6_nh fib6_nh; |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 63 | }; |
| 64 | }; |
| 65 | |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 66 | struct nh_grp_entry { |
| 67 | struct nexthop *nh; |
| 68 | u8 weight; |
| 69 | atomic_t upper_bound; |
| 70 | |
| 71 | struct list_head nh_list; |
| 72 | struct nexthop *nh_parent; /* nexthop of group with this entry */ |
| 73 | }; |
| 74 | |
| 75 | struct nh_group { |
Nikolay Aleksandrov | 90f33bf | 2020-05-26 12:56:15 -0600 | [diff] [blame] | 76 | struct nh_group *spare; /* spare group for removals */ |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 77 | u16 num_nh; |
| 78 | bool mpath; |
| 79 | bool has_v4; |
Gustavo A. R. Silva | 97a888c | 2020-02-28 18:14:11 -0600 | [diff] [blame] | 80 | struct nh_grp_entry nh_entries[]; |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 83 | struct nexthop { |
| 84 | struct rb_node rb_node; /* entry on netns rbtree */ |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 85 | struct list_head fi_list; /* v4 entries using nh */ |
David Ahern | f88d8ea | 2019-06-03 20:19:52 -0700 | [diff] [blame] | 86 | struct list_head f6i_list; /* v6 entries using nh */ |
Roopa Prabhu | 38428d6 | 2020-05-21 22:26:13 -0700 | [diff] [blame] | 87 | struct list_head fdb_list; /* fdb entries using this nh */ |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 88 | struct list_head grp_list; /* nh group entries using this nh */ |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 89 | struct net *net; |
| 90 | |
| 91 | u32 id; |
| 92 | |
| 93 | u8 protocol; /* app managing this nh */ |
| 94 | u8 nh_flags; |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 95 | bool is_group; |
Roopa Prabhu | 38428d6 | 2020-05-21 22:26:13 -0700 | [diff] [blame] | 96 | bool is_fdb_nh; |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 97 | |
| 98 | refcount_t refcnt; |
| 99 | struct rcu_head rcu; |
| 100 | |
| 101 | union { |
| 102 | struct nh_info __rcu *nh_info; |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 103 | struct nh_group __rcu *nh_grp; |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 104 | }; |
| 105 | }; |
| 106 | |
Roopa Prabhu | 8590ceed | 2020-05-21 22:26:15 -0700 | [diff] [blame] | 107 | enum nexthop_event_type { |
| 108 | NEXTHOP_EVENT_ADD, |
| 109 | NEXTHOP_EVENT_DEL |
| 110 | }; |
| 111 | |
| 112 | int call_nexthop_notifier(struct notifier_block *nb, struct net *net, |
| 113 | enum nexthop_event_type event_type, |
| 114 | struct nexthop *nh); |
| 115 | int register_nexthop_notifier(struct net *net, struct notifier_block *nb); |
| 116 | int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb); |
| 117 | |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 118 | /* caller is holding rcu or rtnl; no reference taken to nexthop */ |
| 119 | struct nexthop *nexthop_find_by_id(struct net *net, u32 id); |
| 120 | void nexthop_free_rcu(struct rcu_head *head); |
| 121 | |
| 122 | static inline bool nexthop_get(struct nexthop *nh) |
| 123 | { |
| 124 | return refcount_inc_not_zero(&nh->refcnt); |
| 125 | } |
| 126 | |
| 127 | static inline void nexthop_put(struct nexthop *nh) |
| 128 | { |
| 129 | if (refcount_dec_and_test(&nh->refcnt)) |
| 130 | call_rcu(&nh->rcu, nexthop_free_rcu); |
| 131 | } |
| 132 | |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 133 | static inline bool nexthop_cmp(const struct nexthop *nh1, |
| 134 | const struct nexthop *nh2) |
| 135 | { |
| 136 | return nh1 == nh2; |
| 137 | } |
| 138 | |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 139 | static inline bool nexthop_is_multipath(const struct nexthop *nh) |
| 140 | { |
| 141 | if (nh->is_group) { |
| 142 | struct nh_group *nh_grp; |
| 143 | |
| 144 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 145 | return nh_grp->mpath; |
| 146 | } |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | struct nexthop *nexthop_select_path(struct nexthop *nh, int hash); |
| 151 | |
| 152 | static inline unsigned int nexthop_num_path(const struct nexthop *nh) |
| 153 | { |
| 154 | unsigned int rc = 1; |
| 155 | |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 156 | if (nh->is_group) { |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 157 | struct nh_group *nh_grp; |
| 158 | |
| 159 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 160 | if (nh_grp->mpath) |
| 161 | rc = nh_grp->num_nh; |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | return rc; |
| 165 | } |
| 166 | |
| 167 | static inline |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 168 | struct nexthop *nexthop_mpath_select(const struct nh_group *nhg, int nhsel) |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 169 | { |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 170 | /* for_nexthops macros in fib_semantics.c grabs a pointer to |
| 171 | * the nexthop before checking nhsel |
| 172 | */ |
Dan Carpenter | 5270041 | 2019-06-07 18:31:07 +0300 | [diff] [blame] | 173 | if (nhsel >= nhg->num_nh) |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 174 | return NULL; |
| 175 | |
| 176 | return nhg->nh_entries[nhsel].nh; |
| 177 | } |
| 178 | |
| 179 | static inline |
Donald Sharp | 7bdf4de | 2019-09-04 10:11:58 -0400 | [diff] [blame] | 180 | int nexthop_mpath_fill_node(struct sk_buff *skb, struct nexthop *nh, |
| 181 | u8 rt_family) |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 182 | { |
| 183 | struct nh_group *nhg = rtnl_dereference(nh->nh_grp); |
| 184 | int i; |
| 185 | |
| 186 | for (i = 0; i < nhg->num_nh; i++) { |
| 187 | struct nexthop *nhe = nhg->nh_entries[i].nh; |
| 188 | struct nh_info *nhi = rcu_dereference_rtnl(nhe->nh_info); |
| 189 | struct fib_nh_common *nhc = &nhi->fib_nhc; |
| 190 | int weight = nhg->nh_entries[i].weight; |
| 191 | |
Donald Sharp | 7bdf4de | 2019-09-04 10:11:58 -0400 | [diff] [blame] | 192 | if (fib_add_nexthop(skb, nhc, weight, rt_family) < 0) |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 193 | return -EMSGSIZE; |
| 194 | } |
| 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 199 | /* called with rcu lock */ |
| 200 | static inline bool nexthop_is_blackhole(const struct nexthop *nh) |
| 201 | { |
| 202 | const struct nh_info *nhi; |
| 203 | |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 204 | if (nh->is_group) { |
| 205 | struct nh_group *nh_grp; |
| 206 | |
| 207 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 208 | if (nh_grp->num_nh > 1) |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 209 | return false; |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 210 | |
| 211 | nh = nh_grp->nh_entries[0].nh; |
David Ahern | 430a049 | 2019-05-24 14:43:08 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | nhi = rcu_dereference_rtnl(nh->nh_info); |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 215 | return nhi->reject_nh; |
| 216 | } |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 217 | |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 218 | static inline void nexthop_path_fib_result(struct fib_result *res, int hash) |
| 219 | { |
| 220 | struct nh_info *nhi; |
| 221 | struct nexthop *nh; |
| 222 | |
| 223 | nh = nexthop_select_path(res->fi->nh, hash); |
| 224 | nhi = rcu_dereference(nh->nh_info); |
| 225 | res->nhc = &nhi->fib_nhc; |
| 226 | } |
| 227 | |
| 228 | /* called with rcu read lock or rtnl held */ |
| 229 | static inline |
| 230 | struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel) |
| 231 | { |
| 232 | struct nh_info *nhi; |
| 233 | |
| 234 | BUILD_BUG_ON(offsetof(struct fib_nh, nh_common) != 0); |
| 235 | BUILD_BUG_ON(offsetof(struct fib6_nh, nh_common) != 0); |
| 236 | |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 237 | if (nh->is_group) { |
| 238 | struct nh_group *nh_grp; |
| 239 | |
| 240 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 241 | if (nh_grp->mpath) { |
| 242 | nh = nexthop_mpath_select(nh_grp, nhsel); |
| 243 | if (!nh) |
| 244 | return NULL; |
| 245 | } |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | nhi = rcu_dereference_rtnl(nh->nh_info); |
| 249 | return &nhi->fib_nhc; |
| 250 | } |
| 251 | |
David Ahern | af7888a | 2020-05-26 12:56:17 -0600 | [diff] [blame] | 252 | /* called from fib_table_lookup with rcu_lock */ |
| 253 | static inline |
| 254 | struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh, |
| 255 | int fib_flags, |
| 256 | const struct flowi4 *flp, |
| 257 | int *nhsel) |
| 258 | { |
| 259 | struct nh_info *nhi; |
| 260 | |
| 261 | if (nh->is_group) { |
| 262 | struct nh_group *nhg = rcu_dereference(nh->nh_grp); |
| 263 | int i; |
| 264 | |
| 265 | for (i = 0; i < nhg->num_nh; i++) { |
| 266 | struct nexthop *nhe = nhg->nh_entries[i].nh; |
| 267 | |
| 268 | nhi = rcu_dereference(nhe->nh_info); |
| 269 | if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) { |
| 270 | *nhsel = i; |
| 271 | return &nhi->fib_nhc; |
| 272 | } |
| 273 | } |
| 274 | } else { |
| 275 | nhi = rcu_dereference(nh->nh_info); |
| 276 | if (fib_lookup_good_nhc(&nhi->fib_nhc, fib_flags, flp)) { |
| 277 | *nhsel = 0; |
| 278 | return &nhi->fib_nhc; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | return NULL; |
| 283 | } |
| 284 | |
David Ahern | 1fd1c76 | 2020-05-26 12:56:18 -0600 | [diff] [blame] | 285 | static inline bool nexthop_uses_dev(const struct nexthop *nh, |
| 286 | const struct net_device *dev) |
| 287 | { |
| 288 | struct nh_info *nhi; |
| 289 | |
| 290 | if (nh->is_group) { |
| 291 | struct nh_group *nhg = rcu_dereference(nh->nh_grp); |
| 292 | int i; |
| 293 | |
| 294 | for (i = 0; i < nhg->num_nh; i++) { |
| 295 | struct nexthop *nhe = nhg->nh_entries[i].nh; |
| 296 | |
| 297 | nhi = rcu_dereference(nhe->nh_info); |
| 298 | if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev)) |
| 299 | return true; |
| 300 | } |
| 301 | } else { |
| 302 | nhi = rcu_dereference(nh->nh_info); |
| 303 | if (nhc_l3mdev_matches_dev(&nhi->fib_nhc, dev)) |
| 304 | return true; |
| 305 | } |
| 306 | |
| 307 | return false; |
| 308 | } |
| 309 | |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 310 | static inline unsigned int fib_info_num_path(const struct fib_info *fi) |
| 311 | { |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 312 | if (unlikely(fi->nh)) |
| 313 | return nexthop_num_path(fi->nh); |
| 314 | |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 315 | return fi->fib_nhs; |
| 316 | } |
| 317 | |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 318 | int fib_check_nexthop(struct nexthop *nh, u8 scope, |
| 319 | struct netlink_ext_ack *extack); |
| 320 | |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 321 | static inline struct fib_nh_common *fib_info_nhc(struct fib_info *fi, int nhsel) |
| 322 | { |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 323 | if (unlikely(fi->nh)) |
| 324 | return nexthop_fib_nhc(fi->nh, nhsel); |
| 325 | |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 326 | return &fi->fib_nh[nhsel].nh_common; |
| 327 | } |
| 328 | |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 329 | /* only used when fib_nh is built into fib_info */ |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 330 | static inline struct fib_nh *fib_info_nh(struct fib_info *fi, int nhsel) |
| 331 | { |
David Ahern | 4c7e808 | 2019-06-03 20:19:51 -0700 | [diff] [blame] | 332 | WARN_ON(fi->nh); |
| 333 | |
David Ahern | 5481d73 | 2019-06-03 20:19:49 -0700 | [diff] [blame] | 334 | return &fi->fib_nh[nhsel]; |
| 335 | } |
David Ahern | f88d8ea | 2019-06-03 20:19:52 -0700 | [diff] [blame] | 336 | |
| 337 | /* |
| 338 | * IPv6 variants |
| 339 | */ |
| 340 | int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg, |
| 341 | struct netlink_ext_ack *extack); |
| 342 | |
| 343 | static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) |
| 344 | { |
| 345 | struct nh_info *nhi; |
| 346 | |
David Ahern | 0b5e2e3 | 2020-05-26 12:56:16 -0600 | [diff] [blame] | 347 | if (nh->is_group) { |
| 348 | struct nh_group *nh_grp; |
| 349 | |
| 350 | nh_grp = rcu_dereference_rtnl(nh->nh_grp); |
| 351 | nh = nexthop_mpath_select(nh_grp, 0); |
David Ahern | f88d8ea | 2019-06-03 20:19:52 -0700 | [diff] [blame] | 352 | if (!nh) |
| 353 | return NULL; |
| 354 | } |
| 355 | |
| 356 | nhi = rcu_dereference_rtnl(nh->nh_info); |
| 357 | if (nhi->family == AF_INET6) |
| 358 | return &nhi->fib6_nh; |
| 359 | |
| 360 | return NULL; |
| 361 | } |
| 362 | |
| 363 | static inline struct net_device *fib6_info_nh_dev(struct fib6_info *f6i) |
| 364 | { |
| 365 | struct fib6_nh *fib6_nh; |
| 366 | |
| 367 | fib6_nh = f6i->nh ? nexthop_fib6_nh(f6i->nh) : f6i->fib6_nh; |
| 368 | return fib6_nh->fib_nh_dev; |
| 369 | } |
| 370 | |
| 371 | static inline void nexthop_path_fib6_result(struct fib6_result *res, int hash) |
| 372 | { |
| 373 | struct nexthop *nh = res->f6i->nh; |
| 374 | struct nh_info *nhi; |
| 375 | |
| 376 | nh = nexthop_select_path(nh, hash); |
| 377 | |
| 378 | nhi = rcu_dereference_rtnl(nh->nh_info); |
| 379 | if (nhi->reject_nh) { |
| 380 | res->fib6_type = RTN_BLACKHOLE; |
| 381 | res->fib6_flags |= RTF_REJECT; |
| 382 | res->nh = nexthop_fib6_nh(nh); |
| 383 | } else { |
| 384 | res->nh = &nhi->fib6_nh; |
| 385 | } |
| 386 | } |
David Ahern | f88c9aa | 2019-06-08 14:53:22 -0700 | [diff] [blame] | 387 | |
| 388 | int nexthop_for_each_fib6_nh(struct nexthop *nh, |
| 389 | int (*cb)(struct fib6_nh *nh, void *arg), |
| 390 | void *arg); |
Roopa Prabhu | 38428d6 | 2020-05-21 22:26:13 -0700 | [diff] [blame] | 391 | |
| 392 | static inline int nexthop_get_family(struct nexthop *nh) |
| 393 | { |
| 394 | struct nh_info *nhi = rcu_dereference_rtnl(nh->nh_info); |
| 395 | |
| 396 | return nhi->family; |
| 397 | } |
| 398 | |
| 399 | static inline |
| 400 | struct fib_nh_common *nexthop_fdb_nhc(struct nexthop *nh) |
| 401 | { |
| 402 | struct nh_info *nhi = rcu_dereference_rtnl(nh->nh_info); |
| 403 | |
| 404 | return &nhi->fib_nhc; |
| 405 | } |
| 406 | |
| 407 | static inline struct fib_nh_common *nexthop_path_fdb_result(struct nexthop *nh, |
| 408 | int hash) |
| 409 | { |
| 410 | struct nh_info *nhi; |
| 411 | struct nexthop *nhp; |
| 412 | |
| 413 | nhp = nexthop_select_path(nh, hash); |
| 414 | if (unlikely(!nhp)) |
| 415 | return NULL; |
| 416 | nhi = rcu_dereference(nhp->nh_info); |
| 417 | return &nhi->fib_nhc; |
| 418 | } |
David Ahern | ab84be7 | 2019-05-24 14:43:04 -0700 | [diff] [blame] | 419 | #endif |