linux/net/batman-adv/soft-interface.c

// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) B.A.T.M.A.N. contributors:
 *
 * Marek Lindner, Simon Wunderlich
 */

#include "soft-interface.h"
#include "main.h"

#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/cpumask.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/percpu.h>
#include <linux/random.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/socket.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/types.h>
#include <net/net_namespace.h>
#include <net/netlink.h>
#include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>

#include "bat_algo.h"
#include "bridge_loop_avoidance.h"
#include "distributed-arp-table.h"
#include "gateway_client.h"
#include "hard-interface.h"
#include "multicast.h"
#include "network-coding.h"
#include "send.h"
#include "translation-table.h"

/**
 * batadv_skb_head_push() - Increase header size and move (push) head pointer
 * @skb: packet buffer which should be modified
 * @len: number of bytes to add
 *
 * Return: 0 on success or negative error number in case of failure
 */
int batadv_skb_head_push(struct sk_buff *skb, unsigned int len)
{}

static int batadv_interface_open(struct net_device *dev)
{}

static int batadv_interface_release(struct net_device *dev)
{}

/**
 * batadv_sum_counter() - Sum the cpu-local counters for index 'idx'
 * @bat_priv: the bat priv with all the soft interface information
 * @idx: index of counter to sum up
 *
 * Return: sum of all cpu-local counters
 */
static u64 batadv_sum_counter(struct batadv_priv *bat_priv,  size_t idx)
{}

static struct net_device_stats *batadv_interface_stats(struct net_device *dev)
{}

static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)
{}

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

/**
 * batadv_interface_set_rx_mode() - set the rx mode of a device
 * @dev: registered network device to modify
 *
 * We do not actually need to set any rx filters for the virtual batman
 * soft interface. However a dummy handler enables a user to set static
 * multicast listeners for instance.
 */
static void batadv_interface_set_rx_mode(struct net_device *dev)
{}

static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
				       struct net_device *soft_iface)
{}

/**
 * batadv_interface_rx() - receive ethernet frame on local batman-adv interface
 * @soft_iface: local interface which will receive the ethernet frame
 * @skb: ethernet frame for @soft_iface
 * @hdr_size: size of already parsed batman-adv header
 * @orig_node: originator from which the batman-adv packet was sent
 *
 * Sends an ethernet frame to the receive path of the local @soft_iface.
 * skb->data has still point to the batman-adv header with the size @hdr_size.
 * The caller has to have parsed this header already and made sure that at least
 * @hdr_size bytes are still available for pull in @skb.
 *
 * The packet may still get dropped. This can happen when the encapsulated
 * ethernet frame is invalid or contains again an batman-adv packet. Also
 * unicast packets will be dropped directly when it was sent between two
 * isolated clients.
 */
void batadv_interface_rx(struct net_device *soft_iface,
			 struct sk_buff *skb, int hdr_size,
			 struct batadv_orig_node *orig_node)
{}

/**
 * batadv_softif_vlan_release() - release vlan from lists and queue for free
 *  after rcu grace period
 * @ref: kref pointer of the vlan object
 */
void batadv_softif_vlan_release(struct kref *ref)
{}

/**
 * batadv_softif_vlan_get() - get the vlan object for a specific vid
 * @bat_priv: the bat priv with all the soft interface information
 * @vid: the identifier of the vlan object to retrieve
 *
 * Return: the private data of the vlan matching the vid passed as argument or
 * NULL otherwise. The refcounter of the returned object is incremented by 1.
 */
struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv,
						  unsigned short vid)
{}

/**
 * batadv_softif_create_vlan() - allocate the needed resources for a new vlan
 * @bat_priv: the bat priv with all the soft interface information
 * @vid: the VLAN identifier
 *
 * Return: 0 on success, a negative error otherwise.
 */
int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
{}

/**
 * batadv_softif_destroy_vlan() - remove and destroy a softif_vlan object
 * @bat_priv: the bat priv with all the soft interface information
 * @vlan: the object to remove
 */
static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv,
				       struct batadv_softif_vlan *vlan)
{}

/**
 * batadv_interface_add_vid() - ndo_add_vid API implementation
 * @dev: the netdev of the mesh interface
 * @proto: protocol of the vlan id
 * @vid: identifier of the new vlan
 *
 * Set up all the internal structures for handling the new vlan on top of the
 * mesh interface
 *
 * Return: 0 on success or a negative error code in case of failure.
 */
static int batadv_interface_add_vid(struct net_device *dev, __be16 proto,
				    unsigned short vid)
{}

/**
 * batadv_interface_kill_vid() - ndo_kill_vid API implementation
 * @dev: the netdev of the mesh interface
 * @proto: protocol of the vlan id
 * @vid: identifier of the deleted vlan
 *
 * Destroy all the internal structures used to handle the vlan identified by vid
 * on top of the mesh interface
 *
 * Return: 0 on success, -EINVAL if the specified prototype is not ETH_P_8021Q
 * or -ENOENT if the specified vlan id wasn't registered.
 */
