Fix the problem with O_LIMIT states introduced in r344018.

dyn_install_state() uses `rule` pointer when it creates state.
For O_LIMIT states this pointer actually is not struct ip_fw,
it is pointer to O_LIMIT_PARENT state, that keeps actual pointer
to ip_fw parent rule. Thus we need to cache rule id and number
before calling dyn_get_parent_state(), so we can use them later
when the `rule` pointer is overrided.

PR:		236292
MFC after:	3 days
This commit is contained in:
Andrey V. Elsukov 2019-03-07 04:40:44 +00:00
parent 8ea23c2b5b
commit 83354acf5a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344870

View File

@ -1868,11 +1868,13 @@ dyn_install_state(const struct ipfw_flow_id *pkt, uint32_t zoneid,
uint16_t kidx, uint8_t type)
{
struct ipfw_flow_id id;
uint32_t hashval, parent_hashval;
uint32_t hashval, parent_hashval, ruleid, rulenum;
int ret;
MPASS(type == O_LIMIT || type == O_KEEP_STATE);
ruleid = rule->id;
rulenum = rule->rulenum;
if (type == O_LIMIT) {
/* Create masked flow id and calculate bucket */
id.addr_type = pkt->addr_type;
@ -1927,11 +1929,11 @@ dyn_install_state(const struct ipfw_flow_id *pkt, uint32_t zoneid,
hashval = hash_packet(pkt);
if (IS_IP4_FLOW_ID(pkt))
ret = dyn_add_ipv4_state(rule, rule->id, rule->rulenum, pkt,
ret = dyn_add_ipv4_state(rule, ruleid, rulenum, pkt,
ulp, pktlen, hashval, info, fibnum, kidx, type);
#ifdef INET6
else if (IS_IP6_FLOW_ID(pkt))
ret = dyn_add_ipv6_state(rule, rule->id, rule->rulenum, pkt,
ret = dyn_add_ipv6_state(rule, ruleid, rulenum, pkt,
zoneid, ulp, pktlen, hashval, info, fibnum, kidx, type);
#endif /* INET6 */
else