From 2b34e84335149a2d464c8e4b1334fb8f65a1fa8f Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 17 Jun 2017 00:57:26 +0000 Subject: Add abstime kqueue(2) timers and expand struct kevent members. This change implements NOTE_ABSTIME flag for EVFILT_TIMER, which specifies that the data field contains absolute time to fire the event. To make this useful, data member of the struct kevent must be extended to 64bit. Using the opportunity, I also added ext members. This changes struct kevent almost to Apple struct kevent64, except I did not changed type of ident and udata, the later would cause serious API incompatibilities. The type of ident was kept uintptr_t since EVFILT_AIO returns a pointer in this field, and e.g. CHERI is sensitive to the type (discussed with brooks, jhb). Unlike Apple kevent64, symbol versioning allows us to claim ABI compatibility and still name the new syscall kevent(2). Compat shims are provided for both host native and compat32. Requested by: bapt Reviewed by: bapt, brooks, ngie (previous version) Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D11025 --- contrib/netbsd-tests/kernel/kqueue/t_proc1.c | 4 ---- contrib/netbsd-tests/kernel/kqueue/t_sig.c | 4 ---- 2 files changed, 8 deletions(-) (limited to 'contrib') diff --git a/contrib/netbsd-tests/kernel/kqueue/t_proc1.c b/contrib/netbsd-tests/kernel/kqueue/t_proc1.c index 5f8c2a4948b2..947e6e317a0a 100644 --- a/contrib/netbsd-tests/kernel/kqueue/t_proc1.c +++ b/contrib/netbsd-tests/kernel/kqueue/t_proc1.c @@ -139,11 +139,7 @@ ATF_TC_BODY(proc1, tc) printf(" NOTE_FORK"); } if (event[0].fflags & NOTE_CHILD) -#ifdef __FreeBSD__ - printf(" NOTE_CHILD, parent = %" PRIdPTR, event[0].data); -#else printf(" NOTE_CHILD, parent = %" PRId64, event[0].data); -#endif printf("\n"); } diff --git a/contrib/netbsd-tests/kernel/kqueue/t_sig.c b/contrib/netbsd-tests/kernel/kqueue/t_sig.c index 12e3d6115586..ea707e9af9e2 100644 --- a/contrib/netbsd-tests/kernel/kqueue/t_sig.c +++ b/contrib/netbsd-tests/kernel/kqueue/t_sig.c @@ -127,11 +127,7 @@ ATF_TC_BODY(sig, tc) if (n == 0) continue; -#ifdef __FreeBSD__ - (void)printf("sig: kevent flags: 0x%x, data: %" PRIdPTR " (# " -#else (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# " -#endif "times signal posted)\n", event[0].flags, event[0].data); } -- cgit v1.2.3 From eeafb4bc10f61939e08ad40f4855eb7941ee4c6f Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Mon, 19 Jun 2017 12:33:22 +0000 Subject: Flag poolcommand() (ippool -A and ippool -R) command line syntax errors. --- contrib/ipfilter/tools/ippool.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index e204b0074098..72c3bf309826 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -297,8 +297,14 @@ poolcommand(remove, argc, argv) case 'v' : opts |= OPT_VERBOSE; break; + default : + usage(argv[0]); + break; /* keep compiler happy */ } + if (argc - 1 - optind > 0) + usage(argv[0]); + if (opts & OPT_DEBUG) fprintf(stderr, "poolcommand: opts = %#x\n", opts); -- cgit v1.2.3 From 254a06e0b3c003d47956aa013514c2ec84684e61 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Mon, 19 Jun 2017 19:27:37 +0000 Subject: poolcommand() (ippool -A and ippool -R) seed takes an argument. --- contrib/ipfilter/tools/ippool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index 72c3bf309826..ac6690c49f4d 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -268,7 +268,7 @@ poolcommand(remove, argc, argv) bzero((char *)&iph, sizeof(iph)); bzero((char *)&pool, sizeof(pool)); - while ((c = getopt(argc, argv, "dm:no:RSv")) != -1) + while ((c = getopt(argc, argv, "dm:no:RS:v")) != -1) switch (c) { case 'd' : -- cgit v1.2.3 From 49742409a36022443e1d2353738b955d617be05b Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Tue, 20 Jun 2017 12:31:58 +0000 Subject: Flag poolnodecommand() (ippool -a and ippool -r) command line syntax errors. --- contrib/ipfilter/tools/ippool.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index ac6690c49f4d..8218df9472b8 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -210,8 +210,14 @@ poolnodecommand(remove, argc, argv) case 'v' : opts |= OPT_VERBOSE; break; + default : + usage(argv[0]); + break; /* keep compiler happy */ } + if (argc - 1 - optind > 0) + usage(argv[0]); + if (argv[optind] != NULL && ipset == 0) { if (setnodeaddr(type, role, ptr, argv[optind]) == 0) ipset = 1; -- cgit v1.2.3 From cec9c3b13bef10d823f15e7bee8807b8064d263e Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Tue, 20 Jun 2017 16:40:31 +0000 Subject: remove bogus declaration of malloc from tcp_wrappers The declaration was already inactive when INET6 was enabled and it causes a build error in the other case because of a conflict with the correct definition in stdlib.h. Discussed with: dim, ume MFC after: 2 weeks --- contrib/tcp_wrappers/scaffold.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'contrib') diff --git a/contrib/tcp_wrappers/scaffold.c b/contrib/tcp_wrappers/scaffold.c index dd8f1fbfedcc..ba3dfac7ea98 100644 --- a/contrib/tcp_wrappers/scaffold.c +++ b/contrib/tcp_wrappers/scaffold.c @@ -28,10 +28,6 @@ static char sccs_id[] = "@(#) scaffold.c 1.6 97/03/21 19:27:24"; #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ #endif -#ifndef INET6 -extern char *malloc(); -#endif - /* Application-specific. */ #include "tcpd.h" -- cgit v1.2.3 From 3f6a9d3760a33b40fe308dc32c4b06c909aa05d8 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Wed, 21 Jun 2017 12:19:05 +0000 Subject: Fix -S handling within poolcommand(). Specifying a seed (-S) is only valid when adding a pool (ippool -A), not when removing a pool (ippool -R). It is a command line syntax error if specifying a seed (-S) is specified when emoving a pool (-R). --- contrib/ipfilter/tools/ippool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index 8218df9472b8..d326ec094208 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -298,7 +298,10 @@ poolcommand(remove, argc, argv) opts |= OPT_NORESOLVE; break; case 'S' : - iph.iph_seed = atoi(optarg); + if (remove == 0) + iph.iph_seed = atoi(optarg); + else + usage(argv[0]); break; case 'v' : opts |= OPT_VERBOSE; -- cgit v1.2.3 From 3f296d78cc06489bec4546959b8b66644a6efe70 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Thu, 22 Jun 2017 06:25:34 +0000 Subject: poolflush() has no positional arguments. --- contrib/ipfilter/tools/ippool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index d326ec094208..b0466b110af2 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -583,7 +583,7 @@ poolflush(argc, argv) break; /* keep compiler happy */ } - if (argc - 1 - optind > 0) + if (argc - optind > 0) usage(argv[0]); if (opts & OPT_DEBUG) -- cgit v1.2.3 From cd32671786af38a406273cf12351e1e563135110 Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Thu, 22 Jun 2017 12:46:48 +0000 Subject: In poolnodcommand(): TTL (-T) is only valid when adding a node to a pool (ippool -a) not when removing a node from a pool (ippool -r). Flag -T as an error in ippool -r. --- contrib/ipfilter/tools/ippool.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c index b0466b110af2..c8a9c70b136e 100644 --- a/contrib/ipfilter/tools/ippool.c +++ b/contrib/ipfilter/tools/ippool.c @@ -201,10 +201,14 @@ poolnodecommand(remove, argc, argv) } break; case 'T' : - ttl = atoi(optarg); - if (ttl < 0) { - fprintf(stderr, "cannot set negative ttl\n"); - return -1; + if (remove == 0) { + ttl = atoi(optarg); + if (ttl < 0) { + fprintf(stderr, "cannot set negative ttl\n"); + return -1; + } + } else { + usage(argv[0]); } break; case 'v' : -- cgit v1.2.3 From 43988e3f509abc137da6a7f19cbeeafb2160816e Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Fri, 23 Jun 2017 02:42:04 +0000 Subject: Replace AF_INET6 ifdefs with USE_INET6 ifdefs. This is more consistent and guaranteed to build everywhere in ipfilter. Not all of this commit can be MFCed. Some is original code while others are not. --- contrib/ipfilter/lib/familyname.c | 2 +- contrib/ipfilter/lib/printhashnode.c | 4 ++-- contrib/ipfilter/lib/printip.c | 2 +- contrib/ipfilter/lib/printpoolnode.c | 4 +--- contrib/ipfilter/tools/ipf_y.y | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) (limited to 'contrib') diff --git a/contrib/ipfilter/lib/familyname.c b/contrib/ipfilter/lib/familyname.c index 35bb975cc6b1..891c6715ed0b 100644 --- a/contrib/ipfilter/lib/familyname.c +++ b/contrib/ipfilter/lib/familyname.c @@ -4,7 +4,7 @@ const char *familyname(int family) { if (family == AF_INET) return "inet"; -#ifdef AF_INET6 +#ifdef USE_INET6 if (family == AF_INET6) return "inet6"; #endif diff --git a/contrib/ipfilter/lib/printhashnode.c b/contrib/ipfilter/lib/printhashnode.c index 5f0f5f67938f..8a45d86c5134 100644 --- a/contrib/ipfilter/lib/printhashnode.c +++ b/contrib/ipfilter/lib/printhashnode.c @@ -35,7 +35,7 @@ printhashnode(iph, ipep, copyfunc, opts, fields) } printf("\n"); } else if ((opts & OPT_DEBUG) != 0) { -#ifdef AF_INET6 +#ifdef USE_INET6 if (ipe.ipe_family == AF_INET6) { char buf[INET6_ADDRSTRLEN + 1]; const char *str; @@ -59,7 +59,7 @@ printhashnode(iph, ipep, copyfunc, opts, fields) } else if (ipe.ipe_family == AF_INET) { #else if (ipe.ipe_family == AF_INET) { -#endif /* AF_INET6 */ +#endif /* USE_INET6 */ PRINTF("\t%d\tAddress: %s", hv, inet_ntoa(ipe.ipe_addr.in4)); printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr); diff --git a/contrib/ipfilter/lib/printip.c b/contrib/ipfilter/lib/printip.c index 6d414fe3fa41..a0b8bd37f277 100644 --- a/contrib/ipfilter/lib/printip.c +++ b/contrib/ipfilter/lib/printip.c @@ -25,7 +25,7 @@ printip(family, addr) else PRINTF("%s", inet_ntoa(ipa)); } -#ifdef AF_INET6 +#ifdef USE_INET6 else if (family == AF_INET6) { char buf[INET6_ADDRSTRLEN + 1]; const char *str; diff --git a/contrib/ipfilter/lib/printpoolnode.c b/contrib/ipfilter/lib/printpoolnode.c index 59e09228f05e..6b58b8459327 100644 --- a/contrib/ipfilter/lib/printpoolnode.c +++ b/contrib/ipfilter/lib/printpoolnode.c @@ -33,7 +33,7 @@ printpoolnode(np, opts, fields) printmask(np->ipn_addr.adf_family, (u_32_t *)&np->ipn_mask.adf_addr); } else { -#ifdef AF_INET6 +#ifdef USE_INET6 if (np->ipn_addr.adf_family == AF_INET6) { char buf[INET6_ADDRSTRLEN + 1]; const char *str; @@ -54,9 +54,7 @@ printpoolnode(np, opts, fields) } else { PRINTF("\tAddress: family: %d\n", np->ipn_addr.adf_family); -#ifdef AF_INET6 } -#endif printmask(np->ipn_addr.adf_family, (u_32_t *)&np->ipn_mask.adf_addr); #ifdef USE_QUAD_T diff --git a/contrib/ipfilter/tools/ipf_y.y b/contrib/ipfilter/tools/ipf_y.y index 26db2a22e45e..2240a2a1c21f 100644 --- a/contrib/ipfilter/tools/ipf_y.y +++ b/contrib/ipfilter/tools/ipf_y.y @@ -2303,7 +2303,7 @@ makepool(list) for (n = top, a = list; (n != NULL) && (a != NULL); a = a->al_next) { if (use_inet6 == 1) { -#ifdef AF_INET6 +#ifdef USE_INET6 n->ipn_addr.adf_family = AF_INET6; n->ipn_addr.adf_addr = a->al_i6addr; n->ipn_addr.adf_len = offsetof(addrfamily_t, -- cgit v1.2.3 From f21680fd983784341c88dbe1015548f65c79868d Mon Sep 17 00:00:00 2001 From: Cy Schubert Date: Tue, 27 Jun 2017 04:54:58 +0000 Subject: Replace AF_INET6 ifdefs with USE_INET6 to be consistent with the rest of the ipfilter souce tree. --- contrib/ipfilter/tools/ippool_y.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/ipfilter/tools/ippool_y.y b/contrib/ipfilter/tools/ippool_y.y index 93593ce82eca..2c7574f9432d 100644 --- a/contrib/ipfilter/tools/ippool_y.y +++ b/contrib/ipfilter/tools/ippool_y.y @@ -273,7 +273,7 @@ grouplist: | addrmask next { $$ = calloc(1, sizeof(iphtent_t)); $$->ipe_addr = $1[0].adf_addr; $$->ipe_mask = $1[1].adf_addr; -#ifdef AF_INET6 +#ifdef USE_INET6 if (use_inet6) $$->ipe_family = AF_INET6; else @@ -297,7 +297,7 @@ groupentry: $$->ipe_mask = $1[1].adf_addr; strncpy($$->ipe_group, $3, FR_GROUPLEN); -#ifdef AF_INET6 +#ifdef USE_INET6 if (use_inet6) $$->ipe_family = AF_INET6; else -- cgit v1.2.3