diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-09 03:52:56 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-09 05:32:52 +0200 |
commit | d503fba828ed4b736938b7c828b1bce6e43dcb8e (patch) | |
tree | 809db0ca8b39c6b8fb751d8686dd082906505194 /src/routingtable.h | |
parent | routingtable: only use device's mutex, not a special rt one (diff) | |
download | wireguard-monolithic-historical-d503fba828ed4b736938b7c828b1bce6e43dcb8e.tar.xz wireguard-monolithic-historical-d503fba828ed4b736938b7c828b1bce6e43dcb8e.zip |
routingtable: iterate progressively
Diffstat (limited to 'src/routingtable.h')
-rw-r--r-- | src/routingtable.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/routingtable.h b/src/routingtable.h index 815118c..d8666f8 100644 --- a/src/routingtable.h +++ b/src/routingtable.h @@ -13,15 +13,22 @@ struct routing_table_node; struct routing_table { struct routing_table_node __rcu *root4; struct routing_table_node __rcu *root6; + u64 seq; +}; + +struct routing_table_cursor { + u64 seq; + struct routing_table_node *stack[128]; + unsigned int len; + bool second_half; }; void routing_table_init(struct routing_table *table); void routing_table_free(struct routing_table *table, struct mutex *mutex); -int routing_table_insert_v4(struct routing_table *table, const struct in_addr *ip, u8 cidr, struct wireguard_peer *peer, struct mutex *mutex); -int routing_table_insert_v6(struct routing_table *table, const struct in6_addr *ip, u8 cidr, struct wireguard_peer *peer, struct mutex *mutex); -void routing_table_remove_by_peer(struct routing_table *table, struct wireguard_peer *peer, struct mutex *mutex); - -int routing_table_walk_ips_by_peer(struct routing_table *table, void *ctx, struct wireguard_peer *peer, int (*func)(void *ctx, union nf_inet_addr ip, u8 cidr, int family), struct mutex *mutex); +int routing_table_insert_v4(struct routing_table *table, const struct in_addr *ip, u8 cidr, struct wireguard_peer *peer, struct mutex *lock); +int routing_table_insert_v6(struct routing_table *table, const struct in6_addr *ip, u8 cidr, struct wireguard_peer *peer, struct mutex *lock); +void routing_table_remove_by_peer(struct routing_table *table, struct wireguard_peer *peer, struct mutex *lock); +int routing_table_walk_by_peer(struct routing_table *table, struct routing_table_cursor *cursor, struct wireguard_peer *peer, int (*func)(void *ctx, const u8 *ip, u8 cidr, int family), void *ctx, struct mutex *lock); /* These return a strong reference to a peer: */ struct wireguard_peer *routing_table_lookup_dst(struct routing_table *table, struct sk_buff *skb); |