blob: e843937fb30aee0006def9f3243c3b1ea744c5e3 [file] [log] [blame]
Thomas Graff38a9eb2015-07-21 10:43:56 +02001#ifndef __NET_DST_METADATA_H
2#define __NET_DST_METADATA_H 1
3
4#include <linux/skbuff.h>
5#include <net/ip_tunnels.h>
6#include <net/dst.h>
7
8struct metadata_dst {
9 struct dst_entry dst;
10 size_t opts_len;
Thomas Grafee122c72015-07-21 10:43:58 +020011 union {
12 struct ip_tunnel_info tun_info;
13 } u;
Thomas Graff38a9eb2015-07-21 10:43:56 +020014};
15
16static inline struct metadata_dst *skb_metadata_dst(struct sk_buff *skb)
17{
18 struct metadata_dst *md_dst = (struct metadata_dst *) skb_dst(skb);
19
20 if (md_dst && md_dst->dst.flags & DST_METADATA)
21 return md_dst;
22
23 return NULL;
24}
25
Thomas Grafee122c72015-07-21 10:43:58 +020026static inline struct ip_tunnel_info *skb_tunnel_info(struct sk_buff *skb)
27{
28 struct metadata_dst *md_dst = skb_metadata_dst(skb);
29
30 if (md_dst)
31 return &md_dst->u.tun_info;
32
33 return NULL;
34}
35
Thomas Graff38a9eb2015-07-21 10:43:56 +020036static inline bool skb_valid_dst(const struct sk_buff *skb)
37{
38 struct dst_entry *dst = skb_dst(skb);
39
40 return dst && !(dst->flags & DST_METADATA);
41}
42
43struct metadata_dst *metadata_dst_alloc(u8 optslen, gfp_t flags);
44
45#endif /* __NET_DST_METADATA_H */