From: Kristof Provost Date: Mon, 22 Aug 2022 20:28:17 +0200 Message-ID: In-Reply-To: References: <20220812134154.16729-3-kprovost@...2661...> <202208201401.27KE12Cm014083@...2054...> <21B552DE-38FE-41F0-8FC7-606EA4C06093@...1376...> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_MailMate_88FEFF15-033E-412E-BF3B-C076110C0FEB_=" Subject: Re: [Openvpn-devel] route/iroute handling on FreeBSD List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gert Doering Cc: openvpn-devel@lists.sourceforge.net --=_MailMate_88FEFF15-033E-412E-BF3B-C076110C0FEB_= Content-Type: text/plain On 22 Aug 2022, at 20:16, Gert Doering wrote: > On Mon, Aug 22, 2022 at 02:55:09PM +0200, Kristof Provost wrote: >>> Now, back to FreeBSD. >>> >>> - our code does not try to set metrics on FreeBSD >>> - my reading of route(8) does not show me anything in that direction >>> (metric, preference, administrative distance, ...) >>> - I do not understand FreeBSD internals well enough to know whether >>> it can be done at all, or not. >>> >> It???s rather poorly (i.e. not) documented, but it is possible to set a >> route metric. It???s called a ???weight???, and not actually mentioned >> in the man page. Or shown in netstat output. >> >> But: >> >> $ sudo route add 172.16.2.0/24 10.0.2.1 >> add net 172.16.2.0: gateway 10.0.2.1 >> $ sudo route add 172.16.2.0/24 -weight 2 10.0.2.254 >> add net 172.16.2.0: gateway 10.0.2.254 > > Oh, this is interesting, and good to know. > > What is the default weight? "1"? Yes, the default is RT_DEFAULT_WEIGHT: /usr/include/net/route.h 105:#define RT_DEFAULT_WEIGHT 1 Best regards, Kristof --=_MailMate_88FEFF15-033E-412E-BF3B-C076110C0FEB_= Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

On 22 Aug 2022, at 20:16, Gert Doering wrote:

On Mon, Aug 22, 2022 at 02:55:09PM +0200,= Kristof Provost wrote:

Now, back to Fre= eBSD.

- our code does not try to set metrics on FreeBSD
- my reading of route(8) does not show me anything in that direction
(metric, preference, administrative distance, ...)
- I do not understand FreeBSD internals well enough to know whether
it can be done at all, or not.

It???s rather poorly (i.e. not) documented, bu= t it is possible to set a
route metric. It???s called a ???weight???, and not actually mentioned
in the man page. Or shown in netstat output.

But:

$ sudo route add 172.16.2.0/24 10.0.2.1
add net 172.16.2.0: gateway 10.0.2.1
$ sudo route add 172.16.2.0/24 -weight 2 10.0.2.254
add net 172.16.2.0: gateway 10.0.2.254

Oh, this is interesting, and good to know.

What is the default weight? "1"?

Yes, the default is RT_DEFAULT_WEIGHT:

/usr/include/net/route.h
105:#define	RT_DEFAULT_WEIGHT	1

Best regards,
Kristof

--=_MailMate_88FEFF15-033E-412E-BF3B-C076110C0FEB_=--