From e3bf606c5d658e5fafb5d6168b0d4e7c9b0dd5ce Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Wed, 11 Mar 2020 08:08:53 +0000 Subject: [PATCH] Revert r358858 as it breaks some ipfw(8) setups. Reported by: O. Hartmann --- sbin/ipfw/ipfw2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index b54ffc74ec9f..c81822782644 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -3717,10 +3717,11 @@ add_src(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate) if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 || inet_pton(AF_INET6, host, &a) == 1) ret = add_srcip6(cmd, av, cblen, tstate); - else if (proto == IPPROTO_IP || strcmp(av, "me") == 0 || - inet_pton(AF_INET, host, &a) == 1) + /* XXX: should check for IPv4, not !IPv6 */ + if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 || + inet_pton(AF_INET6, host, &a) != 1)) ret = add_srcip(cmd, av, cblen, tstate); - else if (ret == NULL && strcmp(av, "any") != 0) + if (ret == NULL && strcmp(av, "any") != 0) ret = cmd; return ret; @@ -3747,10 +3748,11 @@ add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen, struct tidx *tstate) if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 || inet_pton(AF_INET6, host, &a) == 1) ret = add_dstip6(cmd, av, cblen, tstate); - else if (proto == IPPROTO_IP || strcmp(av, "me") == 0 || - inet_pton(AF_INET, host, &a) == 1) + /* XXX: should check for IPv4, not !IPv6 */ + if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 || + inet_pton(AF_INET6, host, &a) != 1)) ret = add_dstip(cmd, av, cblen, tstate); - else if (ret == NULL && strcmp(av, "any") != 0) + if (ret == NULL && strcmp(av, "any") != 0) ret = cmd; return ret;