jpirko / libteam

team netdevice library
GNU Lesser General Public License v2.1
231 stars 59 forks source link

How to use lacp runner with port priority? #77

Open batmancn opened 7 months ago

batmancn commented 7 months ago

Hi all,

I'm using teamd-v1.31(tag v1.31) from source compile from https://github.com/jpirko/libteam .

This is my network topo:

teamd-1
    |              |
    veth11    veth01
    |              |
    |              |
    veth10    veth00
    |              |
teamd-0

Which is run team-1 with veth11 and veth01, run team-2 with veth10 and veth00.

This is my conf:

### teamd-0

[root@centos8-20240407 public-libteam]# cat ../lacp-t0.conf
{
    "device":       "team0",
    "runner": {
        "name": "lacp",
                "sys_prio": 5,
        "agg_select_policy": "lacp_prio",
        "active": true,
        "tx_hash": ["eth", "ipv4", "ipv6"]
    },
    "link_watch":       {"name": "ethtool"},
    "ports":        {
        "veth00": {"lacp_prio": 30},
        "veth10": {"lacp_prio": 20}
    }
}

### teamd-1

[root@centos8-20240407 public-libteam]# cat ../lacp-t1.conf
{
    "device":       "team0",
    "runner": {
        "name": "lacp",
                "sys_prio": 66,
        "active": true,
        "tx_hash": ["eth", "ipv4", "ipv6"]
    },
    "link_watch":       {"name": "ethtool"},
    "ports":        {
        "veth01": {},
        "veth11": {}
    }
}

Then I run these commands on teamd-0 and teamd-1:

./teamd/teamd -f ../lacp-tX.conf -g -l stdio
ip link set team0 up

In my opinion and code, I think this conf will cause this behavior:

But in fact, veth11 and veth10 is UP, veth01 and veth00 is also UP.

### teamd-0

[root@centos8-20240407 public-libteam]# ip netns exec t0 utils/teamdctl -vvv t0 state dump
{
    "ports": {
        "veth00": {
            "ifinfo": {
                "dev_addr": "2a:2b:fc:7f:11:6f",
                "dev_addr_len": 6,
                "ifindex": 16,
                "ifname": "veth00"
            },
            "link": {
                "duplex": "full",
                "speed": 10000,
                "up": true
            },
            "link_watches": {
                "list": {
                    "link_watch_0": {
                        "delay_down": 0,
                        "delay_up": 0,
                        "down_count": 0,
                        "name": "ethtool",
                        "up": true
                    }
                },
                "up": true
            },
            "runner": {
                "actor_lacpdu_info": {
                    "key": 0,
                    "port": 16,
                    "port_priority": 30,
                    "state": 61,
                    "system": "2a:2b:fc:7f:11:6f",
                    "system_priority": 5
                },
                "aggregator": {
                    "id": 18,
                    "selected": true
                },
                "key": 0,
                "partner_lacpdu_info": {
                    "key": 0,
                    "port": 15,
                    "port_priority": 255,
                    "state": 61,
                    "system": "82:24:a6:f9:13:91",
                    "system_priority": 66
                },
                "prio": 30,
                "selected": true,
                "state": "current"
            }
        },
        "veth10": {
            "ifinfo": {
                "dev_addr": "2a:2b:fc:7f:11:6f",
                "dev_addr_len": 6,
                "ifindex": 18,
                "ifname": "veth10"
            },
            "link": {
                "duplex": "full",
                "speed": 10000,
                "up": true
            },
            "link_watches": {
                "list": {
                    "link_watch_0": {
                        "delay_down": 0,
                        "delay_up": 0,
                        "down_count": 0,
                        "name": "ethtool",
                        "up": true
                    }
                },
                "up": true
            },
            "runner": {
                "actor_lacpdu_info": {
                    "key": 0,
                    "port": 18,
                    "port_priority": 20,
                    "state": 61,
                    "system": "2a:2b:fc:7f:11:6f",
                    "system_priority": 5
                },
                "aggregator": {
                    "id": 18,
                    "selected": true
                },
                "key": 0,
                "partner_lacpdu_info": {
                    "key": 0,
                    "port": 17,
                    "port_priority": 255,
                    "state": 61,
                    "system": "82:24:a6:f9:13:91",
                    "system_priority": 66
                },
                "prio": 20,
                "selected": true,
                "state": "current"
            }
        }
    },
    "runner": {
        "active": true,
        "fast_rate": false,
        "select_policy": "lacp_prio",
        "sys_prio": 5
    },
    "setup": {
        "daemonized": false,
        "dbus_enabled": false,
        "debug_level": 1,
        "kernel_team_mode_name": "loadbalance",
        "pid": 66929,
        "pid_file": "/var/run/teamd/t0.pid",
        "runner_name": "lacp",
        "zmq_enabled": false
    },
    "team_device": {
        "ifinfo": {
            "dev_addr": "2a:2b:fc:7f:11:6f",
            "dev_addr_len": 6,
            "ifindex": 4,
            "ifname": "t0"
        }
    }
}

