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

Custom ifinfmsg plugin stopped working with version 0.6 #886

Closed
MJDickensheets opened this issue Mar 4, 2022 · 6 comments
Closed

Custom ifinfmsg plugin stopped working with version 0.6 #886

MJDickensheets opened this issue Mar 4, 2022 · 6 comments

Comments

@MJDickensheets
Copy link

We have been using a custom plugin module and adding it to the ifinfmsg handler via the following procedure:

from pyroute2.netlink.rtnl import ifinfmsg
ifinfmsg.ifinfbase.ifinfo.data_map.update(
    ifinfmsg.load_plugins_by_path(_plugins)
)

An interface with our custom type can then be added:

ipr = IPRoute()
ipr.link("add", kind="custom-kind", msgfield1="data")

As of version 0.6, the link("add") results in pr2modules.netlink.exceptions.NetlinkError: (22, 'Invalid argument'). Some investigation revealed that the ifinfmsg instance visible to the IPRoute object did not have its ifinfo.data_map updated as we would have expected.

As a side note, it would also be nice to have a proper API with which to load plugins, particularly dynamically and not just at import time.

@svinota
Copy link
Owner

svinota commented Mar 4, 2022

Got it, working on the issue.

svinota added a commit that referenced this issue Mar 7, 2022
1. to define a custom link kind "foo"::

    # file: .../my_package/foo.py
    from pyroute2.netlink import nla

    class foo(nla):
        prefix = 'IFLA_'
        nla_map = (
            ('IFLA_FOO_UNSPEC', 'none),
            ('IFLA_FOO_PARAM', 'uint16'),
        )

    # your code
    import my_package
    from my_package.foo import foo

    ipr = IPRoute()
    ipr.register_link_kind(path='.../my_package/')
    ipr.register_link_kind(package=my_package)
    ipr.register_link_kind(module={'foo': foo})

Bug-Url: #886
@svinota
Copy link
Owner

svinota commented Mar 7, 2022

@MJDickensheets pls review the commit: 7dd1d55

it is also possible to override existing kinds like to make your own bridge, bond etc. implementation

@MJDickensheets
Copy link
Author

Looks like there may be a left-over print statement, but otherwise I think this will do very nicely for our purposes. Thank you for the quick work!

svinota added a commit that referenced this issue Mar 7, 2022
@svinota
Copy link
Owner

svinota commented Mar 7, 2022

Please reopen the ticket if there will be issues with the functionality, I'm to fix it asap.

@svinota svinota added the fixed label Mar 7, 2022
@svinota svinota closed this as completed Mar 7, 2022
@MJDickensheets
Copy link
Author

I have tested the fix/feature from my end, everything appears to be working as expected. Would it be possible to schedule a tagged release in the near term?

@svinota
Copy link
Owner

svinota commented Mar 9, 2022

0.6.8 is to be tagged on Saturday.

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

No branches or pull requests

2 participants