linux/include/net/dst.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * net/dst.h	Protocol independent destination cache definitions.
 *
 * Authors:	Alexey Kuznetsov, <[email protected]>
 *
 */

#ifndef _NET_DST_H
#define _NET_DST_H

#include <net/dst_ops.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/rcupdate.h>
#include <linux/bug.h>
#include <linux/jiffies.h>
#include <linux/refcount.h>
#include <linux/rcuref.h>
#include <net/neighbour.h>
#include <asm/processor.h>
#include <linux/indirect_call_wrapper.h>

struct sk_buff;

struct dst_entry {};

struct dst_metrics {} __aligned();		/* Low pointer bits contain DST_METRICS_FLAGS */
extern const struct dst_metrics dst_default_metrics;

u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);

#define DST_METRICS_READ_ONLY
#define DST_METRICS_REFCOUNTED
#define DST_METRICS_FLAGS
#define __DST_METRICS_PTR(Y)
#define DST_METRICS_PTR(X)

static inline bool dst_metrics_read_only(const struct dst_entry *dst)
{}

void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old);

static inline void dst_destroy_metrics_generic(struct dst_entry *dst)
{}

static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst)
{}

/* This may only be invoked before the entry has reached global
 * visibility.
 */
static inline void dst_init_metrics(struct dst_entry *dst,
				    const u32 *src_metrics,
				    bool read_only)
{}

static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
{}

static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
{}

static inline u32
dst_metric_raw(const struct dst_entry *dst, const int metric)
{}

static inline u32
dst_metric(const struct dst_entry *dst, const int metric)
{}

static inline u32
dst_metric_advmss(const struct dst_entry *dst)
{}

static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
{}

/* Kernel-internal feature bits that are unallocated in user space. */
#define DST_FEATURE_ECN_CA

#define DST_FEATURE_MASK
#define DST_FEATURE_ECN_MASK

static inline u32
dst_feature(const struct dst_entry *dst, u32 feature)
{}

INDIRECT_CALLABLE_DECLARE();
INDIRECT_CALLABLE_DECLARE();
static inline u32 dst_mtu(const struct dst_entry *dst)
{}

/* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */
static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metric)
{}

static inline int
dst_metric_locked(const struct dst_entry *dst, int metric)
{}

static inline void dst_hold(struct dst_entry *dst)
{}

static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
{}

static inline struct dst_entry *dst_clone(struct dst_entry *dst)
{}

void dst_release(struct dst_entry *dst);

void dst_release_immediate(struct dst_entry *dst);

static inline void refdst_drop(unsigned long refdst)
{}

/**
 * skb_dst_drop - drops skb dst
 * @skb: buffer
 *
 * Drops dst reference count if a reference was taken.
 */
static inline void skb_dst_drop(struct sk_buff *skb)
{}

static inline void __skb_dst_copy(struct sk_buff *nskb, unsigned long refdst)
{}

static inline void skb_dst_copy(struct sk_buff *nskb, const struct sk_buff *oskb)
{}

/**
 * dst_hold_safe - Take a reference on a dst if possible
 * @dst: pointer to dst entry
 *
 * This helper returns false if it could not safely
 * take a reference on a dst.
 */
static inline bool dst_hold_safe(struct dst_entry *dst)
{}

/**
 * skb_dst_force - makes sure skb dst is refcounted
 * @skb: buffer
 *
 * If dst is not yet refcounted and not destroyed, grab a ref on it.
 * Returns true if dst is refcounted.
 */
static inline bool skb_dst_force(struct sk_buff *skb)
{}


/**
 *	__skb_tunnel_rx - prepare skb for rx reinsert
 *	@skb: buffer
 *	@dev: tunnel device
 *	@net: netns for packet i/o
 *
 *	After decapsulation, packet is going to re-enter (netif_rx()) our stack,
 *	so make some cleanups. (no accounting done)
 */
static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
				   struct net *net)
{}

/**
 *	skb_tunnel_rx - prepare skb for rx reinsert
 *	@skb: buffer
 *	@dev: tunnel device
 *	@net: netns for packet i/o
 *
 *	After decapsulation, packet is going to re-enter (netif_rx()) our stack,
 *	so make some cleanups, and perform accounting.
 *	Note: this accounting is not SMP safe.
 */
