Lines Matching refs:nexthop

2 /* Generic nexthop implementation
8 #include <linux/nexthop.h>
16 #include <net/nexthop.h>
23 static void remove_nexthop(struct net *net, struct nexthop *nh,
81 return !net->nexthop.notifier_chain.head;
101 const struct nexthop *nh)
181 const struct nexthop *nh)
193 const struct nexthop *nh)
204 const struct nexthop *nh)
215 const struct nexthop *nh)
225 struct nexthop *nh,
241 NL_SET_ERR_MSG(extack, "Failed to initialize nexthop notifier info");
245 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
258 struct nexthop *nh;
261 /* When 'force' is false, nexthop bucket replacement is performed
346 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
379 struct nexthop *old_nh,
380 struct nexthop *new_nh,
390 static int call_nexthop_res_table_notifiers(struct net *net, struct nexthop *nh,
405 /* At this point, the nexthop buckets are still not populated. Only
412 NL_SET_ERR_MSG(extack, "Failed to initialize nexthop notifier info");
416 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
426 struct nexthop *nh,
463 head = &net->nexthop.devhash[hash];
467 static void nexthop_free_group(struct nexthop *nh)
489 static void nexthop_free_single(struct nexthop *nh)
507 struct nexthop *nh = container_of(head, struct nexthop, rcu);
518 static struct nexthop *nexthop_alloc(void)
520 struct nexthop *nh;
522 nh = kzalloc(sizeof(struct nexthop), GFP_KERNEL);
569 while (++net->nexthop.seq == 0)
574 struct nexthop *nexthop_find_by_id(struct net *net, u32 id)
578 pp = &net->nexthop.rb_root.rb_node;
580 struct nexthop *nh;
587 nh = rb_entry(parent, struct nexthop, rb_node);
602 u32 id_start = net->nexthop.last_id_allocated;
605 net->nexthop.last_id_allocated++;
606 if (net->nexthop.last_id_allocated == id_start)
609 if (!nexthop_find_by_id(net, net->nexthop.last_id_allocated))
610 return net->nexthop.last_id_allocated;
693 static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
783 static size_t nh_nlmsg_size_grp(struct nexthop *nh)
796 static size_t nh_nlmsg_size_single(struct nexthop *nh)
827 static size_t nh_nlmsg_size(struct nexthop *nh)
841 static void nexthop_notify(int event, struct nexthop *nh, struct nl_info *info)
914 static int nh_fill_res_bucket(struct sk_buff *skb, struct nexthop *nh,
966 struct nexthop *nh = nhge->nh_parent;
989 static bool valid_group_nh(struct nexthop *nh, unsigned int npaths,
998 "Hash-threshold group can not be a nexthop within a group");
1003 "Resilient group can not be a nexthop within a group");
1012 "Blackhole nexthop can not be used in a group with more than 1 path");
1021 static int nh_check_attr_fdb_group(struct nexthop *nh, u8 *nh_family,
1029 NL_SET_ERR_MSG(extack, "FDB nexthop group can only have fdb nexthops");
1036 NL_SET_ERR_MSG(extack, "FDB nexthop group cannot have mixed family nexthops");
1055 "Invalid length for nexthop group attribute");
1059 /* convert len to number of nexthop ids */
1084 struct nexthop *nh;
1089 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
1099 NL_SET_ERR_MSG(extack, "Non FDB nexthop group cannot have fdb nexthops");
1115 "No other attributes can be set in nexthop groups");
1155 static bool nexthop_is_good_nh(const struct nexthop *nh)
1169 static struct nexthop *nexthop_select_path_fdb(struct nh_group *nhg, int hash)
1186 static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash)
1188 struct nexthop *rc = NULL;
1215 static struct nexthop *nexthop_select_path_res(struct nh_group *nhg, int hash)
1231 struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
1249 int nexthop_for_each_fib6_nh(struct nexthop *nh,
1284 NL_SET_ERR_MSG(extack, "IPv6 routes using source address can not use nexthop objects");
1290 int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg,
1297 * routes in fib6_nh within a nexthop that is potentially shared
1299 * routing it can not use nexthop objects. mlxsw also does not allow
1320 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1326 NL_SET_ERR_MSG(extack, "IPv6 routes can not use an IPv4 nexthop");
1331 /* if existing nexthop has ipv6 routes linked to it, need
1334 static int fib6_check_nh_list(struct nexthop *old, struct nexthop *new,
1360 NL_SET_ERR_MSG(extack, "Scope mismatch with nexthop");
1367 /* Invoked by fib add code to verify nexthop by id is ok with
1368 * config for prefix; parts of fib_check_nh not done when nexthop
1371 int fib_check_nexthop(struct nexthop *nh, u8 scope,
1382 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1399 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1410 static int fib_check_nh_list(struct nexthop *old, struct nexthop *new,
1485 * nexthop, do not migrate.
1491 * overweight nexthop. It needs to be migrated to a new nexthop if
1558 * just clear the hardware flags from the nexthop
1760 struct nexthop *nhp = nhge->nh_parent;
1762 struct nexthop *nh = nhge->nh;
1790 /* current nexthop getting removed */
1832 static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
1844 static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)
1865 /* not called for nexthop replace */
1866 static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)
1888 static void __remove_nexthop(struct net *net, struct nexthop *nh,
1906 static void remove_nexthop(struct net *net, struct nexthop *nh,
1912 rb_erase(&nh->rb_node, &net->nexthop.rb_root);
1923 /* if any FIB entries reference this nexthop, any dst entries
1926 static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
1927 struct nexthop *replaced_nh)
1955 static int replace_nexthop_grp(struct net *net, struct nexthop *old,
1956 struct nexthop *new, const struct nh_config *cfg,
1966 NL_SET_ERR_MSG(extack, "Can not replace a nexthop group with a nexthop.");
1974 NL_SET_ERR_MSG(extack, "Can not replace a nexthop group with one of a different type.");
1993 NL_SET_ERR_MSG(extack, "Can not change number of buckets of a resilient nexthop group.");
2020 /* update parents - used by nexthop code for cleanup */
2061 struct nexthop *old,
2102 struct nexthop *group_nh,
2103 struct nexthop *old,
2124 static int replace_nexthop_single(struct net *net, struct nexthop *old,
2125 struct nexthop *new,
2134 NL_SET_ERR_MSG(extack, "Can not replace a nexthop with a nexthop group.");
2162 /* Send a replace notification for all the groups using the nexthop. */
2164 struct nexthop *nhp = nhge->nh_parent;
2172 /* When replacing an IPv4 nexthop with an IPv6 nexthop, potentially
2173 * update IPv4 indication in all the groups using the nexthop.
2177 struct nexthop *nhp = nhge->nh_parent;
2195 struct nexthop *nhp = nhge->nh_parent;
2203 static void __nexthop_replace_notify(struct net *net, struct nexthop *nh,
2211 /* expectation is a few fib_info per nexthop and then
2229 * linked to this nexthop and for all groups that the nexthop
2232 static void nexthop_replace_notify(struct net *net, struct nexthop *nh,
2243 static int replace_nexthop(struct net *net, struct nexthop *old,
2244 struct nexthop *new, const struct nh_config *cfg,
2252 * new nexthop definition
2269 /* if new nexthop is a blackhole, any groups using this
2270 * nexthop cannot have more than 1 path
2274 NL_SET_ERR_MSG(extack, "Blackhole nexthop can not be a member of a group with more than one path");
2303 static int insert_nexthop(struct net *net, struct nexthop *new_nh,
2307 struct rb_root *root = &net->nexthop.rb_root;
2316 struct nexthop *nh;
2324 nh = rb_entry(parent, struct nexthop, rb_node);
2359 NL_SET_ERR_MSG(extack, "Number of buckets not specified for nexthop group insertion");
2381 rb_erase(&new_nh->rb_node, &net->nexthop.rb_root);
2401 struct hlist_head *head = &net->nexthop.devhash[hash];
2420 struct rb_root *root = &net->nexthop.rb_root;
2422 struct nexthop *nh;
2425 nh = rb_entry(node, struct nexthop, rb_node);
2431 static struct nexthop *nexthop_create_group(struct net *net,
2438 struct nexthop *nh;
2467 struct nexthop *nhe;
2529 static int nh_create_ipv4(struct net *net, struct nexthop *nh,
2568 static int nh_create_ipv6(struct net *net, struct nexthop *nh,
2603 static struct nexthop *nexthop_create(struct net *net, struct nh_config *cfg,
2607 struct nexthop *nh;
2660 static struct nexthop *nexthop_add(struct net *net, struct nh_config *cfg,
2663 struct nexthop *nh;
2667 NL_SET_ERR_MSG(extack, "Replace requires nexthop id");
2786 NL_SET_ERR_MSG(extack, "Invalid nexthop flags in ancillary header");
2823 NL_SET_ERR_MSG(extack, "Unsupported nexthop flags in ancillary header");
2887 NL_SET_ERR_MSG(extack, "Carrier for nexthop device is down");
2918 /* device only nexthop (no gateway) */
2921 "ONLINK flag can not be set for nexthop without a gateway");
2956 struct nexthop *nh;
2987 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
3019 struct nexthop *nh;
3042 struct nexthop *nh;
3084 static bool nh_dump_filtered(struct nexthop *nh,
3149 NL_SET_ERR_MSG(extack, "Invalid values in header for nexthop dump request");
3191 struct nexthop *nh, void *data),
3200 struct nexthop *nh;
3202 nh = rb_entry(node, struct nexthop, rb_node);
3216 struct nexthop *nh, void *data)
3234 struct rb_root *root = &net->nexthop.rb_root;
3249 cb->seq = net->nexthop.seq;
3254 static struct nexthop *
3259 struct nexthop *nh;
3266 NL_SET_ERR_MSG(extack, "Not a nexthop group");
3287 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
3357 struct nexthop *nh,
3400 struct nexthop *nh, void *data)
3422 struct nexthop *nh;
3436 struct rb_root *root = &net->nexthop.rb_root;
3447 cb->seq = net->nexthop.seq;
3511 struct nexthop *nh;
3555 struct hlist_head *head = &net->nexthop.devhash[hash];
3601 struct rb_root *root = &net->nexthop.rb_root;
3606 struct nexthop *nh;
3608 nh = rb_entry(node, struct nexthop, rb_node);
3626 err = blocking_notifier_chain_register(&net->nexthop.notifier_chain,
3639 err = blocking_notifier_chain_unregister(&net->nexthop.notifier_chain,
3652 struct nexthop *nexthop;
3656 nexthop = nexthop_find_by_id(net, id);
3657 if (!nexthop)
3660 nexthop->nh_flags &= ~(RTNH_F_OFFLOAD | RTNH_F_TRAP);
3662 nexthop->nh_flags |= RTNH_F_OFFLOAD;
3664 nexthop->nh_flags |= RTNH_F_TRAP;
3676 struct nexthop *nexthop;
3681 nexthop = nexthop_find_by_id(net, id);
3682 if (!nexthop || !nexthop->is_group)
3685 nhg = rcu_dereference(nexthop->nh_grp);
3709 struct nexthop *nexthop;
3715 nexthop = nexthop_find_by_id(net, id);
3716 if (!nexthop || !nexthop->is_group)
3719 nhg = rcu_dereference(nexthop->nh_grp);
3747 kfree(net->nexthop.devhash);
3756 net->nexthop.rb_root = RB_ROOT;
3757 net->nexthop.devhash = kzalloc(sz, GFP_KERNEL);
3758 if (!net->nexthop.devhash)
3760 BLOCKING_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain);