flow: Clarify and enforce flow state transitions
Flows move over several different states in their lifetime. The rules for these are documented in comments, but they're pretty complex and a number of the transitions are implicit, which makes this pretty fragile and error prone. Change the code to explicitly track the states in a field. Make all transitions explicit and logged. To the extent that it's practical in C, enforce what can and can't be done in various states with ASSERT()s. While we're at it, tweak the docs to clarify the restrictions on each state a bit. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:

committed by
Stefano Brivio

parent
a63199832a
commit
0060acd11b
4
icmp.c
4
icmp.c
@@ -167,7 +167,7 @@ static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c,
|
||||
if (!flow)
|
||||
return NULL;
|
||||
|
||||
pingf = FLOW_START(flow, flowtype, ping, TAPSIDE);
|
||||
pingf = FLOW_SET_TYPE(flow, flowtype, ping, TAPSIDE);
|
||||
|
||||
pingf->seq = -1;
|
||||
pingf->id = id;
|
||||
@@ -198,6 +198,8 @@ static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c,
|
||||
|
||||
*id_sock = pingf;
|
||||
|
||||
FLOW_ACTIVATE(pingf);
|
||||
|
||||
return pingf;
|
||||
|
||||
cancel:
|
||||
|
Reference in New Issue
Block a user