summaryrefslogtreecommitdiff
path: root/include/net/af_unix.h
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2024-03-25 23:24:15 +0300
committerJakub Kicinski <kuba@kernel.org>2024-03-29 18:27:59 +0300
commit6ba76fd2848e107594ea4f03b737230f74bc23ea (patch)
treeeea4636063f3c09114f1df07b22f74171b41c369 /include/net/af_unix.h
parent22c3c0c52d32f41cc38cd936ea0c93f22ced3315 (diff)
downloadlinux-6ba76fd2848e107594ea4f03b737230f74bc23ea.tar.xz
af_unix: Iterate all vertices by DFS.
The new GC will use a depth first search graph algorithm to find cyclic references. The algorithm visits every vertex exactly once. Here, we implement the DFS part without recursion so that no one can abuse it. unix_walk_scc() marks every vertex unvisited by initialising index as UNIX_VERTEX_INDEX_UNVISITED and iterates inflight vertices in unix_unvisited_vertices and call __unix_walk_scc() to start DFS from an arbitrary vertex. __unix_walk_scc() iterates all edges starting from the vertex and explores the neighbour vertices with DFS using edge_stack. After visiting all neighbours, __unix_walk_scc() moves the visited vertex to unix_visited_vertices so that unix_walk_scc() will not restart DFS from the visited vertex. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Link: https://lore.kernel.org/r/20240325202425.60930-6-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/af_unix.h')
-rw-r--r--include/net/af_unix.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index f31ad1166346..970a91da2239 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -33,12 +33,14 @@ struct unix_vertex {
struct list_head edges;
struct list_head entry;
unsigned long out_degree;
+ unsigned long index;
};
struct unix_edge {
struct unix_sock *predecessor;
struct unix_sock *successor;
struct list_head vertex_entry;
+ struct list_head stack_entry;
};
struct sock *unix_peer_get(struct sock *sk);