Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update sample scripts to use iproute #165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kaechele
Copy link
Contributor

Old ioctl based tools like brctl are deprecated and have been
removed from the default package set of some distributions.

Also drop usage of ebtables in favour of native bridge port isolation
available in kernels 4.18 and newer.

Signed-off-by: Felix Kaechele [email protected]

Old `ioctl` based tools like `brctl` are deprecated and have been
removed from the default package set of some distributions.

Also drop usage of ebtables in favour of native bridge port isolation
available in kernels 4.18 and newer.

Signed-off-by: Felix Kaechele <[email protected]>

# Turn on bridge port isolation
bridge link set dev $INTERFACE isolated on
Copy link
Member

Choose a reason for hiding this comment

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

This looks nicer than ebtables indeed, but OTOH there is a race condition here now, is there? Between the time this is added to the bridge, and when this bridge link set is executed, the host can communicate with all other hosts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I think you might be right. Maybe we can up the link only after setting isolated on. I'll test that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would a similar "isolated on" be needed in the mtu_changed script?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just checked, and yes, it would be necessary to set to isolated again when changing bridges with the mtu script. The port status can be seen in /sys/class/net/$INTERFACE/brport/isolated

Also, it's not necessary to use the bridge command. You can also simply echo 1 > /sys/class/net/$INTERFACE/brport/isolated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a fix to my branch. Thanks for testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still recommend doing the port isolation with echo 1 > /sys/class/net/$INTERFACE/brport/isolated since it does not depend on bridge being installed.

This is most likely only important for embedded devices which try to minimize the amount of packages installed on the system.

@@ -16,8 +16,6 @@ ensure_bridge()
ip addr add 10.254.0.2/16 dev $brname
# TODO Policy routing should probably not be hardcoded here?
ensure_policy from all iif $brname lookup mesh prio 1000
# Disable forwarding between bridge ports
ebtables -A FORWARD --logical-in $brname -j DROP
Copy link
Member

Choose a reason for hiding this comment

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

Why didn't you put the isolation on here? That would avoid having to audit all places where ensure_bridge is used.

Copy link
Contributor

Choose a reason for hiding this comment

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

You have to do the isolation per port, and isolating the bridge interface itself would mean that none of the attached bridge porst would be able to communicate with host.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pmelange is correct. isolation on is a function of the bridge port, not the bridge itself. As such it would functionally belong into the session handler scripts.


# Bring the tunnel interface up only after port isolation is enabled
ip link set dev $INTERFACE up
Copy link
Contributor

@pmelange pmelange Aug 8, 2023

Choose a reason for hiding this comment

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

I believe that just removing the interface from the old bridge does not bring the interface down. So, I suggest just after removing the interface from the old bridge, do an ip link set dev $INTERFACE down

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will need to test this. Conversely, if what you say is true we could, things should continue to work even if we don't bring up the interface as we add it to the bridge for the new MTU value.

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.

3 participants