OpenBSD manual page server

Manual Page Search Parameters

RTREQUEST(9) Kernel Developer's Manual RTREQUEST(9)

rtrequestadd or remove entries from a routing table

#include <sys/types.h>
#include <net/route.h>

int
rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, struct rtentry **rtp, u_int rtableid);

struct rt_addrinfo {
	int	rti_addrs;
	struct	sockaddr *rti_info[RTAX_MAX];
	int	rti_flags;
	struct	ifaddr *rti_ifa;
	struct	rt_msghdr *rti_rtm;
	u_char	rti_mpls;
};

#define RTAX_DST	0	/* destination sockaddr present */
#define RTAX_GATEWAY	1	/* gateway sockaddr present */
#define RTAX_NETMASK	2	/* netmask sockaddr present */
#define RTAX_IFP	4	/* interface name sockaddr present */
#define RTAX_IFA	5	/* interface addr sockaddr present */
#define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
#define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest */
#define RTAX_SRC	8	/* source sockaddr present */
#define RTAX_SRCMASK	9	/* source netmask present */
#define RTAX_LABEL	10	/* route label present */
#define RTAX_MAX	11	/* size of array to allocate */

The () function is used to add or remove entries from a specific routing table. It takes the following arguments:

req
One of the following actions to perform:
Add an entry to a given routing table.
Remove an entry from a given routing table. In case of a cloning entry, all its children are deleted.
Add a cloned entry, based on the parent cloning entry pointed by rtp, to a given routing table.
info
Describes the routing entry to add or remove.
prio
Specifies the priority of the routing entry described by info. If it is 0 and the requested action is RTM_ADD then a default priority based on the priority of the associated interface is chosen.
rtp
Must point to the cloning entry if the action is RTM_RESOLVE. In all cases when no error is returned and it is not NULL, a pointer to the deleted or added entry is placed there. The caller must take care of releasing the returned reference by calling rtfree(9).
rtableid
The ID of the routing table to modify.

rtrequest() can be called during autoconf, from process context, or from interrupt context.

rtrequest() may fail with:

[EAFNOSUPPORT]
The routing table with ID of rtableid does not exist or it does not support the protocol specified in info.
[ESRCH]
No routing entry corresponding to info could be found.
[ESRCH]
Multipath routing entry with no gateway provided in info.
[ESRCH]
The entry could not be found in the routing table of ID rtableid. specified
[EINVAL]
The entry pointed by rtp is not valid or does not point to a cloning entry in the RTM_RESOLVE case.
[EEXIST]
Multipath routing entry conflicts with an existing one.
[EEXIST]
The entry could not be entered into the routing table.
[ENOMEM]
Space for MPLS protocol data could not be allocated.
[ENOBUFS]
Space for a new routing entry could not be allocated.
[ENETUNREACH]
An interface address corresponding to the routing entry described by info could not be found.

rtfree(9)

July 12, 2019 OpenBSD-current