HomeFreeBSD

Description

MFC r338947:

Add "src-ip" or "dst-ip" keyword to the output, when we are printing the
rest of rule options.

Reported by:	lev

Details

Provenance
aeAuthored on Oct 3 2018, 12:47 PM
Parents
rGb1abbe55ca7e: MFC r338955:
Branches
Unknown
Tags
Unknown

Event Timeline

Shouldn't the state->flags be set before invoking print_instruction from inside print_address, i.e. before 2076?

The state->flags is set in line 2102 in the function print_address. If it is set at the end, what is its purpose?

2058 static void
2059 print_address(struct buf_pr *bp, struct format_opts *fo,
2060 struct show_state *state, const int opcodes[], size_t nops, int portop,
2061 int flag)
2062 {
2063 ipfw_insn *cmd;
2064 int count, l, portcnt, pf;
2065
2066 count = portcnt = 0;
2067 for (l = state->rule->act_ofs, cmd = state->rule->cmd;
2068 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) {
2069 if (match_opcode(cmd->opcode, opcodes, nops))
2070 count++;
2071 else if (cmd->opcode == portop)
2072 portcnt++;
2073 }
2074 if (count == 0)
2075 bprintf(bp, " any");
2076 for (l = state->rule->act_ofs, cmd = state->rule->cmd;
2077 l > 0 && count > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) {
2078 if (!match_opcode(cmd->opcode, opcodes, nops))
2079 continue;
2080 print_instruction(bp, fo, state, cmd);
2081 if ((cmd->len & F_OR) == 0)
2082 break;
2083 count--;
2084 }
2085 /*
2086 * If several O_IP_?PORT opcodes specified, leave them to the
2087 * options section.
2088 */
2089 if (portcnt == 1) {
2090 for (l = state->rule->act_ofs, cmd = state->rule->cmd, pf = 0;
2091 l > 0; l -= F_LEN(cmd), cmd += F_LEN(cmd)) {
2092 if (cmd->opcode != portop) {
2093 pf = (cmd->len & F_OR);
2094 continue;
2095 }
2096 /* Print opcode iff it is not in OR block. */
2097 if (pf == 0 && (cmd->len & F_OR) == 0)
2098 print_instruction(bp, fo, state, cmd);
2099 break;
2100 }
2101 }
2102 state->flags |= flag;
2103 }