Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2#ifndef __LINUX_NEIGHBOUR_H
3#define __LINUX_NEIGHBOUR_H
4
5#include <linux/types.h>
6#include <linux/netlink.h>
7
8struct ndmsg {
9 __u8 ndm_family;
10 __u8 ndm_pad1;
11 __u16 ndm_pad2;
12 __s32 ndm_ifindex;
13 __u16 ndm_state;
14 __u8 ndm_flags;
15 __u8 ndm_type;
16};
17
18enum {
19 NDA_UNSPEC,
20 NDA_DST,
21 NDA_LLADDR,
22 NDA_CACHEINFO,
23 NDA_PROBES,
24 NDA_VLAN,
25 NDA_PORT,
26 NDA_VNI,
27 NDA_IFINDEX,
28 NDA_MASTER,
29 NDA_LINK_NETNSID,
30 NDA_SRC_VNI,
31 NDA_PROTOCOL, /* Originator of entry */
32 NDA_NH_ID,
33 NDA_FDB_EXT_ATTRS,
34 NDA_FLAGS_EXT,
35 __NDA_MAX
36};
37
38#define NDA_MAX (__NDA_MAX - 1)
39
40/*
41 * Neighbor Cache Entry Flags
42 */
43
44#define NTF_USE (1 << 0)
45#define NTF_SELF (1 << 1)
46#define NTF_MASTER (1 << 2)
47#define NTF_PROXY (1 << 3) /* == ATF_PUBL */
48#define NTF_EXT_LEARNED (1 << 4)
49#define NTF_OFFLOADED (1 << 5)
50#define NTF_STICKY (1 << 6)
51#define NTF_ROUTER (1 << 7)
52/* Extended flags under NDA_FLAGS_EXT: */
53#define NTF_EXT_MANAGED (1 << 0)
54
55/*
56 * Neighbor Cache Entry States.
57 */
58
59#define NUD_INCOMPLETE 0x01
60#define NUD_REACHABLE 0x02
61#define NUD_STALE 0x04
62#define NUD_DELAY 0x08
63#define NUD_PROBE 0x10
64#define NUD_FAILED 0x20
65
66/* Dummy states */
67#define NUD_NOARP 0x40
68#define NUD_PERMANENT 0x80
69#define NUD_NONE 0x00
70
71/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no
72 * address resolution or NUD.
73 *
74 * NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true
75 * for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier
76 * down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED
77 * flagged entries explicitly are (which is also consistent with the routing
78 * subsystem).
79 *
80 * When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
81 * states don't make sense and thus are ignored. Such entries don't age and
82 * can roam.
83 *
84 * NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
85 * of a user space control plane, and automatically refreshed so that (if
86 * possible) they remain in NUD_REACHABLE state.
87 */
88
89struct nda_cacheinfo {
90 __u32 ndm_confirmed;
91 __u32 ndm_used;
92 __u32 ndm_updated;
93 __u32 ndm_refcnt;
94};
95
96/*****************************************************************
97 * Neighbour tables specific messages.
98 *
99 * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
100 * NLM_F_DUMP flag set. Every neighbour table configuration is
101 * spread over multiple messages to avoid running into message
102 * size limits on systems with many interfaces. The first message
103 * in the sequence transports all not device specific data such as
104 * statistics, configuration, and the default parameter set.
105 * This message is followed by 0..n messages carrying device
106 * specific parameter sets.
107 * Although the ordering should be sufficient, NDTA_NAME can be
108 * used to identify sequences. The initial message can be identified
109 * by checking for NDTA_CONFIG. The device specific messages do
110 * not contain this TLV but have NDTPA_IFINDEX set to the
111 * corresponding interface index.
112 *
113 * To change neighbour table attributes, send RTM_SETNEIGHTBL
114 * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
115 * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
116 * otherwise. Device specific parameter sets can be changed by
117 * setting NDTPA_IFINDEX to the interface index of the corresponding
118 * device.
119 ****/
120
121struct ndt_stats {
122 __u64 ndts_allocs;
123 __u64 ndts_destroys;
124 __u64 ndts_hash_grows;
125 __u64 ndts_res_failed;
126 __u64 ndts_lookups;
127 __u64 ndts_hits;
128 __u64 ndts_rcv_probes_mcast;
129 __u64 ndts_rcv_probes_ucast;
130 __u64 ndts_periodic_gc_runs;
131 __u64 ndts_forced_gc_runs;
132 __u64 ndts_table_fulls;
133};
134
135enum {
136 NDTPA_UNSPEC,
137 NDTPA_IFINDEX, /* u32, unchangeable */
138 NDTPA_REFCNT, /* u32, read-only */
139 NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */
140 NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
141 NDTPA_RETRANS_TIME, /* u64, msecs */
142 NDTPA_GC_STALETIME, /* u64, msecs */
143 NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
144 NDTPA_QUEUE_LEN, /* u32 */
145 NDTPA_APP_PROBES, /* u32 */
146 NDTPA_UCAST_PROBES, /* u32 */
147 NDTPA_MCAST_PROBES, /* u32 */
148 NDTPA_ANYCAST_DELAY, /* u64, msecs */
149 NDTPA_PROXY_DELAY, /* u64, msecs */
150 NDTPA_PROXY_QLEN, /* u32 */
151 NDTPA_LOCKTIME, /* u64, msecs */
152 NDTPA_QUEUE_LENBYTES, /* u32 */
153 NDTPA_MCAST_REPROBES, /* u32 */
154 NDTPA_PAD,
155 __NDTPA_MAX
156};
157#define NDTPA_MAX (__NDTPA_MAX - 1)
158
159struct ndtmsg {
160 __u8 ndtm_family;
161 __u8 ndtm_pad1;
162 __u16 ndtm_pad2;
163};
164
165struct ndt_config {
166 __u16 ndtc_key_len;
167 __u16 ndtc_entry_size;
168 __u32 ndtc_entries;
169 __u32 ndtc_last_flush; /* delta to now in msecs */
170 __u32 ndtc_last_rand; /* delta to now in msecs */
171 __u32 ndtc_hash_rnd;
172 __u32 ndtc_hash_mask;
173 __u32 ndtc_hash_chain_gc;
174 __u32 ndtc_proxy_qlen;
175};
176
177enum {
178 NDTA_UNSPEC,
179 NDTA_NAME, /* char *, unchangeable */
180 NDTA_THRESH1, /* u32 */
181 NDTA_THRESH2, /* u32 */
182 NDTA_THRESH3, /* u32 */
183 NDTA_CONFIG, /* struct ndt_config, read-only */
184 NDTA_PARMS, /* nested TLV NDTPA_* */
185 NDTA_STATS, /* struct ndt_stats, read-only */
186 NDTA_GC_INTERVAL, /* u64, msecs */
187 NDTA_PAD,
188 __NDTA_MAX
189};
190#define NDTA_MAX (__NDTA_MAX - 1)
191
192 /* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
193 * - FDB_NOTIFY_BIT - notify on activity/expire for any entry
194 * - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
195 */
196enum {
197 FDB_NOTIFY_BIT = (1 << 0),
198 FDB_NOTIFY_INACTIVE_BIT = (1 << 1)
199};
200
201/* embedded into NDA_FDB_EXT_ATTRS:
202 * [NDA_FDB_EXT_ATTRS] = {
203 * [NFEA_ACTIVITY_NOTIFY]
204 * ...
205 * }
206 */
207enum {
208 NFEA_UNSPEC,
209 NFEA_ACTIVITY_NOTIFY,
210 NFEA_DONT_REFRESH,
211 __NFEA_MAX
212};
213#define NFEA_MAX (__NFEA_MAX - 1)
214
215#endif