-
Notifications
You must be signed in to change notification settings - Fork 96
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 mesh information packages async implmentation and reference state #1112
Merged
Merged
Changes from 45 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
97c6e58
shared-state: moving to async
javierajorge 9221be5
Merge branch 'libremesh:master' into moving_to_async
javierbrk 5a36c2c
shared-state-async: Removes cron task
javierajorge 9ab43ff
shared-state-async: move publishers to new location
javierajorge 6d1d112
shared_satate_bat_links: addss new key pair structure
javierajorge 8cceccc
adds hook to insert config
javierajorge 1f72404
fixes typo
javierajorge ccfd634
bat_links_info_ref: adds data type registration
javierajorge b53b37d
ref_state: add babel and missing bat links reference state
javierajorge e686037
ref_state: adds key index to links
javierajorge 825e1a5
Merge branch 'libremesh:master' into moving_to_async
javierbrk 331e5f0
shared-state: fiexes broken tests
javierajorge 4f5c936
shared-state: adds wifi key to info data type
javierajorge f9054bc
ref_state: implements commons package
javierajorge 2495b39
Merge branch 'moving_to_async' into f/reference_state
javierajorge 991fa73
ref_state: implement publishser
javierajorge f4d2124
ref_state: improve doc
javierajorge bea395b
ref_state: fiexes print and nodeinfo ref datatype
javierajorge 49adce0
removes reference data type old sync method
javierajorge bf3dfbb
Merge branch 'libremesh:master' into f/reference_state
javierbrk 6ce5f04
ref_state: adds insert rpc call
javierajorge 8c2a7de
ref_state: removes rpcd publish
javierajorge 9c5e287
ref_state: fixes bug in wifi interface
javierajorge af48dd6
ref_state: fixes sync with ips
javierajorge 098de02
updates packages and publisher
javierajorge f6d4f11
ref_state: renaming
javierajorge 8cd9ec5
ref_state: fixes typo
javierajorge c9084b9
fixes more typos
javierajorge c14ce5e
ref_state:fixes publication strings error
javierajorge b95fed2
ref_state: fix test for write_if_diff
javierajorge 3f55caf
change default reference state
javierajorge 8034373
Merge branch 'libremesh:master' into f/reference_state
javierbrk 5312ac4
ref_state: add missing new line at end of files and removes extra f
javierajorge 02bdc7f
ref_state: adds wifi links location
javierajorge a9224f9
ref_state: fixes location issue
javierajorge bb44561
Ref_state: removes unnecessary locations
javierajorge 1eca555
ref_state: new generic location implementation
javierbrk 0e45a85
ref_state: new generic location for bat links and babel links
javierbrk f06d125
f_ref_state: add commit at the end of the uci defaults files
javierbrk e85670d
ref_state: fix typos
javierbrk b19b1ca
Merge branch 'master' into f/reference_state
javierbrk f46ea9a
ref_state: implements persistence
javierbrk cf4c38e
ref_state: fix script dir
javierbrk 660b0ce
ref_state: fixes lime default usage
javierbrk c27def8
ref_state: fixes early call to publish error in bat_links
javierbrk e27ba12
ref_state: clean up unused functions
javierbrk 8791409
ref_state: add new line at the end of file
javierbrk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
packages/lime-app/files/etc/uci-defaults/shared-state-reference_state_nodes_info_cron
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/lime-app/files/etc/uci-defaults/shared-state-reference_state_wifi_links_info_cron
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ define Package/$(PKG_NAME) | |
TITLE:=Babel links module for shared-state | ||
MAINTAINER:=Asociación Civil Altermundi <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+libubus-lua shared-state-async | ||
+libubus-lua +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
1 change: 1 addition & 0 deletions
1
.../shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...info/files/usr/share/shared-state/hooks/babel_links_info_ref/shared-state-update_refstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,11 @@ | |
-- ! Copyright (c) 2023 Instituto Nacional de Tecnología Industrial | ||
-- ! Copyright (C) 2023 Asociación Civil Altermundi <[email protected]> | ||
-- ! | ||
-- ! This program is free software: you can redistribute it and/or modify | ||
-- ! it under the terms of the GNU Affero General Public License as | ||
-- ! published by the Free Software Foundation, either version 3 of the | ||
-- ! License, or (at your option) any later version. | ||
-- ! | ||
-- ! This program is distributed in the hope that it will be useful, | ||
-- ! but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
-- ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
-- ! GNU Affero General Public License for more details. | ||
-- ! | ||
-- ! You should have received a copy of the GNU Affero General Public License | ||
-- ! along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
-- ! SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
local JSON = require("luci.jsonc") | ||
local utils = require('lime.utils') | ||
local ubus = require "ubus" | ||
local shared_state_links_info = require ("shared_state_links_info") | ||
|
||
local ifaceip = {} | ||
|
||
|
@@ -40,16 +29,16 @@ function get_babel_links_info() | |
babelneigt_obj = ubus.call(conn, "babeld", "get_neighbours", {}) | ||
if babelneigt_obj ~= nil then | ||
for key, value in pairs(babelneigt_obj.IPv6) do | ||
table.insert(links, { | ||
local key_table = {(string.gsub(get_interface_ip(value.dev),":","")),(string.gsub(key,":",""))} | ||
table.sort(key_table) | ||
links[table.concat(key_table)]= { | ||
src_ip = get_interface_ip(value.dev), | ||
dst_ip = key, | ||
iface = value.dev | ||
}) | ||
} | ||
end | ||
end | ||
return links | ||
end | ||
|
||
local hostname = io.input("/proc/sys/kernel/hostname"):read("*line") | ||
local result = { [hostname] = get_babel_links_info() } | ||
io.popen("shared-state-async insert babel_links_info", "w"):write(JSON.stringify(result)) | ||
shared_state_links_info.insert_in_ss_with_location(get_babel_links_info(),"babel_links_info") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ define Package/$(PKG_NAME) | |
TITLE:=Batman protocol links information module for shared-state | ||
MAINTAINER:= Javier <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+lime-system +batctl-default shared-state-async | ||
+lime-system +batctl-default +shared-state-ref_state_commons shared-state-async | ||
PKGARCH:=all | ||
endef | ||
|
||
|
1 change: 1 addition & 0 deletions
1
...ages/shared-state-bat_links_info/files/etc/shared-state/ref_state/bat_links_info_ref.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,18 @@ unique_append() | |
{ | ||
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not used anymore should be removed, also the script should be renamed ;) |
||
|
||
## information generator datatype | ||
uci set shared-state.bat_links_info=dataType | ||
uci set shared-state.bat_links_info.name='bat_links_info' | ||
uci set shared-state.bat_links_info.scope='community' | ||
uci set shared-state.bat_links_info.ttl='2400' | ||
uci set shared-state.bat_links_info.update_interval='30' | ||
|
||
## Reference state data type | ||
uci set shared-state.bat_links_info_ref=dataType | ||
uci set shared-state.bat_links_info_ref.name='bat_links_info_ref' | ||
uci set shared-state.bat_links_info_ref.scope='community' | ||
uci set shared-state.bat_links_info_ref.ttl='2400' | ||
uci set shared-state.bat_links_info_ref.update_interval='50' | ||
|
||
uci commit shared-state |
1 change: 1 addition & 0 deletions
1
...s_info/files/usr/share/shared-state/hooks/bat_links_info_ref/shared-state-update_refstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/usr/bin/shared-state-update_refstate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,12 @@ | |
--! Copyright (C) 2023 Javier Jorge <[email protected]> | ||
--! Copyright (C) 2023 Asociación Civil Altermundi <[email protected]> | ||
--! | ||
--! This program is free software: you can redistribute it and/or modify | ||
--! it under the terms of the GNU Affero General Public License as | ||
--! published by the Free Software Foundation, either version 3 of the | ||
--! License, or (at your option) any later version. | ||
--! | ||
--! This program is distributed in the hope that it will be useful, | ||
--! but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
--! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
--! GNU Affero General Public License for more details. | ||
--! | ||
--! You should have received a copy of the GNU Affero General Public License | ||
--! along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--! SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
local JSON = require("luci.jsonc") | ||
local utils = require('lime.utils') | ||
local network = require ("lime.network") | ||
|
||
local hostname = utils.hostname() | ||
local shared_state_links_info = require ("shared_state_links_info") | ||
|
||
function get_bat_links_info() | ||
local bat_neighbors_obj={} | ||
|
@@ -34,25 +22,30 @@ function get_bat_links_info() | |
bat_neighbors = string.gsub(bat_neighbors,"neigh_address","dst_mac") | ||
bat_neighbors = string.gsub(bat_neighbors,"hard_ifname","iface") | ||
bat_neighbors_obj = JSON.parse(bat_neighbors) | ||
|
||
for key,neight_value in pairs (bat_neighbors_obj) do | ||
local macparts = network.get_mac(neight_value.iface) | ||
local src_macaddr = table.concat(macparts,":") | ||
neight_value.hard_ifindex=nil | ||
neight_value.src_mac=src_macaddr | ||
for key,originator_value in pairs (bat_originators_obj) do | ||
if originator_value.hard_ifname == neight_value.iface and | ||
originator_value.neigh_address== originator_value.orig_address and | ||
originator_value.neigh_address== neight_value.dst_mac then | ||
-- Batman "transmit link quality" (tq) is a byte that describes | ||
-- the probability of a successful transmission towards a | ||
-- neighbor node | ||
neight_value.tq = originator_value.tq | ||
local kv_fromlinks = {} | ||
if bat_neighbors_obj then | ||
for key,neight_value in pairs (bat_neighbors_obj) do | ||
local macparts = network.get_mac(neight_value.iface) | ||
local src_macaddr = table.concat(macparts,":") | ||
neight_value.hard_ifindex=nil | ||
neight_value.src_mac=string.lower(src_macaddr) | ||
neight_value.dst_mac=string.lower(neight_value.dst_mac) | ||
for key,originator_value in pairs (bat_originators_obj) do | ||
if originator_value.hard_ifname == neight_value.iface and | ||
originator_value.neigh_address== originator_value.orig_address and | ||
originator_value.neigh_address== neight_value.dst_mac then | ||
-- Batman "transmit link quality" (tq) is a byte that describes | ||
-- the probability of a successful transmission towards a | ||
-- neighbor node | ||
neight_value.tq = originator_value.tq | ||
end | ||
end | ||
local key_table = {(string.gsub(neight_value.src_mac,":","")),(string.gsub(neight_value.dst_mac,":",""))} | ||
table.sort(key_table) | ||
kv_fromlinks[table.concat(key_table)]=neight_value | ||
end | ||
end | ||
return bat_neighbors_obj | ||
return kv_fromlinks | ||
end | ||
|
||
local result = { [hostname] = get_bat_links_info() } | ||
io.popen("shared-state-async insert bat_links_info", "w"):write(JSON.stringify(result)) | ||
shared_state_links_info.insert_in_ss_with_location(get_bat_links_info(),"bat_links_info") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
"LiMe-430b0c": [ | ||
{ | ||
"dst_mac": "02:cc:4e:1f:73:aa", | ||
"last_seen_msecs": 1560, | ||
"tq": 255, | ||
"src_mac": "02:cc:4e:43:0b:0c", | ||
"iface": "wlan2-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:1f:73:aa", | ||
"last_seen_msecs": 1000, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:43:0b:0c", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:dd:69:1c", | ||
"last_seen_msecs": 1670, | ||
"tq": 251, | ||
"src_mac": "02:ab:46:43:0b:0c", | ||
"iface": "wlan1-mesh_29" | ||
} | ||
], | ||
"cheche": [ | ||
{ | ||
"dst_mac": "02:ab:46:dd:69:1c", | ||
"last_seen_msecs": 20, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:1f:73:aa", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:43:0b:0c", | ||
"last_seen_msecs": 1300, | ||
"tq": 251, | ||
"src_mac": "02:ab:46:1f:73:aa", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:cc:4e:43:0b:0c", | ||
"last_seen_msecs": 900, | ||
"tq": 242, | ||
"src_mac": "02:cc:4e:1f:73:aa", | ||
"iface": "wlan2-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:dd:69:1c", | ||
"last_seen_msecs": 1460, | ||
"tq": 255, | ||
"src_mac": "02:58:47:1f:73:aa", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:1f:73:f6", | ||
"last_seen_msecs": 520, | ||
"tq": 255, | ||
"src_mac": "02:58:47:1f:73:aa", | ||
"iface": "wlan0-mesh_29" | ||
} | ||
], | ||
"konB-11s": [ | ||
{ | ||
"dst_mac": "02:58:47:1f:73:aa", | ||
"last_seen_msecs": 1020, | ||
"tq": 255, | ||
"src_mac": "02:58:47:dd:69:1c", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:58:47:1f:73:f6", | ||
"last_seen_msecs": 1010, | ||
"tq": 255, | ||
"src_mac": "02:58:47:dd:69:1c", | ||
"iface": "wlan0-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:1f:73:aa", | ||
"last_seen_msecs": 540, | ||
"tq": 235, | ||
"src_mac": "02:ab:46:dd:69:1c", | ||
"iface": "wlan1-mesh_29" | ||
}, | ||
{ | ||
"dst_mac": "02:ab:46:43:0b:0c", | ||
"last_seen_msecs": 1140, | ||
"tq": 255, | ||
"src_mac": "02:ab:46:dd:69:1c", | ||
"iface": "wlan1-mesh_29" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not used anymore should be removed ;)