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
This commit is contained in:
Andrey V. Elsukov 2018-12-10 16:23:11 +00:00
parent 5f9c94c592
commit a895c1c28a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341799

View File

@ -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