[BACK]Return to rtable_add.9 CVS log [TXT][DIR] Up to [local] / src / share / man / man9

File: [local] / src / share / man / man9 / rtable_add.9 (download)

Revision 1.9, Fri Mar 26 22:41:06 2021 UTC (3 years, 2 months ago) by mvs
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, HEAD
Changes since 1.8: +2 -6 lines

Push kernel lock within rtable_add(9) and rework it to return 0 in the
case when requested table is already exists.

Except initialization time, route_output() and if_createrdomain() are the
only paths where we call rtable_add(9). We check requested table existence
by rtable_exists(9) and it's not the error condition if the table exists.
Otherwise we are trying to create requested table by rtable_add(9). Those
paths are kernel locked so concurrent thread can't create requested table
just after rtable_exists(9) check. Also rtable_add(9) has internal
rtable_exists(9) check and in this case the table existence assumed as
EEXIST error. This error path is never reached.

We are going to unlock PF_ROUTE sockets. This means route_output() will
not be serialized with if_createrdomain() and concurrent thread could
create requested table. Table existence check and creation should be
serialized and it makes sense to do this within rtable_add(9). This time
kernel lock is used for this so it pushed down to rtable_add(9). The
internal rtable_exists(9) check was modified and table existence is not
error now.

Since the external rtable_exists(9) check is useless it was removed from
if_createrdomain(). It still exists in route_output() path because the
logic is more complicated here.

ok mpi@

.\"     $OpenBSD: rtable_add.9,v 1.9 2021/03/26 22:41:06 mvs Exp $
.\"
.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
.\" All rights reserved.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 26 2021 $
.Dt RTABLE_ADD 9
.Os
.Sh NAME
.Nm rtable_add ,
.Nm rtable_exists ,
.Nm rtable_loindex ,
.Nm rtable_l2 ,
.Nm rtable_l2set
.Nd routing tables and routing domains interface
.Sh SYNOPSIS
.In net/rtable.h
.Ft int
.Fn rtable_add "unsigned int id"
.Ft int
.Fn rtable_exists "unsigned int id"
.Ft unsigned int
.Fn rtable_loindex "unsigned int id"
.Ft unsigned int
.Fn rtable_l2 "unsigned int id"
.Ft void
.Fn rtable_l2set "unsigned int id" "unsigned int rdomain"
.Sh DESCRIPTION
Routing tables contain layer 2 and 3 forwarding information.
Each address family in use will have its own routing table.
Routing domains are a way of logically segmenting a router among multiple
networks and may contain more than one routing table.
.Bl -tag -width Ds
.It Fn rtable_add "unsigned int id"
Add routing table with ID of
.Fa id
to routing domain
.Fa 0 .
.It Fn rtable_exists "unsigned int id"
Return
.Fa 1
if routing table with ID
.Fa id
exists,
.Fa 0
otherwise.
.It Fn rtable_loindex "unsigned int id"
Return the default
.Xr lo 4
interface index for the routing table with ID of
.Fa id .
.It Fn rtable_l2 "unsigned int id"
Get the routing domain of routing table with ID of
.Fa id .
.It Fn rtable_l2set "unsigned int id" "unsigned int rdomain"
Place routing table with ID of
.Fa id
under the routing domain with ID of
.Fa rdomain .
.El
.Sh CONTEXT
.Fn rtable_add ,
.Fn rtable_exists ,
.Fn rtable_loindex ,
.Fn rtable_l2 ,
and
.Fn task_l2set
can be called during autoconf, from process context, or from interrupt context.
.Sh RETURN VALUES
.Fn rtable_add
may fail with:
.Pp
.Bl -tag -width Er -compact
.It Bq Er ENOMEM
Memory could not be allocated to extend the list of routing domains.
.El
.Sh SEE ALSO
.Xr lo 4 ,
.Xr route 4 ,
.Xr route 8