xref: /linux/include/uapi/linux/neighbour.h (revision 0ad53fe3ae82443c74ff8cfd7bd13377cc1134a3)
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 
8 struct 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 
18 enum {
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_MAX
35 };
36 
37 #define NDA_MAX (__NDA_MAX - 1)
38 
39 /*
40  *	Neighbor Cache Entry Flags
41  */
42 
43 #define NTF_USE		0x01
44 #define NTF_SELF	0x02
45 #define NTF_MASTER	0x04
46 #define NTF_PROXY	0x08	/* == ATF_PUBL */
47 #define NTF_EXT_LEARNED	0x10
48 #define NTF_OFFLOADED   0x20
49 #define NTF_STICKY	0x40
50 #define NTF_ROUTER	0x80
51 
52 /*
53  *	Neighbor Cache Entry States.
54  */
55 
56 #define NUD_INCOMPLETE	0x01
57 #define NUD_REACHABLE	0x02
58 #define NUD_STALE	0x04
59 #define NUD_DELAY	0x08
60 #define NUD_PROBE	0x10
61 #define NUD_FAILED	0x20
62 
63 /* Dummy states */
64 #define NUD_NOARP	0x40
65 #define NUD_PERMANENT	0x80
66 #define NUD_NONE	0x00
67 
68 /* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change
69  * and make no address resolution or NUD.
70  * NUD_PERMANENT also cannot be deleted by garbage collectors.
71  * When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
72  * states don't make sense and thus are ignored. Such entries don't age and
73  * can roam.
74  */
75 
76 struct nda_cacheinfo {
77 	__u32		ndm_confirmed;
78 	__u32		ndm_used;
79 	__u32		ndm_updated;
80 	__u32		ndm_refcnt;
81 };
82 
83 /*****************************************************************
84  *		Neighbour tables specific messages.
85  *
86  * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
87  * NLM_F_DUMP flag set. Every neighbour table configuration is
88  * spread over multiple messages to avoid running into message
89  * size limits on systems with many interfaces. The first message
90  * in the sequence transports all not device specific data such as
91  * statistics, configuration, and the default parameter set.
92  * This message is followed by 0..n messages carrying device
93  * specific parameter sets.
94  * Although the ordering should be sufficient, NDTA_NAME can be
95  * used to identify sequences. The initial message can be identified
96  * by checking for NDTA_CONFIG. The device specific messages do
97  * not contain this TLV but have NDTPA_IFINDEX set to the
98  * corresponding interface index.
99  *
100  * To change neighbour table attributes, send RTM_SETNEIGHTBL
101  * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
102  * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
103  * otherwise. Device specific parameter sets can be changed by
104  * setting NDTPA_IFINDEX to the interface index of the corresponding
105  * device.
106  ****/
107 
108 struct ndt_stats {
109 	__u64		ndts_allocs;
110 	__u64		ndts_destroys;
111 	__u64		ndts_hash_grows;
112 	__u64		ndts_res_failed;
113 	__u64		ndts_lookups;
114 	__u64		ndts_hits;
115 	__u64		ndts_rcv_probes_mcast;
116 	__u64		ndts_rcv_probes_ucast;
117 	__u64		ndts_periodic_gc_runs;
118 	__u64		ndts_forced_gc_runs;
119 	__u64		ndts_table_fulls;
120 };
121 
122 enum {
123 	NDTPA_UNSPEC,
124 	NDTPA_IFINDEX,			/* u32, unchangeable */
125 	NDTPA_REFCNT,			/* u32, read-only */
126 	NDTPA_REACHABLE_TIME,		/* u64, read-only, msecs */
127 	NDTPA_BASE_REACHABLE_TIME,	/* u64, msecs */
128 	NDTPA_RETRANS_TIME,		/* u64, msecs */
129 	NDTPA_GC_STALETIME,		/* u64, msecs */
130 	NDTPA_DELAY_PROBE_TIME,		/* u64, msecs */
131 	NDTPA_QUEUE_LEN,		/* u32 */
132 	NDTPA_APP_PROBES,		/* u32 */
133 	NDTPA_UCAST_PROBES,		/* u32 */
134 	NDTPA_MCAST_PROBES,		/* u32 */
135 	NDTPA_ANYCAST_DELAY,		/* u64, msecs */
136 	NDTPA_PROXY_DELAY,		/* u64, msecs */
137 	NDTPA_PROXY_QLEN,		/* u32 */
138 	NDTPA_LOCKTIME,			/* u64, msecs */
139 	NDTPA_QUEUE_LENBYTES,		/* u32 */
140 	NDTPA_MCAST_REPROBES,		/* u32 */
141 	NDTPA_PAD,
142 	__NDTPA_MAX
143 };
144 #define NDTPA_MAX (__NDTPA_MAX - 1)
145 
146 struct ndtmsg {
147 	__u8		ndtm_family;
148 	__u8		ndtm_pad1;
149 	__u16		ndtm_pad2;
150 };
151 
152 struct ndt_config {
153 	__u16		ndtc_key_len;
154 	__u16		ndtc_entry_size;
155 	__u32		ndtc_entries;
156 	__u32		ndtc_last_flush;	/* delta to now in msecs */
157 	__u32		ndtc_last_rand;		/* delta to now in msecs */
158 	__u32		ndtc_hash_rnd;
159 	__u32		ndtc_hash_mask;
160 	__u32		ndtc_hash_chain_gc;
161 	__u32		ndtc_proxy_qlen;
162 };
163 
164 enum {
165 	NDTA_UNSPEC,
166 	NDTA_NAME,			/* char *, unchangeable */
167 	NDTA_THRESH1,			/* u32 */
168 	NDTA_THRESH2,			/* u32 */
169 	NDTA_THRESH3,			/* u32 */
170 	NDTA_CONFIG,			/* struct ndt_config, read-only */
171 	NDTA_PARMS,			/* nested TLV NDTPA_* */
172 	NDTA_STATS,			/* struct ndt_stats, read-only */
173 	NDTA_GC_INTERVAL,		/* u64, msecs */
174 	NDTA_PAD,
175 	__NDTA_MAX
176 };
177 #define NDTA_MAX (__NDTA_MAX - 1)
178 
179  /* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
180   * - FDB_NOTIFY_BIT - notify on activity/expire for any entry
181   * - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
182   */
183 enum {
184 	FDB_NOTIFY_BIT		= (1 << 0),
185 	FDB_NOTIFY_INACTIVE_BIT	= (1 << 1)
186 };
187 
188 /* embedded into NDA_FDB_EXT_ATTRS:
189  * [NDA_FDB_EXT_ATTRS] = {
190  *     [NFEA_ACTIVITY_NOTIFY]
191  *     ...
192  * }
193  */
194 enum {
195 	NFEA_UNSPEC,
196 	NFEA_ACTIVITY_NOTIFY,
197 	NFEA_DONT_REFRESH,
198 	__NFEA_MAX
199 };
200 #define NFEA_MAX (__NFEA_MAX - 1)
201 
202 #endif
203