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

LinkAttribute in LinkAddRequest ignored? #72

Open
KarstenB opened this issue Jul 5, 2024 · 0 comments
Open

LinkAttribute in LinkAddRequest ignored? #72

KarstenB opened this issue Jul 5, 2024 · 0 comments

Comments

@KarstenB
Copy link

KarstenB commented Jul 5, 2024

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

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

No branches or pull requests

1 participant