Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/arp Teach arp that it's okay to close sockets after...
details: https://anonhg.NetBSD.org/src/rev/ce59d0377ea2
branches: trunk
changeset: 449234:ce59d0377ea2
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Feb 27 23:29:50 2019 +0000
description:
Teach arp that it's okay to close sockets after using them.
(this requires adding a close op to the rump turds)
Fixes PR 53974 reporting too many open files.
diffstat:
usr.sbin/arp/arp.c | 18 ++++++++++++++----
usr.sbin/arp/arp_hostops.c | 5 +++--
usr.sbin/arp/arp_rumpops.c | 5 +++--
usr.sbin/arp/prog_ops.h | 6 +++++-
4 files changed, 25 insertions(+), 9 deletions(-)
diffs (171 lines):
diff -r f1bb872ef56c -r ce59d0377ea2 usr.sbin/arp/arp.c
--- a/usr.sbin/arp/arp.c Wed Feb 27 21:37:24 2019 +0000
+++ b/usr.sbin/arp/arp.c Wed Feb 27 23:29:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp.c,v 1.63 2018/07/31 09:45:52 nonaka Exp $ */
+/* $NetBSD: arp.c,v 1.64 2019/02/27 23:29:50 dholland Exp $ */
/*
* Copyright (c) 1984, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: arp.c,v 1.63 2018/07/31 09:45:52 nonaka Exp $");
+__RCSID("$NetBSD: arp.c,v 1.64 2019/02/27 23:29:50 dholland Exp $");
#endif
#endif /* not lint */
@@ -276,8 +276,10 @@
argc -= 2;
argv += 2;
- if (getinetaddr(host, &sin_m.sin_addr) == -1)
+ if (getinetaddr(host, &sin_m.sin_addr) == -1) {
+ prog_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 @@
}
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) {
+ prog_close(s);
return 1;
+ }
}
tryagain:
rtm = rtmsg(s, RTM_GET, NULL, &sin_m, &sdl_m);
if (rtm == NULL) {
warn("%s", host);
+ prog_close(s);
return (1);
}
sina = (struct sockaddr_inarp *)(void *)(rtm + 1);
@@ -327,10 +332,12 @@
goto overwrite;
if (doing_proxy == 0) {
warnx("set: can only proxy for %s", host);
+ prog_close(s);
return (1);
}
if (sin_m.sin_other & SIN_PROXY) {
warnx("set: proxy entry exists for non 802 device");
+ prog_close(s);
return (1);
}
sin_m.sin_other = SIN_PROXY;
@@ -341,6 +348,7 @@
if (sdl->sdl_family != AF_LINK) {
warnx("cannot intuit interface index and type for %s",
host);
+ prog_close(s);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
@@ -351,6 +359,7 @@
rtm = rtmsg(s, RTM_ADD, NULL, &sin_m, &sdl_m);
if (vflag)
(void)printf("%s (%s) added\n", host, eaddr);
+ prog_close(s);
return (rtm == NULL) ? 1 : 0;
}
@@ -407,6 +416,7 @@
if (sdl->sdl_family != AF_LINK)
return (1);
rtm = rtmsg(s, RTM_DELETE, rtm, sina, sdl);
+ prog_close(s);
if (rtm == NULL)
return (1);
return (0);
diff -r f1bb872ef56c -r ce59d0377ea2 usr.sbin/arp/arp_hostops.c
--- a/usr.sbin/arp/arp_hostops.c Wed Feb 27 21:37:24 2019 +0000
+++ b/usr.sbin/arp/arp_hostops.c Wed Feb 27 23:29:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp_hostops.c,v 1.1 2015/07/29 06:07:35 ozaki-r Exp $ */
+/* $NetBSD: arp_hostops.c,v 1.2 2019/02/27 23:29:50 dholland Exp $ */
/*
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: arp_hostops.c,v 1.1 2015/07/29 06:07:35 ozaki-r Exp $");
+__RCSID("$NetBSD: arp_hostops.c,v 1.2 2019/02/27 23:29:50 dholland Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -47,6 +47,7 @@
.op_read = read,
.op_write = write,
+ .op_close = close,
.op_sysctl = sysctl,
};
diff -r f1bb872ef56c -r ce59d0377ea2 usr.sbin/arp/arp_rumpops.c
--- a/usr.sbin/arp/arp_rumpops.c Wed Feb 27 21:37:24 2019 +0000
+++ b/usr.sbin/arp/arp_rumpops.c Wed Feb 27 23:29:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arp_rumpops.c,v 1.1 2015/07/29 06:07:35 ozaki-r Exp $ */
+/* $NetBSD: arp_rumpops.c,v 1.2 2019/02/27 23:29:50 dholland Exp $ */
/*
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: arp_rumpops.c,v 1.1 2015/07/29 06:07:35 ozaki-r Exp $");
+__RCSID("$NetBSD: arp_rumpops.c,v 1.2 2019/02/27 23:29:50 dholland Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -51,6 +51,7 @@
.op_read = rump_sys_read,
.op_write = rump_sys_write,
+ .op_close = rump_sys_close,
.op_sysctl = rump_sys___sysctl,
};
diff -r f1bb872ef56c -r ce59d0377ea2 usr.sbin/arp/prog_ops.h
--- a/usr.sbin/arp/prog_ops.h Wed Feb 27 21:37:24 2019 +0000
+++ b/usr.sbin/arp/prog_ops.h Wed Feb 27 23:29:50 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prog_ops.h,v 1.1 2015/07/29 06:07:35 ozaki-r Exp $ */
+/* $NetBSD: prog_ops.h,v 1.2 2019/02/27 23:29:50 dholland Exp $ */
/*
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -45,6 +45,8 @@
ssize_t (*op_read)(int, void *, size_t);
ssize_t (*op_write)(int, const void *, size_t);
+
+ int (*op_close)(int);
};
extern const struct prog_ops prog_ops;
@@ -54,6 +56,7 @@
#define prog_getpid prog_ops.op_getpid
#define prog_read prog_ops.op_read
#define prog_write prog_ops.op_write
+#define prog_close prog_ops.op_close
#define prog_sysctl prog_ops.op_sysctl
#else
#define prog_init ((int (*)(void))NULL)
@@ -62,6 +65,7 @@
#define prog_getpid getpid
#define prog_read read
#define prog_write write
+#define prog_close close
#define prog_sysctl sysctl
#endif
Home |
Main Index |
Thread Index |
Old Index