xref: /openbsd-src/share/man/man9/rtrequest.9 (revision d05e1b8a15c614fded2def9e0f39b9593d9c631d)
1.\"     $OpenBSD: rtrequest.9,v 1.3 2019/07/12 16:57:45 mpi Exp $
2.\"
3.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
4.\" All rights reserved.
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: July 12 2019 $
19.Dt RTREQUEST 9
20.Os
21.Sh NAME
22.Nm rtrequest
23.Nd add or remove entries from a routing table
24.Sh SYNOPSIS
25.In sys/types.h
26.In net/route.h
27.Ft int
28.Fn rtrequest "int req" "struct rt_addrinfo *info" "u_int8_t prio" \
29"struct rtentry **rtp" "u_int rtableid"
30.Bd -literal
31struct rt_addrinfo {
32	int	rti_addrs;
33	struct	sockaddr *rti_info[RTAX_MAX];
34	int	rti_flags;
35	struct	ifaddr *rti_ifa;
36	struct	rt_msghdr *rti_rtm;
37	u_char	rti_mpls;
38};
39
40#define RTAX_DST	0	/* destination sockaddr present */
41#define RTAX_GATEWAY	1	/* gateway sockaddr present */
42#define RTAX_NETMASK	2	/* netmask sockaddr present */
43#define RTAX_IFP	4	/* interface name sockaddr present */
44#define RTAX_IFA	5	/* interface addr sockaddr present */
45#define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
46#define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest */
47#define RTAX_SRC	8	/* source sockaddr present */
48#define RTAX_SRCMASK	9	/* source netmask present */
49#define RTAX_LABEL	10	/* route label present */
50#define RTAX_MAX	11	/* size of array to allocate */
51.Ed
52.Sh DESCRIPTION
53The
54.Fn rtrequest
55function is used to add or remove entries from a specific routing table.
56It takes the following arguments:
57.Bl -tag -width rtableid
58.It Fa req
59One of the following actions to perform:
60.Bl -tag -width RTM_RESOLVE -offset indent
61.It Dv RTM_ADD
62Add an entry to a given routing table.
63.It Dv RTM_DELETE
64Remove an entry from a given routing table.
65In case of a cloning entry, all its children are deleted.
66.It Dv RTM_RESOLVE
67Add a cloned entry, based on the parent cloning entry pointed by
68.Fa rtp ,
69to a given routing table.
70.El
71.It Fa info
72Describes the routing entry to add or remove.
73.It Fa prio
74Specifies the priority of the routing entry described by
75.Fa info .
76If it is
77.Dv 0
78and the requested action is
79.Dv RTM_ADD
80then a default priority based on the priority of the associated
81interface is chosen.
82.It Fa rtp
83Must point to the cloning entry if the action is
84.Dv RTM_RESOLVE .
85In all cases when no error is returned and it is not
86.Dv NULL ,
87a pointer to the deleted or added entry is placed there.
88The caller must take care of releasing the returned reference by
89calling
90.Xr rtfree 9 .
91.It Fa rtableid
92The ID of the routing table to modify.
93.El
94.Sh CONTEXT
95.Fn rtrequest
96can be called during autoconf, from process context, or from interrupt context.
97.Sh RETURN VALUES
98.Fn rtrequest
99may fail with:
100.Pp
101.Bl -tag -width Er -compact
102.It Bq Er EAFNOSUPPORT
103The routing table with ID of
104.Fa rtableid
105does not exist or it does not support the protocol specified in
106.Fa info .
107.It Bq Er ESRCH
108No routing entry corresponding to
109.Fa info
110could be found.
111.It Bq Er ESRCH
112Multipath routing entry with no gateway provided in
113.Fa info .
114.It Bq Er ESRCH
115The entry could not be found in the routing table of ID
116.Fa rtableid .
117specified
118.It Bq Er EINVAL
119The entry pointed by
120.Fa rtp
121is not valid or does not point to a cloning entry in the
122.Dv RTM_RESOLVE
123case.
124.It Bq Er EEXIST
125Multipath routing entry conflicts with an existing one.
126.It Bq Er EEXIST
127The entry could not be entered into the routing table.
128.It Bq Er ENOMEM
129Space for MPLS protocol data could not be allocated.
130.It Bq Er ENOBUFS
131Space for a new routing entry could not be allocated.
132.It Bq Er ENETUNREACH
133An interface address corresponding to the routing entry described by
134.Fa info
135could not be found.
136.El
137.Sh SEE ALSO
138.Xr rtfree 9
139