| Fix some errors without messages. |
| Ported from IP Filter Rivoreo fork commit 4c0cbe5. |
| |
| diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/contrib/ipfilter/man/ippool.8 freebsd-11.1/contrib/ipfilter/man/ippool.8 |
| --- /usr/src/contrib/ipfilter/man/ippool.8 2017-07-21 07:42:31.000000000 +0800 |
| +++ freebsd-11.1/contrib/ipfilter/man/ippool.8 2020-01-26 00:05:54.129563000 +0800 |
| @@ -6,10 +6,10 @@ |
| .SH SYNOPSIS |
| .br |
| .B ippool |
| --a [-dnv] [-m <name>] [-o <role>] [-t <type>] [-T ttl] -i <ipaddr>[/<netmask>] |
| +-a [-dnv] -m <name> [-o <role>] [-t <type>] [-T <ttl>] -i <ipaddr>[/<netmask>] |
| .br |
| .B ippool |
| --A [-dnv] [-m <name>] [-o <role>] [-S <seed>] [-t <type>] |
| +-A [-dnv] -m <name> [-o <role>] [-S <seed>] [-t <type>] |
| .br |
| .B ippool |
| -f <file> [-dnuv] |
| @@ -21,7 +21,7 @@ |
| -l [-dv] [-m <name>] [-t <type>] |
| .br |
| .B ippool |
| --r [-dnv] [-m <name>] [-o <role>] [-t <type>] -i <ipaddr>[/<netmask>] |
| +-r [-dnv] -m <name> [-o <role>] [-t <type>] -i <ipaddr>[/<netmask>] |
| .br |
| .B ippool |
| -R [-dnv] [-m <name>] [-o <role>] [-t <type>] |
| diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/contrib/ipfilter/tools/ippool.c freebsd-11.1/contrib/ipfilter/tools/ippool.c |
| --- /usr/src/contrib/ipfilter/tools/ippool.c 2017-07-21 07:42:32.000000000 +0800 |
| +++ freebsd-11.1/contrib/ipfilter/tools/ippool.c 2020-01-26 00:05:54.134632000 +0800 |
| @@ -75,12 +75,12 @@ |
| char *prog; |
| { |
| fprintf(stderr, "Usage:\t%s\n", prog); |
| - fprintf(stderr, "\t-a [-dnv] [-m <name>] [-o <role>] [-t type] [-T ttl] -i <ipaddr>[/netmask]\n"); |
| - fprintf(stderr, "\t-A [-dnv] [-m <name>] [-o <role>] [-S <seed>] [-t <type>]\n"); |
| + fprintf(stderr, "\t-a [-dnv] -m <name> [-o <role>] [-t <type>] [-T <ttl>] -i <ipaddr>[/<netmask>]\n"); |
| + fprintf(stderr, "\t-A [-dnv] -m <name> [-o <role>] [-S <seed>] [-t <type>]\n"); |
| fprintf(stderr, "\t-f <file> [-dnuv]\n"); |
| fprintf(stderr, "\t-F [-dv] [-o <role>] [-t <type>]\n"); |
| fprintf(stderr, "\t-l [-dv] [-m <name>] [-t <type>] [-O <fields>]\n"); |
| - fprintf(stderr, "\t-r [-dnv] [-m <name>] [-o <role>] [-t type] -i <ipaddr>[/netmask]\n"); |
| + fprintf(stderr, "\t-r [-dnv] -m <name> [-o <role>] [-t type] -i <ipaddr>[/<netmask>]\n"); |
| fprintf(stderr, "\t-R [-dnv] [-m <name>] [-o <role>] [-t <type>]\n"); |
| fprintf(stderr, "\t-s [-dtv] [-M <core>] [-N <namelist>]\n"); |
| exit(1); |
| @@ -181,8 +181,10 @@ |
| return -1; |
| } |
| role = getrole(optarg); |
| - if (role == IPL_LOGNONE) |
| + if (role == IPL_LOGNONE) { |
| + fprintf(stderr, "unknown role '%s'\n", optarg); |
| return -1; |
| + } |
| break; |
| case 'R' : |
| opts |= OPT_NORESOLVE; |
| @@ -238,19 +240,21 @@ |
| |
| switch (type) { |
| case IPLT_POOL : |
| - if (remove == 0) |
| - err = load_poolnode(role, poolname, &pnode, ttl, ioctl); |
| - else |
| - err = remove_poolnode(role, poolname, &pnode, ioctl); |
| + err = remove ? remove_poolnode(role, poolname, &pnode, ioctl) : |
| + load_poolnode(role, poolname, &pnode, ttl, ioctl); |
| break; |
| case IPLT_HASH : |
| - if (remove == 0) |
| - err = load_hashnode(role, poolname, &hnode, ttl, ioctl); |
| - else |
| - err = remove_hashnode(role, poolname, &hnode, ioctl); |
| + err = remove ? remove_hashnode(role, poolname, &hnode, ioctl) : |
| + load_hashnode(role, poolname, &hnode, ttl, ioctl); |
| break; |
| default : |
| - break; |
| + fprintf(stderr, "impossible pool type %d!\n", type); |
| + return -1; |
| + } |
| + if(err) { |
| + int e = errno; |
| + fprintf(stderr, "cannot %s node: %s\n", remove ? "remove" : "add", |
| + e ? strerror(e) : "Unknown error"); |
| } |
| return err; |
| } |
| @@ -599,7 +603,7 @@ |
| |
| if (!strcasecmp(rolename, "ipf")) { |
| role = IPL_LOGIPF; |
| -#if 0 |
| +#if 1 |
| } else if (!strcasecmp(rolename, "nat")) { |
| role = IPL_LOGNAT; |
| } else if (!strcasecmp(rolename, "state")) { |