linux/include/net/vxlan.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NET_VXLAN_H
#define __NET_VXLAN_H

#include <linux/if_vlan.h>
#include <linux/rhashtable-types.h>
#include <net/udp_tunnel.h>
#include <net/dst_metadata.h>
#include <net/rtnetlink.h>
#include <net/switchdev.h>
#include <net/nexthop.h>

#define IANA_VXLAN_UDP_PORT
#define IANA_VXLAN_GPE_UDP_PORT

/* VXLAN protocol (RFC 7348) header:
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |R|R|R|R|I|R|R|R|               Reserved                        |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                VXLAN Network Identifier (VNI) |   Reserved    |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * I = VXLAN Network Identifier (VNI) present.
 */
struct vxlanhdr {};

/* VXLAN header flags. */
#define VXLAN_HF_VNI

#define VXLAN_N_VID
#define VXLAN_VID_MASK
#define VXLAN_VNI_MASK
#define VXLAN_HLEN

#define VNI_HASH_BITS
#define VNI_HASH_SIZE
#define FDB_HASH_BITS
#define FDB_HASH_SIZE

/* Remote checksum offload for VXLAN (VXLAN_F_REMCSUM_[RT]X):
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |R|R|R|R|I|R|R|R|R|R|C|              Reserved                   |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |           VXLAN Network Identifier (VNI)      |O| Csum start  |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * C = Remote checksum offload bit. When set indicates that the
 *     remote checksum offload data is present.
 *
 * O = Offset bit. Indicates the checksum offset relative to
 *     checksum start.
 *
 * Csum start = Checksum start divided by two.
 *
 * http://tools.ietf.org/html/draft-herbert-vxlan-rco
 */

/* VXLAN-RCO header flags. */
#define VXLAN_HF_RCO

/* Remote checksum offload header option */
#define VXLAN_RCO_MASK
#define VXLAN_RCO_UDP
#define VXLAN_RCO_SHIFT
#define VXLAN_RCO_SHIFT_MASK
#define VXLAN_MAX_REMCSUM_START

/*
 * VXLAN Group Based Policy Extension (VXLAN_F_GBP):
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |G|R|R|R|I|R|R|R|R|D|R|R|A|R|R|R|        Group Policy ID        |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                VXLAN Network Identifier (VNI) |   Reserved    |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * G = Group Policy ID present.
 *
 * D = Don't Learn bit. When set, this bit indicates that the egress
 *     VTEP MUST NOT learn the source address of the encapsulated frame.
 *
 * A = Indicates that the group policy has already been applied to
 *     this packet. Policies MUST NOT be applied by devices when the
 *     A bit is set.
 *
 * https://tools.ietf.org/html/draft-smith-vxlan-group-policy
 */
struct vxlanhdr_gbp {};

/* VXLAN-GBP header flags. */
#define VXLAN_HF_GBP

#define VXLAN_GBP_USED_BITS

/* skb->mark mapping
 *
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |R|R|R|R|R|R|R|R|R|D|R|R|A|R|R|R|        Group Policy ID        |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 */
#define VXLAN_GBP_DONT_LEARN
#define VXLAN_GBP_POLICY_APPLIED
#define VXLAN_GBP_ID_MASK

#define VXLAN_GBP_MASK

/*
 * VXLAN Generic Protocol Extension (VXLAN_F_GPE):
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |R|R|Ver|I|P|R|O|       Reserved                |Next Protocol  |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 * |                VXLAN Network Identifier (VNI) |   Reserved    |
 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * Ver = Version. Indicates VXLAN GPE protocol version.
 *
 * P = Next Protocol Bit. The P bit is set to indicate that the
 *     Next Protocol field is present.
 *
 * O = OAM Flag Bit. The O bit is set to indicate that the packet
 *     is an OAM packet.
 *
 * Next Protocol = This 8 bit field indicates the protocol header
 * immediately following the VXLAN GPE header.
 *
 * https://tools.ietf.org/html/draft-ietf-nvo3-vxlan-gpe-01
 */

struct vxlanhdr_gpe {};

/* VXLAN-GPE header flags. */
#define VXLAN_HF_VER
#define VXLAN_HF_NP
#define VXLAN_HF_OAM

#define VXLAN_GPE_USED_BITS

struct vxlan_metadata {};

/* per UDP socket information */
struct vxlan_sock {};

vxlan_addr;

