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

enable IPRoute to pass teamd config #699

Open
jtluka opened this issue Apr 16, 2020 · 6 comments
Open

enable IPRoute to pass teamd config #699

jtluka opened this issue Apr 16, 2020 · 6 comments
Labels

Comments

@jtluka
Copy link

jtluka commented Apr 16, 2020

Currently it is impossible to add a team device with specific configuration using IPRoute. Instead a hardcoded config is used.

Code sample:

from pyroute2 import IPRoute                                                    
                                                                                
ipr = IPRoute()
ret_val = ipr.link('add', ifname='myteam', kind='team')
$ pgrep -fa teamd
5727 teamd -d -n -c {"device": "myteam", "runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}
@svinota svinota added the bug label Apr 16, 2020
@svinota
Copy link
Owner

svinota commented Apr 16, 2020

Yep, to be fixed asap. Thanks for heads-up!

svinota added a commit that referenced this issue Apr 16, 2020
@svinota
Copy link
Owner

svinota commented Apr 16, 2020

It should work now like that:

import json
from pyroute2 import IPRoute

config = {'runner': {'name': 'activebackup'},
          'link_watch': {'name': 'ethtool'},
          'hwaddr': '00:11:22:33:44:55'}

ipr = IPRoute()
ipr.link('add',
         ifname='myteam',
         kind='team',
         team_config=json.dumps(config))

Note regarding the device config option: the ifname argument for ipr.link('add',…) is mandatory, and the device option is filled authomatically from it, so you may omit it in the config.

In the case of conflict between the config and ipr.link() arguments, the arguments will override the config.

TODO: support config options like hwaddr that are common for all the devices as normal arguments as well. Not closing the issue.

@jtluka
Copy link
Author

jtluka commented Apr 16, 2020

Thanks Pete! That was fast! Ack on device being autofilled from ifname.

Tested locally with the following script:

from pyroute2 import IPRoute                                                    
import json                                                                     
                                                                                
ipr = IPRoute()                                                                 
                                                                                
obj = getattr(ipr, 'link')                                                      
                                                                                
config = {                                                                      
        'runner': {'name': 'roundrobin'},                                       
        'link_watch': {'name': 'ethtool'},                                      
        'hwaddr': '00:11:22:33:44:55'                                           
        }                                                                       
                                                                                
ret_val = obj('add', ifname='myteam', kind='team',                              
        team_config=json.dumps(config))                                         
$ sudo python3 test-pyroute-team.py
$ pgrep -fa teamd
20027 teamd -d -n -c {"runner": {"name": "roundrobin"}, "link_watch": {"name": "ethtool"}, "hwaddr": "00:11:22:33:44:55", "device": "myteam"}

@olichtne
Copy link

Hi,

I have a related question, for Team pyroute2 is directly calling teamd/teamdctl. Is this because team doesn't use netlink configuration at all or because it is somehow complicated?

I'm asking because currently LNST uses pyroute2 specifically for netlink quite a bit and it feels a little weird having Team be different but still through pyroute2...

@svinota
Copy link
Owner

svinota commented May 6, 2020

@olichtne , as I understand, team interfaces are backed with the teamd, the logic is implemented in the userspace, not in the kernel. Thus we can not simply start it by the netlink — pyroute2 can create the interface, but has no team userspace code to run the created interface.

There are several solutions. One is implemented right now: we don't run any team logic in pyroute2, but start the reference implementation, teamd by @jtluka . Another solution would be to implement all the team logic in the pyroute2 library, but I wouldn't like to do that, I simply have no time resource to write and support it.

@olichtne
Copy link

That makes sense, like I've said I'm not too familiar with how teams are implemented so I was just asking for clarification. Thanks for the answer :).

bmwiedemann added a commit to bmwiedemann/openSUSE that referenced this issue Jun 9, 2020
https://build.opensuse.org/request/show/810907
by user dirkmueller + dimstar_suse
- update to 0.5.12:
  * rtnl: implement team config pass <svinota/pyroute2#699>
  * ndb.auth: example auth modules for RADIUS and OpenStack / Keystone
  * cli: syntax fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants