From owner-freebsd-net@FreeBSD.ORG Tue May 22 15:00:14 2007 Return-Path: X-Original-To: net@FreeBSD.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3130D16A469 for ; Tue, 22 May 2007 15:00:14 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.130]) by mx1.freebsd.org (Postfix) with ESMTP id AB15D13C45A for ; Tue, 22 May 2007 15:00:13 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.1/8.14.1) with ESMTP id l4MEMCx0029930 for ; Tue, 22 May 2007 18:22:12 +0400 (MSD) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.1/8.14.1/Submit) id l4MEMCmf029929 for net@FreeBSD.org; Tue, 22 May 2007 18:22:12 +0400 (MSD) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 22 May 2007 18:22:12 +0400 From: Gleb Smirnoff To: net@FreeBSD.org Message-ID: <20070522142212.GZ89017@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.15 (2007-04-06) Cc: Subject: walking (and cleaning) the routing table on mask change? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2007 15:00:14 -0000 Hello, colleagues, what do you think about cleaning the routing table on mask change? I think it should be done. Currently we are cleaning the routing table only on SIOCDIFADDR operation, because it removes prefix from an interface. However, SIOCAIFADDR also may delete (actually replace) a prefix on interface, in the case of mask change. For example: root@behemoth:~:|>ifconfig em0 10.0.0.195/24 root@behemoth:~:|>route add 10.0.1.0/24 10.0.0.1 add net 10.0.1.0: gateway 10.0.0.1 root@behemoth:~:|>netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 10.0.0.0/24 link#2 UC 0 0 em0 10.0.0.1 link#2 UHLW 2 0 em0 10.0.1.0/24 10.0.0.1 UGS 0 0 em0 127.0.0.1 127.0.0.1 UH 0 26 lo0 root@behemoth:~:|>ifconfig em0 netmask 255.255.255.128 root@behemoth:~:|>netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 10.0.0.128/25 link#2 UC 0 0 em0 10.0.1.0/24 10.0.0.1 UGS 0 0 em0 ^^^^^^^^^^^^^^^^^^ --- shouldn't it be deleted? 127.0.0.1 127.0.0.1 UH 0 26 lo0 root@behemoth:~:|> 10.0.0.1 isn't reachable now. Currently, we have a workaroung in rt_check() (rev. 1.117) that prevents us from panicing. However, the invalid route still remains in the table. I suggest to make the following on the mask change path: rt_tables[AF_INET]->rnh_walktree(xxx_maskchange), where the xxx_maskchange() deletes all routes, which used to be reachable via the old mask and are no longer reachable. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE