From 8a88284568e1573aa970e04f5a05efb126a527c1 Mon Sep 17 00:00:00 2001 From: longxiucai Date: Wed, 14 Oct 2026 16:27:05 +0800 Subject: [PATCH] Fix macvlan gateway interface detection for names with dots or dashes (#13642) The [[:alnum:]]* capture truncates interface names at the first character that is not a letter or digit: eth0.100 (VLAN) becomes eth0, br-9a93... becomes br, bond0.200 becomes bond0. The result feeds node_default_gateway_interface, which the macvlan MASQUERADE rules use as the -o match (RedHat post-up/post-down and the Flatcar NAT service under enable_nat_default_gateway), so pod traffic egressing the default gateway loses NAT because the rule references a wrong or nonexistent interface. Capture the whole whitespace-delimited token after ' dev ' instead. The leading space also keeps the greedy match from latching onto names that themselves end in 'dev' (e.g. lan-dev). --- roles/network_plugin/macvlan/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network_plugin/macvlan/tasks/main.yml b/roles/network_plugin/macvlan/tasks/main.yml index a274fafb1..c35f3597f 100644 --- a/roles/network_plugin/macvlan/tasks/main.yml +++ b/roles/network_plugin/macvlan/tasks/main.yml @@ -11,7 +11,7 @@ - name: Macvlan | Retrieve default gateway network interface become: false - raw: ip -4 route list 0/0 | sed 's/.*dev \([[:alnum:]]*\).*/\1/' + raw: ip -4 route list 0/0 | sed -E 's/.* dev ([^ ]+).*/\1/' changed_when: false register: node_default_gateway_interface_cmd