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>

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:

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.
Describes the routing entry to add or remove.
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.
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).
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:

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


July 12, 2019 OpenBSD-current