flow: Record the pifs for each side of each flow
Currently we have no generic information flows apart from the type and state, everything else is specific to the flow type. Start introducing generic flow information by recording the pifs which the flow connects. To keep track of what information is valid, introduce new flow states: INI for when the initiating side information is complete, and TGT for when both sides information is complete, but we haven't chosen the flow type yet. For now, these states don't do an awful lot, but they'll become more important as we add more generic information. 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
43571852e6
commit
8a2accb847
10
tcp.c
10
tcp.c
@@ -1948,6 +1948,8 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af,
|
||||
if (!(flow = flow_alloc()))
|
||||
return;
|
||||
|
||||
flow_initiate(flow, PIF_TAP);
|
||||
|
||||
if (af == AF_INET) {
|
||||
if (IN4_IS_ADDR_UNSPECIFIED(saddr) ||
|
||||
IN4_IS_ADDR_BROADCAST(saddr) ||
|
||||
@@ -2000,6 +2002,7 @@ static void tcp_conn_from_tap(struct ctx *c, sa_family_t af,
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
flow_target(flow, PIF_HOST);
|
||||
conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
|
||||
conn->tapside = INISIDE;
|
||||
conn->sock = s;
|
||||
@@ -2713,7 +2716,10 @@ static void tcp_tap_conn_from_sock(struct ctx *c, in_port_t dstport,
|
||||
const union sockaddr_inany *sa,
|
||||
const struct timespec *now)
|
||||
{
|
||||
struct tcp_tap_conn *conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
|
||||
struct tcp_tap_conn *conn;
|
||||
|
||||
flow_target(flow, PIF_TAP);
|
||||
conn = FLOW_SET_TYPE(flow, FLOW_TCP, tcp);
|
||||
|
||||
conn->tapside = TGTSIDE;
|
||||
conn->sock = s;
|
||||
@@ -2763,6 +2769,8 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref,
|
||||
if (s < 0)
|
||||
goto cancel;
|
||||
|
||||
flow_initiate(flow, ref.tcp_listen.pif);
|
||||
|
||||
if (sa.sa_family == AF_INET) {
|
||||
const struct in_addr *addr = &sa.sa4.sin_addr;
|
||||
in_port_t port = sa.sa4.sin_port;
|
||||
|
Reference in New Issue
Block a user