Skip to content

Skip routing rules for default mac interface#71

Merged
nmeyerhans merged 1 commit into
amazonlinux:mainfrom
brddan:main
Sep 29, 2022
Merged

Skip routing rules for default mac interface#71
nmeyerhans merged 1 commit into
amazonlinux:mainfrom
brddan:main

Conversation

@brddan
Copy link
Copy Markdown
Contributor

@brddan brddan commented Sep 29, 2022

Issue #, if available: N/A

Description of changes:

Changed lib.sh setup_interface() to fetch the default mac and the device-number for the interface being setup from IMDS. Also changed to skip writing the routing rules table entry for the current interface if it's device-number is 0 (zero) and it's mac matches the default mac for the instance. Also fixed a bug in how $ifid is derived from the interface name by having it also remove uppercase characters from the name.

This change was made to resolve a problem where docker containers could not communicate with each other or with the host instance. Network traffic was exiting the container correctly but responses would be routed elsewhere instead of being sent back to the container.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Copy Markdown
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

Can you also expand a bit on the commit message? Ideally it'll at least contain the same explanation of the change that the PR overview has.

Comment thread lib/lib.sh Outdated
Comment thread lib/lib.sh Outdated
@brddan brddan requested a review from nmeyerhans September 29, 2022 16:31
Copy link
Copy Markdown
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

Changes themselves look ready to go.

Before we merge, can you:

  1. Squash this down to a single commit
  2. Ensure the commit subject (first line of the commit message) is <50 characters long
  3. Flesh out the commit body a bit more. Describe the problem and how you fixed it

You can then force-push the squashed commit to your existing branch.

There are a bunch of resources, online for writing commit messages, but many of them are too more prosciptive than we need. This one is fairly lightweight and worth a quick read, though.

Changed lib.sh setup_interface() to fetch the default mac and the device-
number for the interface being setup from IMDS. Also changed to skip
writing the routing rules table entry for the current interface if it's
device-number is 0 (zero) and it's mac matches the default mac for the
instance. Also fixed a bug in how $ifid is derived from the interface
name by having it also remove uppercase characters from the name.

This change was made to resolve a problem where docker containers could
not communicate with each other or with the host instance. Network
traffic was exiting the container correctly but responses would be
routed elsewhere instead of being sent back to the container.
@brddan brddan changed the title Skip rules for default mac Skip routing rules for default mac interface Sep 29, 2022
Comment thread lib/lib.sh
for family in 4 6; do
changes+=$(create_rules "$iface" "$ifid" $family)
if [ "$device_number" -eq 0 ] && [ "$ether" = "$default_mac" ]; then
debug "Skipping ipv$family rules for default ENI $iface $ether $default_mac $device_number"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thinking about this a little more, I realized that we're still creating the extra routing tables in the create_if_overrides function. I don't think this is a blocker, because the important thing here is that we're skipping rule creation and that the main table has everything we need.

This should be revisited in the future though, as we shouldn't be creating unused resources like this.

@nmeyerhans nmeyerhans merged commit a8580fa into amazonlinux:main Sep 29, 2022
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.

2 participants