neighbour.h 5.7 KB

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