Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/usr.sbin/arp Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/afcc96a05cc8
branches:  netbsd-8
changeset: 852284:afcc96a05cc8
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 03 11:01:48 2019 +0000

description:
Pull up following revision(s) (requested by dholland in ticket #1198):

        usr.sbin/arp/arp_rumpops.c: revision 1.2
        usr.sbin/arp/arp_hostops.c: revision 1.2
        usr.sbin/arp/arp.c: revision 1.64
        usr.sbin/arp/arp.c: revision 1.65
        usr.sbin/arp/prog_ops.h: revision 1.2

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.

 -

arp(8): one more to close socket.

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 (167 lines):

diff -r 05d12e0e8282 -r afcc96a05cc8 usr.sbin/arp/arp.c
--- a/usr.sbin/arp/arp.c        Fri Mar 01 19:02:43 2019 +0000
+++ b/usr.sbin/arp/arp.c        Sun Mar 03 11:01:48 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arp.c,v 1.55.8.4 2018/07/31 17:08:00 martin Exp $ */
+/*     $NetBSD: arp.c,v 1.55.8.5 2019/03/03 11:01:48 martin 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.55.8.4 2018/07/31 17:08:00 martin Exp $");
+__RCSID("$NetBSD: arp.c,v 1.55.8.5 2019/03/03 11:01:48 martin 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 (atosdl(eaddr, &sdl_m))
                warnx("invalid link-level address '%s'", eaddr);
        doing_proxy = flags = export_only = expire_time = 0;
@@ -313,6 +315,7 @@
        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);
@@ -323,10 +326,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;
@@ -337,6 +342,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;
@@ -347,6 +353,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;
 }
 
@@ -400,9 +407,12 @@
        sina = (struct sockaddr_inarp *)(void *)(rtm + 1);
        sdl = (struct sockaddr_dl *)(void *)(RT_ROUNDUP(sina->sin_len) +
            (char *)(void *)sina);
-       if (sdl->sdl_family != AF_LINK)
+       if (sdl->sdl_family != AF_LINK) {
+               prog_close(s);
                return (1);
+       }
        rtm = rtmsg(s, RTM_DELETE, rtm, sina, sdl);
+       prog_close(s);
        if (rtm == NULL)
                return (1);
        return (0);
diff -r 05d12e0e8282 -r afcc96a05cc8 usr.sbin/arp/arp_hostops.c
--- a/usr.sbin/arp/arp_hostops.c        Fri Mar 01 19:02:43 2019 +0000
+++ b/usr.sbin/arp/arp_hostops.c        Sun Mar 03 11:01:48 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.1.8.1 2019/03/03 11:01:48 martin 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.1.8.1 2019/03/03 11:01:48 martin 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 05d12e0e8282 -r afcc96a05cc8 usr.sbin/arp/arp_rumpops.c
--- a/usr.sbin/arp/arp_rumpops.c        Fri Mar 01 19:02:43 2019 +0000
+++ b/usr.sbin/arp/arp_rumpops.c        Sun Mar 03 11:01:48 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.1.8.1 2019/03/03 11:01:48 martin 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.1.8.1 2019/03/03 11:01:48 martin 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 05d12e0e8282 -r afcc96a05cc8 usr.sbin/arp/prog_ops.h
--- a/usr.sbin/arp/prog_ops.h   Fri Mar 01 19:02:43 2019 +0000
+++ b/usr.sbin/arp/prog_ops.h   Sun Mar 03 11:01:48 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.1.8.1 2019/03/03 11:01:48 martin 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