net/8021q/vlan_gvrp.c
Source file repositories/reference/linux-study-clean/net/8021q/vlan_gvrp.c
File Facts
- System
- Linux kernel
- Corpus path
net/8021q/vlan_gvrp.c- Extension
.c- Size
- 1637 bytes
- Lines
- 68
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/if_vlan.hnet/garp.hvlan.h
Detected Declarations
enum gvrp_attributesfunction vlan_gvrp_request_joinfunction vlan_gvrp_request_leavefunction vlan_gvrp_init_applicantfunction vlan_gvrp_uninit_applicantfunction vlan_gvrp_initfunction vlan_gvrp_uninit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* IEEE 802.1Q GARP VLAN Registration Protocol (GVRP)
*
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
*/
#include <linux/types.h>
#include <linux/if_vlan.h>
#include <net/garp.h>
#include "vlan.h"
#define GARP_GVRP_ADDRESS { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x21 }
enum gvrp_attributes {
GVRP_ATTR_INVALID,
GVRP_ATTR_VID,
__GVRP_ATTR_MAX
};
#define GVRP_ATTR_MAX (__GVRP_ATTR_MAX - 1)
static struct garp_application vlan_gvrp_app __read_mostly = {
.proto.group_address = GARP_GVRP_ADDRESS,
.maxattr = GVRP_ATTR_MAX,
.type = GARP_APPLICATION_GVRP,
};
int vlan_gvrp_request_join(const struct net_device *dev)
{
const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
__be16 vlan_id = htons(vlan->vlan_id);
if (vlan->vlan_proto != htons(ETH_P_8021Q))
return 0;
return garp_request_join(vlan->real_dev, &vlan_gvrp_app,
&vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
}
void vlan_gvrp_request_leave(const struct net_device *dev)
{
const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
__be16 vlan_id = htons(vlan->vlan_id);
if (vlan->vlan_proto != htons(ETH_P_8021Q))
return;
garp_request_leave(vlan->real_dev, &vlan_gvrp_app,
&vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
}
int vlan_gvrp_init_applicant(struct net_device *dev)
{
return garp_init_applicant(dev, &vlan_gvrp_app);
}
void vlan_gvrp_uninit_applicant(struct net_device *dev)
{
garp_uninit_applicant(dev, &vlan_gvrp_app);
}
int __init vlan_gvrp_init(void)
{
return garp_register_application(&vlan_gvrp_app);
}
void vlan_gvrp_uninit(void)
{
garp_unregister_application(&vlan_gvrp_app);
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/if_vlan.h`, `net/garp.h`, `vlan.h`.
- Detected declarations: `enum gvrp_attributes`, `function vlan_gvrp_request_join`, `function vlan_gvrp_request_leave`, `function vlan_gvrp_init_applicant`, `function vlan_gvrp_uninit_applicant`, `function vlan_gvrp_init`, `function vlan_gvrp_uninit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.