From nobody Wed Aug 28 16:33:23 2024 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Wv92g71ZZz52YSJ for ; Wed, 28 Aug 2024 16:33:31 +0000 (UTC) (envelope-from yann.masson@thehomecave.fr) Received: from smtp-190e.mail.infomaniak.ch (smtp-190e.mail.infomaniak.ch [IPv6:2001:1600:4:17::190e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "relay.mail.infomaniak.ch", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wv92g4n5vz4ZdM for ; Wed, 28 Aug 2024 16:33:31 +0000 (UTC) (envelope-from yann.masson@thehomecave.fr) Authentication-Results: mx1.freebsd.org; none Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Wv92W74VYzj7y; Wed, 28 Aug 2024 18:33:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thehomecave.fr; s=20230803; t=1724862803; bh=/+e9/chtkfLBwI/Y1pyymBFzH2t45MiajepsoLvoy6o=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=kJ9J+TNU1+pZqkRBNZGJYcaeo6TZuC+mxvZkqZxoEl2gwUgtHoYWgmdU65gXWKgyV mQ+pBHa4W5vIw7KlOM2rY/pltWQRkltZYPu/3EKGX3GKJXMGc4YC9yfn6qzDnytZne vt7MFrC4+AIt+EsENb0z9HIvffkByyP1yPl0OuwI7Q95IMW817S+aaMeKtUDK9PRru u3aWuHaT4WeaIALYk7MJ7l7SXuQuOZQ7csmdJ+XidJV6gotLeVJuOjbsYOCALgsqJy 0SC9jXzKjxniIfI9bPv2iBzlfABF7Ii2sH6rd+PzGyLVhVSrkKcdxNwQDTKk/0j+N3 mFRp7dOxyce3g== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Wv92W4Qyzz5N1; Wed, 28 Aug 2024 18:33:23 +0200 (CEST) Content-Type: multipart/alternative; boundary="------------0qB0u0yPc0p76cb4o3xmB0uH" Message-ID: <203f3066-af9e-40f9-bef3-89dd7b636dc7@thehomecave.fr> Date: Wed, 28 Aug 2024 18:33:23 +0200 List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: wait link up before route configuration To: Freddie Cash Cc: freebsd-net@freebsd.org References: Content-Language: en-US From: "yann.masson@thehomecave.fr" In-Reply-To: X-Infomaniak-Routing: alpha X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:29222, ipnet:2001:1600::/32, country:CH] X-Rspamd-Queue-Id: 4Wv92g4n5vz4ZdM This is a multi-part message in MIME format. --------------0qB0u0yPc0p76cb4o3xmB0uH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit /etc/rc.d/netwait dependencies are # PROVIDE: netwait # REQUIRE: devd ipfw pf routing [truncated] rcorder -p /etc/rc.d/* /etc/rc.d/netif /etc/rc.d/routing /etc/rc.d/netwait I've tested netwait. It doesn't work If i configure routing like that: # /etc/rc.conf.d/routing route_defaultgw="-host 203.0.113.1 -link -interface lagg0" route_default="-net 0.0.0.0/0 -interface lagg0 203.0.113.1" static_routes="defaultgw default" It works, but the routing table went from # netstat -rn Routing tables Internet: Destination Gateway Flags Netif Expire default 203.0.113.1 UGS lagg0 198.51.100.1 link#10 UH lo0 203.0.113.1 link#10 UHS lagg0 127.0.0.1 link#3 UHS lo0 to Internet: Destination Gateway Flags Netif Expire default link#10 US lagg0 198.51.100.1 link#10 UH lo0 203.0.113.1 link#10 UHS lagg0 127.0.0.1 link#3 UHS lo0 I don't know if it's good or not. On 8/28/24 17:40, Freddie Cash wrote: > On Wed, Aug 28, 2024 at 1:21 AM yann.masson@thehomecave.fr > wrote: > > After configuring interfaces and routes, and triggering a 'service > netif restart && service routing restart' is there a way to wait > for the 'carrier up' of the interface before route > reconfiguration? My use case is a server with 2 Mellanox and a > Lagg. The 2 mce interfaces are UP in milliseconds but the lagg > interface takes a few seconds to be UP, and the routing service > says 'Network unreachable'. The subnet is a /32 and the gateway > need a static route like: # /etc/rc.conf.d/netif > cloned_interfaces="lagg0" ifconfig_mce0="up" ifconfig_mce1="up" > ifconfig_lagg0="laggproto lacp laggport mce0 laggport mce1 > 198.51.100.1 netmask 255.255.255.255 mtu 1500" # > /etc/rc.conf.d/routing route_defaultgw="-host 203.0.113.1 -link > -interface lagg0" defaultrouter="203.0.113.1" > static_routes="defaultgw" If I run 'service netif restart && sleep > 5 && service routing restart', everything is ok. I didn't find any > options for that, and was thinking about a patch in the routing > script. Thanks > > Read through the comments in /etc/rc.d/netwait as that should do what > you're looking for (wait until the interface is active or wait until > you get a ping response from an IP before continuing with network > configuration). > > -- > Freddie Cash > fjwcash@gmail.com --------------0qB0u0yPc0p76cb4o3xmB0uH Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

/etc/rc.d/netwait dependencies are
# PROVIDE: netwait
# REQUIRE: devd ipfw pf routing

[truncated] rcorder -p /etc/rc.d/*
/etc/rc.d/netif
/etc/rc.d/routing
/etc/rc.d/netwait

I've tested netwait. It doesn't work


If i configure routing like that:
# /etc/rc.conf.d/routing route_defaultgw="-host 203.0.113.1 -link -interface lagg0" route_default="-net 0.0.0.0/0 -interface lagg0 203.0.113.1" static_routes="defaultgw default"

It works, but the routing table went from
# netstat -rn Routing tables Internet: Destination Gateway Flags Netif Expire default 203.0.113.1 UGS lagg0 198.51.100.1 link#10 UH lo0 203.0.113.1 link#10 UHS lagg0 127.0.0.1 link#3 UHS lo0

to
Internet: Destination Gateway Flags Netif Expire default link#10 US lagg0 198.51.100.1 link#10 UH lo0 203.0.113.1 link#10 UHS lagg0 127.0.0.1 link#3 UHS lo0

I don't know if it's good or not.



On 8/28/24 17:40, Freddie Cash wrote:
On Wed, Aug 28, 2024 at 1:21 AM yann.masson@thehomecave.fr <yann.masson@thehomecave.fr> wrote:

After configuring interfaces and routes, and triggering a 'service netif restart && service routing restart' is there a way to wait for the 'carrier up' of the interface before route reconfiguration? My use case is a server with 2 Mellanox and a Lagg. The 2 mce interfaces are UP in milliseconds but the lagg interface takes a few seconds to be UP, and the routing service says 'Network unreachable'. The subnet is a /32 and the gateway need a static route like: # /etc/rc.conf.d/netif cloned_interfaces="lagg0" ifconfig_mce0="up" ifconfig_mce1="up" ifconfig_lagg0="laggproto lacp laggport mce0 laggport mce1 198.51.100.1 netmask 255.255.255.255 mtu 1500" # /etc/rc.conf.d/routing route_defaultgw="-host 203.0.113.1 -link -interface lagg0" defaultrouter="203.0.113.1" static_routes="defaultgw" If I run 'service netif restart && sleep 5 && service routing restart', everything is ok. I didn't find any options for that, and was thinking about a patch in the routing script. Thanks

Read through the comments in /etc/rc.d/netwait as that should do what you're looking for (wait until the interface is active or wait until you get a ping response from an IP before continuing with network configuration).

--
Freddie Cash
fjwcash@gmail.com
--------------0qB0u0yPc0p76cb4o3xmB0uH--