Add TODO use hash map to get ip from pool

1. Use username as input to count hash then get ip index
2. Change test env cidr
This commit is contained in:
lucheng
2024-08-05 09:18:38 +08:00
parent dc49d5acd4
commit c3e8b29a83
2 changed files with 4 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ func (svc *Server) IdxFromIP(ip net.IP) int {
return int(ipInt - ipStartInt)
}
// TODO(shawnlu): Implement it with hash map, username as input to count hash
func (svc *Server) PopIPFromPool() (net.IP, error) {
for idx := 0; idx < svc.IPCount; idx++ {
if svc.IPIdxInPool(idx) {

View File

@@ -1,5 +1,5 @@
ip l add br-test type bridge
ip a add 10.66.0.254/24 dev br-test
ip a add 10.67.0.254/24 dev br-test
ip l set br-test up
ip netns add c1
@@ -8,7 +8,7 @@ ip l add hTc1 type veth peer name c1Th
ip l set hTc1 master br-test
ip l set hTc1 up
ip l set c1Th netns c1
ip netns exec c1 ip a add 10.66.0.1/24 dev c1Th
ip netns exec c1 ip a add 10.67.0.1/24 dev c1Th
ip netns exec c1 ip l set c1Th up
ip netns add c2
@@ -17,7 +17,7 @@ ip l add hTc2 type veth peer name c2Th
ip l set hTc2 master br-test
ip l set hTc2 up
ip l set c2Th netns c2
ip netns exec c2 ip a add 10.66.0.2/24 dev c2Th
ip netns exec c2 ip a add 10.67.0.2/24 dev c2Th
ip netns exec c2 ip l set c2Th up
ip netns add n1