xref: /linux-6.15/include/uapi/linux/nexthop.h (revision 746c19a5)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_NEXTHOP_H
3 #define _UAPI_LINUX_NEXTHOP_H
4 
5 #include <linux/types.h>
6 
7 struct nhmsg {
8 	unsigned char	nh_family;
9 	unsigned char	nh_scope;     /* return only */
10 	unsigned char	nh_protocol;  /* Routing protocol that installed nh */
11 	unsigned char	resvd;
12 	unsigned int	nh_flags;     /* RTNH_F flags */
13 };
14 
15 /* entry in a nexthop group */
16 struct nexthop_grp {
17 	__u32	id;	  /* nexthop id - must exist */
18 	__u8	weight;   /* weight of this nexthop */
19 	__u8	resvd1;
20 	__u16	resvd2;
21 };
22 
23 enum {
24 	NEXTHOP_GRP_TYPE_MPATH,  /* hash-threshold nexthop group
25 				  * default type if not specified
26 				  */
27 	NEXTHOP_GRP_TYPE_RES,    /* resilient nexthop group */
28 	__NEXTHOP_GRP_TYPE_MAX,
29 };
30 
31 #define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)
32 
33 #define NHA_OP_FLAG_DUMP_STATS		BIT(0)
34 
35 enum {
36 	NHA_UNSPEC,
37 	NHA_ID,		/* u32; id for nexthop. id == 0 means auto-assign */
38 
39 	NHA_GROUP,	/* array of nexthop_grp */
40 	NHA_GROUP_TYPE,	/* u16 one of NEXTHOP_GRP_TYPE */
41 	/* if NHA_GROUP attribute is added, no other attributes can be set */
42 
43 	NHA_BLACKHOLE,	/* flag; nexthop used to blackhole packets */
44 	/* if NHA_BLACKHOLE is added, OIF, GATEWAY, ENCAP can not be set */
45 
46 	NHA_OIF,	/* u32; nexthop device */
47 	NHA_GATEWAY,	/* be32 (IPv4) or in6_addr (IPv6) gw address */
48 	NHA_ENCAP_TYPE, /* u16; lwt encap type */
49 	NHA_ENCAP,	/* lwt encap data */
50 
51 	/* NHA_OIF can be appended to dump request to return only
52 	 * nexthops using given device
53 	 */
54 	NHA_GROUPS,	/* flag; only return nexthop groups in dump */
55 	NHA_MASTER,	/* u32;  only return nexthops with given master dev */
56 
57 	NHA_FDB,	/* flag; nexthop belongs to a bridge fdb */
58 	/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */
59 
60 	/* nested; resilient nexthop group attributes */
61 	NHA_RES_GROUP,
62 	/* nested; nexthop bucket attributes */
63 	NHA_RES_BUCKET,
64 
65 	/* u32; operation-specific flags */
66 	NHA_OP_FLAGS,
67 
68 	/* nested; nexthop group stats */
69 	NHA_GROUP_STATS,
70 
71 	/* u32; nexthop hardware stats enable */
72 	NHA_HW_STATS_ENABLE,
73 
74 	__NHA_MAX,
75 };
76 
77 #define NHA_MAX	(__NHA_MAX - 1)
78 
79 enum {
80 	NHA_RES_GROUP_UNSPEC,
81 	/* Pad attribute for 64-bit alignment. */
82 	NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC,
83 
84 	/* u16; number of nexthop buckets in a resilient nexthop group */
85 	NHA_RES_GROUP_BUCKETS,
86 	/* clock_t as u32; nexthop bucket idle timer (per-group) */
87 	NHA_RES_GROUP_IDLE_TIMER,
88 	/* clock_t as u32; nexthop unbalanced timer */
89 	NHA_RES_GROUP_UNBALANCED_TIMER,
90 	/* clock_t as u64; nexthop unbalanced time */
91 	NHA_RES_GROUP_UNBALANCED_TIME,
92 
93 	__NHA_RES_GROUP_MAX,
94 };
95 
96 #define NHA_RES_GROUP_MAX	(__NHA_RES_GROUP_MAX - 1)
97 
98 enum {
99 	NHA_RES_BUCKET_UNSPEC,
100 	/* Pad attribute for 64-bit alignment. */
101 	NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC,
102 
103 	/* u16; nexthop bucket index */
104 	NHA_RES_BUCKET_INDEX,
105 	/* clock_t as u64; nexthop bucket idle time */
106 	NHA_RES_BUCKET_IDLE_TIME,
107 	/* u32; nexthop id assigned to the nexthop bucket */
108 	NHA_RES_BUCKET_NH_ID,
109 
110 	__NHA_RES_BUCKET_MAX,
111 };
112 
113 #define NHA_RES_BUCKET_MAX	(__NHA_RES_BUCKET_MAX - 1)
114 
115 enum {
116 	NHA_GROUP_STATS_UNSPEC,
117 
118 	/* nested; nexthop group entry stats */
119 	NHA_GROUP_STATS_ENTRY,
120 
121 	__NHA_GROUP_STATS_MAX,
122 };
123 
124 #define NHA_GROUP_STATS_MAX	(__NHA_GROUP_STATS_MAX - 1)
125 
126 enum {
127 	NHA_GROUP_STATS_ENTRY_UNSPEC,
128 
129 	/* u32; nexthop id of the nexthop group entry */
130 	NHA_GROUP_STATS_ENTRY_ID,
131 
132 	/* uint; number of packets forwarded via the nexthop group entry */
133 	NHA_GROUP_STATS_ENTRY_PACKETS,
134 
135 	__NHA_GROUP_STATS_ENTRY_MAX,
136 };
137 
138 #define NHA_GROUP_STATS_ENTRY_MAX	(__NHA_GROUP_STATS_ENTRY_MAX - 1)
139 
140 #endif
141