NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/53974: arp(8): Attempting to set many ARP entries with -f option, it can cause "socket: Too many open files" error.
The following reply was made to PR bin/53974; it has been noted by GNATS.
From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/53974: arp(8): Attempting to set many ARP entries with -f
option, it can cause "socket: Too many open files" error.
Date: Sun, 17 Feb 2019 02:18:10 +0000
On Thu, Feb 14, 2019 at 04:40:00AM +0000, nonakap%gmail.com@localhost wrote:
> arp: socket: Too many open files
Maybe it should close the sockets it opens :-)
I'm not really in a position to test the following right now so please
let me know if it works and doesn't blow things up.
Index: arp.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/arp/arp.c,v
retrieving revision 1.63
diff -u -p -r1.63 arp.c
--- arp.c 31 Jul 2018 09:45:52 -0000 1.63
+++ arp.c 17 Feb 2019 02:16:34 -0000
@@ -276,8 +276,10 @@ set(int argc, char **argv)
argc -= 2;
argv += 2;
- if (getinetaddr(host, &sin_m.sin_addr) == -1)
+ if (getinetaddr(host, &sin_m.sin_addr) == -1) {
+ close(s);
return (1);
+ }
if (strcmp(eaddr, "auto") != 0 && atosdl(eaddr, &sdl_m))
warnx("invalid link-level address '%s'", eaddr);
doing_proxy = flags = export_only = expire_time = 0;
@@ -310,13 +312,16 @@ set(int argc, char **argv)
}
if (doing_proxy && strcmp(eaddr, "auto") == 0) {
- if (getetheraddr(sin_m.sin_addr, &sdl_m) == -1)
+ if (getetheraddr(sin_m.sin_addr, &sdl_m) == -1) {
+ close(s);
return 1;
+ }
}
tryagain:
rtm = rtmsg(s, RTM_GET, NULL, &sin_m, &sdl_m);
if (rtm == NULL) {
warn("%s", host);
+ close(s);
return (1);
}
sina = (struct sockaddr_inarp *)(void *)(rtm + 1);
@@ -327,10 +332,12 @@ tryagain:
goto overwrite;
if (doing_proxy == 0) {
warnx("set: can only proxy for %s", host);
+ close(s);
return (1);
}
if (sin_m.sin_other & SIN_PROXY) {
warnx("set: proxy entry exists for non 802 device");
+ close(s);
return (1);
}
sin_m.sin_other = SIN_PROXY;
@@ -341,6 +348,7 @@ overwrite:
if (sdl->sdl_family != AF_LINK) {
warnx("cannot intuit interface index and type for %s",
host);
+ close(s);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
@@ -351,6 +359,7 @@ overwrite:
rtm = rtmsg(s, RTM_ADD, NULL, &sin_m, &sdl_m);
if (vflag)
(void)printf("%s (%s) added\n", host, eaddr);
+ close(s);
return (rtm == NULL) ? 1 : 0;
}
@@ -407,6 +416,7 @@ delete_one(struct rt_msghdr *rtm)
if (sdl->sdl_family != AF_LINK)
return (1);
rtm = rtmsg(s, RTM_DELETE, rtm, sina, sdl);
+ close(s);
if (rtm == NULL)
return (1);
return (0);
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index