[PATCH] IPv6 rtadvd: little optimization

From: Maryse LEVAVASSEUR <maryse.levavasseur_at_netasq.com>
Date: Thu, 24 May 2012 14:24:08 +0200
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)
_at__at_ -472,11 +472,18 _at__at_ 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;
_at__at_ -495,15 +502,7 _at__at_ 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,
===
Received on Thu May 24 2012 - 10:24:15 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:27 UTC