neighbour.h 6.0 KB

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