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

Links information module for shared state according to babeld #1056

Merged
merged 11 commits into from
Mar 12, 2024

Conversation

javierbrk
Copy link
Collaborator

@javierbrk javierbrk commented Sep 28, 2023

This module incorporates links information extracted from babel using ubus infrastructure.
The module has been tested in two librerouters and the output of the shared-state-async get babel_links_info in my setup is

    "lrprimero": [
        {
            "dst_ip": "fe80::aa40:41ff:fe1f:73ab",
            "iface": "eth1-2_17",
            "src_ip": "fe80::aa40:41ff:fe1f:723b"
        },
        {
            "dst_ip": "fe80::c24a:ff:fefc:3abd",
            "iface": "eth1-2_17",
            "src_ip": "fe80::aa40:41ff:fe1f:723b"
        }
    ],
    "lrsegundo": [
        {
            "dst_ip": "fe80::aa40:41ff:fe1f:723b",
            "iface": "eth1-2_17",
            "src_ip": "fe80::aa40:41ff:fe1f:73ab"
        },
        {
            "dst_ip": "fe80::c24a:ff:fefc:3abd",
            "iface": "eth1-2_17",
            "src_ip": "fe80::aa40:41ff:fe1f:73ab"
        }
    ]
}

@G10h4ck G10h4ck added this to the mesh-wide milestone Oct 4, 2023
Copy link
Member

@G10h4ck G10h4ck left a comment

Choose a reason for hiding this comment

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

See my inline comments

-- !
-- ! 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/>.
local JSON = require("luci.jsonc")
Copy link
Member

Choose a reason for hiding this comment

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

Better add an empty line here, between license and includes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

local utils = require('lime.utils')
local ubus = require "ubus"

local ifaceip = {}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this allocated outside the function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a "cache" for IPV6 addresses

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea is that each time the script is run this structure contains an empty list witch will be filled with each call to the get_ip method. Subsequent calls will use the information contained in the list.


local ifaceip = {}

function get_interface_ip(ifname)
Copy link
Member

@G10h4ck G10h4ck Oct 4, 2023

Choose a reason for hiding this comment

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

this function may fail, is it relevant to deal with the error conditions (for example an interface that miss IPv6 link local) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added a new test, for ci and also tested locally, there is no problem with that kind of error, the result will be an empty string (non existing interfaces and no ipv6). Do you think the function should report error explicitly ? If

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.59%. Comparing base (4dc7f98) to head (f442b02).

❗ Current head f442b02 differs from pull request most recent head d4175d5. Consider uploading reports for the commit d4175d5 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1056      +/-   ##
==========================================
+ Coverage   79.56%   79.59%   +0.03%     
==========================================
  Files          53       53              
  Lines        4566     4568       +2     
==========================================
+ Hits         3633     3636       +3     
+ Misses        933      932       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@G10h4ck
Copy link
Member

G10h4ck commented Feb 8, 2024

should be ported to shared-state-async before merging

@G10h4ck G10h4ck merged commit 7b7fcd7 into libremesh:master Mar 12, 2024
1 check passed
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.

4 participants