include/net/neighbour.h
Source file repositories/reference/linux-study-clean/include/net/neighbour.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/neighbour.h- Extension
.h- Size
- 17678 bytes
- Lines
- 622
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/neighbour.hlinux/atomic.hlinux/refcount.hlinux/netdevice.hlinux/skbuff.hlinux/rcupdate.hlinux/seq_file.hlinux/bitmap.hlinux/err.hlinux/sysctl.hlinux/workqueue.hnet/rtnetlink.hnet/neighbour_tables.h
Detected Declarations
struct neighbourstruct neigh_parmsstruct neigh_statisticsstruct neighbourstruct neigh_opsstruct pneigh_entrystruct neigh_hash_tablestruct neigh_tablestruct neigh_seq_statestruct neighbour_cbfunction neigh_var_setfunction neigh_parms_data_state_setallfunction neigh_parms_data_state_cleanallfunction neigh_parms_familyfunction neigh_key_eq32function neigh_key_eq128function neigh_confirmfunction neigh_set_reach_timefunction __neigh_parms_putfunction neigh_releasefunction neigh_clonefunction neigh_event_send_probefunction neigh_event_sendfunction neigh_hh_bridgefunction neigh_hh_outputfunction neigh_outputfunction __neigh_lookupfunction __neigh_lookup_errnofunction neigh_ha_snapshotfunction neigh_update_is_router
Annotated Snippet
struct neigh_parms {
possible_net_t net;
struct net_device *dev;
netdevice_tracker dev_tracker;
struct list_head list;
int (*neigh_setup)(struct neighbour *);
struct neigh_table *tbl;
void *sysctl_table;
int dead;
refcount_t refcnt;
struct rcu_head rcu_head;
int reachable_time;
u32 qlen;
int data[NEIGH_VAR_DATA_MAX];
DECLARE_BITMAP(data_state, NEIGH_VAR_DATA_MAX);
};
static inline void neigh_var_set(struct neigh_parms *p, int index, int val)
{
set_bit(index, p->data_state);
WRITE_ONCE(p->data[index], val);
}
#define __NEIGH_VAR(p, attr) ((p)->data[NEIGH_VAR_ ## attr])
#define NEIGH_VAR(p, attr) READ_ONCE(__NEIGH_VAR(p, attr))
#define NEIGH_VAR_PTR(p, attr) (&(__NEIGH_VAR(p, attr)))
/* In ndo_neigh_setup, NEIGH_VAR_INIT should be used.
* In other cases, NEIGH_VAR_SET should be used.
*/
#define NEIGH_VAR_INIT(p, attr, val) (__NEIGH_VAR(p, attr) = val)
#define NEIGH_VAR_SET(p, attr, val) neigh_var_set(p, NEIGH_VAR_ ## attr, val)
static inline void neigh_parms_data_state_setall(struct neigh_parms *p)
{
bitmap_fill(p->data_state, NEIGH_VAR_DATA_MAX);
}
static inline void neigh_parms_data_state_cleanall(struct neigh_parms *p)
{
bitmap_zero(p->data_state, NEIGH_VAR_DATA_MAX);
}
struct neigh_statistics {
unsigned long allocs; /* number of allocated neighs */
unsigned long destroys; /* number of destroyed neighs */
unsigned long hash_grows; /* number of hash resizes */
unsigned long res_failed; /* number of failed resolutions */
unsigned long lookups; /* number of lookups */
unsigned long hits; /* number of hits (among lookups) */
unsigned long rcv_probes_mcast; /* number of received mcast ipv6 */
unsigned long rcv_probes_ucast; /* number of received ucast ipv6 */
unsigned long periodic_gc_runs; /* number of periodic GC runs */
unsigned long forced_gc_runs; /* number of forced GC runs */
unsigned long unres_discards; /* number of unresolved drops */
unsigned long table_fulls; /* times even gc couldn't help */
};
#define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field)
struct neighbour {
struct hlist_node hash;
struct hlist_node dev_list;
struct neigh_table *tbl;
struct neigh_parms *parms;
unsigned long confirmed;
unsigned long updated;
rwlock_t lock;
refcount_t refcnt;
unsigned int arp_queue_len_bytes;
struct sk_buff_head arp_queue;
struct timer_list timer;
unsigned long used;
atomic_t probes;
u8 nud_state;
u8 type;
u8 dead;
u8 protocol;
u32 flags;
seqlock_t ha_lock;
unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))] __aligned(8);
struct hh_cache hh;
Annotation
- Immediate include surface: `linux/neighbour.h`, `linux/atomic.h`, `linux/refcount.h`, `linux/netdevice.h`, `linux/skbuff.h`, `linux/rcupdate.h`, `linux/seq_file.h`, `linux/bitmap.h`.
- Detected declarations: `struct neighbour`, `struct neigh_parms`, `struct neigh_statistics`, `struct neighbour`, `struct neigh_ops`, `struct pneigh_entry`, `struct neigh_hash_table`, `struct neigh_table`, `struct neigh_seq_state`, `struct neighbour_cb`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.