linux/include/net/nexthop.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Generic nexthop implementation
 *
 * Copyright (c) 2017-19 Cumulus Networks
 * Copyright (c) 2017-19 David Ahern <[email protected]>
 */

#ifndef __LINUX_NEXTHOP_H
#define __LINUX_NEXTHOP_H

#include <linux/netdevice.h>
#include <linux/notifier.h>
#include <linux/route.h>
#include <linux/types.h>
#include <net/ip_fib.h>
#include <net/ip6_fib.h>
#include <net/netlink.h>

#define NEXTHOP_VALID_USER_FLAGS

struct nexthop;

struct nh_config {};

struct nh_info {};

struct nh_res_bucket {};

struct nh_res_table {};

struct nh_grp_entry_stats {};

struct nh_grp_entry {};

struct nh_group {};

struct nexthop {};

enum nexthop_event_type {};

enum nh_notifier_info_type {};

struct nh_notifier_single_info {};

struct nh_notifier_grp_entry_info {};

struct nh_notifier_grp_info {};

struct nh_notifier_res_bucket_info {};

struct nh_notifier_res_table_info {};

struct nh_notifier_grp_hw_stats_entry_info {};

struct nh_notifier_grp_hw_stats_info {};

struct nh_notifier_info {};

int register_nexthop_notifier(struct net *net, struct notifier_block *nb,
			      struct netlink_ext_ack *extack);
int __unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);
int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);
void nexthop_set_hw_flags(struct net *net, u32 id, bool offload, bool trap);
void nexthop_bucket_set_hw_flags(struct net *net, u32 id, u16 bucket_index,
				 bool offload, bool trap);
void nexthop_res_grp_activity_update(struct net *net, u32 id, u16 num_buckets,
				     unsigned long *activity);
void nh_grp_hw_stats_report_delta(struct nh_notifier_grp_hw_stats_info *info,
				  unsigned int nh_idx,
				  u64 delta_packets);

/* caller is holding rcu or rtnl; no reference taken to nexthop */
struct nexthop *nexthop_find_by_id(struct net *net, u32 id);
void nexthop_free_rcu(struct rcu_head *head);

static inline bool nexthop_get(struct nexthop *nh)
{}

static inline void nexthop_put(struct nexthop *nh)
{}

static inline bool nexthop_cmp(const struct nexthop *nh1,
			       const struct nexthop *nh2)
{}

static inline bool nexthop_is_fdb(const struct nexthop *nh)
{}

static inline bool nexthop_has_v4(const struct nexthop *nh)
{}

static inline bool nexthop_is_multipath(const struct nexthop *nh)
{}

struct nexthop *nexthop_select_path(struct nexthop *nh, int hash);

static inline unsigned int nexthop_num_path(const struct nexthop *nh)
{}

static inline
struct nexthop *nexthop_mpath_select(const struct nh_group *nhg, int nhsel)
{}

static inline
int nexthop_mpath_fill_node(struct sk_buff *skb, struct nexthop *nh,
			    u8 rt_family)
{}

/* called with rcu lock */
static inline bool nexthop_is_blackhole(const struct nexthop *nh)
{}

static inline void nexthop_path_fib_result(struct fib_result *res, int hash)
{}

/* called with rcu read lock or rtnl held */
static inline
struct fib_nh_common *nexthop_fib_nhc(struct nexthop *nh, int nhsel)
{}

/* called from fib_table_lookup with rcu_lock */
static inline
struct fib_nh_common *nexthop_get_nhc_lookup(const struct nexthop *nh,
					     int fib_flags,
					     const struct flowi4 *flp,
					     int *nhsel)
{}

static inline bool nexthop_uses_dev(const struct nexthop *nh,
				    const struct net_device *dev)
{}

static inline unsigned int fib_info_num_path(const struct fib_info *fi)
{}

int fib_check_nexthop(struct nexthop *nh, u8 scope,
		      struct netlink_ext_ack *extack);

static inline struct fib_nh_common *fib_info_nhc(struct fib_info *fi, int nhsel)
{}

/* only used when fib_nh is built into fib_info */
static inline struct fib_nh *fib_info_nh(struct fib_info *fi, int nhsel)
{}

/*
 * IPv6 variants
 */
int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg,
		       struct netlink_ext_ack *extack);

/* Caller should either hold rcu_read_lock(), or RTNL. */
static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh)
{}

static inline struct net_device *fib6_info_nh_dev(struct fib6_info *f6i)
{}

static inline void nexthop_path_fib6_result(struct fib6_result *res, int hash)
{}

int nexthop_for_each_fib6_nh(struct nexthop *nh,
			     int (*cb)(struct fib6_nh *nh, void *arg),
			     void *arg);

static inline int nexthop_get_family(struct nexthop *nh)
{}

static inline
struct fib_nh_common *nexthop_fdb_nhc(struct nexthop *nh)
{}

static inline struct fib_nh_common *nexthop_path_fdb_result(struct nexthop *nh,
							    int hash)
{}
#endif