Re: rdomain.4: on removing rtables

2020-09-22 Thread Remi Locherer
On Tue, Sep 22, 2020 at 10:03:29PM +0200, Klemens Nanni wrote:
> We have never been able to remove an rtable;  until claudio moved them
> explicitly with rtable_l2set() in  if_loop.c:loop_clone_destroy(), i.e.
> 
>   revision 1.90
>   date: 2020/01/08 09:09:10;  author: claudio;  state: Exp;  lines: +6 -2;
>   In loop_clone_destroy() reset the rdomain with rtable_l2set() after
>   the if_detach() call. In if_detach() various route messages are 
> generated
>   and during that time the rtable_l2() mapping needs to stay.
>   OK kn@
> 
> it would still exist but not be assigned to any valid rdomain. Back then this
> could be obvserved with `route -T1 ...' still "working" after having
> destroyed lo1.
> 
> Reverting claudio's commit on -CURRENT, that is with `netstat -R' now
> available, confirms this:
> 
>   # sysctl kern.version
>   kern.version=OpenBSD 6.8-beta (GENERIC) #0: Tue Sep 22 21:24:48 CEST 
> 2020
>   kn@eru:/sys/arch/amd64/compile/GENERIC
>   # ifconfig lo1 rdomain 1
>   # netstat -R
>   Rdomain 0
> Interfaces: lo0 vio0
> Routing table: 0
> 
>   Rdomain 1
> Interface: lo1
> Routing table: 1
> 
>   # ifconfig lo1 destroy
>   # netstat -R
>   Rdomain 0
> Interfaces: lo0 vio0
> Routing table: 0
> 
>   # route -T1 show
>   Routing tables
>   # echo $?
>   0
> 
> 
> This is not documented anywhere and I'd certainly not expect it after
> reading rtable(4).  The manual says we can delete rdomains and is quiet
> about deleting rtables, which can imply that rtables cannot be deleted
> but might also imply that rtables are deleted automatically when
> rdomains are deleted.
> 
> Either way, explicit is better here, I think.
> 
> Feedback? OK?

The comment at the beginning of src/sys/net/rtable.c is the only
place I'm aware of that documents that routing tables can not be
deleted.

I think it makes sense to document this in rtable(4).

ok remi@

> 
> 
> Index: rdomain.4
> ===
> RCS file: /cvs/src/share/man/man4/rdomain.4,v
> retrieving revision 1.14
> diff -u -p -r1.14 rdomain.4
> --- rdomain.4 30 Jul 2020 21:44:34 -  1.14
> +++ rdomain.4 22 Sep 2020 19:58:57 -
> @@ -146,3 +146,5 @@ and IPv6 support first appeared in
>  .Sh CAVEATS
>  No tool is available to assign more than one rtable to an rdomain
>  other than to the default one (0).
> +An rtable cannot be deleted.
> +Deleting an rdomain will move its rtable into the default rdomain.
> 



rdomain.4: on removing rtables

2020-09-22 Thread Klemens Nanni
We have never been able to remove an rtable;  until claudio moved them
explicitly with rtable_l2set() in  if_loop.c:loop_clone_destroy(), i.e.

revision 1.90
date: 2020/01/08 09:09:10;  author: claudio;  state: Exp;  lines: +6 -2;
In loop_clone_destroy() reset the rdomain with rtable_l2set() after
the if_detach() call. In if_detach() various route messages are 
generated
and during that time the rtable_l2() mapping needs to stay.
OK kn@

it would still exist but not be assigned to any valid rdomain. Back then this
could be obvserved with `route -T1 ...' still "working" after having
destroyed lo1.

Reverting claudio's commit on -CURRENT, that is with `netstat -R' now
available, confirms this:

# sysctl kern.version
kern.version=OpenBSD 6.8-beta (GENERIC) #0: Tue Sep 22 21:24:48 CEST 
2020
kn@eru:/sys/arch/amd64/compile/GENERIC
# ifconfig lo1 rdomain 1
# netstat -R
Rdomain 0
  Interfaces: lo0 vio0
  Routing table: 0

Rdomain 1
  Interface: lo1
  Routing table: 1

# ifconfig lo1 destroy
# netstat -R
Rdomain 0
  Interfaces: lo0 vio0
  Routing table: 0

# route -T1 show
Routing tables
# echo $?
0


This is not documented anywhere and I'd certainly not expect it after
reading rtable(4).  The manual says we can delete rdomains and is quiet
about deleting rtables, which can imply that rtables cannot be deleted
but might also imply that rtables are deleted automatically when
rdomains are deleted.

Either way, explicit is better here, I think.

Feedback? OK?


Index: rdomain.4
===
RCS file: /cvs/src/share/man/man4/rdomain.4,v
retrieving revision 1.14
diff -u -p -r1.14 rdomain.4
--- rdomain.4   30 Jul 2020 21:44:34 -  1.14
+++ rdomain.4   22 Sep 2020 19:58:57 -
@@ -146,3 +146,5 @@ and IPv6 support first appeared in
 .Sh CAVEATS
 No tool is available to assign more than one rtable to an rdomain
 other than to the default one (0).
+An rtable cannot be deleted.
+Deleting an rdomain will move its rtable into the default rdomain.