static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev,
				 struct net *net)
{}

static inline u32 dst_tclassid(const struct sk_buff *skb)
{}

int dst_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb);
static inline int dst_discard(struct sk_buff *skb)
{}
void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
		int initial_obsolete, unsigned short flags);
void dst_init(struct dst_entry *dst, struct dst_ops *ops,
	      struct net_device *dev, int initial_obsolete,
	      unsigned short flags);
void dst_dev_put(struct dst_entry *dst);

static inline void dst_confirm(struct dst_entry *dst)
{}

static inline struct neighbour *dst_neigh_lookup(const struct dst_entry *dst, const void *daddr)
{}

static inline struct neighbour *dst_neigh_lookup_skb(const struct dst_entry *dst,
						     struct sk_buff *skb)
{}

static inline void dst_confirm_neigh(const struct dst_entry *dst,
				     const void *daddr)
{}

static inline void dst_link_failure(struct sk_buff *skb)
{}

static inline void dst_set_expires(struct dst_entry *dst, int timeout)
{}

INDIRECT_CALLABLE_DECLARE();
INDIRECT_CALLABLE_DECLARE();
/* Output packet to network from transport.  */
static inline int dst_output(struct net *net, struct sock *sk, struct sk_buff *skb)
{}

INDIRECT_CALLABLE_DECLARE();
INDIRECT_CALLABLE_DECLARE();
/* Input packet from network to transport.  */
static inline int dst_input(struct sk_buff *skb)
{}

INDIRECT_CALLABLE_DECLARE();
INDIRECT_CALLABLE_DECLARE();
static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie)
{}

/* Flags for xfrm_lookup flags argument. */
enum {};

struct flowi;
#ifndef CONFIG_XFRM
static inline struct dst_entry *xfrm_lookup(struct net *net,
					    struct dst_entry *dst_orig,
					    const struct flowi *fl,
					    const struct sock *sk,
					    int flags)
{
	return dst_orig;
}

static inline struct dst_entry *
xfrm_lookup_with_ifid(struct net *net, struct dst_entry *dst_orig,
		      const struct flowi *fl, const struct sock *sk,
		      int flags, u32 if_id)
{
	return dst_orig;
}

static inline struct dst_entry *xfrm_lookup_route(struct net *net,
						  struct dst_entry *dst_orig,
						  const struct flowi *fl,
						  const struct sock *sk,
						  int flags)
{
	return dst_orig;
}

static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
{
	return NULL;
}

#else
struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
			      const struct flowi *fl, const struct sock *sk,
			      int flags);

struct dst_entry *xfrm_lookup_with_ifid(struct net *net,
					struct dst_entry *dst_orig,
					const struct flowi *fl,
					const struct sock *sk, int flags,
					u32 if_id);

struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig,
				    const struct flowi *fl, const struct sock *sk,
				    int flags);

/* skb attached with this dst needs transformation if dst->xfrm is valid */
static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
{}
#endif

static inline void skb_dst_update_pmtu(struct sk_buff *skb, u32 mtu)
{}

/* update dst pmtu but not do neighbor confirm */
static inline void skb_dst_update_pmtu_no_confirm(struct sk_buff *skb, u32 mtu)
{}

struct dst_entry *dst_blackhole_check(struct dst_entry *dst, u32 cookie);
void dst_blackhole_update_pmtu(struct dst_entry *dst, struct sock *sk,
			       struct sk_buff *skb, u32 mtu, bool confirm_neigh);
void dst_blackhole_redirect(struct dst_entry *dst, struct sock *sk,
			    struct sk_buff *skb);
u32 *dst_blackhole_cow_metrics(struct dst_entry *dst, unsigned long old);
struct neighbour *dst_blackhole_neigh_lookup(const struct dst_entry *dst,
					     struct sk_buff *skb,
					     const void *daddr);
unsigned int dst_blackhole_mtu(const struct dst_entry *dst);

#endif /* _NET_DST_H */