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