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.
This commit is contained in:
parent
ec9ed1a7a2
commit
edfc20d9bd
|
@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 1993\
|
|||
#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 @@ 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) {
|
||||
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 @@ 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);
|
||||
|
@ -323,10 +326,12 @@ tryagain:
|
|||
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 @@ overwrite:
|
|||
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 @@ overwrite:
|
|||
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 @@ delete_one(struct rt_msghdr *rtm)
|
|||
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);
|
||||
|
|
|
@ -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 @@ const struct prog_ops prog_ops = {
|
|||
|
||||
.op_read = read,
|
||||
.op_write = write,
|
||||
.op_close = close,
|
||||
|
||||
.op_sysctl = sysctl,
|
||||
};
|
||||
|
|
|
@ -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 @@ const struct prog_ops prog_ops = {
|
|||
|
||||
.op_read = rump_sys_read,
|
||||
.op_write = rump_sys_write,
|
||||
.op_close = rump_sys_close,
|
||||
|
||||
.op_sysctl = rump_sys___sysctl,
|
||||
};
|
||||
|
|
|
@ -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 @@ struct prog_ops {
|
|||
|
||||
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 @@ extern const struct prog_ops prog_ops;
|
|||
#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 @@ extern const struct prog_ops prog_ops;
|
|||
#define prog_getpid getpid
|
||||
#define prog_read read
|
||||
#define prog_write write
|
||||
#define prog_close close
|
||||
#define prog_sysctl sysctl
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue