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

vrrp: For use_vmac and use_ipvlan, copy the group from the base interface #2390

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

sim-
Copy link
Contributor

@sim- sim- commented Mar 1, 2024

It is useful in many instances to set up firewall rules based on interface groups so that sets of interfaces may be aggregated by group and matched with a single rule rather than by listing them all.

Prior to this change, when use_vmac or use_ipvlan is used, new interfaces are created with the default group, which breaks this ability.

Further complicating the issue is that nftables resolves interface names to ifindex at load time. This is problematic with keepalived's interface creation, which usually comes after the firewall loading, forcing the use of iifname, oifname instead (similar to iptables -i, -o).

By copying the group value, such firewall rules can continue to work regardless of the use_vmac or use_ipvlan settings, since packets may now arrive on, or be routed out from, the new interfaces.

I've tested that this works with use_vmac, but I'm not sure about use_ipvlan or cross-namespace cases. There is already a function for setting interface groups, netlink_link_group(), but it was introduced to work around a netlink issue by setting it to the current value, and it creates a whole new request, which is unnecessary here.

I've thought about other ways to make firewall rules that play more nicely with the use_vmac interfaces, but so far the best I've come up with is interface groups and iifname, oifname for all of the other cases. Eventually, maybe it would make sense for the kernel to update nft findexes dynamically whenever an interface name appears, rather than doing it only at load time.

…face

It is useful in many instances to set up firewall rules based on
interface groups so that sets of interfaces may be aggregated by group
and matched with a single rule rather than by listing them all.

Prior to this change, when use_vmac or use_ipvlan is used, new interfaces
are created with the default group, which breaks this ability.

Further complicating the issue is that nftables resolves interface names
to ifindex at load time. This is problematic with keepalived's interface
creation, which usually comes after the firewall loading, forcing the
use of iifname, oifname instead (similar to iptables -i, -o).

By copying the group value, such firewall rules can continue to work
regardless of the use_vmac or use_ipvlan settings, since packets may
now arrive on, or be routed out from, the new interfaces.

Signed-off-by: Simon Kirby <[email protected]>
@pqarmitage pqarmitage merged commit 8732924 into acassen:master Mar 1, 2024
10 checks passed
@pqarmitage
Copy link
Collaborator

Many thanks for this patch.

I can confirm that it works fine when using network namespaces, but it did not handle ipvlans.

Based on your patch I have added the following further patches:

4883311 use addattr32() for setting IFLA_GROUP rather than addattr_l(). I have changed the original code where IFLA_GROUP was being set as well.

2f3c193 Make setting the interface group to the parent's interface group work for ipvlans.

5fcaa2d This commit adds an option to explicitly set the interface group for a VMAC or ipvlan, so it can be independent of the the interface group of the parent interface.

Once again, many thanks for your patch, and I think it has led to further enhancements to keepalived.

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