linux/drivers/net/geneve.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * GENEVE: Generic Network Virtualization Encapsulation
 *
 * Copyright (c) 2015 Red Hat, Inc.
 */

#define pr_fmt(fmt)

#include <linux/ethtool.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/etherdevice.h>
#include <linux/hash.h>
#include <net/ipv6_stubs.h>
#include <net/dst_metadata.h>
#include <net/gro_cells.h>
#include <net/rtnetlink.h>
#include <net/geneve.h>
#include <net/gro.h>
#include <net/protocol.h>

#define GENEVE_NETDEV_VER

#define GENEVE_N_VID
#define GENEVE_VID_MASK

#define VNI_HASH_BITS
#define VNI_HASH_SIZE

static bool log_ecn_error =;
module_param(log_ecn_error, bool, 0644);
MODULE_PARM_DESC();

#define GENEVE_VER
#define GENEVE_BASE_HLEN
#define GENEVE_IPV4_HLEN
#define GENEVE_IPV6_HLEN

/* per-network namespace private data for this module */
struct geneve_net {};

static unsigned int geneve_net_id;

struct geneve_dev_node {};

struct geneve_config {};

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

struct geneve_sock {};

static inline __u32 geneve_net_vni_hash(u8 vni[3])
{}

static __be64 vni_to_tunnel_id(const __u8 *vni)
{}

/* Convert 64 bit tunnel ID to 24 bit VNI. */
static void tunnel_id_to_vni(__be64 tun_id, __u8 *vni)
{}

static bool eq_tun_id_and_vni(u8 *tun_id, u8 *vni)
{}

static sa_family_t geneve_get_sk_family(struct geneve_sock *gs)
{}

static struct geneve_dev *geneve_lookup(struct geneve_sock *gs,
					__be32 addr, u8 vni[])
{}

#if IS_ENABLED(CONFIG_IPV6)
static struct geneve_dev *geneve6_lookup(struct geneve_sock *gs,
					 struct in6_addr addr6, u8 vni[])
{}
#endif

static inline struct genevehdr *geneve_hdr(const struct sk_buff *skb)
{}

static struct geneve_dev *geneve_lookup_skb(struct geneve_sock *gs,
					    struct sk_buff *skb)
{}

/* geneve receive/decap routine */
static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
		      struct sk_buff *skb)
{}

/* Setup stats when device is created */
static int geneve_init(struct net_device *dev)
{}

static void geneve_uninit(struct net_device *dev)
{}

/* Callback from net/ipv4/udp.c to receive packets */
static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
{}

/* Callback from net/ipv{4,6}/udp.c to check that we have a tunnel for errors */
static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
{}

static struct socket *geneve_create_sock(struct net *net, bool ipv6,
					 __be16 port, bool ipv6_rx_csum)
{}

static int geneve_hlen(struct genevehdr *gh)
{}

static struct sk_buff *geneve_gro_receive(struct sock *sk,
					  struct list_head *head,
					  struct sk_buff *skb)
{}

static int geneve_gro_complete(struct sock *sk, struct sk_buff *skb,
			       int nhoff)
{}

/* Create new listen socket if needed */
static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,
						bool ipv6, bool ipv6_rx_csum)
{}

static void __geneve_sock_release(struct geneve_sock *gs)
{}

static void geneve_sock_release(struct geneve_dev *geneve)
{}

static struct geneve_sock *geneve_find_sock(struct geneve_net *gn,
					    sa_family_t family,
					    __be16 dst_port)
{}

static int geneve_sock_add(struct geneve_dev *geneve, bool ipv6)
{}

static int geneve_open(struct net_device *dev)
{}

static int geneve_stop(struct net_device *dev)
{}

static void geneve_build_header(struct genevehdr *geneveh,
				const struct ip_tunnel_info *info,
				__be16 inner_proto)
{}

static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
			    const struct ip_tunnel_info *info,
			    bool xnet, int ip_hdr_len,
			    bool inner_proto_inherit)
{}

static u8 geneve_get_dsfield(struct sk_buff *skb, struct net_device *dev,
			     const struct ip_tunnel_info *info,
			     bool *use_cache)
{}

static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
			   struct geneve_dev *geneve,
			   const struct ip_tunnel_info *info)
{}

#if IS_ENABLED(CONFIG_IPV6)
static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
			    struct geneve_dev *geneve,
			    const struct ip_tunnel_info *info)
{}
#endif

