Skip to content

Support small ipv4 networks#42626

Merged
thaJeztah merged 1 commit intomoby:masterfrom
mfeit-internet2:small-ipv4-networks
Jun 7, 2022
Merged

Support small ipv4 networks#42626
thaJeztah merged 1 commit intomoby:masterfrom
mfeit-internet2:small-ipv4-networks

Conversation

@mfeit-internet2
Copy link
Copy Markdown
Contributor

This was originally in moby/libnetwork#2624, which has been closed since the code was moved here. It fixes #32444 and moby/libnetwork#2249.

What I did

When creating a new network, IPAM's address allocator attempts to reserve the network and broadcast addresses on IPv4 networks of all sizes. For RFC 3021 point-to-point networks (IPv4 /31s), this consumes both available addresses and renders any attempt to allocate an address from the block unsuccessful.

This change prevents those reservations from taking place on IPv4 networks having two or fewer addresses (i.e., /31s and /32s) while retaining the existing behavior for larger IPv4 blocks and all IPv6 blocks.

In case you're wondering why anyone would allocate /31s: I work for a network service provider. We use a lot of point-to-point networks. This cuts our address space utilization for those by 50%, which makes ARIN happy.

How I did it

The network allocator was modified to recognize when an network is too small for network and broadcast addresses and skip those reservations.

How to verify it

There are additional unit tests to make sure the functions involved behave as expected.

Try these out:

  • docker network create --driver bridge --subnet 10.200.1.0/31 --ip-range 10.200.1.0/31 test-31
  • docker network create --driver bridge --subnet 10.200.1.0/32 --ip-range 10.200.1.0/32 test-32

My installation has been running this patch in production with /31s since March.

Description for the changelog

Added support for RFC 3021 point-to-point networks (IPv4 /31s) and single hosts (IPv4 /32s).

A picture of a cute animal (not mandatory but encouraged)

How about Linda Ball's ASCII art bunny?

  //
 ('>
 /rr
*\))_

@cpuguy83
Copy link
Copy Markdown
Member

Looks like a bad rebase, maybe? There's several unrelated commits.

@mfeit-internet2
Copy link
Copy Markdown
Contributor Author

Possibly. I ran into some difficulties with getting everything signed off. Should I start over?

@cpuguy83
Copy link
Copy Markdown
Member

Maybe start a new branch from master and see if your change can be cherry-picked onto the new branch.

@thaJeztah
Copy link
Copy Markdown
Member

I think it's just because the branch wasn't up to date with master (commits that don't belong in here look to be PR's that were already merged).

I suspect a rebase should fix that (but you can duplicate your branch to have a backup if you're unsure 😅)

@thaJeztah
Copy link
Copy Markdown
Member

Tried rebasing, and that looks to automatically resolve the issue;

git fetch upstream -v
git rebase upstream/master

Rebasing (1/5)
dropping 37df8ca4734aca4e165186032fc10d7e52dda9c7 Make the network allocator handle IPv4 blocks too small for network/broadcast addresses. -- patch contents already upstream
dropping 0b9ff2bb4f0bf4d7a9dae662faf8bcf424e45366 Don't clobber network/broadcast addresses on small IPv4 networks -- patch contents already upstream
dropping 0f846d933cf7b7d0e1c6c9479f8252f2dec0f5a1 Make the network allocator handle IPv4 blocks too small for network/broadcast addresses. -- patch contents already upstream
Rebasing (5/5)
Successfully rebased and updated refs/heads/small-ipv4-networks.

(after that, a "force" push to this branch should update the PR)

@mfeit-internet2 do you want me to do the rebase and push to your branch?

@thaJeztah
Copy link
Copy Markdown
Member

Oh .. if you do a rebase, could you also squash the last two commits? (so that the fix-up commit is combined with the actual changes?)

@mfeit-internet2
Copy link
Copy Markdown
Contributor Author

@thaJeztah Sure, go for it.

@mfeit-internet2
Copy link
Copy Markdown
Contributor Author

At long last, this looks ready to go.

@mfeit-internet2
Copy link
Copy Markdown
Contributor Author

None of what failed in the last CI iteration had anything to do with the code changed here.

How do we proceed?

…roadcast addresses.

This was originally in moby/libnetwork#2624, which has been closed since the
code was moved here.

When creating a new network, IPAM's address allocator attempts to reserve the
network and broadcast addresses on IPv4 networks of all sizes. For RFC 3021
point-to-point networks (IPv4 /31s), this consumes both available addresses and
renders any attempt to allocate an address from the block unsuccessful.

This change prevents those reservations from taking place on IPv4 networks having
two or fewer addresses (i.e., /31s and /32s) while retaining the existing behavior
for larger IPv4 blocks and all IPv6 blocks.

In case you're wondering why anyone would allocate /31s:  I work for a network
service provider.  We use a lot of point-to-point networks.  This cuts our
address space utilization for those by 50%, which makes ARIN happy.

This patch modifies the network allocator to recognize when an network is too
small for network and broadcast addresses and skip those reservations.

There are additional unit tests to make sure the functions involved behave as expected.

Try these out:

 * `docker network create --driver bridge --subnet 10.200.1.0/31 --ip-range 10.200.1.0/31 test-31`
 * `docker network create --driver bridge --subnet 10.200.1.0/32 --ip-range 10.200.1.0/32 test-32`

My installation has been running this patch in production with /31s since March.

Signed-off-by: Mark Feit <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the small-ipv4-networks branch from 9d50097 to 3a938df Compare October 27, 2021 11:05
@thaJeztah
Copy link
Copy Markdown
Member

Did a rebase/squash, as it looked like some unrelated changes made it into the PR, and some fixes to CI were merged on master, so getting a fresh new run of CI

@thaJeztah thaJeztah added this to the 21.xx milestone Oct 27, 2021
@mfeit-internet2
Copy link
Copy Markdown
Contributor Author

@thaJeztah Thanks for looking into that; we're looking forward to having this in the released code.

The CI still fails on Windows for, again, nothing having to do with the changes.

@thaJeztah
Copy link
Copy Markdown
Member

Yes, CI was looking better, but then I triggered too many PRs and apparently there was a cap on the auto-scaler, so PR's got in queue waiting for Windows machines to be available; let me kick it again.

@evol262
Copy link
Copy Markdown

evol262 commented Apr 26, 2022

This looks sane in general, but it's also been open long enough that it's probably worth the effort to also support RFC6164 for /127 IPv6 point to point addressing as part of it.

I wouldn't block on this, but it's a logical addition to support for /31 addressing

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. impact/changelog labels Jun 7, 2022
@thaJeztah thaJeztah merged commit 9959ece into moby:master Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking Networking impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow networks with /31 subnet mask (point-to-point links)

4 participants