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

shared-state-publish_dnsmasq_leases recognize IPv6 when IPv6 leases are present #975

Merged

Conversation

ilario
Copy link
Member

@ilario ilario commented Jan 27, 2023

Fix #969
I still have to test the modified code.
@pony1k can you test this?

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2023

Codecov Report

Merging #975 (ee65122) into master (8de4eb1) will increase coverage by 0.15%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
+ Coverage   77.71%   77.87%   +0.15%     
==========================================
  Files          52       52              
  Lines        4362     4388      +26     
==========================================
+ Hits         3390     3417      +27     
+ Misses        972      971       -1     
Impacted Files Coverage Δ
...i-unstuck-wa/files/usr/lib/lua/wifi_unstuck_wa.lua 100.00% <0.00%> (ø)
...kages/lime-system/files/usr/lib/lua/lime/utils.lua 85.79% <0.00%> (+0.29%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ilario
Copy link
Member Author

ilario commented Jan 27, 2023

Just realized that the if statements can be rearranged in a more useful way, will improve in a few days.

@ilario ilario force-pushed the shared-state-publish_dnsmasq_leases-IPv6 branch 2 times, most recently from eba7b15 to 0158a34 Compare January 30, 2023 08:48
@ilario
Copy link
Member Author

ilario commented Jan 30, 2023

Now the if sentences are more useful.
@pony1k can you test if this works?
Thanks!!!

if type(client_hostname) == "string" and client_hostname:len() > 1 then
-- client_ip will be nil in duid lines
-- https://dnsmasq-discuss.thekelleys.org.narkive.com/ia9YNLmE/dnsmasq-leases-file-format-specification
if client_ip and type(client_hostname) == "string" and client_hostname:len() > 1 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dhcp.leases file contains lines with hostname *, i.e.

1675107518 12:34:65:3d:ce:2b 10.51.147.128 * 01:12:34:65:3d:ce:2b
1675106752 ab:cd:15:8a:62:93 10.51.147.146 * 01:ab:cd:15:8a:62:93

It is correct that we don't want to add * into the hostTable. But I think we still want to add them into the leasesTable, which will not happen with this arrangement of if-statements.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, it makes sense, thanks! I am going to correct this today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just updated, please check it.
Thanks!

@ilario ilario force-pushed the shared-state-publish_dnsmasq_leases-IPv6 branch from 0158a34 to c762ff9 Compare January 31, 2023 12:03
@G10h4ck
Copy link
Member

G10h4ck commented Feb 1, 2023

looks ok, please test it both with anygw and without, if it works well we can merge it

@pony1k
Copy link
Contributor

pony1k commented Feb 2, 2023

I have tested it on different routers with and without anygw. It works fine except one thing: As stated in the man-page, when dnsmasq calls the script with add for an ipv6-lease, it will pass the duid of the host instead of the mac-address. The duid then appears in the /tmp/dhcp.hosts_remote-file in other nodes, in the place where the mac-address would be. The man-page of dnsmasq states that in this case, the duid should be prefixed with id:. I.e.
id:00:01:00:01:29:9d:9c:12:00:4c:e0:ab:cd:ef,[fd43:1508:3393:fe00::d312]
instead of
00:01:00:01:29:9d:9c:12:00:4c:e0:ab:cd:ef,[fd43:1508:3393:fe00::d312]

@ilario
Copy link
Member Author

ilario commented Feb 6, 2023

@pony1k with the current code of this PR, that should not appear at all: a line like

1674755842 1276192316 fd70:d3e4:df63:184d::ccbf katze 00:04:eb:cf:8f:90:ce:2c:e3:20:12:55:c6:fe:9b:c7:16:ee

does not get added to leasesTable which is then used for generating /tmp/dhcp.hosts_remote as it will match the not tonumber(second field of the string that usually is the MAC).

But I think I got what you mean: that also this line should be added but using the last field prefixed with id:.
I can add that over the next days :)
Thanks!

@pony1k
Copy link
Contributor

pony1k commented Feb 6, 2023

does not get added to leasesTable which is then used for generating /tmp/dhcp.hosts_remote as it will match the not tonumber(second field of the string that usually is the MAC).

It does not get added to leasesTable, but it still ends up in the dnsmasq-leases.json. Look in the add_lease-function. This function gets called when the script is run with add as first argument.

But I think I got what you mean: that also this line should be added but using the last field prefixed with id:. I can add that over the next days :)

I'm not sure if it should. Maybe it's fine to not share ipv6-leases, since collisions are very unlikely. I haven't reflected on this.

@ilario
Copy link
Member Author

ilario commented Feb 6, 2023

does not get added to leasesTable which is then used for generating /tmp/dhcp.hosts_remote as it will match the not tonumber(second field of the string that usually is the MAC).

It does not get added to leasesTable, but it still ends up in the dnsmasq-leases.json. Look in the add_lease-function. This function gets called when the script is run with add as first argument.

Ooh, ok!
I will modify that also there then!

But I think I got what you mean: that also this line should be added but using the last field prefixed with id:. I can add that over the next days :)

I'm not sure if it should. Maybe it's fine to not share ipv6-leases, since collisions are very unlikely. I haven't reflected on this.

Meh, it shouldn't harm neither.

@G10h4ck
Copy link
Member

G10h4ck commented Feb 7, 2023

I'm not sure if it should. Maybe it's fine to not share ipv6-leases, since collisions are very unlikely. I haven't reflected on this.

Yeah unless a very conflict prone assignation algorithm is used (never saw anything like that, plus it make no sense at all in a mesh network), no need to share IPv6 leases as the collision is so unlikely that also the RFC standards take that for granted. Most probably we didn't share those also with this motivation. As it is not needed, avoid sharing them is better, so the global state is lighter, less RAM is used, less CPU is used, less traffic is generated, everything works better.

@ilario
Copy link
Member Author

ilario commented Feb 12, 2023

Ok, I added the filter also to the add_lease function, for leaving out the IPv6.
@pony1k @G10h4ck do you think is ok now?

@G10h4ck
Copy link
Member

G10h4ck commented Feb 14, 2023

Looks good to me, @pony1k can you test this and report back so we can merge it before re-targeting?

@pony1k
Copy link
Contributor

pony1k commented Feb 15, 2023

I have tested it. It works fine. Thank you!

@ilario ilario merged commit 696bfef into libremesh:master Feb 15, 2023
@ilario
Copy link
Member Author

ilario commented Feb 15, 2023

Thank you both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shared-state-publish_dnsmasq_leases errors
4 participants