1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_NEXTHOP_H
3 #define _UAPI_LINUX_NEXTHOP_H
5 #include <linux/types.h>
8 unsigned char nh_family
;
9 unsigned char nh_scope
; /* return only */
10 unsigned char nh_protocol
; /* Routing protocol that installed nh */
12 unsigned int nh_flags
; /* RTNH_F flags */
15 /* entry in a nexthop group */
17 __u32 id
; /* nexthop id - must exist */
18 __u8 weight
; /* weight of this nexthop */
19 __u8 weight_high
; /* high order bits of weight */
23 static inline __u16
nexthop_grp_weight(const struct nexthop_grp
*entry
)
25 return ((entry
->weight_high
<< 8) | entry
->weight
) + 1;
29 NEXTHOP_GRP_TYPE_MPATH
, /* hash-threshold nexthop group
30 * default type if not specified
32 NEXTHOP_GRP_TYPE_RES
, /* resilient nexthop group */
33 __NEXTHOP_GRP_TYPE_MAX
,
36 #define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)
38 #define NHA_OP_FLAG_DUMP_STATS BIT(0)
39 #define NHA_OP_FLAG_DUMP_HW_STATS BIT(1)
41 /* Response OP_FLAGS. */
42 #define NHA_OP_FLAG_RESP_GRP_RESVD_0 BIT(31) /* Dump clears resvd fields. */
46 NHA_ID
, /* u32; id for nexthop. id == 0 means auto-assign */
48 NHA_GROUP
, /* array of nexthop_grp */
49 NHA_GROUP_TYPE
, /* u16 one of NEXTHOP_GRP_TYPE */
50 /* if NHA_GROUP attribute is added, no other attributes can be set */
52 NHA_BLACKHOLE
, /* flag; nexthop used to blackhole packets */
53 /* if NHA_BLACKHOLE is added, OIF, GATEWAY, ENCAP can not be set */
55 NHA_OIF
, /* u32; nexthop device */
56 NHA_GATEWAY
, /* be32 (IPv4) or in6_addr (IPv6) gw address */
57 NHA_ENCAP_TYPE
, /* u16; lwt encap type */
58 NHA_ENCAP
, /* lwt encap data */
60 /* NHA_OIF can be appended to dump request to return only
61 * nexthops using given device
63 NHA_GROUPS
, /* flag; only return nexthop groups in dump */
64 NHA_MASTER
, /* u32; only return nexthops with given master dev */
66 NHA_FDB
, /* flag; nexthop belongs to a bridge fdb */
67 /* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */
69 /* nested; resilient nexthop group attributes */
71 /* nested; nexthop bucket attributes */
74 /* u32; operation-specific flags */
77 /* nested; nexthop group stats */
80 /* u32; nexthop hardware stats enable */
83 /* u32; read-only; whether any driver collects HW stats */
89 #define NHA_MAX (__NHA_MAX - 1)
93 /* Pad attribute for 64-bit alignment. */
94 NHA_RES_GROUP_PAD
= NHA_RES_GROUP_UNSPEC
,
96 /* u16; number of nexthop buckets in a resilient nexthop group */
97 NHA_RES_GROUP_BUCKETS
,
98 /* clock_t as u32; nexthop bucket idle timer (per-group) */
99 NHA_RES_GROUP_IDLE_TIMER
,
100 /* clock_t as u32; nexthop unbalanced timer */
101 NHA_RES_GROUP_UNBALANCED_TIMER
,
102 /* clock_t as u64; nexthop unbalanced time */
103 NHA_RES_GROUP_UNBALANCED_TIME
,
108 #define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1)
111 NHA_RES_BUCKET_UNSPEC
,
112 /* Pad attribute for 64-bit alignment. */
113 NHA_RES_BUCKET_PAD
= NHA_RES_BUCKET_UNSPEC
,
115 /* u16; nexthop bucket index */
116 NHA_RES_BUCKET_INDEX
,
117 /* clock_t as u64; nexthop bucket idle time */
118 NHA_RES_BUCKET_IDLE_TIME
,
119 /* u32; nexthop id assigned to the nexthop bucket */
120 NHA_RES_BUCKET_NH_ID
,
122 __NHA_RES_BUCKET_MAX
,
125 #define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1)
128 NHA_GROUP_STATS_UNSPEC
,
130 /* nested; nexthop group entry stats */
131 NHA_GROUP_STATS_ENTRY
,
133 __NHA_GROUP_STATS_MAX
,
136 #define NHA_GROUP_STATS_MAX (__NHA_GROUP_STATS_MAX - 1)
139 NHA_GROUP_STATS_ENTRY_UNSPEC
,
141 /* u32; nexthop id of the nexthop group entry */
142 NHA_GROUP_STATS_ENTRY_ID
,
144 /* uint; number of packets forwarded via the nexthop group entry */
145 NHA_GROUP_STATS_ENTRY_PACKETS
,
147 /* uint; number of packets forwarded via the nexthop group entry in
150 NHA_GROUP_STATS_ENTRY_PACKETS_HW
,
152 __NHA_GROUP_STATS_ENTRY_MAX
,
155 #define NHA_GROUP_STATS_ENTRY_MAX (__NHA_GROUP_STATS_ENTRY_MAX - 1)