f15bb0308ba258591f64e850e20ee9043572dcd5
[cascardo/ovs.git] / datapath / linux / compat / include / net / dst_metadata.h
1 #ifndef __NET_DST_METADATA_WRAPPER_H
2 #define __NET_DST_METADATA_WRAPPER_H 1
3
4 #ifdef HAVE_METADATA_DST
5 #include_next <net/dst_metadata.h>
6 #else
7 #include <linux/skbuff.h>
8 #include <net/ip_tunnels.h>
9 #include <net/dst.h>
10
11 struct metadata_dst {
12         unsigned long dst;
13         union {
14                 struct ip_tunnel_info   tun_info;
15         } u;
16 };
17
18 static inline struct metadata_dst *metadata_dst_alloc(u8 optslen, gfp_t flags)
19 {
20         struct metadata_dst *md_dst;
21
22         md_dst = kmalloc(sizeof(*md_dst) + optslen, flags);
23         if (!md_dst)
24                 return NULL;
25
26         return md_dst;
27 }
28 #define skb_tunnel_info ovs_skb_tunnel_info
29 #endif
30 static inline void ovs_ip_tun_rx_dst(struct ip_tunnel_info *tun_info,
31                                  struct sk_buff *skb, __be16 flags,
32                                  __be64 tunnel_id, int md_size)
33 {
34         const struct iphdr *iph = ip_hdr(skb);
35
36         ip_tunnel_key_init(&tun_info->key,
37                            iph->saddr, iph->daddr, iph->tos, iph->ttl,
38                            0, 0, tunnel_id, flags);
39         tun_info->mode = 0;
40 }
41
42 void ovs_ip_tunnel_rcv(struct net_device *dev, struct sk_buff *skb,
43                       struct metadata_dst *tun_dst);
44 #endif /* __NET_DST_METADATA_WRAPPER_H */