Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndcli modify pool p add subnet --no-default-reserve does not have specified effect #220

Open
miesi opened this issue Mar 18, 2022 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@miesi
Copy link
Collaborator

miesi commented Mar 18, 2022

observed behaviour:

ndcli modify pool deleteme add subnet 10.120.144.0/20 --no-default-reserve
ndcli list ips 10.120.144.0/20 -L 9999 | grep Reserved
INFO - Result for list ips 10.120.144.0/20
10.120.144.0   Reserved             
10.120.144.255 Reserved             
10.120.145.0   Reserved             
10.120.145.255 Reserved             
10.120.146.0   Reserved             
10.120.146.255 Reserved             
10.120.147.0   Reserved             
10.120.147.255 Reserved             
10.120.148.0   Reserved             
10.120.148.255 Reserved             
10.120.149.0   Reserved             
10.120.149.255 Reserved             
10.120.150.0   Reserved             
10.120.150.255 Reserved             
10.120.151.0   Reserved             
10.120.151.255 Reserved             
10.120.152.0   Reserved             
10.120.152.255 Reserved             
10.120.153.0   Reserved             
10.120.153.255 Reserved             
10.120.154.0   Reserved             
10.120.154.255 Reserved             
10.120.155.0   Reserved             
10.120.155.255 Reserved             
10.120.156.0   Reserved             
10.120.156.255 Reserved             
10.120.157.0   Reserved             
10.120.157.255 Reserved             
10.120.158.0   Reserved             
10.120.158.255 Reserved             
10.120.159.0   Reserved             
10.120.159.255 Reserved             

Expected behaviour:

INFO - Result for list ips 10.120.144.0/20
10.120.144.0   Reserved          
10.120.159.255 Reserved             

empty result

@miesi miesi changed the title ndcli modify pool deleteme add subnet --no-default-reserve does not have speified effect ndcli modify pool deleteme add subnet --no-default-reserve does not have specified effect Mar 18, 2022
@miesi miesi changed the title ndcli modify pool deleteme add subnet --no-default-reserve does not have specified effect ndcli modify pool p add subnet --no-default-reserve does not have specified effect Mar 18, 2022
miesi pushed a commit that referenced this issue Mar 18, 2022
@miesi
Copy link
Collaborator Author

miesi commented Mar 18, 2022

testcase dim-testsuite/t/todo/pool-add-subnet-ndr-1.t added.

I hope the output of ndcli show ip is parsed.

@miesi miesi added this to the next milestone Apr 7, 2022
@miesi miesi added the bug Something isn't working label Apr 7, 2022
@zeromind
Copy link
Collaborator

zeromind commented Aug 8, 2023

Seems this is a naming issue again, the flag/parameter names does not match what the API and rest of the documentation calls it;
from the man page:

  ndcli modify pool POOLNAME add subnet SUBNET [gw GW] [NAME:VALUE]...
          Add SUBNET to POOLNAME. If the subnet does not exist, it is created.
[...]
       --no-default-reserve
              don't reserve network and broadcast addresses
[...]

ndcli has --no-default-reserve,
DIM API has dont_reserve_network_broadcast.
So it currently "works as expected", I guess.

dim/dim/dim/rpc.py

Lines 3749 to 3774 in 99fcbf2

def subnet_reserved_ips(subnet, dont_reserve_network_broadcast):
reserved = []
if subnet.version == 4:
if not dont_reserve_network_broadcast:
reserved.append(subnet.network)
reserved.append(subnet.broadcast)
start = subnet.network.address
end = subnet.broadcast.address
# Reserve .0 and .255 addresses because some buggy routers have problems
# with them
zero = start - (start % 256)
while zero < end:
if start <= zero:
reserved.append(IP(zero, prefix=32, version=4))
if zero + 255 <= end:
reserved.append(IP(zero + 255, prefix=32, version=4))
zero += 256
# Remove duplicates
if not dont_reserve_network_broadcast:
for address in [subnet.network, subnet.broadcast]:
if reserved.count(address) == 2:
reserved.remove(address)
elif subnet.version == 6 and not dont_reserve_network_broadcast:
reserved = [IP(subnet.address, prefix=128, version=6)]
return reserved

However, we should probably add a flag/parameter to not reserve .0s and .255s, while still reserving network and broadcast address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants