From owner-freebsd-net@FreeBSD.ORG Thu May 24 12:24:15 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 435FA106564A; Thu, 24 May 2012 12:24:15 +0000 (UTC) (envelope-from maryse.levavasseur@netasq.com) Received: from work.netasq.com (gwlille.netasq.com [91.212.116.1]) by mx1.freebsd.org (Postfix) with ESMTP id 09B9F8FC16; Thu, 24 May 2012 12:24:14 +0000 (UTC) Received: from diablotine.netasq.com (unknown [10.2.200.254]) by work.netasq.com (Postfix) with ESMTPSA id E1A5427044A0; Thu, 24 May 2012 14:26:16 +0200 (CEST) Message-ID: <4FBE2868.8010602@netasq.com> Date: Thu, 24 May 2012 14:24:08 +0200 From: Maryse LEVAVASSEUR User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120503 Thunderbird/12.0.1 MIME-Version: 1.0 To: freebsd-current@freebsd.org, freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: [PATCH] IPv6 rtadvd: little optimization 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: Thu, 24 May 2012 12:24:15 -0000 Hi, Since upgrading to FreeBSD 8.3, I noticed that after rtadvd starts, it does not respond to router solicitations during a quite long time. I have made a patch which speeds up rtadvd's start by making fewer calls to if_indextoname. Moreover, it will react properly in case if_indextoname fails. Would anyone object to this patch ? === Index: if.c =================================================================== --- if.c (revision 235474) +++ if.c (working copy) @@ -472,11 +472,18 @@ update_ifinfo(struct ifilist_head_t *ifi_head, int ifindex != ifm->ifm_index) continue; + /* ifname */ + if (if_indextoname(ifm->ifm_index, ifname) == NULL) { + syslog(LOG_WARNING, + "<%s> ifname not found (idx=%d)", + __func__, ifm->ifm_index); + continue; + } + /* lookup an entry with the same ifindex */ TAILQ_FOREACH(ifi, ifi_head, ifi_next) { if (ifm->ifm_index == ifi->ifi_ifindex) break; - if_indextoname(ifm->ifm_index, ifname); if (strncmp(ifname, ifi->ifi_ifname, sizeof(ifname)) == 0) break; @@ -495,15 +502,7 @@ update_ifinfo(struct ifilist_head_t *ifi_head, int ifi->ifi_ifindex = ifm->ifm_index; /* ifname */ - if_indextoname(ifm->ifm_index, ifi->ifi_ifname); - if (ifi->ifi_ifname == NULL) { - syslog(LOG_WARNING, - "<%s> ifname not found (idx=%d)", - __func__, ifm->ifm_index); - if (ifi_new) - free(ifi); - continue; - } + strncpy(ifi->ifi_ifname, ifname, IFNAMSIZ); if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, ===