net/802/garp.c
Source file repositories/reference/linux-study-clean/net/802/garp.c
File Facts
- System
- Linux kernel
- Corpus path
net/802/garp.c- Extension
.c- Size
- 18382 bytes
- Lines
- 654
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/timer.hlinux/skbuff.hlinux/netdevice.hlinux/etherdevice.hlinux/rtnetlink.hlinux/llc.hlinux/slab.hlinux/module.hnet/llc.hnet/llc_pdu.hnet/garp.hlinux/unaligned.h
Detected Declarations
function garp_attr_cmpfunction garp_attr_destroyfunction garp_attr_destroy_allfunction garp_pdu_initfunction garp_pdu_append_end_markfunction garp_pdu_queuefunction garp_queue_xmitfunction garp_pdu_append_msgfunction garp_pdu_append_attrfunction garp_attr_eventfunction garp_request_joinfunction garp_request_leavefunction garp_gid_eventfunction garp_join_timer_armfunction garp_join_timerfunction garp_pdu_parse_end_markfunction garp_pdu_parse_attrfunction garp_pdu_parse_msgfunction garp_pdu_rcvfunction garp_init_portfunction garp_release_portfunction garp_init_applicantfunction garp_uninit_applicantfunction garp_register_applicationfunction garp_unregister_applicationexport garp_request_joinexport garp_request_leaveexport garp_init_applicantexport garp_uninit_applicantexport garp_register_applicationexport garp_unregister_application
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* IEEE 802.1D Generic Attribute Registration Protocol (GARP)
*
* Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
*/
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/llc.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <net/llc.h>
#include <net/llc_pdu.h>
#include <net/garp.h>
#include <linux/unaligned.h>
static unsigned int garp_join_time __read_mostly = 200;
module_param(garp_join_time, uint, 0644);
MODULE_PARM_DESC(garp_join_time, "Join time in ms (default 200ms)");
MODULE_DESCRIPTION("IEEE 802.1D Generic Attribute Registration Protocol (GARP)");
MODULE_LICENSE("GPL");
static const struct garp_state_trans {
u8 state;
u8 action;
} garp_applicant_state_table[GARP_APPLICANT_MAX + 1][GARP_EVENT_MAX + 1] = {
[GARP_APPLICANT_VA] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_AA,
.action = GARP_ACTION_S_JOIN_IN },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_AA },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_LEAVE_IN] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_LEAVE_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_REQ_JOIN] = { .state = GARP_APPLICANT_INVALID },
[GARP_EVENT_REQ_LEAVE] = { .state = GARP_APPLICANT_LA },
},
[GARP_APPLICANT_AA] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_QA,
.action = GARP_ACTION_S_JOIN_IN },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_QA },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_LEAVE_IN] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_LEAVE_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_REQ_JOIN] = { .state = GARP_APPLICANT_INVALID },
[GARP_EVENT_REQ_LEAVE] = { .state = GARP_APPLICANT_LA },
},
[GARP_APPLICANT_QA] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_INVALID },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_QA },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_R_LEAVE_IN] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_R_LEAVE_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_REQ_JOIN] = { .state = GARP_APPLICANT_INVALID },
[GARP_EVENT_REQ_LEAVE] = { .state = GARP_APPLICANT_LA },
},
[GARP_APPLICANT_LA] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_VO,
.action = GARP_ACTION_S_LEAVE_EMPTY },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_LA },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VO },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_LA },
[GARP_EVENT_R_LEAVE_IN] = { .state = GARP_APPLICANT_LA },
[GARP_EVENT_R_LEAVE_EMPTY] = { .state = GARP_APPLICANT_VO },
[GARP_EVENT_REQ_JOIN] = { .state = GARP_APPLICANT_VA },
[GARP_EVENT_REQ_LEAVE] = { .state = GARP_APPLICANT_INVALID },
},
[GARP_APPLICANT_VP] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_AA,
.action = GARP_ACTION_S_JOIN_IN },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_AP },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_R_LEAVE_IN] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_R_LEAVE_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_REQ_JOIN] = { .state = GARP_APPLICANT_INVALID },
[GARP_EVENT_REQ_LEAVE] = { .state = GARP_APPLICANT_VO },
},
[GARP_APPLICANT_AP] = {
[GARP_EVENT_TRANSMIT_PDU] = { .state = GARP_APPLICANT_QA,
.action = GARP_ACTION_S_JOIN_IN },
[GARP_EVENT_R_JOIN_IN] = { .state = GARP_APPLICANT_QP },
[GARP_EVENT_R_JOIN_EMPTY] = { .state = GARP_APPLICANT_VP },
[GARP_EVENT_R_EMPTY] = { .state = GARP_APPLICANT_VP },
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/timer.h`, `linux/skbuff.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/rtnetlink.h`, `linux/llc.h`, `linux/slab.h`.
- Detected declarations: `function garp_attr_cmp`, `function garp_attr_destroy`, `function garp_attr_destroy_all`, `function garp_pdu_init`, `function garp_pdu_append_end_mark`, `function garp_pdu_queue`, `function garp_queue_xmit`, `function garp_pdu_append_msg`, `function garp_pdu_append_attr`, `function garp_attr_event`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.