xref: /openbmc/linux/include/net/dst.h (revision d33e455337ea2c71d09d7f4367d6ad6dd32b6965)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * net/dst.h	Protocol independent destination cache definitions.
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  */
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #ifndef _NET_DST_H
91da177e4SLinus Torvalds #define _NET_DST_H
101da177e4SLinus Torvalds 
1186393e52SAlexey Dobriyan #include <net/dst_ops.h>
1214c85021SArnaldo Carvalho de Melo #include <linux/netdevice.h>
131da177e4SLinus Torvalds #include <linux/rtnetlink.h>
141da177e4SLinus Torvalds #include <linux/rcupdate.h>
151da177e4SLinus Torvalds #include <linux/jiffies.h>
161da177e4SLinus Torvalds #include <net/neighbour.h>
171da177e4SLinus Torvalds #include <asm/processor.h>
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds /*
201da177e4SLinus Torvalds  * 0 - no debugging messages
211da177e4SLinus Torvalds  * 1 - rare events and bugs (default)
221da177e4SLinus Torvalds  * 2 - trace mode.
231da177e4SLinus Torvalds  */
241da177e4SLinus Torvalds #define RT_CACHE_DEBUG		0
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds #define DST_GC_MIN	(HZ/10)
271da177e4SLinus Torvalds #define DST_GC_INC	(HZ/2)
281da177e4SLinus Torvalds #define DST_GC_MAX	(120*HZ)
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds /* Each dst_entry has reference count and sits in some parent list(s).
311da177e4SLinus Torvalds  * When it is removed from parent list, it is "freed" (dst_free).
321da177e4SLinus Torvalds  * After this it enters dead state (dst->obsolete > 0) and if its refcnt
331da177e4SLinus Torvalds  * is zero, it can be destroyed immediately, otherwise it is added
341da177e4SLinus Torvalds  * to gc list and garbage collector periodically checks the refcnt.
351da177e4SLinus Torvalds  */
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds struct sk_buff;
381da177e4SLinus Torvalds 
39fd2c3ef7SEric Dumazet struct dst_entry {
401e19e02cSEric Dumazet 	struct rcu_head		rcu_head;
411da177e4SLinus Torvalds 	struct dst_entry	*child;
421da177e4SLinus Torvalds 	struct net_device       *dev;
43c4d54110SHerbert Xu 	short			error;
44c4d54110SHerbert Xu 	short			obsolete;
451da177e4SLinus Torvalds 	int			flags;
46c7d4426aSEric Dumazet #define DST_HOST		0x0001
47c7d4426aSEric Dumazet #define DST_NOXFRM		0x0002
48c7d4426aSEric Dumazet #define DST_NOPOLICY		0x0004
49c7d4426aSEric Dumazet #define DST_NOHASH		0x0008
50c7d4426aSEric Dumazet #define DST_NOCACHE		0x0010
511da177e4SLinus Torvalds 	unsigned long		expires;
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds 	unsigned short		header_len;	/* more space at head required */
541da177e4SLinus Torvalds 	unsigned short		trailer_len;	/* space to reserve at tail */
551da177e4SLinus Torvalds 
5669a73829SEric Dumazet 	unsigned int		rate_tokens;
57f1dd9c37SZhang Yanmin 	unsigned long		rate_last;	/* rate limiting for ICMP */
5869a73829SEric Dumazet 
59f1dd9c37SZhang Yanmin 	struct dst_entry	*path;
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds 	struct neighbour	*neighbour;
621da177e4SLinus Torvalds 	struct hh_cache		*hh;
63def8b4faSAlexey Dobriyan #ifdef CONFIG_XFRM
641da177e4SLinus Torvalds 	struct xfrm_state	*xfrm;
655635c10dSEric Dumazet #else
665635c10dSEric Dumazet 	void			*__pad1;
67def8b4faSAlexey Dobriyan #endif
681da177e4SLinus Torvalds 	int			(*input)(struct sk_buff*);
691da177e4SLinus Torvalds 	int			(*output)(struct sk_buff*);
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds 	struct  dst_ops	        *ops;
721da177e4SLinus Torvalds 
73defb3519SDavid S. Miller 	u32			_metrics[RTAX_MAX];
74f1dd9c37SZhang Yanmin 
75f1dd9c37SZhang Yanmin #ifdef CONFIG_NET_CLS_ROUTE
76f1dd9c37SZhang Yanmin 	__u32			tclassid;
775635c10dSEric Dumazet #else
785635c10dSEric Dumazet 	__u32			__pad2;
79f1dd9c37SZhang Yanmin #endif
80f1dd9c37SZhang Yanmin 
815635c10dSEric Dumazet 
825635c10dSEric Dumazet 	/*
835635c10dSEric Dumazet 	 * Align __refcnt to a 64 bytes alignment
845635c10dSEric Dumazet 	 * (L1_CACHE_SIZE would be too much)
855635c10dSEric Dumazet 	 */
865635c10dSEric Dumazet #ifdef CONFIG_64BIT
875635c10dSEric Dumazet 	long			__pad_to_align_refcnt[1];
885635c10dSEric Dumazet #endif
89f1dd9c37SZhang Yanmin 	/*
90f1dd9c37SZhang Yanmin 	 * __refcnt wants to be on a different cache line from
91f1dd9c37SZhang Yanmin 	 * input/output/ops or performance tanks badly
92f1dd9c37SZhang Yanmin 	 */
931e19e02cSEric Dumazet 	atomic_t		__refcnt;	/* client references	*/
941e19e02cSEric Dumazet 	int			__use;
95f1dd9c37SZhang Yanmin 	unsigned long		lastuse;
961e19e02cSEric Dumazet 	union {
971e19e02cSEric Dumazet 		struct dst_entry	*next;
981c31720aSEric Dumazet 		struct rtable __rcu	*rt_next;
991e19e02cSEric Dumazet 		struct rt6_info		*rt6_next;
100fc766e4cSEric Dumazet 		struct dn_route __rcu	*dn_next;
1011e19e02cSEric Dumazet 	};
1021da177e4SLinus Torvalds };
1031da177e4SLinus Torvalds 
1041da177e4SLinus Torvalds #ifdef __KERNEL__
1051da177e4SLinus Torvalds 
1061da177e4SLinus Torvalds static inline u32
1075170ae82SDavid S. Miller dst_metric_raw(const struct dst_entry *dst, const int metric)
1081da177e4SLinus Torvalds {
109defb3519SDavid S. Miller 	return dst->_metrics[metric-1];
110defb3519SDavid S. Miller }
111defb3519SDavid S. Miller 
1125170ae82SDavid S. Miller static inline u32
1135170ae82SDavid S. Miller dst_metric(const struct dst_entry *dst, const int metric)
1145170ae82SDavid S. Miller {
1150dbaee3bSDavid S. Miller 	WARN_ON_ONCE(metric == RTAX_HOPLIMIT ||
116*d33e4553SDavid S. Miller 		     metric == RTAX_ADVMSS ||
117*d33e4553SDavid S. Miller 		     metric == RTAX_MTU);
1185170ae82SDavid S. Miller 	return dst_metric_raw(dst, metric);
1195170ae82SDavid S. Miller }
1205170ae82SDavid S. Miller 
1210dbaee3bSDavid S. Miller static inline u32
1220dbaee3bSDavid S. Miller dst_metric_advmss(const struct dst_entry *dst)
1230dbaee3bSDavid S. Miller {
1240dbaee3bSDavid S. Miller 	u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS);
1250dbaee3bSDavid S. Miller 
1260dbaee3bSDavid S. Miller 	if (!advmss)
1270dbaee3bSDavid S. Miller 		advmss = dst->ops->default_advmss(dst);
1280dbaee3bSDavid S. Miller 
1290dbaee3bSDavid S. Miller 	return advmss;
1300dbaee3bSDavid S. Miller }
1310dbaee3bSDavid S. Miller 
132defb3519SDavid S. Miller static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val)
133defb3519SDavid S. Miller {
134defb3519SDavid S. Miller 	dst->_metrics[metric-1] = val;
135defb3519SDavid S. Miller }
136defb3519SDavid S. Miller 
137defb3519SDavid S. Miller static inline void dst_import_metrics(struct dst_entry *dst, const u32 *src_metrics)
138defb3519SDavid S. Miller {
139defb3519SDavid S. Miller 	memcpy(dst->_metrics, src_metrics, RTAX_MAX * sizeof(u32));
140defb3519SDavid S. Miller }
141defb3519SDavid S. Miller 
142defb3519SDavid S. Miller static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src)
143defb3519SDavid S. Miller {
144defb3519SDavid S. Miller 	dst_import_metrics(dest, src->_metrics);
145defb3519SDavid S. Miller }
146defb3519SDavid S. Miller 
147defb3519SDavid S. Miller static inline u32 *dst_metrics_ptr(struct dst_entry *dst)
148defb3519SDavid S. Miller {
149defb3519SDavid S. Miller 	return dst->_metrics;
1501da177e4SLinus Torvalds }
1511da177e4SLinus Torvalds 
1520c3adfb8SGilad Ben-Yossef static inline u32
1530c3adfb8SGilad Ben-Yossef dst_feature(const struct dst_entry *dst, u32 feature)
1540c3adfb8SGilad Ben-Yossef {
155bb5b7c11SDavid S. Miller 	return dst_metric(dst, RTAX_FEATURES) & feature;
1560c3adfb8SGilad Ben-Yossef }
1570c3adfb8SGilad Ben-Yossef 
1581da177e4SLinus Torvalds static inline u32 dst_mtu(const struct dst_entry *dst)
1591da177e4SLinus Torvalds {
160*d33e4553SDavid S. Miller 	u32 mtu = dst_metric_raw(dst, RTAX_MTU);
161*d33e4553SDavid S. Miller 
162*d33e4553SDavid S. Miller 	if (!mtu)
163*d33e4553SDavid S. Miller 		mtu = dst->ops->default_mtu(dst);
164*d33e4553SDavid S. Miller 
1651da177e4SLinus Torvalds 	return mtu;
1661da177e4SLinus Torvalds }
1671da177e4SLinus Torvalds 
168c1e20f7cSStephen Hemminger /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */
169c1e20f7cSStephen Hemminger static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metric)
170c1e20f7cSStephen Hemminger {
171c1e20f7cSStephen Hemminger 	return msecs_to_jiffies(dst_metric(dst, metric));
172c1e20f7cSStephen Hemminger }
173c1e20f7cSStephen Hemminger 
174c1e20f7cSStephen Hemminger static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,
175c1e20f7cSStephen Hemminger 				      unsigned long rtt)
176c1e20f7cSStephen Hemminger {
177defb3519SDavid S. Miller 	dst_metric_set(dst, metric, jiffies_to_msecs(rtt));
178c1e20f7cSStephen Hemminger }
179c1e20f7cSStephen Hemminger 
1801da177e4SLinus Torvalds static inline u32
1811da177e4SLinus Torvalds dst_allfrag(const struct dst_entry *dst)
1821da177e4SLinus Torvalds {
1830c3adfb8SGilad Ben-Yossef 	int ret = dst_feature(dst,  RTAX_FEATURE_ALLFRAG);
1841da177e4SLinus Torvalds 	/* Yes, _exactly_. This is paranoia. */
1851da177e4SLinus Torvalds 	barrier();
1861da177e4SLinus Torvalds 	return ret;
1871da177e4SLinus Torvalds }
1881da177e4SLinus Torvalds 
1891da177e4SLinus Torvalds static inline int
190*d33e4553SDavid S. Miller dst_metric_locked(const struct dst_entry *dst, int metric)
1911da177e4SLinus Torvalds {
1921da177e4SLinus Torvalds 	return dst_metric(dst, RTAX_LOCK) & (1<<metric);
1931da177e4SLinus Torvalds }
1941da177e4SLinus Torvalds 
1951da177e4SLinus Torvalds static inline void dst_hold(struct dst_entry * dst)
1961da177e4SLinus Torvalds {
1975635c10dSEric Dumazet 	/*
1985635c10dSEric Dumazet 	 * If your kernel compilation stops here, please check
1995635c10dSEric Dumazet 	 * __pad_to_align_refcnt declaration in struct dst_entry
2005635c10dSEric Dumazet 	 */
2015635c10dSEric Dumazet 	BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63);
2021da177e4SLinus Torvalds 	atomic_inc(&dst->__refcnt);
2031da177e4SLinus Torvalds }
2041da177e4SLinus Torvalds 
20503f49f34SPavel Emelyanov static inline void dst_use(struct dst_entry *dst, unsigned long time)
20603f49f34SPavel Emelyanov {
20703f49f34SPavel Emelyanov 	dst_hold(dst);
20803f49f34SPavel Emelyanov 	dst->__use++;
20903f49f34SPavel Emelyanov 	dst->lastuse = time;
21003f49f34SPavel Emelyanov }
21103f49f34SPavel Emelyanov 
2127fee226aSEric Dumazet static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
2137fee226aSEric Dumazet {
2147fee226aSEric Dumazet 	dst->__use++;
2157fee226aSEric Dumazet 	dst->lastuse = time;
2167fee226aSEric Dumazet }
2177fee226aSEric Dumazet 
2181da177e4SLinus Torvalds static inline
2191da177e4SLinus Torvalds struct dst_entry * dst_clone(struct dst_entry * dst)
2201da177e4SLinus Torvalds {
2211da177e4SLinus Torvalds 	if (dst)
2221da177e4SLinus Torvalds 		atomic_inc(&dst->__refcnt);
2231da177e4SLinus Torvalds 	return dst;
2241da177e4SLinus Torvalds }
2251da177e4SLinus Torvalds 
2268d330868SIlpo Järvinen extern void dst_release(struct dst_entry *dst);
2277fee226aSEric Dumazet 
2287fee226aSEric Dumazet static inline void refdst_drop(unsigned long refdst)
2297fee226aSEric Dumazet {
2307fee226aSEric Dumazet 	if (!(refdst & SKB_DST_NOREF))
2317fee226aSEric Dumazet 		dst_release((struct dst_entry *)(refdst & SKB_DST_PTRMASK));
2327fee226aSEric Dumazet }
2337fee226aSEric Dumazet 
2347fee226aSEric Dumazet /**
2357fee226aSEric Dumazet  * skb_dst_drop - drops skb dst
2367fee226aSEric Dumazet  * @skb: buffer
2377fee226aSEric Dumazet  *
2387fee226aSEric Dumazet  * Drops dst reference count if a reference was taken.
2397fee226aSEric Dumazet  */
240adf30907SEric Dumazet static inline void skb_dst_drop(struct sk_buff *skb)
241adf30907SEric Dumazet {
2427fee226aSEric Dumazet 	if (skb->_skb_refdst) {
2437fee226aSEric Dumazet 		refdst_drop(skb->_skb_refdst);
2447fee226aSEric Dumazet 		skb->_skb_refdst = 0UL;
2457fee226aSEric Dumazet 	}
2467fee226aSEric Dumazet }
2477fee226aSEric Dumazet 
2487fee226aSEric Dumazet static inline void skb_dst_copy(struct sk_buff *nskb, const struct sk_buff *oskb)
2497fee226aSEric Dumazet {
2507fee226aSEric Dumazet 	nskb->_skb_refdst = oskb->_skb_refdst;
2517fee226aSEric Dumazet 	if (!(nskb->_skb_refdst & SKB_DST_NOREF))
2527fee226aSEric Dumazet 		dst_clone(skb_dst(nskb));
2537fee226aSEric Dumazet }
2547fee226aSEric Dumazet 
2557fee226aSEric Dumazet /**
2567fee226aSEric Dumazet  * skb_dst_force - makes sure skb dst is refcounted
2577fee226aSEric Dumazet  * @skb: buffer
2587fee226aSEric Dumazet  *
2597fee226aSEric Dumazet  * If dst is not yet refcounted, let's do it
2607fee226aSEric Dumazet  */
2617fee226aSEric Dumazet static inline void skb_dst_force(struct sk_buff *skb)
2627fee226aSEric Dumazet {
2637fee226aSEric Dumazet 	if (skb_dst_is_noref(skb)) {
2647fee226aSEric Dumazet 		WARN_ON(!rcu_read_lock_held());
2657fee226aSEric Dumazet 		skb->_skb_refdst &= ~SKB_DST_NOREF;
2667fee226aSEric Dumazet 		dst_clone(skb_dst(skb));
2677fee226aSEric Dumazet 	}
268adf30907SEric Dumazet }
2691da177e4SLinus Torvalds 
270d19d56ddSEric Dumazet 
271d19d56ddSEric Dumazet /**
272290b895eSEric Dumazet  *	__skb_tunnel_rx - prepare skb for rx reinsert
273290b895eSEric Dumazet  *	@skb: buffer
274290b895eSEric Dumazet  *	@dev: tunnel device
275290b895eSEric Dumazet  *
276290b895eSEric Dumazet  *	After decapsulation, packet is going to re-enter (netif_rx()) our stack,
277290b895eSEric Dumazet  *	so make some cleanups. (no accounting done)
278290b895eSEric Dumazet  */
279290b895eSEric Dumazet static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
280290b895eSEric Dumazet {
281290b895eSEric Dumazet 	skb->dev = dev;
282290b895eSEric Dumazet 	skb->rxhash = 0;
283290b895eSEric Dumazet 	skb_set_queue_mapping(skb, 0);
284290b895eSEric Dumazet 	skb_dst_drop(skb);
285290b895eSEric Dumazet 	nf_reset(skb);
286290b895eSEric Dumazet }
287290b895eSEric Dumazet 
288290b895eSEric Dumazet /**
289d19d56ddSEric Dumazet  *	skb_tunnel_rx - prepare skb for rx reinsert
290d19d56ddSEric Dumazet  *	@skb: buffer
291d19d56ddSEric Dumazet  *	@dev: tunnel device
292d19d56ddSEric Dumazet  *
293d19d56ddSEric Dumazet  *	After decapsulation, packet is going to re-enter (netif_rx()) our stack,
294d19d56ddSEric Dumazet  *	so make some cleanups, and perform accounting.
295290b895eSEric Dumazet  *	Note: this accounting is not SMP safe.
296d19d56ddSEric Dumazet  */
297d19d56ddSEric Dumazet static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
298d19d56ddSEric Dumazet {
299d19d56ddSEric Dumazet 	/* TODO : stats should be SMP safe */
300d19d56ddSEric Dumazet 	dev->stats.rx_packets++;
301d19d56ddSEric Dumazet 	dev->stats.rx_bytes += skb->len;
302290b895eSEric Dumazet 	__skb_tunnel_rx(skb, dev);
303d19d56ddSEric Dumazet }
304d19d56ddSEric Dumazet 
3051da177e4SLinus Torvalds /* Children define the path of the packet through the
3061da177e4SLinus Torvalds  * Linux networking.  Thus, destinations are stackable.
3071da177e4SLinus Torvalds  */
3081da177e4SLinus Torvalds 
3098764ab2cSSteffen Klassert static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb)
3101da177e4SLinus Torvalds {
3118764ab2cSSteffen Klassert 	struct dst_entry *child = skb_dst(skb)->child;
3121da177e4SLinus Torvalds 
3138764ab2cSSteffen Klassert 	skb_dst_drop(skb);
3141da177e4SLinus Torvalds 	return child;
3151da177e4SLinus Torvalds }
3161da177e4SLinus Torvalds 
317352e512cSHerbert Xu extern int dst_discard(struct sk_buff *skb);
3181da177e4SLinus Torvalds extern void * dst_alloc(struct dst_ops * ops);
3191da177e4SLinus Torvalds extern void __dst_free(struct dst_entry * dst);
3201da177e4SLinus Torvalds extern struct dst_entry *dst_destroy(struct dst_entry * dst);
3211da177e4SLinus Torvalds 
3221da177e4SLinus Torvalds static inline void dst_free(struct dst_entry * dst)
3231da177e4SLinus Torvalds {
3241da177e4SLinus Torvalds 	if (dst->obsolete > 1)
3251da177e4SLinus Torvalds 		return;
3261da177e4SLinus Torvalds 	if (!atomic_read(&dst->__refcnt)) {
3271da177e4SLinus Torvalds 		dst = dst_destroy(dst);
3281da177e4SLinus Torvalds 		if (!dst)
3291da177e4SLinus Torvalds 			return;
3301da177e4SLinus Torvalds 	}
3311da177e4SLinus Torvalds 	__dst_free(dst);
3321da177e4SLinus Torvalds }
3331da177e4SLinus Torvalds 
3341da177e4SLinus Torvalds static inline void dst_rcu_free(struct rcu_head *head)
3351da177e4SLinus Torvalds {
3361da177e4SLinus Torvalds 	struct dst_entry *dst = container_of(head, struct dst_entry, rcu_head);
3371da177e4SLinus Torvalds 	dst_free(dst);
3381da177e4SLinus Torvalds }
3391da177e4SLinus Torvalds 
3401da177e4SLinus Torvalds static inline void dst_confirm(struct dst_entry *dst)
3411da177e4SLinus Torvalds {
3421da177e4SLinus Torvalds 	if (dst)
3431da177e4SLinus Torvalds 		neigh_confirm(dst->neighbour);
3441da177e4SLinus Torvalds }
3451da177e4SLinus Torvalds 
3461da177e4SLinus Torvalds static inline void dst_link_failure(struct sk_buff *skb)
3471da177e4SLinus Torvalds {
348adf30907SEric Dumazet 	struct dst_entry *dst = skb_dst(skb);
3491da177e4SLinus Torvalds 	if (dst && dst->ops && dst->ops->link_failure)
3501da177e4SLinus Torvalds 		dst->ops->link_failure(skb);
3511da177e4SLinus Torvalds }
3521da177e4SLinus Torvalds 
3531da177e4SLinus Torvalds static inline void dst_set_expires(struct dst_entry *dst, int timeout)
3541da177e4SLinus Torvalds {
3551da177e4SLinus Torvalds 	unsigned long expires = jiffies + timeout;
3561da177e4SLinus Torvalds 
3571da177e4SLinus Torvalds 	if (expires == 0)
3581da177e4SLinus Torvalds 		expires = 1;
3591da177e4SLinus Torvalds 
3601da177e4SLinus Torvalds 	if (dst->expires == 0 || time_before(expires, dst->expires))
3611da177e4SLinus Torvalds 		dst->expires = expires;
3621da177e4SLinus Torvalds }
3631da177e4SLinus Torvalds 
3641da177e4SLinus Torvalds /* Output packet to network from transport.  */
3651da177e4SLinus Torvalds static inline int dst_output(struct sk_buff *skb)
3661da177e4SLinus Torvalds {
367adf30907SEric Dumazet 	return skb_dst(skb)->output(skb);
3681da177e4SLinus Torvalds }
3691da177e4SLinus Torvalds 
3701da177e4SLinus Torvalds /* Input packet from network to transport.  */
3711da177e4SLinus Torvalds static inline int dst_input(struct sk_buff *skb)
3721da177e4SLinus Torvalds {
373adf30907SEric Dumazet 	return skb_dst(skb)->input(skb);
3741da177e4SLinus Torvalds }
3751da177e4SLinus Torvalds 
3761da177e4SLinus Torvalds static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie)
3771da177e4SLinus Torvalds {
3781da177e4SLinus Torvalds 	if (dst->obsolete)
3791da177e4SLinus Torvalds 		dst = dst->ops->check(dst, cookie);
3801da177e4SLinus Torvalds 	return dst;
3811da177e4SLinus Torvalds }
3821da177e4SLinus Torvalds 
3831da177e4SLinus Torvalds extern void		dst_init(void);
3841da177e4SLinus Torvalds 
385815f4e57SHerbert Xu /* Flags for xfrm_lookup flags argument. */
386815f4e57SHerbert Xu enum {
387815f4e57SHerbert Xu 	XFRM_LOOKUP_WAIT = 1 << 0,
3888b7817f3SHerbert Xu 	XFRM_LOOKUP_ICMP = 1 << 1,
389815f4e57SHerbert Xu };
390815f4e57SHerbert Xu 
3911da177e4SLinus Torvalds struct flowi;
3921da177e4SLinus Torvalds #ifndef CONFIG_XFRM
39352479b62SAlexey Dobriyan static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p,
39452479b62SAlexey Dobriyan 			      struct flowi *fl, struct sock *sk, int flags)
3951da177e4SLinus Torvalds {
3961da177e4SLinus Torvalds 	return 0;
3971da177e4SLinus Torvalds }
39852479b62SAlexey Dobriyan static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p,
39952479b62SAlexey Dobriyan 				struct flowi *fl, struct sock *sk, int flags)
40014e50e57SDavid S. Miller {
40114e50e57SDavid S. Miller 	return 0;
40214e50e57SDavid S. Miller }
4031da177e4SLinus Torvalds #else
40452479b62SAlexey Dobriyan extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p,
40552479b62SAlexey Dobriyan 		       struct flowi *fl, struct sock *sk, int flags);
40652479b62SAlexey Dobriyan extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p,
40752479b62SAlexey Dobriyan 			 struct flowi *fl, struct sock *sk, int flags);
4081da177e4SLinus Torvalds #endif
4091da177e4SLinus Torvalds #endif
4101da177e4SLinus Torvalds 
4111da177e4SLinus Torvalds #endif /* _NET_DST_H */
412