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

オープン
#5,985 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
PHP
スター
1.2k
フォーク
932
平均マージ
1日 11時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opnsense/plugins のほかの issue

opnsense/plugins の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。