aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipfw
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2018-12-10 16:23:11 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2018-12-10 16:23:11 +0000
commita895c1c28ad1b241f7d49c1694c6d40fddbfddcd (patch)
tree2f4b8619a26303348519a231c3f3f06a62765cd9 /sbin/ipfw
parent5f9c94c592ce49d967632eb912cb3c3c33ef5f9e (diff)
downloadsrc-a895c1c28ad1b241f7d49c1694c6d40fddbfddcd.tar.gz
src-a895c1c28ad1b241f7d49c1694c6d40fddbfddcd.zip
Rework how protocol number is tracked in rule. Save it when O_PROTO
opcode will be printed. This should solve the problem, when protocol name is not printed in `ipfw -N show`. Reported by: Claudio Eichenberger <cei at yourshop.com> MFC after: 1 week
Notes
Notes: svn path=/head/; revision=341799
Diffstat (limited to 'sbin/ipfw')
-rw-r--r--sbin/ipfw/ipfw2.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 4bc91ee26980..3a41deaca448 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -1511,6 +1511,7 @@ print_instruction(struct buf_pr *bp, const struct format_opts *fo,
bprintf(bp, " %s", pe->p_name);
else
bprintf(bp, " %u", cmd->arg1);
+ state->proto = cmd->arg1;
break;
case O_MACADDR2:
print_mac(bp, insntod(cmd, mac));
@@ -1992,10 +1993,10 @@ print_proto(struct buf_pr *bp, struct format_opts *fo,
struct show_state *state)
{
ipfw_insn *cmd;
- int l, proto, ip4, ip6, tmp;
+ int l, proto, ip4, ip6;
/* Count all O_PROTO, O_IP4, O_IP6 instructions. */
- proto = tmp = ip4 = ip6 = 0;
+ proto = ip4 = ip6 = 0;
for (l = state->rule->act_ofs, cmd = state->rule->cmd;
l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) {
switch (cmd->opcode) {
@@ -2031,18 +2032,13 @@ print_proto(struct buf_pr *bp, struct format_opts *fo,
if (cmd == NULL || (cmd->len & F_OR))
for (l = proto; l > 0; l--) {
cmd = print_opcode(bp, fo, state, O_PROTO);
- if (cmd != NULL && (cmd->len & F_OR) == 0)
+ if (cmd == NULL || (cmd->len & F_OR) == 0)
break;
- tmp = cmd->arg1;
}
/* Initialize proto, it is used by print_newports() */
- if (tmp != 0)
- state->proto = tmp;
- else if (ip6 != 0)
- state->proto = IPPROTO_IPV6;
- else
- state->proto = IPPROTO_IP;
state->flags |= HAVE_PROTO;
+ if (state->proto == 0 && ip6 != 0)
+ state->proto = IPPROTO_IPV6;
}
static int