Skip to content

Conversation

@nmezhenskyi
Copy link
Contributor

@nmezhenskyi nmezhenskyi commented May 28, 2025

Fixes #15479.

This is to prevent lxc network info <net> failing when used on a macvlan network.

Example output:

root@vm1:~/lxd# lxc network info net1
Name: net1
MAC address: ab:cd:ef:12:34:56
MTU: 1500
State: up
Type: broadcast

Network usage:
  Bytes received: 0B
  Bytes sent: 0B
  Packets received: 0
  Packets sent: 0

@nmezhenskyi nmezhenskyi marked this pull request as draft May 28, 2025 18:03
@nmezhenskyi nmezhenskyi requested a review from simondeziel May 28, 2025 21:22
@nmezhenskyi nmezhenskyi marked this pull request as ready for review May 28, 2025 21:24
@nmezhenskyi nmezhenskyi requested a review from tomponline May 28, 2025 21:24
Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a tiny comment.

This is to prevent `lxc network info <net>` failing when used on
a macvlan network.

Signed-off-by: Nikita Mezhenskyi <[email protected]>
Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

mtu = parentState.Mtu
}

return &api.NetworkState{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you didnt use the state returned by resources.GetNetworkState directly, and just modify the MTU field if the network config overrode the MTU from the parent?

Did you explicitly want to exclude the Counters and Addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you explicitly want to exclude the Counters and Addresses?

Yes, I thought these might be confusing for the user since they're related to the parent interface. As a user, I'd probably expect the Addresses to show all associated container/vm NIC IPs. And I saw that we also explicitly exclude the Counters for ovn networks.

What are your thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I saw that we also explicitly exclude the Counters for ovn networks.

That is because OVN networks dont have a parent as such.

I thought these might be confusing for the user since they're related to the parent interface.

Yes I suppose so, the addresses and counters of the macvlan parent, whilst might be partially relevant/associated to the NICs hanging off of it are not exclusively related to the macvlan NICs, so I think your decision makes sense.

Thanks!

lxc network create "${ctName}net" --type=macvlan parent="${ctName}"

echo "==> Check that lxc network info succeeds for macvlan network."
lxc network info "${ctName}net"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also test for the MTU override logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will do

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tomponline tomponline merged commit 2b5132a into canonical:main Jun 3, 2025
30 checks passed
tomponline added a commit that referenced this pull request Jun 6, 2025
…15718)

Follow-up to #15682.  

Adds tests to check that `lxc network info` shows correct MTU values for
a macvlan network.
@nmezhenskyi nmezhenskyi deleted the fix-macvlan-info branch June 10, 2025 13:29
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

Successfully merging this pull request may close these issues.

LXD macvlan network issue

3 participants