### teamd-1

[root@centos8-20240407 public-libteam]# ip netns exec t1 utils/teamdctl -vvv t1 state dump
{
    "ports": {
        "veth01": {
            "ifinfo": {
                "dev_addr": "82:24:a6:f9:13:91",
                "dev_addr_len": 6,
                "ifindex": 15,
                "ifname": "veth01"
            },
            "link": {
                "duplex": "full",
                "speed": 10000,
                "up": true
            },
            "link_watches": {
                "list": {
                    "link_watch_0": {
                        "delay_down": 0,
                        "delay_up": 0,
                        "down_count": 0,
                        "name": "ethtool",
                        "up": true
                    }
                },
                "up": true
            },
            "runner": {
                "actor_lacpdu_info": {
                    "key": 0,
                    "port": 15,
                    "port_priority": 255,
                    "state": 61,
                    "system": "82:24:a6:f9:13:91",
                    "system_priority": 66
                },
                "aggregator": {
                    "id": 17,
                    "selected": true
                },
                "key": 0,
                "partner_lacpdu_info": {
                    "key": 0,
                    "port": 16,
                    "port_priority": 30,
                    "state": 61,
                    "system": "2a:2b:fc:7f:11:6f",
                    "system_priority": 5
                },
                "prio": 255,
                "selected": true,
                "state": "current"
            }
        },
        "veth11": {
            "ifinfo": {
                "dev_addr": "82:24:a6:f9:13:91",
                "dev_addr_len": 6,
                "ifindex": 17,
                "ifname": "veth11"
            },
            "link": {
                "duplex": "full",
                "speed": 10000,
                "up": true
            },
            "link_watches": {
                "list": {
                    "link_watch_0": {
                        "delay_down": 0,
                        "delay_up": 0,
                        "down_count": 0,
                        "name": "ethtool",
                        "up": true
                    }
                },
                "up": true
            },
            "runner": {
                "actor_lacpdu_info": {
                    "key": 0,
                    "port": 17,
                    "port_priority": 255,
                    "state": 61,
                    "system": "82:24:a6:f9:13:91",
                    "system_priority": 66
                },
                "aggregator": {
                    "id": 17,
                    "selected": true
                },
                "key": 0,
                "partner_lacpdu_info": {
                    "key": 0,
                    "port": 18,
                    "port_priority": 20,
                    "state": 61,
                    "system": "2a:2b:fc:7f:11:6f",
                    "system_priority": 5
                },
                "prio": 255,
                "selected": true,
                "state": "current"
            }
        }
    },
    "runner": {
        "active": true,
        "fast_rate": false,
        "select_policy": "lacp_prio",
        "sys_prio": 66
    },
    "setup": {
        "daemonized": false,
        "dbus_enabled": false,
        "debug_level": 1,
        "kernel_team_mode_name": "loadbalance",
        "pid": 66946,
        "pid_file": "/var/run/teamd/team1.pid",
        "runner_name": "lacp",
        "zmq_enabled": false
    },
    "team_device": {
        "ifinfo": {
            "dev_addr": "82:24:a6:f9:13:91",
            "dev_addr_len": 6,
            "ifindex": 5,
            "ifname": "t1"
        }
    }
}

So: 1) What's wrong with my configure? 2) How to configure use lacp port priority?

batmancn commented 7 months ago

Even if I change teamd-1 conf as this, also all port UP:

[root@centos8-20240407 public-libteam]# cat ../lacp-t1.conf
{
    "device":       "team0",
    "runner": {
        "name": "lacp",
                "sys_prio": 66,
        "active": true,
        "tx_hash": ["eth", "ipv4", "ipv6"]
    },
    "link_watch":       {"name": "ethtool"},
    "ports":        {
        "veth01": {"lacp_prio": 60},
        "veth11": {"lacp_prio": 50}
    }
}