Rework ipfw rules parsing and printing code.
Introduce show_state structure to keep information about printed opcodes. Split show_static_rule() function into several smaller functions. Make parsing and printing opcodes into several passes. Each printed opcode is marked in show_state structure and will be skipped in next passes. Now show_static_rule() function is simple, it just prints each part of rule separately: action, modifiers, proto, src and dst addresses, options. The main goal of this change is avoiding occurrence of wrong result of `ifpw show` command, that can not be parsed by ipfw(8). Also now it is possible to make some simple static optimizations by reordering of opcodes in the rule. PR: 222705 Discussed with: melifaro MFC after: 2 weeks Sponsored by: Yandex LLC
This commit is contained in:
parent
f4043145f2
commit
aed0267989
1548
sbin/ipfw/ipfw2.c
1548
sbin/ipfw/ipfw2.c
File diff suppressed because it is too large
Load Diff
@ -56,6 +56,12 @@ struct cmdline_opts {
|
||||
|
||||
};
|
||||
|
||||
enum {
|
||||
TIMESTAMP_NONE = 0,
|
||||
TIMESTAMP_STRING,
|
||||
TIMESTAMP_NUMERIC,
|
||||
};
|
||||
|
||||
extern struct cmdline_opts co;
|
||||
|
||||
/*
|
||||
|
@ -324,11 +324,11 @@ ipfw_main(int oldac, char **oldav)
|
||||
break;
|
||||
|
||||
case 't':
|
||||
co.do_time = 1;
|
||||
co.do_time = TIMESTAMP_STRING;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
co.do_time = 2; /* numeric timestamp */
|
||||
co.do_time = TIMESTAMP_NUMERIC;
|
||||
break;
|
||||
|
||||
case 'v': /* verbose */
|
||||
|
Loading…
Reference in New Issue
Block a user