Lines Matching defs: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,
93 return !net->nexthop.notifier_chain.head;
114 const struct nexthop *nh)
195 const struct nexthop *nh)
207 const struct nexthop *nh)
218 const struct nexthop *nh)
229 const struct nexthop *nh)
239 struct nexthop *nh,
255 NL_SET_ERR_MSG(extack, "Failed to initialize nexthop notifier info");
259 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
272 struct nexthop *nh;
275 /* When 'force' is false, nexthop bucket replacement is performed
360 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
393 struct nexthop *old_nh,
394 struct nexthop *new_nh,
404 static int call_nexthop_res_table_notifiers(struct net *net, struct nexthop *nh,
420 /* At this point, the nexthop buckets are still not populated. Only
427 NL_SET_ERR_MSG(extack, "Failed to initialize nexthop notifier info");
431 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
441 struct nexthop *nh,
478 head = &net->nexthop.devhash[hash];
482 static void nexthop_free_group(struct nexthop *nh)
505 static void nexthop_free_single(struct nexthop *nh)
523 struct nexthop *nh = container_of(head, struct nexthop, rcu);
534 static struct nexthop *nexthop_alloc(void)
536 struct nexthop *nh;
538 nh = kzalloc(sizeof(struct nexthop), GFP_KERNEL);
586 while (++net->nexthop.seq == 0)
591 struct nexthop *nexthop_find_by_id(struct net *net, u32 id)
595 pp = &net->nexthop.rb_root.rb_node;
597 struct nexthop *nh;
604 nh = rb_entry(parent, struct nexthop, rb_node);
619 u32 id_start = net->nexthop.last_id_allocated;
622 net->nexthop.last_id_allocated++;
623 if (net->nexthop.last_id_allocated == id_start)
626 if (!nexthop_find_by_id(net, net->nexthop.last_id_allocated))
627 return net->nexthop.last_id_allocated;
708 const struct nexthop *nh)
748 static void nh_grp_hw_stats_apply_update(struct nexthop *nh,
764 static int nh_grp_hw_stats_update(struct nexthop *nh, bool *hw_stats_used)
781 err = blocking_notifier_call_chain(&net->nexthop.notifier_chain,
826 static int nla_put_nh_group_stats(struct sk_buff *skb, struct nexthop *nh,
868 static int nla_put_nh_group(struct sk_buff *skb, struct nexthop *nh,
918 static int nh_fill_node(struct sk_buff *skb, struct nexthop *nh,
1011 static size_t nh_nlmsg_size_grp(struct nexthop *nh)
1024 static size_t nh_nlmsg_size_single(struct nexthop *nh)
1055 static size_t nh_nlmsg_size(struct nexthop *nh)
1071 static void nexthop_notify(int event, struct nexthop *nh, struct nl_info *info)
1143 static int nh_fill_res_bucket(struct sk_buff *skb, struct nexthop *nh,
1195 struct nexthop *nh = nhge->nh_parent;
1217 static bool valid_group_nh(struct nexthop *nh, unsigned int npaths,
1226 "Hash-threshold group can not be a nexthop within a group");
1231 "Resilient group can not be a nexthop within a group");
1240 "Blackhole nexthop can not be used in a group with more than 1 path");
1249 static int nh_check_attr_fdb_group(struct nexthop *nh, u8 *nh_family,
1257 NL_SET_ERR_MSG(extack, "FDB nexthop group can only have fdb nexthops");
1264 NL_SET_ERR_MSG(extack, "FDB nexthop group cannot have mixed family nexthops");
1281 "Invalid length for nexthop group attribute");
1285 /* convert len to number of nexthop ids */
1323 "No other attributes can be set in nexthop groups");
1344 struct nexthop *nh;
1349 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
1359 NL_SET_ERR_MSG(extack, "Non FDB nexthop group cannot have fdb nexthops");
1400 static bool nexthop_is_good_nh(const struct nexthop *nh)
1414 static struct nexthop *nexthop_select_path_fdb(struct nh_group *nhg, int hash)
1432 static struct nexthop *nexthop_select_path_hthr(struct nh_group *nhg, int hash)
1465 static struct nexthop *nexthop_select_path_res(struct nh_group *nhg, int hash)
1482 struct nexthop *nexthop_select_path(struct nexthop *nh, int hash)
1500 int nexthop_for_each_fib6_nh(struct nexthop *nh,
1535 NL_SET_ERR_MSG(extack, "IPv6 routes using source address can not use nexthop objects");
1541 int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg,
1548 * routes in fib6_nh within a nexthop that is potentially shared
1550 * routing it can not use nexthop objects. mlxsw also does not allow
1571 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1577 NL_SET_ERR_MSG(extack, "IPv6 routes can not use an IPv4 nexthop");
1582 /* if existing nexthop has ipv6 routes linked to it, need
1585 static int fib6_check_nh_list(struct nexthop *old, struct nexthop *new,
1611 NL_SET_ERR_MSG(extack, "Scope mismatch with nexthop");
1618 /* Invoked by fib add code to verify nexthop by id is ok with
1619 * config for prefix; parts of fib_check_nh not done when nexthop
1622 int fib_check_nexthop(struct nexthop *nh, u8 scope,
1633 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1650 NL_SET_ERR_MSG(extack, "Route cannot point to a fdb nexthop");
1661 static int fib_check_nh_list(struct nexthop *old, struct nexthop *new,
1736 * nexthop, do not migrate.
1742 * overweight nexthop. It needs to be migrated to a new nexthop if
1809 * just clear the hardware flags from the nexthop
2012 struct nexthop *nhp = nhge->nh_parent;
2014 struct nexthop *nh = nhge->nh;
2042 /* current nexthop getting removed */
2086 static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
2098 static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)
2119 /* not called for nexthop replace */
2120 static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)
2153 static void __remove_nexthop(struct net *net, struct nexthop *nh,
2171 static void remove_nexthop(struct net *net, struct nexthop *nh,
2177 rb_erase(&nh->rb_node, &net->nexthop.rb_root);
2188 /* if any FIB entries reference this nexthop, any dst entries
2191 static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,
2192 struct nexthop *replaced_nh)
2220 static int replace_nexthop_grp(struct net *net, struct nexthop *old,
2221 struct nexthop *new, const struct nh_config *cfg,
2231 NL_SET_ERR_MSG(extack, "Can not replace a nexthop group with a nexthop.");
2239 NL_SET_ERR_MSG(extack, "Can not replace a nexthop group with one of a different type.");
2258 NL_SET_ERR_MSG(extack, "Can not change number of buckets of a resilient nexthop group.");
2285 /* update parents - used by nexthop code for cleanup */
2326 struct nexthop *old,
2367 struct nexthop *group_nh,
2368 struct nexthop *old,
2389 static int replace_nexthop_single(struct net *net, struct nexthop *old,
2390 struct nexthop *new,
2399 NL_SET_ERR_MSG(extack, "Can not replace a nexthop with a nexthop group.");
2427 /* Send a replace notification for all the groups using the nexthop. */
2429 struct nexthop *nhp = nhge->nh_parent;
2437 /* When replacing an IPv4 nexthop with an IPv6 nexthop, potentially
2438 * update IPv4 indication in all the groups using the nexthop.
2442 struct nexthop *nhp = nhge->nh_parent;
2460 struct nexthop *nhp = nhge->nh_parent;
2468 static void __nexthop_replace_notify(struct net *net, struct nexthop *nh,
2476 /* expectation is a few fib_info per nexthop and then
2494 * linked to this nexthop and for all groups that the nexthop
2497 static void nexthop_replace_notify(struct net *net, struct nexthop *nh,
2508 static int replace_nexthop(struct net *net, struct nexthop *old,
2509 struct nexthop *new, const struct nh_config *cfg,
2517 * new nexthop definition
2534 /* if new nexthop is a blackhole, any groups using this
2535 * nexthop cannot have more than 1 path
2539 NL_SET_ERR_MSG(extack, "Blackhole nexthop can not be a member of a group with more than one path");
2568 static int insert_nexthop(struct net *net, struct nexthop *new_nh,
2572 struct rb_root *root = &net->nexthop.rb_root;
2581 struct nexthop *nh;
2589 nh = rb_entry(parent, struct nexthop, rb_node);
2624 NL_SET_ERR_MSG(extack, "Number of buckets not specified for nexthop group insertion");
2646 rb_erase(&new_nh->rb_node, &net->nexthop.rb_root);
2666 struct hlist_head *head = &net->nexthop.devhash[hash];
2685 struct rb_root *root = &net->nexthop.rb_root;
2687 struct nexthop *nh;
2690 nh = rb_entry(node, struct nexthop, rb_node);
2696 static struct nexthop *nexthop_create_group(struct net *net,
2703 struct nexthop *nh;
2729 struct nexthop *nhe;
2803 static int nh_create_ipv4(struct net *net, struct nexthop *nh,
2842 static int nh_create_ipv6(struct net *net, struct nexthop *nh,
2877 static struct nexthop *nexthop_create(struct net *net, struct nh_config *cfg,
2881 struct nexthop *nh;
2934 static struct nexthop *nexthop_add(struct net *net, struct nh_config *cfg,
2937 struct nexthop *nh;
3049 NL_SET_ERR_MSG(extack, "Invalid nexthop flags in ancillary header");
3086 NL_SET_ERR_MSG(extack, "Unsupported nexthop flags in ancillary header");
3166 /* device only nexthop (no gateway) */
3169 "ONLINK flag can not be set for nexthop without a gateway");
3193 NL_SET_ERR_MSG(extack, "Cannot enable nexthop hardware statistics for non-group nexthops");
3225 NL_SET_ERR_MSG(extack, "Carrier for nexthop device is down");
3240 struct nexthop *nh;
3254 NL_SET_ERR_MSG(extack, "Replace requires nexthop id");
3293 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
3314 struct nexthop *nh;
3348 struct nexthop *nh;
3398 static bool nh_dump_filtered(struct nexthop *nh,
3463 NL_SET_ERR_MSG(extack, "Invalid values in header for nexthop dump request");
3507 struct nexthop *nh, void *data),
3516 struct nexthop *nh;
3518 nh = rb_entry(node, struct nexthop, rb_node);
3532 struct nexthop *nh, void *data)
3550 struct rb_root *root = &net->nexthop.rb_root;
3561 cb->seq = net->nexthop.seq;
3566 static struct nexthop *
3571 struct nexthop *nh;
3578 NL_SET_ERR_MSG(extack, "Not a nexthop group");
3599 NL_SET_ERR_MSG(extack, "Invalid nexthop id");
3669 struct nexthop *nh,
3712 struct nexthop *nh, void *data)
3734 struct nexthop *nh;
3748 struct rb_root *root = &net->nexthop.rb_root;
3754 cb->seq = net->nexthop.seq;
3818 struct nexthop *nh;
3862 struct hlist_head *head = &net->nexthop.devhash[hash];
3908 struct rb_root *root = &net->nexthop.rb_root;
3913 struct nexthop *nh;
3915 nh = rb_entry(node, struct nexthop, rb_node);
3933 err = blocking_notifier_chain_register(&net->nexthop.notifier_chain,
3945 err = blocking_notifier_chain_unregister(&net->nexthop.notifier_chain,
3966 struct nexthop *nexthop;
3970 nexthop = nexthop_find_by_id(net, id);
3971 if (!nexthop)
3974 nexthop->nh_flags &= ~(RTNH_F_OFFLOAD | RTNH_F_TRAP);
3976 nexthop->nh_flags |= RTNH_F_OFFLOAD;
3978 nexthop->nh_flags |= RTNH_F_TRAP;
3990 struct nexthop *nexthop;
3995 nexthop = nexthop_find_by_id(net, id);
3996 if (!nexthop || !nexthop->is_group)
3999 nhg = rcu_dereference(nexthop->nh_grp);
4023 struct nexthop *nexthop;
4029 nexthop = nexthop_find_by_id(net, id);
4030 if (!nexthop || !nexthop->is_group)
4033 nhg = rcu_dereference(nexthop->nh_grp);
4063 kfree(net->nexthop.devhash);
4064 net->nexthop.devhash = NULL;
4071 net->nexthop.rb_root = RB_ROOT;
4072 net->nexthop.devhash = kzalloc(sz, GFP_KERNEL);
4073 if (!net->nexthop.devhash)
4075 BLOCKING_INIT_NOTIFIER_HEAD(&net->nexthop.notifier_chain);