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 __NHA_MAX, 72 }; 73 74 #define NHA_MAX (__NHA_MAX - 1) 75 76 enum { 77 NHA_RES_GROUP_UNSPEC, 78 /* Pad attribute for 64-bit alignment. */ 79 NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC, 80 81 /* u16; number of nexthop buckets in a resilient nexthop group */ 82 NHA_RES_GROUP_BUCKETS, 83 /* clock_t as u32; nexthop bucket idle timer (per-group) */ 84 NHA_RES_GROUP_IDLE_TIMER, 85 /* clock_t as u32; nexthop unbalanced timer */ 86 NHA_RES_GROUP_UNBALANCED_TIMER, 87 /* clock_t as u64; nexthop unbalanced time */ 88 NHA_RES_GROUP_UNBALANCED_TIME, 89 90 __NHA_RES_GROUP_MAX, 91 }; 92 93 #define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1) 94 95 enum { 96 NHA_RES_BUCKET_UNSPEC, 97 /* Pad attribute for 64-bit alignment. */ 98 NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC, 99 100 /* u16; nexthop bucket index */ 101 NHA_RES_BUCKET_INDEX, 102 /* clock_t as u64; nexthop bucket idle time */ 103 NHA_RES_BUCKET_IDLE_TIME, 104 /* u32; nexthop id assigned to the nexthop bucket */ 105 NHA_RES_BUCKET_NH_ID, 106 107 __NHA_RES_BUCKET_MAX, 108 }; 109 110 #define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1) 111 112 enum { 113 NHA_GROUP_STATS_UNSPEC, 114 115 /* nested; nexthop group entry stats */ 116 NHA_GROUP_STATS_ENTRY, 117 118 __NHA_GROUP_STATS_MAX, 119 }; 120 121 #define NHA_GROUP_STATS_MAX (__NHA_GROUP_STATS_MAX - 1) 122 123 enum { 124 NHA_GROUP_STATS_ENTRY_UNSPEC, 125 126 /* u32; nexthop id of the nexthop group entry */ 127 NHA_GROUP_STATS_ENTRY_ID, 128 129 /* uint; number of packets forwarded via the nexthop group entry */ 130 NHA_GROUP_STATS_ENTRY_PACKETS, 131 132 __NHA_GROUP_STATS_ENTRY_MAX, 133 }; 134 135 #define NHA_GROUP_STATS_ENTRY_MAX (__NHA_GROUP_STATS_ENTRY_MAX - 1) 136 137 #endif 138