neighbour.h 6.2 KB

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