struct vxlan_rdst {};

struct vxlan_config {};

enum {};

struct vxlan_vni_stats {};

struct vxlan_vni_stats_pcpu {};

struct vxlan_dev_node {};

struct vxlan_vni_node {};

struct vxlan_vni_group {};

/* Pseudo network device */
struct vxlan_dev {};

#define VXLAN_F_LEARN
#define VXLAN_F_PROXY
#define VXLAN_F_RSC
#define VXLAN_F_L2MISS
#define VXLAN_F_L3MISS
#define VXLAN_F_IPV6
#define VXLAN_F_UDP_ZERO_CSUM_TX
#define VXLAN_F_UDP_ZERO_CSUM6_TX
#define VXLAN_F_UDP_ZERO_CSUM6_RX
#define VXLAN_F_REMCSUM_TX
#define VXLAN_F_REMCSUM_RX
#define VXLAN_F_GBP
#define VXLAN_F_REMCSUM_NOPARTIAL
#define VXLAN_F_COLLECT_METADATA
#define VXLAN_F_GPE
#define VXLAN_F_IPV6_LINKLOCAL
#define VXLAN_F_TTL_INHERIT
#define VXLAN_F_VNIFILTER
#define VXLAN_F_MDB
#define VXLAN_F_LOCALBYPASS

/* Flags that are used in the receive path. These flags must match in
 * order for a socket to be shareable
 */
#define VXLAN_F_RCV_FLAGS

/* Flags that can be set together with VXLAN_F_GPE. */
#define VXLAN_F_ALLOWED_GPE

struct net_device *vxlan_dev_create(struct net *net, const char *name,
				    u8 name_assign_type, struct vxlan_config *conf);

static inline netdev_features_t vxlan_features_check(struct sk_buff *skb,
						     netdev_features_t features)
{}

static inline int vxlan_headroom(u32 flags)
{}

static inline struct vxlanhdr *vxlan_hdr(struct sk_buff *skb)
{}

static inline __be32 vxlan_vni(__be32 vni_field)
{}

static inline __be32 vxlan_vni_field(__be32 vni)
{}

static inline size_t vxlan_rco_start(__be32 vni_field)
{}

static inline size_t vxlan_rco_offset(__be32 vni_field)
{}

static inline __be32 vxlan_compute_rco(unsigned int start, unsigned int offset)
{}

static inline unsigned short vxlan_get_sk_family(struct vxlan_sock *vs)
{}

#if IS_ENABLED(CONFIG_IPV6)

static inline bool vxlan_addr_any(const union vxlan_addr *ipa)
{}

static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)
{}

#else /* !IS_ENABLED(CONFIG_IPV6) */

static inline bool vxlan_addr_any(const union vxlan_addr *ipa)
{
	return ipa->sin.sin_addr.s_addr == htonl(INADDR_ANY);
}

static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)
{
	return ipv4_is_multicast(ipa->sin.sin_addr.s_addr);
}

#endif /* IS_ENABLED(CONFIG_IPV6) */

static inline bool netif_is_vxlan(const struct net_device *dev)
{}

struct switchdev_notifier_vxlan_fdb_info {};

#if IS_ENABLED(CONFIG_VXLAN)
int vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni,
		      struct switchdev_notifier_vxlan_fdb_info *fdb_info);
int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
		     struct notifier_block *nb,
		     struct netlink_ext_ack *extack);
void vxlan_fdb_clear_offload(const struct net_device *dev, __be32 vni);

#else
static inline int
vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni,
		  struct switchdev_notifier_vxlan_fdb_info *fdb_info)
{
	return -ENOENT;
}

static inline int vxlan_fdb_replay(const struct net_device *dev, __be32 vni,
				   struct notifier_block *nb,
				   struct netlink_ext_ack *extack)
{
	return -EOPNOTSUPP;
}

static inline void
vxlan_fdb_clear_offload(const struct net_device *dev, __be32 vni)
{
}
#endif

static inline void vxlan_flag_attr_error(int attrtype,
					 struct netlink_ext_ack *extack)
{}

static inline bool vxlan_fdb_nh_path_select(struct nexthop *nh,
					    u32 hash,
					    struct vxlan_rdst *rdst)
{}

static inline void vxlan_build_gbp_hdr(struct vxlanhdr *vxh, const struct vxlan_metadata *md)
{}

#endif