static int batadv_interface_kill_vid(struct net_device *dev, __be16 proto,
				     unsigned short vid)
{}

/* batman-adv network devices have devices nesting below it and are a special
 * "super class" of normal network devices; split their locks off into a
 * separate class since they always nest.
 */
static struct lock_class_key batadv_netdev_xmit_lock_key;
static struct lock_class_key batadv_netdev_addr_lock_key;

/**
 * batadv_set_lockdep_class_one() - Set lockdep class for a single tx queue
 * @dev: device which owns the tx queue
 * @txq: tx queue to modify
 * @_unused: always NULL
 */
static void batadv_set_lockdep_class_one(struct net_device *dev,
					 struct netdev_queue *txq,
					 void *_unused)
{}

/**
 * batadv_set_lockdep_class() - Set txq and addr_list lockdep class
 * @dev: network device to modify
 */
static void batadv_set_lockdep_class(struct net_device *dev)
{}

/**
 * batadv_softif_init_late() - late stage initialization of soft interface
 * @dev: registered network device to modify
 *
 * Return: error code on failures
 */
static int batadv_softif_init_late(struct net_device *dev)
{}

/**
 * batadv_softif_slave_add() - Add a slave interface to a batadv_soft_interface
 * @dev: batadv_soft_interface used as master interface
 * @slave_dev: net_device which should become the slave interface
 * @extack: extended ACK report struct
 *
 * Return: 0 if successful or error otherwise.
 */
static int batadv_softif_slave_add(struct net_device *dev,
				   struct net_device *slave_dev,
				   struct netlink_ext_ack *extack)
{}

/**
 * batadv_softif_slave_del() - Delete a slave iface from a batadv_soft_interface
 * @dev: batadv_soft_interface used as master interface
 * @slave_dev: net_device which should be removed from the master interface
 *
 * Return: 0 if successful or error otherwise.
 */
static int batadv_softif_slave_del(struct net_device *dev,
				   struct net_device *slave_dev)
{}

static const struct net_device_ops batadv_netdev_ops =;

static void batadv_get_drvinfo(struct net_device *dev,
			       struct ethtool_drvinfo *info)
{}

/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702
 * Declare each description string in struct.name[] to get fixed sized buffer
 * and compile time checking for strings longer than ETH_GSTRING_LEN.
 */
static const struct {} batadv_counters_strings[] =;

static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{}

static void batadv_get_ethtool_stats(struct net_device *dev,
				     struct ethtool_stats *stats, u64 *data)
{}

static int batadv_get_sset_count(struct net_device *dev, int stringset)
{}

static const struct ethtool_ops batadv_ethtool_ops =;

/**
 * batadv_softif_free() - Deconstructor of batadv_soft_interface
 * @dev: Device to cleanup and remove
 */
static void batadv_softif_free(struct net_device *dev)
{}

/**
 * batadv_softif_init_early() - early stage initialization of soft interface
 * @dev: registered network device to modify
 */
static void batadv_softif_init_early(struct net_device *dev)
{}

/**
 * batadv_softif_validate() - validate configuration of new batadv link
 * @tb: IFLA_INFO_DATA netlink attributes
 * @data: enum batadv_ifla_attrs attributes
 * @extack: extended ACK report struct
 *
 * Return: 0 if successful or error otherwise.
 */
static int batadv_softif_validate(struct nlattr *tb[], struct nlattr *data[],
				  struct netlink_ext_ack *extack)
{}

/**
 * batadv_softif_newlink() - pre-initialize and register new batadv link
 * @src_net: the applicable net namespace
 * @dev: network device to register
 * @tb: IFLA_INFO_DATA netlink attributes
 * @data: enum batadv_ifla_attrs attributes
 * @extack: extended ACK report struct
 *
 * Return: 0 if successful or error otherwise.
 */
static int batadv_softif_newlink(struct net *src_net, struct net_device *dev,
				 struct nlattr *tb[], struct nlattr *data[],
				 struct netlink_ext_ack *extack)
{}

/**
 * batadv_softif_destroy_netlink() - deletion of batadv_soft_interface via
 *  netlink
 * @soft_iface: the to-be-removed batman-adv interface
 * @head: list pointer
 */
static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
					  struct list_head *head)
{}

/**
 * batadv_softif_is_valid() - Check whether device is a batadv soft interface
 * @net_dev: device which should be checked
 *
 * Return: true when net_dev is a batman-adv interface, false otherwise
 */
bool batadv_softif_is_valid(const struct net_device *net_dev)
{}

static const struct nla_policy batadv_ifla_policy[IFLA_BATADV_MAX + 1] =;

struct rtnl_link_ops batadv_link_ops __read_mostly =;