Interface MTU has to be equal or less then 32767 (2^15-1), but it should be 2^16-1 #1936

Closed
opened 2025-12-29 17:20:44 +01:00 by adam · 1 comment
Owner

Originally created by @ghost on GitHub (Aug 13, 2018).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.3.8-dev

Steps to Reproduce

Edit an interface of a device, and set an MTU of i.e. 65536.

Expected Behavior

Accept an 16-bit value, or at least 16-bit minus 1.

Observed Behavior

Netbox threw an error: "Ensure this value is less than or equal to 32767."

Additional notes

I'm somehow confused that Linux has an MTU for the loopback interface lo a value of 65536, seen by

# cat /sys/class/net/lo/mtu
65536
# uname -r
4.17.0-1-amd64

but regarding to https://tools.ietf.org/html/rfc791 the maximum value of MTU is just 65535 (2^16-1).

The value of 2^16 comes directly from https://github.com/torvalds/linux/blob/master/drivers/net/loopback.c#L176

	dev->mtu	= 64 * 1024;

So one thing is that the max. MTU in netbox is not as big as the RFC says it can be; and why David and Eric had chosen 2^16 instead of 2^16-1 is another :)

Originally created by @ghost on GitHub (Aug 13, 2018). ### Environment * Python version: 3.5.2 * NetBox version: 2.3.8-dev ### Steps to Reproduce Edit an interface of a device, and set an MTU of i.e. 65536. ### Expected Behavior Accept an 16-bit value, or at least 16-bit minus 1. ### Observed Behavior Netbox threw an error: "Ensure this value is less than or equal to 32767." ### Additional notes I'm somehow confused that Linux has an MTU for the loopback interface `lo` a value of `65536`, seen by ``` # cat /sys/class/net/lo/mtu 65536 # uname -r 4.17.0-1-amd64 ``` but regarding to https://tools.ietf.org/html/rfc791 the maximum value of MTU is just `65535` (`2^16-1`). The value of `2^16` comes directly from https://github.com/torvalds/linux/blob/master/drivers/net/loopback.c#L176 ``` dev->mtu = 64 * 1024; ``` So one thing is that the max. MTU in netbox is not as big as the RFC says it can be; and why David and Eric had chosen `2^16` instead of `2^16-1` is another :)
adam added the type: bugstatus: accepted labels 2025-12-29 17:20:44 +01:00
adam closed this issue 2025-12-29 17:20:44 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 13, 2018):

This is because we use a PositiveSmallIntegerField to store the MTU, which uses a signed 16-bit small integer for the database column but only allows positive values.

To accommodate values larger than 32767 we would need to migrate this to a PositiveIntegerField and add a validator to limit the maximum to 65535 (or 65536?).

@jeremystretch commented on GitHub (Aug 13, 2018): This is because we use a [`PositiveSmallIntegerField`](https://docs.djangoproject.com/en/2.0/ref/models/fields/#positivesmallintegerfield) to store the MTU, which uses a signed 16-bit [small integer](https://www.postgresql.org/docs/9.6/static/datatype-numeric.html) for the database column but only allows positive values. To accommodate values larger than 32767 we would need to migrate this to a `PositiveIntegerField` and add a validator to limit the maximum to 65535 (or 65536?).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1936