linux/net/bridge/br_vlan.c

// SPDX-License-Identifier: GPL-2.0-only
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/slab.h>
#include <net/switchdev.h>

#include "br_private.h"
#include "br_private_tunnel.h"

static void nbp_vlan_set_vlan_dev_state(struct net_bridge_port *p, u16 vid);

static inline int br_vlan_cmp(struct rhashtable_compare_arg *arg,
			      const void *ptr)
{}

static const struct rhashtable_params br_vlan_rht_params =;

static struct net_bridge_vlan *br_vlan_lookup(struct rhashtable *tbl, u16 vid)
{}

static void __vlan_add_pvid(struct net_bridge_vlan_group *vg,
			    const struct net_bridge_vlan *v)
{}

static void __vlan_delete_pvid(struct net_bridge_vlan_group *vg, u16 vid)
{}

/* Update the BRIDGE_VLAN_INFO_PVID and BRIDGE_VLAN_INFO_UNTAGGED flags of @v.
 * If @commit is false, return just whether the BRIDGE_VLAN_INFO_PVID and
 * BRIDGE_VLAN_INFO_UNTAGGED bits of @flags would produce any change onto @v.
 */
static bool __vlan_flags_update(struct net_bridge_vlan *v, u16 flags,
				bool commit)
{}

static bool __vlan_flags_would_change(struct net_bridge_vlan *v, u16 flags)
{}

static void __vlan_flags_commit(struct net_bridge_vlan *v, u16 flags)
{}

static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
			  struct net_bridge_vlan *v, u16 flags,
			  struct netlink_ext_ack *extack)
{}

static void __vlan_add_list(struct net_bridge_vlan *v)
{}

static void __vlan_del_list(struct net_bridge_vlan *v)
{}

static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br,
			  const struct net_bridge_vlan *v)
{}

/* Returns a master vlan, if it didn't exist it gets created. In all cases
 * a reference is taken to the master vlan before returning.
 */
static struct net_bridge_vlan *
br_vlan_get_master(struct net_bridge *br, u16 vid,
		   struct netlink_ext_ack *extack)
{}

static void br_master_vlan_rcu_free(struct rcu_head *rcu)
{}

static void br_vlan_put_master(struct net_bridge_vlan *masterv)
{}

static void nbp_vlan_rcu_free(struct rcu_head *rcu)
{}

static void br_vlan_init_state(struct net_bridge_vlan *v)
{}

/* This is the shared VLAN add function which works for both ports and bridge
 * devices. There are four possible calls to this function in terms of the
 * vlan entry type:
 * 1. vlan is being added on a port (no master flags, global entry exists)
 * 2. vlan is being added on a bridge (both master and brentry flags)
 * 3. vlan is being added on a port, but a global entry didn't exist which
 *    is being created right now (master flag set, brentry flag unset), the
 *    global entry is used for global per-vlan features, but not for filtering
 * 4. same as 3 but with both master and brentry flags set so the entry
 *    will be used for filtering in both the port and the bridge
 */
static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
		      struct netlink_ext_ack *extack)
{}

static int __vlan_del(struct net_bridge_vlan *v)
{}

static void __vlan_group_free(struct net_bridge_vlan_group *vg)
{}

static void __vlan_flush(const struct net_bridge *br,
			 const struct net_bridge_port *p,
			 struct net_bridge_vlan_group *vg)
{}

struct sk_buff *br_handle_vlan(struct net_bridge *br,
			       const struct net_bridge_port *p,
			       struct net_bridge_vlan_group *vg,
			       struct sk_buff *skb)
{}

/* Called under RCU */
static bool __allowed_ingress(const struct net_bridge *br,
			      struct net_bridge_vlan_group *vg,
			      struct sk_buff *skb, u16 *vid,
			      u8 *state,
			      struct net_bridge_vlan **vlan)
{}

bool br_allowed_ingress(const struct net_bridge *br,
			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
			u16 *vid, u8 *state,
			struct net_bridge_vlan **vlan)
{}

/* Called under RCU. */
bool br_allowed_egress(struct net_bridge_vlan_group *vg,
		       const struct sk_buff *skb)
{}

/* Called under RCU */
bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
{}

static int br_vlan_add_existing(struct net_bridge *br,
				struct net_bridge_vlan_group *vg,
				struct net_bridge_vlan *vlan,
				u16 flags, bool *changed,
				struct netlink_ext_ack *extack)
{}

/* Must be protected by RTNL.
 * Must be called with vid in range from 1 to 4094 inclusive.
 * changed must be true only if the vlan was created or updated
 */
int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, bool *changed,
		struct netlink_ext_ack *extack)
{}

/* Must be protected by RTNL.
 * Must be called with vid in range from 1 to 4094 inclusive.
 */
int br_vlan_delete(struct net_bridge *br, u16 vid)
{}

void br_vlan_flush(struct net_bridge *br)
{}

struct net_bridge_vlan *br_vlan_find(struct net_bridge_vlan_group *vg, u16 vid)
{}

/* Must be protected by RTNL. */
static void recalculate_group_addr(struct net_bridge *br)
{}

/* Must be protected by RTNL. */
void br_recalculate_fwd_mask(struct net_bridge *br)
{}

int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val,
			  struct netlink_ext_ack *extack)
{}

bool br_vlan_enabled(const struct net_device *dev)
{}
EXPORT_SYMBOL_GPL();

int br_vlan_get_proto(const struct net_device *dev, u16 *p_proto)
{}
EXPORT_SYMBOL_GPL();

int __br_vlan_set_proto(struct net_bridge *br, __be16 proto,
			struct netlink_ext_ack *extack)
{}

