aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/rtadvd/if.c
diff options
context:
space:
mode:
authorFabien Thomas <fabient@FreeBSD.org>2016-11-02 15:11:23 +0000
committerFabien Thomas <fabient@FreeBSD.org>2016-11-02 15:11:23 +0000
commit5ffb56f0577308c76e28e1c730bb1388722749c3 (patch)
treeecfd750f59c03d5cbce48c7b67463237f45e1d8a /usr.sbin/rtadvd/if.c
parent7846f73cc85f87878e35bbca66037edd1778d6e8 (diff)
downloadsrc-5ffb56f0577308c76e28e1c730bb1388722749c3.tar.gz
src-5ffb56f0577308c76e28e1c730bb1388722749c3.zip
In rtadvd, interface lookup calls if_indextoname() many times in a loop,
(it takes a long time on systems with many interfaces) without reason and without checking its return value. Reviewed by: cem Obtained from: Maryse Levavasseur <maryse.levavasseur@stormshield.eu> MFC after: 1 month Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D6979
Notes
Notes: svn path=/head/; revision=308216
Diffstat (limited to 'usr.sbin/rtadvd/if.c')
-rw-r--r--usr.sbin/rtadvd/if.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c
index dc6ac8e320db..6013e9ba08c1 100644
--- a/usr.sbin/rtadvd/if.c
+++ b/usr.sbin/rtadvd/if.c
@@ -470,11 +470,18 @@ update_ifinfo(struct ifilist_head_t *ifi_head, int ifindex)
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;
@@ -493,15 +500,7 @@ update_ifinfo(struct ifilist_head_t *ifi_head, int ifindex)
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;
- }
+ strlcpy(ifi->ifi_ifname, ifname, IFNAMSIZ);
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
syslog(LOG_ERR,