Skip to content

Commit

Permalink
ipfw: make 'ipfw show' output compatible with 'ipfw add' command
Browse files Browse the repository at this point in the history
If rule was added in compact form and rule body is empty, print
'proto ip' opcode to be compatible with ipfw(8) syntax parser.

  Before:
  $ ipfw add allow proto ip
  000700 allow
  After:
  $ ipfw add allow proto ip
  000700 allow proto ip

(cherry picked from commit 706a03f61bbb6e0cf10e6c3727966495b30d763e)
  • Loading branch information
bu7cher authored and fichtner committed Feb 24, 2025
1 parent 1114065 commit fd3d1a7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sbin/ipfw/ipfw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,13 @@ show_static_rule(struct cmdline_opts *co, struct format_opts *fo,

if (rule->flags & IPFW_RULE_JUSTOPTS) {
state.flags |= HAVE_PROTO | HAVE_SRCIP | HAVE_DSTIP;
/*
* Print `proto ip` if all opcodes has been already printed.
*/
if (memchr(state.printed, 0, rule->act_ofs) == NULL) {
bprintf(bp, " proto ip");
goto end;
}
goto justopts;
}

Expand Down

0 comments on commit fd3d1a7

Please sign in to comment.