On Wed, Jan 08, 2020 at 09:27:27AM +0100, Klemens Nanni wrote:
> On Wed, Jan 08, 2020 at 08:45:50AM +0100, Claudio Jeker wrote:
> > rt_ifa_add() and rt_ifa_del() have a major confusion when it comes to
> > rtlabelid (as in labels on a route) vs rtableid (as in routing table id).
> > Because of this 'ifconfig <if> rtlabel XYZ' fails to add route labels to
> > the routing table.
> > The following diff fixes this issue.
> It looks more complicated: Changes to the route label get through, but
> won't show up in route(8) unless the interface is changed, for example
> it's address.
>
> > To test:
> > ifconfig tap1001 rtlabel TEST
> > ifconfig tap1001 192.0.2.6/24
> > route -n get 192.0.2.1
>
> # ifconfig tap1001 rtlabel TEST
> # ifconfig tap1001 192.0.2.6/24
> # route -n get 192.0.2.1
> route to: 192.0.2.1
> destination: 192.0.2.0
> mask: 255.255.255.0
> interface: tap1001
> if address: 192.0.2.6
> priority: 4 (connected)
> flags: <DONE,CLONING,CONNECTED>
> label: TEST
> use mtu expire
> 0 0 0
> sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA,LABEL>
>
> The label got added for me. Change the label and it won't be seen:
>
> # ifconfig tap1001 rtlabel FOO
> # route -n get 192.0.2.1 | grep label
> label: FOO
>
> Change the address and the new label appears:
>
> # ifconfig tap1001 192.1.2.6/24
> # route -n get 192.1.2.1 | grep label
> label: FOO
>
> Same with removal:
>
> # ifconfig tap1001 -rtlabel
> # route -n get 192.1.2.1 | grep label
> label: FOO
> # ifconfig tap1001 192.2.2.6/24
> # route -n get 192.2.2.1 | grep label ; echo $?
> 0
Yes, the label is only applied to routes added after the rtlabel was added
to the interface. Changing this behaviour is outside of the scope of this
fix. Since nobody noticed that ifconfig rtlabel was totally broken for
some time I doubt this is critical right now.
Also ifconfig(8) is documenting this correctly:
rtlabel route-label
(inet) Attach route-label to new network routes of the
specified interface. Route labels can be used to
implement policy routing; see route(4), route(8), and
pf.conf(5).
It does mention it only works for new network routes.
--
:wq Claudio