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

Fix wrong interface match when using the "iface-regex" option #1536

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

spideyfusion
Copy link
Contributor

Description

We've noticed that when using the iface-regex CLI option, the wrong interface would get selected even though it was the only interface matching the IP specified in the regex pattern.

Upon closer inspection of the code, it looks like attempting to break away from the main for loop only exits the switch statement.

This makes it so when there is a regex match, as we continue iterating through all the available network interfaces, the last element will always get stored since ifaceToMatch is passed by reference.

Scenario

Interface list

3: enp3s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d0:50:99:fe:29:21 brd ff:ff:ff:ff:ff:ff
    inet 172.16.15.2/16 brd 172.16.255.255 scope global enp3s0f1
       valid_lft forever preferred_lft forever

...

166872: vethf134d2d5@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master cni0 state UP group default
    link/ether 82:82:b4:8d:b5:bc brd ff:ff:ff:ff:ff:ff link-netns cni-206b7340-a74b-2ae2-999d-6f4ecc4a3398
    inet6 fe80::8082:b4ff:fe8d:b5bc/64 scope link
       valid_lft forever preferred_lft forever

Launch options used

./flanneld --ip-masq --kube-subnet-mgr --iface-regex=^172\\.16\\.

Expected result

I0207 09:15:43.273911       1 main.go:698] Using interface with name enp3s0f1 and address 172.16.15.2
I0207 09:15:43.273930       1 main.go:720] Defaulting external address to interface address (172.16.15.2)

Actual result

I0207 09:15:43.273911       1 main.go:698] Using interface with name vethf134d2d5 and address 172.16.15.2
I0207 09:15:43.273930       1 main.go:720] Defaulting external address to interface address (172.16.15.2)

Todos

  • Tests
  • Documentation
  • Release note

Release Note

None required

ttys3 added a commit to ttys3/flannel that referenced this pull request Feb 16, 2022
@luthermonson luthermonson merged commit f8aa6a7 into flannel-io:master Feb 17, 2022
ttys3 added a commit to ttys3/flannel that referenced this pull request Feb 17, 2022
ttys3 added a commit to ttys3/flannel that referenced this pull request Feb 18, 2022
ttys3 added a commit to ttys3/flannel that referenced this pull request Feb 23, 2022
ttys3 added a commit to ttys3/flannel that referenced this pull request Feb 26, 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.

None yet

2 participants