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

feat: add support for --iface-regex match interface with multi IP addresses #1538

Merged
merged 7 commits into from
Feb 28, 2022

Conversation

ttys3
Copy link
Contributor

@ttys3 ttys3 commented Feb 16, 2022

Description

resolve #981

if interface has multi IPs, current match implementation will failed to get the right IP.

for example, interface dummy0 has 4 IPs:

1.10.100.1
192.168.200.128
172.16.30.18
172.16.31.200

we expect to use 192\.168\.200\.\d+ as --iface-regex option to get 192.168.200.128 matched.

Todos

  • Tests
  • Documentation
  • Release note

Release Note

None required

@ttys3 ttys3 changed the title feat: add support for ifregex match interface with multi IP addresses feat: add support for --iface-regex match interface with multi IP addresses Feb 16, 2022
@luthermonson
Copy link
Contributor

@ttys3 have you tested this on a real environment and does it fix your issues? we're ready to merge as it looks good but want to confirm

@ttys3
Copy link
Contributor Author

ttys3 commented Feb 17, 2022

@luthermonson yes, I just tested it on a new created Linux node. It works.

/etc/systemd/system/flanneld.service

[Service]
Environment=FLANNELD_IFACE_REGEX=192\\.168\\.\\d+\\.\\d+

The interface is eth0 and it has 2 ipv4 ips (one public IP and one LAN) and 2 ipv6 ips.

Feb 17 18:17:02  flanneld[41261]: I0217 18:17:02.554665   41261 main.go:226] Created subnet manager: Etcd Local Manager with Previous Subnet: None
Feb 17 18:17:02  flanneld[41261]: I0217 18:17:02.554687   41261 main.go:229] Installing signal handlers
Feb 17 18:17:02  flanneld[41261]: I0217 18:17:02.558901   41261 main.go:550] Start healthz server on 0.0.0.0:8072
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.569659   41261 main.go:453] Found network config - Backend type: vxlan
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.571698   41261 match.go:228] Using interface with name eth0 and address 192.168.138.76
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.571845   41261 match.go:250] Defaulting external address to interface address (192.168.138.76)
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.571955   41261 match.go:263] Defaulting external v6 address to interface address (<nil>)
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.572153   41261 vxlan.go:138] VXLAN config: VNI=1 Port=0 GBP=false Learning=false DirectRouting=false
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.625600   41261 local_manager.go:237] Picking subnet in range 10.5.1.0 ... 10.5.255.0
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.634146   41261 local_manager.go:223] Allocated lease (10.5.32.0/24) to current node (192.168.138.76)
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.634585   41261 main.go:402] Current network or subnet (10.5.0.0/16, 10.5.32.0/24) is not equal to previous one (0.0.0.0/0, 0.0.0.0/0), tryin>
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.654269   41261 iptables.go:241] Deleting iptables rule: -s 0.0.0.0/0 -d 0.0.0.0/0 -m comment --comment flanneld masq -j RETURN
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.730145   41261 iptables.go:241] Deleting iptables rule: -s 0.0.0.0/0 ! -d 224.0.0.0/4 -m comment --comment flannel masq -j MASQUERADE --rand>
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.750423   41261 iptables.go:241] Deleting iptables rule: ! -s 0.0.0.0/0 -d 0.0.0.0/0 -m comment --comment flanneld masq -j RETURN
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.753980   41261 iptables.go:241] Deleting iptables rule: ! -s 0.0.0.0/0 -d 0.0.0.0/0 -m comment --comment flanneld masq -j MASQUERADE --rando>
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.766815   41261 main.go:334] Setting up masking rules
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.774181   41261 main.go:355] Changing default FORWARD chain policy to ACCEPT
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.774654   41261 main.go:368] Wrote subnet file to /run/flannel/subnet.env
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.775982   41261 main.go:372] Running backend.
Feb 17 18:17:03  systemd[1]: Started FlannelD Network fabric for containers.
Feb 17 18:17:03  flanneld[41261]: I0217 18:17:03.788493   41261 vxlan_network.go:61] watching for new subnet leases

pkg/ip/iface.go Outdated Show resolved Hide resolved
@ttys3
Copy link
Contributor Author

ttys3 commented Feb 18, 2022

@luthermonson PTAL, the CI need approve again

@manuelbuil
Copy link
Collaborator

Could you please rebase? There is a new test in CI (golangci-lint)

@ttys3
Copy link
Contributor Author

ttys3 commented Feb 23, 2022

Could you please rebase? There is a new test in CI (golangci-lint)

rebased, PTAL @manuelbuil @luthermonson

@manuelbuil
Copy link
Collaborator

@ttys3 could you resolve the conflict please? After that I'll merge the PR. Sorry for the delay!

@ttys3
Copy link
Contributor Author

ttys3 commented Feb 26, 2022

@manuelbuil rebased. PTAL

@manuelbuil manuelbuil merged commit 5e948c4 into flannel-io:master Feb 28, 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.

--iface-regex doesn't work with interfaces that have multiple IPs
3 participants