static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static int geneve_change_mtu(struct net_device *dev, int new_mtu)
{}

static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
{}

static const struct net_device_ops geneve_netdev_ops =;

static void geneve_get_drvinfo(struct net_device *dev,
			       struct ethtool_drvinfo *drvinfo)
{}

static const struct ethtool_ops geneve_ethtool_ops =;

/* Info for udev, that this is a virtual tunnel endpoint */
static const struct device_type geneve_type =;

/* Calls the ndo_udp_tunnel_add of the caller in order to
 * supply the listening GENEVE udp ports. Callers are expected
 * to implement the ndo_udp_tunnel_add.
 */
static void geneve_offload_rx_ports(struct net_device *dev, bool push)
{}

/* Initialize the device structure. */
static void geneve_setup(struct net_device *dev)
{}

static const struct nla_policy geneve_policy[IFLA_GENEVE_MAX + 1] =;

static int geneve_validate(struct nlattr *tb[], struct nlattr *data[],
			   struct netlink_ext_ack *extack)
{}

static struct geneve_dev *geneve_find_dev(struct geneve_net *gn,
					  const struct ip_tunnel_info *info,
					  bool *tun_on_same_port,
					  bool *tun_collect_md)
{}

static bool is_tnl_info_zero(const struct ip_tunnel_info *info)
{}

static bool geneve_dst_addr_equal(struct ip_tunnel_info *a,
				  struct ip_tunnel_info *b)
{}

static int geneve_configure(struct net *net, struct net_device *dev,
			    struct netlink_ext_ack *extack,
			    const struct geneve_config *cfg)
{}

static void init_tnl_info(struct ip_tunnel_info *info, __u16 dst_port)
{}

static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],
			  struct netlink_ext_ack *extack,
			  struct geneve_config *cfg, bool changelink)
{}

static void geneve_link_config(struct net_device *dev,
			       struct ip_tunnel_info *info, struct nlattr *tb[])
{}

static int geneve_newlink(struct net *net, struct net_device *dev,
			  struct nlattr *tb[], struct nlattr *data[],
			  struct netlink_ext_ack *extack)
{}

/* Quiesces the geneve device data path for both TX and RX.
 *
 * On transmit geneve checks for non-NULL geneve_sock before it proceeds.
 * So, if we set that socket to NULL under RCU and wait for synchronize_net()
 * to complete for the existing set of in-flight packets to be transmitted,
 * then we would have quiesced the transmit data path. All the future packets
 * will get dropped until we unquiesce the data path.
 *
 * On receive geneve dereference the geneve_sock stashed in the socket. So,
 * if we set that to NULL under RCU and wait for synchronize_net() to
 * complete, then we would have quiesced the receive data path.
 */
static void geneve_quiesce(struct geneve_dev *geneve, struct geneve_sock **gs4,
			   struct geneve_sock **gs6)
{}

/* Resumes the geneve device data path for both TX and RX. */
static void geneve_unquiesce(struct geneve_dev *geneve, struct geneve_sock *gs4,
			     struct geneve_sock __maybe_unused *gs6)
{}

static int geneve_changelink(struct net_device *dev, struct nlattr *tb[],
			     struct nlattr *data[],
			     struct netlink_ext_ack *extack)
{}

static void geneve_dellink(struct net_device *dev, struct list_head *head)
{}

static size_t geneve_get_size(const struct net_device *dev)
{}

static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
{}

static struct rtnl_link_ops geneve_link_ops __read_mostly =;

struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
					u8 name_assign_type, u16 dst_port)
{}
EXPORT_SYMBOL_GPL();

static int geneve_netdevice_event(struct notifier_block *unused,
				  unsigned long event, void *ptr)
{}

static struct notifier_block geneve_notifier_block __read_mostly =;

static __net_init int geneve_init_net(struct net *net)
{}

static void geneve_destroy_tunnels(struct net *net, struct list_head *head)
{}

static void __net_exit geneve_exit_batch_rtnl(struct list_head *net_list,
					      struct list_head *dev_to_kill)
{}

static void __net_exit geneve_exit_net(struct net *net)
{}

static struct pernet_operations geneve_net_ops =;

static int __init geneve_init_module(void)
{}
late_initcall(geneve_init_module);

static void __exit geneve_cleanup_module(void)
{}
module_exit(geneve_cleanup_module);

MODULE_LICENSE();
MODULE_VERSION();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_ALIAS_RTNL_LINK();