Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef __LINUX_NEIGHBOUR_H
0003 #define __LINUX_NEIGHBOUR_H
0004 
0005 #include <linux/types.h>
0006 #include <linux/netlink.h>
0007 
0008 struct ndmsg {
0009     __u8        ndm_family;
0010     __u8        ndm_pad1;
0011     __u16       ndm_pad2;
0012     __s32       ndm_ifindex;
0013     __u16       ndm_state;
0014     __u8        ndm_flags;
0015     __u8        ndm_type;
0016 };
0017 
0018 enum {
0019     NDA_UNSPEC,
0020     NDA_DST,
0021     NDA_LLADDR,
0022     NDA_CACHEINFO,
0023     NDA_PROBES,
0024     NDA_VLAN,
0025     NDA_PORT,
0026     NDA_VNI,
0027     NDA_IFINDEX,
0028     NDA_MASTER,
0029     NDA_LINK_NETNSID,
0030     NDA_SRC_VNI,
0031     NDA_PROTOCOL,  /* Originator of entry */
0032     NDA_NH_ID,
0033     NDA_FDB_EXT_ATTRS,
0034     NDA_FLAGS_EXT,
0035     NDA_NDM_STATE_MASK,
0036     NDA_NDM_FLAGS_MASK,
0037     __NDA_MAX
0038 };
0039 
0040 #define NDA_MAX (__NDA_MAX - 1)
0041 
0042 /*
0043  *  Neighbor Cache Entry Flags
0044  */
0045 
0046 #define NTF_USE     (1 << 0)
0047 #define NTF_SELF    (1 << 1)
0048 #define NTF_MASTER  (1 << 2)
0049 #define NTF_PROXY   (1 << 3)    /* == ATF_PUBL */
0050 #define NTF_EXT_LEARNED (1 << 4)
0051 #define NTF_OFFLOADED   (1 << 5)
0052 #define NTF_STICKY  (1 << 6)
0053 #define NTF_ROUTER  (1 << 7)
0054 /* Extended flags under NDA_FLAGS_EXT: */
0055 #define NTF_EXT_MANAGED (1 << 0)
0056 
0057 /*
0058  *  Neighbor Cache Entry States.
0059  */
0060 
0061 #define NUD_INCOMPLETE  0x01
0062 #define NUD_REACHABLE   0x02
0063 #define NUD_STALE   0x04
0064 #define NUD_DELAY   0x08
0065 #define NUD_PROBE   0x10
0066 #define NUD_FAILED  0x20
0067 
0068 /* Dummy states */
0069 #define NUD_NOARP   0x40
0070 #define NUD_PERMANENT   0x80
0071 #define NUD_NONE    0x00
0072 
0073 /* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no
0074  * address resolution or NUD.
0075  *
0076  * NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true
0077  * for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier
0078  * down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED
0079  * flagged entries explicitly are (which is also consistent with the routing
0080  * subsystem).
0081  *
0082  * When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
0083  * states don't make sense and thus are ignored. Such entries don't age and
0084  * can roam.
0085  *
0086  * NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
0087  * of a user space control plane, and automatically refreshed so that (if
0088  * possible) they remain in NUD_REACHABLE state.
0089  */
0090 
0091 struct nda_cacheinfo {
0092     __u32       ndm_confirmed;
0093     __u32       ndm_used;
0094     __u32       ndm_updated;
0095     __u32       ndm_refcnt;
0096 };
0097 
0098 /*****************************************************************
0099  *      Neighbour tables specific messages.
0100  *
0101  * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
0102  * NLM_F_DUMP flag set. Every neighbour table configuration is
0103  * spread over multiple messages to avoid running into message
0104  * size limits on systems with many interfaces. The first message
0105  * in the sequence transports all not device specific data such as
0106  * statistics, configuration, and the default parameter set.
0107  * This message is followed by 0..n messages carrying device
0108  * specific parameter sets.
0109  * Although the ordering should be sufficient, NDTA_NAME can be
0110  * used to identify sequences. The initial message can be identified
0111  * by checking for NDTA_CONFIG. The device specific messages do
0112  * not contain this TLV but have NDTPA_IFINDEX set to the
0113  * corresponding interface index.
0114  *
0115  * To change neighbour table attributes, send RTM_SETNEIGHTBL
0116  * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
0117  * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
0118  * otherwise. Device specific parameter sets can be changed by
0119  * setting NDTPA_IFINDEX to the interface index of the corresponding
0120  * device.
0121  ****/
0122 
0123 struct ndt_stats {
0124     __u64       ndts_allocs;
0125     __u64       ndts_destroys;
0126     __u64       ndts_hash_grows;
0127     __u64       ndts_res_failed;
0128     __u64       ndts_lookups;
0129     __u64       ndts_hits;
0130     __u64       ndts_rcv_probes_mcast;
0131     __u64       ndts_rcv_probes_ucast;
0132     __u64       ndts_periodic_gc_runs;
0133     __u64       ndts_forced_gc_runs;
0134     __u64       ndts_table_fulls;
0135 };
0136 
0137 enum {
0138     NDTPA_UNSPEC,
0139     NDTPA_IFINDEX,          /* u32, unchangeable */
0140     NDTPA_REFCNT,           /* u32, read-only */
0141     NDTPA_REACHABLE_TIME,       /* u64, read-only, msecs */
0142     NDTPA_BASE_REACHABLE_TIME,  /* u64, msecs */
0143     NDTPA_RETRANS_TIME,     /* u64, msecs */
0144     NDTPA_GC_STALETIME,     /* u64, msecs */
0145     NDTPA_DELAY_PROBE_TIME,     /* u64, msecs */
0146     NDTPA_QUEUE_LEN,        /* u32 */
0147     NDTPA_APP_PROBES,       /* u32 */
0148     NDTPA_UCAST_PROBES,     /* u32 */
0149     NDTPA_MCAST_PROBES,     /* u32 */
0150     NDTPA_ANYCAST_DELAY,        /* u64, msecs */
0151     NDTPA_PROXY_DELAY,      /* u64, msecs */
0152     NDTPA_PROXY_QLEN,       /* u32 */
0153     NDTPA_LOCKTIME,         /* u64, msecs */
0154     NDTPA_QUEUE_LENBYTES,       /* u32 */
0155     NDTPA_MCAST_REPROBES,       /* u32 */
0156     NDTPA_PAD,
0157     NDTPA_INTERVAL_PROBE_TIME_MS,   /* u64, msecs */
0158     __NDTPA_MAX
0159 };
0160 #define NDTPA_MAX (__NDTPA_MAX - 1)
0161 
0162 struct ndtmsg {
0163     __u8        ndtm_family;
0164     __u8        ndtm_pad1;
0165     __u16       ndtm_pad2;
0166 };
0167 
0168 struct ndt_config {
0169     __u16       ndtc_key_len;
0170     __u16       ndtc_entry_size;
0171     __u32       ndtc_entries;
0172     __u32       ndtc_last_flush;    /* delta to now in msecs */
0173     __u32       ndtc_last_rand;     /* delta to now in msecs */
0174     __u32       ndtc_hash_rnd;
0175     __u32       ndtc_hash_mask;
0176     __u32       ndtc_hash_chain_gc;
0177     __u32       ndtc_proxy_qlen;
0178 };
0179 
0180 enum {
0181     NDTA_UNSPEC,
0182     NDTA_NAME,          /* char *, unchangeable */
0183     NDTA_THRESH1,           /* u32 */
0184     NDTA_THRESH2,           /* u32 */
0185     NDTA_THRESH3,           /* u32 */
0186     NDTA_CONFIG,            /* struct ndt_config, read-only */
0187     NDTA_PARMS,         /* nested TLV NDTPA_* */
0188     NDTA_STATS,         /* struct ndt_stats, read-only */
0189     NDTA_GC_INTERVAL,       /* u64, msecs */
0190     NDTA_PAD,
0191     __NDTA_MAX
0192 };
0193 #define NDTA_MAX (__NDTA_MAX - 1)
0194 
0195  /* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
0196   * - FDB_NOTIFY_BIT - notify on activity/expire for any entry
0197   * - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
0198   */
0199 enum {
0200     FDB_NOTIFY_BIT      = (1 << 0),
0201     FDB_NOTIFY_INACTIVE_BIT = (1 << 1)
0202 };
0203 
0204 /* embedded into NDA_FDB_EXT_ATTRS:
0205  * [NDA_FDB_EXT_ATTRS] = {
0206  *     [NFEA_ACTIVITY_NOTIFY]
0207  *     ...
0208  * }
0209  */
0210 enum {
0211     NFEA_UNSPEC,
0212     NFEA_ACTIVITY_NOTIFY,
0213     NFEA_DONT_REFRESH,
0214     __NFEA_MAX
0215 };
0216 #define NFEA_MAX (__NFEA_MAX - 1)
0217 
0218 #endif