Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Support for link slave info #227

@lights0123

Description

@lights0123

Currently, slave links are just returned as raw bytes:

SlaveKind(Vec<u8>),
SlaveData(Vec<u8>),

These should be decoded just like master links. The bridge slave info can be printed currently with:

if let Nla::Info(info) = nla {
    if let Some(Info::SlaveKind(name)) = info.get(0) {
        if name == b"bridge\0" {
            if let Some(Info::SlaveData(data)) = info.get(1) {
                let iter = NlasIterator::new(data);
                for i in iter {
                    let i = i.unwrap();
                    match i.kind() {
                        0 => println!("IFLA_BRPORT_UNSPEC: {:?}", i.value()),
                        1 => println!("IFLA_BRPORT_STATE: {:?}", i.value()),
                        2 => println!("IFLA_BRPORT_PRIORITY: {:?}", i.value()),
                        3 => println!("IFLA_BRPORT_COST: {:?}", i.value()),
                        4 => println!("IFLA_BRPORT_MODE: {:?}", i.value()),
                        5 => println!("IFLA_BRPORT_GUARD: {:?}", i.value()),
                        6 => println!("IFLA_BRPORT_PROTECT: {:?}", i.value()),
                        7 => println!("IFLA_BRPORT_FAST_LEAVE: {:?}", i.value()),
                        8 => println!("IFLA_BRPORT_LEARNING: {:?}", i.value()),
                        9 => println!("IFLA_BRPORT_UNICAST_FLOOD: {:?}", i.value()),
                        10 => println!("IFLA_BRPORT_PROXYARP: {:?}", i.value()),
                        11 => println!("IFLA_BRPORT_LEARNING_SYNC: {:?}", i.value()),
                        12 => println!("IFLA_BRPORT_PROXYARP_WIFI: {:?}", i.value()),
                        13 => println!("IFLA_BRPORT_ROOT_ID: {:?}", i.value()),
                        14 => println!("IFLA_BRPORT_BRIDGE_ID: {:?}", i.value()),
                        15 => println!("IFLA_BRPORT_DESIGNATED_PORT: {:?}", i.value()),
                        16 => println!("IFLA_BRPORT_DESIGNATED_COST: {:?}", i.value()),
                        17 => println!("IFLA_BRPORT_ID: {:?}", i.value()),
                        18 => println!("IFLA_BRPORT_NO: {:?}", i.value()),
                        19 => {
                            println!("IFLA_BRPORT_TOPOLOGY_CHANGE_ACK: {:?}", i.value())
                        }
                        20 => println!("IFLA_BRPORT_CONFIG_PENDING: {:?}", i.value()),
                        21 => {
                            println!("IFLA_BRPORT_MESSAGE_AGE_TIMER: {:?}", i.value())
                        }
                        22 => {
                            println!("IFLA_BRPORT_FORWARD_DELAY_TIMER: {:?}", i.value())
                        }
                        23 => println!("IFLA_BRPORT_HOLD_TIMER: {:?}", i.value()),
                        24 => println!("IFLA_BRPORT_FLUSH: {:?}", i.value()),
                        25 => println!("IFLA_BRPORT_MULTICAST_ROUTER: {:?}", i.value()),
                        26 => println!("IFLA_BRPORT_PAD: {:?}", i.value()),
                        27 => println!("IFLA_BRPORT_MCAST_FLOOD: {:?}", i.value()),
                        28 => println!("IFLA_BRPORT_MCAST_TO_UCAST: {:?}", i.value()),
                        29 => println!("IFLA_BRPORT_VLAN_TUNNEL: {:?}", i.value()),
                        30 => println!("IFLA_BRPORT_BCAST_FLOOD: {:?}", i.value()),
                        31 => println!("IFLA_BRPORT_GROUP_FWD_MASK: {:?}", i.value()),
                        32 => println!("IFLA_BRPORT_NEIGH_SUPPRESS: {:?}", i.value()),
                        _ => {}
                    }
                }
            }
        }
    }
}

An example of the data it produces:

