Skip to content

Add mtu option for network attachments#1267

Open
realrajaryan wants to merge 1 commit intoapple:mainfrom
realrajaryan:users/realrajaryan/network-mtu-attachment-option
Open

Add mtu option for network attachments#1267
realrajaryan wants to merge 1 commit intoapple:mainfrom
realrajaryan:users/realrajaryan/network-mtu-attachment-option

Conversation

@realrajaryan
Copy link
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

This PR adds mtu=VALUE as a --network attachment option for container run/create, defaulting to 1280 when unspecified, with validation (1280–65535) and full plumbing through the XPC/sandbox stack to the guest kernel interface.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@realrajaryan realrajaryan requested a review from jglogan February 25, 2026 23:13
public let macAddress: MACAddress?

public init(hostname: String, macAddress: MACAddress? = nil) {
/// The MTU for the network interface (optional). Defaults to 1280 if not specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't default to 1280 here, so I wouldn't mention anything about a default.

macAddress: attachment.macAddress,
// https://github.com/apple/containerization/pull/38
mtu: 1280
mtu: attachment.mtu ?? 1280
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just set the mtu default in Utility? That's where most of the opinion about container containers is today.

return AttachmentConfiguration(
network: item.element.name,
options: AttachmentOptions(hostname: containerId, macAddress: macAddress)
options: AttachmentOptions(hostname: containerId, macAddress: macAddress, mtu: item.element.mtu)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just above the guard:

let mtu = item.element.mtu ?? 1280

private let log: Logger
private var allocator: AttachmentAllocator
private var macAddresses: [UInt32: MACAddress]
private var mtus: [UInt32: UInt32]
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of keeping track of mtu values here? I don't think mtu needs to touch the network helper at all.

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.

[Request]: Add mtu option for network attachments.

2 participants