Skip to content

LinkAttribute in LinkAddRequest ignored? #72

Open
@KarstenB

Description

@KarstenB

I am trying to create a veth pair with a fixed number of rxqueues.

On the shell I do:

ip link add dev veth0 numrxqueues 1 type veth peer name veth1
ip -j -d link show veth0 | jq '.[0].num_rx_queues'
# 1

However the following code produces a veth0 with 32 rxques af it the attribute was ignored.

#[cfg(test)]
mod test {
    use futures::TryStreamExt;
    use netlink_packet_route::link::LinkAttribute;

    #[tokio::test]
    async fn test_veth_creation() {
        let (connection, handle, _) = rtnetlink::new_connection().unwrap();
        tokio::spawn(connection);
        let mut request = handle.link().add();
        request
            .message_mut()
            .attributes
            .push(netlink_packet_route::link::LinkAttribute::NumRxQueues(1));
        let if_name = "veth0".to_string();
        let peer_name = "veth1".to_string();
        request = request.veth(if_name.clone(), peer_name);
        request.execute().await.unwrap();

        // Interface should be created by now with 1 RX queue
        let num_rx_queues = handle
            .link()
            .get()
            .match_name(if_name.to_string())
            .execute()
            .try_next()
            .await
            .unwrap()
            .map(|link| {
                link.attributes.iter().find_map(|attr| match attr {
                    LinkAttribute::NumRxQueues(link) => Some(*link),
                    _ => None,
                })
            })
            .flatten()
            .unwrap();
        assert_eq!(num_rx_queues, 1);
    }
}

The test fails and it shows 32 queues.

ip -j -d link show veth0 | jq '.[0].num_rx_queues'
# 32

Am I doing something wrong?
Thanks for any help in advance,
Karsten

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions