Andy Zhou | 0b5e8b8 | 2014-10-03 15:35:28 -0700 | [diff] [blame] | 1 | #ifndef __NET_GENEVE_H |
| 2 | #define __NET_GENEVE_H 1 |
| 3 | |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 4 | #ifdef CONFIG_INET |
Andy Zhou | 0b5e8b8 | 2014-10-03 15:35:28 -0700 | [diff] [blame] | 5 | #include <net/udp_tunnel.h> |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 6 | #endif |
Andy Zhou | 0b5e8b8 | 2014-10-03 15:35:28 -0700 | [diff] [blame] | 7 | |
Andy Zhou | 0b5e8b8 | 2014-10-03 15:35:28 -0700 | [diff] [blame] | 8 | |
| 9 | /* Geneve Header: |
| 10 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 11 | * |Ver| Opt Len |O|C| Rsvd. | Protocol Type | |
| 12 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 13 | * | Virtual Network Identifier (VNI) | Reserved | |
| 14 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 15 | * | Variable Length Options | |
| 16 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 17 | * |
| 18 | * Option Header: |
| 19 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 20 | * | Option Class | Type |R|R|R| Length | |
| 21 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 22 | * | Variable Option Data | |
| 23 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 24 | */ |
| 25 | |
| 26 | struct geneve_opt { |
| 27 | __be16 opt_class; |
| 28 | u8 type; |
| 29 | #ifdef __LITTLE_ENDIAN_BITFIELD |
| 30 | u8 length:5; |
| 31 | u8 r3:1; |
| 32 | u8 r2:1; |
| 33 | u8 r1:1; |
| 34 | #else |
| 35 | u8 r1:1; |
| 36 | u8 r2:1; |
| 37 | u8 r3:1; |
| 38 | u8 length:5; |
| 39 | #endif |
| 40 | u8 opt_data[]; |
| 41 | }; |
| 42 | |
| 43 | #define GENEVE_CRIT_OPT_TYPE (1 << 7) |
| 44 | |
| 45 | struct genevehdr { |
| 46 | #ifdef __LITTLE_ENDIAN_BITFIELD |
| 47 | u8 opt_len:6; |
| 48 | u8 ver:2; |
| 49 | u8 rsvd1:6; |
| 50 | u8 critical:1; |
| 51 | u8 oam:1; |
| 52 | #else |
| 53 | u8 ver:2; |
| 54 | u8 opt_len:6; |
| 55 | u8 oam:1; |
| 56 | u8 critical:1; |
| 57 | u8 rsvd1:6; |
| 58 | #endif |
| 59 | __be16 proto_type; |
| 60 | u8 vni[3]; |
| 61 | u8 rsvd2; |
| 62 | struct geneve_opt options[]; |
| 63 | }; |
| 64 | |
John W. Linville | 35d32e8 | 2015-05-13 12:57:27 -0400 | [diff] [blame] | 65 | static inline struct genevehdr *geneve_hdr(const struct sk_buff *skb) |
| 66 | { |
| 67 | return (struct genevehdr *)(udp_hdr(skb) + 1); |
| 68 | } |
| 69 | |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 70 | #ifdef CONFIG_INET |
| 71 | struct geneve_sock; |
| 72 | |
| 73 | typedef void (geneve_rcv_t)(struct geneve_sock *gs, struct sk_buff *skb); |
| 74 | |
| 75 | struct geneve_sock { |
Jesse Gross | df5dba8 | 2015-01-02 18:26:04 -0800 | [diff] [blame] | 76 | struct list_head list; |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 77 | geneve_rcv_t *rcv; |
| 78 | void *rcv_data; |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 79 | struct socket *sock; |
| 80 | struct rcu_head rcu; |
Jesse Gross | 829a3ad | 2015-01-02 18:26:03 -0800 | [diff] [blame] | 81 | int refcnt; |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 82 | struct udp_offload udp_offloads; |
| 83 | }; |
| 84 | |
Andy Zhou | 0b5e8b8 | 2014-10-03 15:35:28 -0700 | [diff] [blame] | 85 | #define GENEVE_VER 0 |
| 86 | #define GENEVE_BASE_HLEN (sizeof(struct udphdr) + sizeof(struct genevehdr)) |
| 87 | |
| 88 | struct geneve_sock *geneve_sock_add(struct net *net, __be16 port, |
| 89 | geneve_rcv_t *rcv, void *data, |
| 90 | bool no_share, bool ipv6); |
| 91 | |
| 92 | void geneve_sock_release(struct geneve_sock *vs); |
| 93 | |
| 94 | int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt, |
| 95 | struct sk_buff *skb, __be32 src, __be32 dst, __u8 tos, |
| 96 | __u8 ttl, __be16 df, __be16 src_port, __be16 dst_port, |
| 97 | __be16 tun_flags, u8 vni[3], u8 opt_len, u8 *opt, |
Jesse Gross | b869387 | 2015-01-28 16:32:46 -0800 | [diff] [blame] | 98 | bool csum, bool xnet); |
Andy Zhou | 7c5df8f | 2014-10-06 15:15:14 -0700 | [diff] [blame] | 99 | #endif /*ifdef CONFIG_INET */ |
| 100 | |
| 101 | #endif /*ifdef__NET_GENEVE_H */ |