vrrp: For use_vmac and use_ipvlan, copy the group from the base interface #2390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.