]> git.proxmox.com Git - mirror_ovs.git/blame - lib/netdev-native-tnl.h
netdev: Reject empty names in netdev_open().
[mirror_ovs.git] / lib / netdev-native-tnl.h
CommitLineData
6b241d64
PS
1/*
2 * Copyright (c) 2010, 2011, 2013, 2015 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NETDEV_VPORT_NATIVE_TNL_H
18#define NETDEV_VPORT_NATIVE_TNL_H 1
19
20#include <stdbool.h>
21#include <stddef.h>
22#include "compiler.h"
aca40d4f
TLSC
23#include "dp-packet.h"
24#include "packets.h"
6b241d64
PS
25#include "unixctl.h"
26
aca40d4f
TLSC
27struct netdev;
28struct ovs_action_push_tnl;
29struct netdev_tnl_build_header_params;
30
6b241d64
PS
31int
32netdev_gre_build_header(const struct netdev *netdev,
33 struct ovs_action_push_tnl *data,
4975aa3e
PS
34 const struct netdev_tnl_build_header_params *params);
35
6b241d64
PS
36void
37netdev_gre_push_header(struct dp_packet *packet,
38 const struct ovs_action_push_tnl *data);
1c8f98d9 39struct dp_packet *
6b241d64
PS
40netdev_gre_pop_header(struct dp_packet *packet);
41
42void
43netdev_tnl_push_udp_header(struct dp_packet *packet,
44 const struct ovs_action_push_tnl *data);
45int
46netdev_geneve_build_header(const struct netdev *netdev,
47 struct ovs_action_push_tnl *data,
4975aa3e
PS
48 const struct netdev_tnl_build_header_params *params);
49
1c8f98d9 50struct dp_packet *
6b241d64
PS
51netdev_geneve_pop_header(struct dp_packet *packet);
52
53int
54netdev_vxlan_build_header(const struct netdev *netdev,
55 struct ovs_action_push_tnl *data,
4975aa3e
PS
56 const struct netdev_tnl_build_header_params *params);
57
1c8f98d9 58struct dp_packet *
6b241d64
PS
59netdev_vxlan_pop_header(struct dp_packet *packet);
60
61static inline bool
62netdev_tnl_is_header_ipv6(const void *header)
63{
64 const struct eth_header *eth;
65 eth = header;
66 return eth->eth_type == htons(ETH_TYPE_IPV6);
67}
68
69static inline struct ip_header *
70netdev_tnl_ip_hdr(void *eth)
71{
72 return (void *)((char *)eth + sizeof (struct eth_header));
73}
74
75static inline struct ovs_16aligned_ip6_hdr *
76netdev_tnl_ipv6_hdr(void *eth)
77{
78 return (void *)((char *)eth + sizeof (struct eth_header));
79}
80
4975aa3e
PS
81void *
82netdev_tnl_ip_build_header(struct ovs_action_push_tnl *data,
83 const struct netdev_tnl_build_header_params *params,
84 uint8_t next_proto);
85
6b241d64
PS
86extern uint16_t tnl_udp_port_min;
87extern uint16_t tnl_udp_port_max;
88
89static inline ovs_be16
90netdev_tnl_get_src_port(struct dp_packet *packet)
91{
92 uint32_t hash;
93
94 hash = dp_packet_get_rss_hash(packet);
95
96 return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
97 tnl_udp_port_min);
98}
99
100void *
101netdev_tnl_ip_extract_tnl_md(struct dp_packet *packet, struct flow_tnl *tnl,
102 unsigned int *hlen);
103void *
104netdev_tnl_push_ip_header(struct dp_packet *packet,
105 const void *header, int size, int *ip_tot_size);
106void
107netdev_tnl_egress_port_range(struct unixctl_conn *conn, int argc,
108 const char *argv[], void *aux OVS_UNUSED);
109#endif