IFLA_BRPORT_STATE: [3]
IFLA_BRPORT_PRIORITY: [32, 0]
IFLA_BRPORT_COST: [4, 0, 0, 0]
IFLA_BRPORT_MODE: [0]
IFLA_BRPORT_GUARD: [0]
IFLA_BRPORT_PROTECT: [0]
IFLA_BRPORT_FAST_LEAVE: [0]
IFLA_BRPORT_MCAST_TO_UCAST: [0]
IFLA_BRPORT_LEARNING: [1]
IFLA_BRPORT_UNICAST_FLOOD: [1]
IFLA_BRPORT_MCAST_FLOOD: [1]
IFLA_BRPORT_BCAST_FLOOD: [1]
IFLA_BRPORT_PROXYARP: [0]
IFLA_BRPORT_PROXYARP_WIFI: [0]
IFLA_BRPORT_ROOT_ID: [128, 0, 120, 208, 4, 44, 61, 251]
IFLA_BRPORT_BRIDGE_ID: [128, 0, 120, 208, 4, 44, 61, 251]
IFLA_BRPORT_DESIGNATED_PORT: [1, 128]
IFLA_BRPORT_DESIGNATED_COST: [0, 0]
IFLA_BRPORT_ID: [1, 128]
IFLA_BRPORT_NO: [1, 0]
IFLA_BRPORT_TOPOLOGY_CHANGE_ACK: [0]
IFLA_BRPORT_CONFIG_PENDING: [0]
IFLA_BRPORT_VLAN_TUNNEL: [0]
IFLA_BRPORT_GROUP_FWD_MASK: [0, 0]
IFLA_BRPORT_NEIGH_SUPPRESS: [0]
IFLA_BRPORT_MESSAGE_AGE_TIMER: [0, 0, 0, 0, 0, 0, 0, 0]
IFLA_BRPORT_FORWARD_DELAY_TIMER: [0, 0, 0, 0, 0, 0, 0, 0]
IFLA_BRPORT_HOLD_TIMER: [0, 0, 0, 0, 0, 0, 0, 0]
IFLA_BRPORT_MULTICAST_ROUTER: [1]

These constants can be uncommented here:

// pub const IFLA_BRPORT_UNSPEC: int = 0;
// pub const IFLA_BRPORT_STATE: int = 1;
// pub const IFLA_BRPORT_PRIORITY: int = 2;
// pub const IFLA_BRPORT_COST: int = 3;
// pub const IFLA_BRPORT_MODE: int = 4;
// pub const IFLA_BRPORT_GUARD: int = 5;
// pub const IFLA_BRPORT_PROTECT: int = 6;
// pub const IFLA_BRPORT_FAST_LEAVE: int = 7;
// pub const IFLA_BRPORT_LEARNING: int = 8;
// pub const IFLA_BRPORT_UNICAST_FLOOD: int = 9;
// pub const IFLA_BRPORT_PROXYARP: int = 10;
// pub const IFLA_BRPORT_LEARNING_SYNC: int = 11;
// pub const IFLA_BRPORT_PROXYARP_WIFI: int = 12;
// pub const IFLA_BRPORT_ROOT_ID: int = 13;
// pub const IFLA_BRPORT_BRIDGE_ID: int = 14;
// pub const IFLA_BRPORT_DESIGNATED_PORT: int = 15;
// pub const IFLA_BRPORT_DESIGNATED_COST: int = 16;
// pub const IFLA_BRPORT_ID: int = 17;
// pub const IFLA_BRPORT_NO: int = 18;
// pub const IFLA_BRPORT_TOPOLOGY_CHANGE_ACK: int = 19;
// pub const IFLA_BRPORT_CONFIG_PENDING: int = 20;
// pub const IFLA_BRPORT_MESSAGE_AGE_TIMER: int = 21;
// pub const IFLA_BRPORT_FORWARD_DELAY_TIMER: int = 22;
// pub const IFLA_BRPORT_HOLD_TIMER: int = 23;
// pub const IFLA_BRPORT_FLUSH: int = 24;
// pub const IFLA_BRPORT_MULTICAST_ROUTER: int = 25;
// pub const IFLA_BRPORT_PAD: int = 26;
// pub const IFLA_BRPORT_MCAST_FLOOD: int = 27;
// pub const IFLA_BRPORT_MCAST_TO_UCAST: int = 28;
// pub const IFLA_BRPORT_VLAN_TUNNEL: int = 29;
// pub const IFLA_BRPORT_BCAST_FLOOD: int = 30;
// pub const IFLA_BRPORT_GROUP_FWD_MASK: int = 31;
// pub const IFLA_BRPORT_NEIGH_SUPPRESS: int = 32;

It appears from the iproute2 source code that only bonds and bridges have slave devices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions