Link-up re-adds an unchanged static IPv4 address, and FreeBSD silently drops the FRR routes using it

Đang mở
#5,985 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend, networking

Hướng nghiên cứu

Start with rc.linkup and interfaces.inc at the linked call sites, then trace how interface_configure() flushes and restores addresses and routes. Check how interface_suspend() preserves static addresses and compare the behavior with FRR routes through the interface. Done means a link-up with an unchanged static IPv4 address leaves routes installed by FRR in the kernel; reproduce with the listed BGP setup and verify using netstat -rn -f inet.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

upstream

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

If AI was used, please disclose:

  • Model used: Claude Opus 5.5
  • Extent of AI involvement: drafted this text from my own logs and source reading; I checked the logs, code references and commands before posting.

Describe the bug

When the LAN link comes back up, rc.linkup start <dev> calls interface_configure(), which deletes the interface's static IPv4 address and adds it back (interfaces_addresses_flush() → legacy_interface_deladdress() → ifconfig <dev> inet <addr> -alias). The address is the same before and after, but deleting it makes FreeBSD remove every route whose next hop uses it (in_difaddr() → in_ifadown()), and those deletions are not reported on the routing socket.

OPNsense's own routes come back, because interface_configure() runs system_routing_configure() afterwards. Routes installed by a routing daemon don't. With os-frr, zebra keeps listing the BGP routes as B>*, the sessions stay up so nothing is announced again, and traffic to those prefixes goes out the default route until FRR is restarted.

For us that was every LoadBalancer address of a Kubernetes cluster that peers with the router over BGP. A switch reboot bounced the LAN link three times within a minute. The rc.linkup runs are serialized behind configd, so the last start for the LAN ran 36 seconds after the link settled, after the BGP sessions had come back, and that flush took the routes out for good.

interface_suspend() already avoids this on link down: its comment says it keeps static addresses because "This helps to retain routes". The attach path flushes them anyway.

No last known working version that I know of.

To Reproduce

Steps to reproduce the behavior:

  1. Set up os-frr with a BGP neighbor on a LAN with a static IPv4 address (here 192.0.2.1/24 on ice1) that advertises a few host routes.
  2. Check that they are installed: vtysh -c 'show ip route bgp' shows B>* 198.51.100.13/32 ... via 192.0.2.55, ice1, and netstat -rn -f inet lists 198.51.100.13 192.0.2.55 UGH1 ice1.
  3. Bounce the LAN link (replug the cable or reboot the switch), or run what devd runs on link-up: configctl interface linkup start ice1.
  4. netstat -rn -f inet no longer has the BGP routes, while vtysh -c 'show ip route bgp' still shows them as B>* and show bgp summary has every session established.
  5. configctl quagga restart brings them back.

The FreeBSD half reproduces without OPNsense; I've reported it to FRR here: https://github.com/FRRouting/frr/issues/24572.

Expected behavior

A link-up on an interface whose configured static address is already present leaves that address alone, so routes through it survive. If the flush has to stay, routing plugins should get a hook after the re-add, the same way system_routing_configure() does for the gateway and static routes.

Describe alternatives you considered

Restarting FRR whenever zebra's installed routes and the kernel table disagree: a cron job compares vtysh -c 'show ip route json' with netstat -rnW every minute and runs configctl quagga restart when routes are missing twice in a row. It works, but the routes are gone for one to two minutes each time. A user in opnsense/core#7113 reported that commenting out the -alias in legacy_interface_deladdress() avoided the same symptom, but that's not something to run in production.

Relevant log files

System log on the router (the LAN is ice1; the VLANs on the same port go through the same sequence and are left out):

23:32:51 kernel: ice1: link state changed to DOWN
23:32:51 /usr/local/etc/rc.linkup: DEVD: Ethernet detached event for lan(ice1)
23:33:26 kernel: ice1: link state changed to UP
23:33:26 /usr/local/etc/rc.linkup: ROUTING: entering configure using lan
23:33:26 /usr/local/etc/rc.linkup: DEVD: Ethernet attached event for lan(ice1)
23:33:29 kernel: ice1: link state changed to DOWN
23:33:32 kernel: ice1: link state changed to UP
23:33:40 kernel: ice1: link state changed to DOWN
23:33:40 kernel: ice1: link state changed to UP
23:33:48 /usr/local/etc/rc.linkup: DEVD: Ethernet detached event for lan(ice1)
23:33:50 /usr/local/etc/rc.linkup: ROUTING: entering configure using lan
23:33:50 /usr/local/etc/rc.linkup: DEVD: Ethernet attached event for lan(ice1)
23:34:15 /usr/local/etc/rc.linkup: DEVD: Ethernet detached event for lan(ice1)
23:34:16 /usr/local/etc/rc.linkup: ROUTING: entering configure using lan
23:34:16 /usr/local/etc/rc.linkup: DEVD: Ethernet attached event for lan(ice1)

The peers had their sessions back between 23:34:00 and 23:34:15. After 23:34:16 the kernel had none of the BGP routes until the router was rebooted almost an hour later.

Additional context

opnsense/core#7113 asks rc.linkup to coalesce devd events. That would shorten the window here, but a single link-up while BGP is established also runs the flush. opnsense/plugins#5624 (OSPF routes O>* in zebra but missing from the kernel after a reboot) and opnsense/plugins#5897 (static FRR routes missing after a reboot, fixed by restarting FRR) may be the same thing, if an interface address gets re-added after FRR has installed its routes. I haven't confirmed that on those setups.

Environment

OPNsense 26.7.9_3 when it happened, upgraded to 26.7.10 since; the code above is unchanged between the two (amd64)
os-frr 2.1_1, FRR 10.7.1
FreeBSD 15.1-RELEASE-p7
Network Intel® E810 (ice), 10 Gbps LAN with VLANs on the same port

Ngôn ngữ chính
PHP
Star
1.2k
Fork
932
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opnsense/plugins

Tất cả issue của opnsense/plugins

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.