int br_vlan_set_proto(struct net_bridge *br, unsigned long val,
		      struct netlink_ext_ack *extack)
{}

int br_vlan_set_stats(struct net_bridge *br, unsigned long val)
{}

int br_vlan_set_stats_per_port(struct net_bridge *br, unsigned long val)
{}

static bool vlan_default_pvid(struct net_bridge_vlan_group *vg, u16 vid)
{}

static void br_vlan_disable_default_pvid(struct net_bridge *br)
{}

int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,
			       struct netlink_ext_ack *extack)
{}

int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val,
			     struct netlink_ext_ack *extack)
{}

int br_vlan_init(struct net_bridge *br)
{}

int nbp_vlan_init(struct net_bridge_port *p, struct netlink_ext_ack *extack)
{}

/* Must be protected by RTNL.
 * Must be called with vid in range from 1 to 4094 inclusive.
 * changed must be true only if the vlan was created or updated
 */
int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
		 bool *changed, struct netlink_ext_ack *extack)
{}

/* Must be protected by RTNL.
 * Must be called with vid in range from 1 to 4094 inclusive.
 */
int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
{}

void nbp_vlan_flush(struct net_bridge_port *port)
{}

void br_vlan_get_stats(const struct net_bridge_vlan *v,
		       struct pcpu_sw_netstats *stats)
{}

int br_vlan_get_pvid(const struct net_device *dev, u16 *p_pvid)
{}
EXPORT_SYMBOL_GPL();

int br_vlan_get_pvid_rcu(const struct net_device *dev, u16 *p_pvid)
{}
EXPORT_SYMBOL_GPL();

void br_vlan_fill_forward_path_pvid(struct net_bridge *br,
				    struct net_device_path_ctx *ctx,
				    struct net_device_path *path)
{}

int br_vlan_fill_forward_path_mode(struct net_bridge *br,
				   struct net_bridge_port *dst,
				   struct net_device_path *path)
{}

int br_vlan_get_info(const struct net_device *dev, u16 vid,
		     struct bridge_vlan_info *p_vinfo)
{}
EXPORT_SYMBOL_GPL();

int br_vlan_get_info_rcu(const struct net_device *dev, u16 vid,
			 struct bridge_vlan_info *p_vinfo)
{}
EXPORT_SYMBOL_GPL();

static int br_vlan_is_bind_vlan_dev(const struct net_device *dev)
{}

static int br_vlan_is_bind_vlan_dev_fn(struct net_device *dev,
			       __always_unused struct netdev_nested_priv *priv)
{}

static bool br_vlan_has_upper_bind_vlan_dev(struct net_device *dev)
{}

struct br_vlan_bind_walk_data {};

static int br_vlan_match_bind_vlan_dev_fn(struct net_device *dev,
					  struct netdev_nested_priv *priv)
{}

static struct net_device *
br_vlan_get_upper_bind_vlan_dev(struct net_device *dev, u16 vid)
{}

static bool br_vlan_is_dev_up(const struct net_device *dev)
{}

static void br_vlan_set_vlan_dev_state(const struct net_bridge *br,
				       struct net_device *vlan_dev)
{}

static void br_vlan_set_all_vlan_dev_state(struct net_bridge_port *p)
{}

static void br_vlan_upper_change(struct net_device *dev,
				 struct net_device *upper_dev,
				 bool linking)
{}

struct br_vlan_link_state_walk_data {};

static int br_vlan_link_state_change_fn(struct net_device *vlan_dev,
					struct netdev_nested_priv *priv)
{}

static void br_vlan_link_state_change(struct net_device *dev,
				      struct net_bridge *br)
{}

/* Must be protected by RTNL. */
static void nbp_vlan_set_vlan_dev_state(struct net_bridge_port *p, u16 vid)
{}

/* Must be protected by RTNL. */
int br_vlan_bridge_event(struct net_device *dev, unsigned long event, void *ptr)
{}

/* Must be protected by RTNL. */
void br_vlan_port_event(struct net_bridge_port *p, unsigned long event)
{}

static bool br_vlan_stats_fill(struct sk_buff *skb,
			       const struct net_bridge_vlan *v)
{}

/* v_opts is used to dump the options which must be equal in the whole range */
static bool br_vlan_fill_vids(struct sk_buff *skb, u16 vid, u16 vid_range,
			      const struct net_bridge_vlan *v_opts,
			      const struct net_bridge_port *p,
			      u16 flags,
			      bool dump_stats)
{}

static size_t rtnl_vlan_nlmsg_size(void)
{}

void br_vlan_notify(const struct net_bridge *br,
		    const struct net_bridge_port *p,
		    u16 vid, u16 vid_range,
		    int cmd)
{}

/* check if v_curr can enter a range ending in range_end */
bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr,
			     const struct net_bridge_vlan *range_end)
{}

static int br_vlan_dump_dev(const struct net_device *dev,
			    struct sk_buff *skb,
			    struct netlink_callback *cb,
			    u32 dump_flags)
{}

static const struct nla_policy br_vlan_db_dump_pol[BRIDGE_VLANDB_DUMP_MAX + 1] =;

static int br_vlan_rtm_dump(struct sk_buff *skb, struct netlink_callback *cb)
{}

static const struct nla_policy br_vlan_db_policy[BRIDGE_VLANDB_ENTRY_MAX + 1] =;

static int br_vlan_rtm_process_one(struct net_device *dev,
				   const struct nlattr *attr,
				   int cmd, struct netlink_ext_ack *extack)
{}

static int br_vlan_rtm_process(struct sk_buff *skb, struct nlmsghdr *nlh,
			       struct netlink_ext_ack *extack)
{}

void br_vlan_rtnl_init(void)
{}

void br_vlan_rtnl_uninit(void)
{}