Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70c03b49 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller
Browse files

vlan: Add GVRP support



Add GVRP support for dynamically registering VLANs with switches.

By default GVRP is disabled because we only support the applicant-only
participant model, which means it should not be enabled on vlans that
are members of a bridge. Since there is currently no way to cleanly
determine that, the user is responsible for enabling it.

The code is pretty small and low impact, its wrapped in a config
option though because it depends on the GARP implementation and
the STP core.

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ce305002
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -402,6 +402,7 @@ enum vlan_ioctl_cmds {

enum vlan_flags {
	VLAN_FLAG_REORDER_HDR	= 0x1,
	VLAN_FLAG_GVRP		= 0x2,
};

enum vlan_name_types {
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ struct garp_attr {
};

enum garp_applications {
	GARP_APPLICATION_GVRP,
	__GARP_APPLICATION_MAX
};
#define GARP_APPLICATION_MAX	(__GARP_APPLICATION_MAX - 1)
+10 −0
Original line number Diff line number Diff line
@@ -17,3 +17,13 @@ config VLAN_8021Q
	  will be called 8021q.

	  If unsure, say N.

config VLAN_8021Q_GVRP
	bool "GVRP (GARP VLAN Registration Protocol) support"
	depends on VLAN_8021Q
	select GARP
	help
	  Select this to enable GVRP end-system support. GVRP is used for
	  automatic propagation of registered VLANs to switches.

	  If unsure, say N.
+3 −6
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@

obj-$(CONFIG_VLAN_8021Q) += 8021q.o

8021q-objs := vlan.o vlan_dev.o vlan_netlink.o

ifeq ($(CONFIG_PROC_FS),y)
8021q-objs += vlanproc.o
endif
8021q-y				:= vlan.o vlan_dev.o vlan_netlink.o
8021q-$(CONFIG_VLAN_8021Q_GVRP)	+= vlan_gvrp.o
8021q-$(CONFIG_PROC_FS)		+= vlanproc.o
+19 −4
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ void unregister_vlan_dev(struct net_device *dev)

	/* If the group is now empty, kill off the group. */
	if (grp->nr_vlans == 0) {
		vlan_gvrp_uninit_applicant(real_dev);

		if (real_dev->features & NETIF_F_HW_VLAN_RX)
			real_dev->vlan_rx_register(real_dev, NULL);

@@ -249,15 +251,18 @@ int register_vlan_dev(struct net_device *dev)
		ngrp = grp = vlan_group_alloc(real_dev);
		if (!grp)
			return -ENOBUFS;
		err = vlan_gvrp_init_applicant(real_dev);
		if (err < 0)
			goto out_free_group;
	}

	err = vlan_group_prealloc_vid(grp, vlan_id);
	if (err < 0)
		goto out_free_group;
		goto out_uninit_applicant;

	err = register_netdevice(dev);
	if (err < 0)
		goto out_free_group;
		goto out_uninit_applicant;

	/* Account for reference in struct vlan_dev_info */
	dev_hold(real_dev);
@@ -278,6 +283,9 @@ int register_vlan_dev(struct net_device *dev)

	return 0;

out_uninit_applicant:
	if (ngrp)
		vlan_gvrp_uninit_applicant(real_dev);
out_free_group:
	if (ngrp)
		vlan_group_free(ngrp);
@@ -713,14 +721,20 @@ static int __init vlan_proto_init(void)
	if (err < 0)
		goto err2;

	err = vlan_netlink_init();
	err = vlan_gvrp_init();
	if (err < 0)
		goto err3;

	err = vlan_netlink_init();
	if (err < 0)
		goto err4;

	dev_add_pack(&vlan_packet_type);
	vlan_ioctl_set(vlan_ioctl_handler);
	return 0;

err4:
	vlan_gvrp_uninit();
err3:
	unregister_netdevice_notifier(&vlan_notifier_block);
err2:
@@ -745,8 +759,9 @@ static void __exit vlan_cleanup_module(void)
		BUG_ON(!hlist_empty(&vlan_group_hash[i]));

	unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops);

	synchronize_net();

	vlan_gvrp_uninit();
}

module_init(vlan_proto_init);
Loading