]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netlink/route/nexthop.h
netlink: allow path weight manipulations for single-path routes.
[FreeBSD/FreeBSD.git] / sys / netlink / route / nexthop.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27
28 /*
29  * NEXTHOP-related (RTM_<NEW|DEL|GET>NEXTHOP) message header and attributes.
30  */
31
32 #ifndef _NETLINK_ROUTE_NEXTHOP_H_
33 #define _NETLINK_ROUTE_NEXTHOP_H_
34
35 /* Base header for all of the relevant messages */
36 struct nhmsg {
37         unsigned char   nh_family;      /* transport family */
38         unsigned char   nh_scope;       /* ignored on RX, filled by kernel */
39         unsigned char   nh_protocol;    /* Routing protocol that installed nh */
40         unsigned char   resvd;
41         unsigned int    nh_flags;       /* RTNH_F_* flags from route.h */
42 };
43
44 enum {
45         NHA_UNSPEC,
46         NHA_ID,         /* u32: nexthop userland index, auto-assigned if 0 */
47         NHA_GROUP,      /* binary: array of struct nexthop_grp */
48         NHA_GROUP_TYPE, /* u16: set to NEXTHOP_GRP_TYPE */
49         NHA_BLACKHOLE,  /* flag: nexthop used to blackhole packets */
50         NHA_OIF,        /* u32: transmit ifindex */
51         NHA_GATEWAY,    /* network: IPv4/IPv6 gateway addr */
52         NHA_ENCAP_TYPE, /* not supported */
53         NHA_ENCAP,      /* not supported */
54         NHA_GROUPS,     /* flag: match nexthop groups */
55         NHA_MASTER,     /* not supported */
56         NHA_FDB,        /* not supported */
57         NHA_RES_GROUP,  /* not supported */
58         NHA_RES_BUCKET, /* not supported */
59         __NHA_MAX,
60 };
61 #define NHA_MAX (__NHA_MAX - 1)
62
63 /*
64  * Attributes that can be used as filters:
65  * NHA_ID (nexhop or group), NHA_OIF, NHA_GROUPS,
66  */
67
68 /*
69  * NHA_GROUP: array of the following structures.
70  * If attribute is set, the only other valid attributes are
71  *  NHA_ID and NHA_GROUP_TYPE.
72  *  NHA_RES_GROUP and NHA_RES_BUCKET are not supported yet
73  */
74 struct nexthop_grp {
75         uint32_t        id;             /* nexhop userland index */
76         uint8_t         weight;         /* weight of this nexthop */
77         uint8_t         resvd1;
78         uint16_t        resvd2;
79 };
80
81 /* NHA_GROUP_TYPE: u16 */
82 enum {
83         NEXTHOP_GRP_TYPE_MPATH,         /* default nexthop group */
84         NEXTHOP_GRP_TYPE_RES,           /* resilient nexthop group */
85         __NEXTHOP_GRP_TYPE_MAX,
86 };
87 #define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)
88
89
90 /* NHA_RES_GROUP */
91 enum {
92         NHA_RES_GROUP_UNSPEC,
93         NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC,
94         NHA_RES_GROUP_BUCKETS,
95         NHA_RES_GROUP_IDLE_TIMER,
96         NHA_RES_GROUP_UNBALANCED_TIMER,
97         NHA_RES_GROUP_UNBALANCED_TIME,
98         __NHA_RES_GROUP_MAX,
99 };
100 #define NHA_RES_GROUP_MAX       (__NHA_RES_GROUP_MAX - 1)
101
102 #endif