-
Notifications
You must be signed in to change notification settings - Fork 2.9k
luci-proto-bfd: add BFD protocol handler #8969
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright 2026 Wolf480pl <wolf480@interia.pl> | ||
| # | ||
| # Modified by Wolf480pl <wolf480@interia.pl>, | ||
| # based on luci-proto-gre, which was: | ||
| # | ||
| # Based on luci-proto-ipip. | ||
| # Credited author of luci-proto-ipip is Roger Pueyo Centelles <roger.pueyo@guifi.net> | ||
| # Copyright 2016 Roger Pueyo Centelles <roger.pueyo@guifi.net> | ||
| # | ||
| # Modified by Jan Betik <jan.betik@svine.su> | ||
| # Copyright 2020 Jan Betik <jan.betik@svine.su> | ||
| # | ||
| # This is free software, licensed under the Apache License, Version 2.0 . | ||
| # | ||
|
|
||
| include $(TOPDIR)/rules.mk | ||
|
|
||
| LUCI_TITLE:=Support for BFD (RFC5880) | ||
| LUCI_DEPENDS:=+bfdd | ||
|
|
||
| PKG_MAINTAINER:=Wolf480pl <wolf480@interia.pl> | ||
| PKG_LICENSE:=Apache-2.0 | ||
|
|
||
| include ../../luci.mk | ||
|
|
||
| # call BuildPackage - OpenWrt buildroot signature |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,82 @@ | ||||||||||
| 'use strict'; | ||||||||||
| 'require form'; | ||||||||||
| 'require network'; | ||||||||||
| 'require tools.widgets as widgets'; | ||||||||||
|
|
||||||||||
| return network.registerProtocol('bfd', { | ||||||||||
| getI18n: function() { | ||||||||||
| return _('Bidirectional Forwarding Detection (BFD) Session'); | ||||||||||
| }, | ||||||||||
|
|
||||||||||
| getPackageName: function() { | ||||||||||
| return 'proto-bfd'; | ||||||||||
| }, | ||||||||||
|
|
||||||||||
| renderFormOptions: function(s) { | ||||||||||
| var o; | ||||||||||
| var proto = this; | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
Same for the Generated by Claude Code |
||||||||||
|
|
||||||||||
| // -- general --------------------------------------------------------------------- | ||||||||||
|
|
||||||||||
| o = s.taboption('general', form.Value, 'peer_address', _("Remote IP address"), _("The IP address of the remote BFD peer.")); | ||||||||||
| o.rmempty = false; | ||||||||||
| o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))'; | ||||||||||
|
|
||||||||||
| o = s.taboption('general', form.Flag, 'multihop', _("Multihop"), _("Allow BFD packats to traverse multiple hops. Use when BFD peer is not a direct neighbour of this router.")); | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: typo "packats" — this string goes into the translation catalogs, so it is worth fixing before merge.
Suggested change
Line 70 has a related one: "Minimum number of milliseconds between BFD packet we transmit" should be "packets". Generated by Claude Code |
||||||||||
|
|
||||||||||
| o = s.taboption('general', form.Value, 'local_address', _("Local IPv4 address"), _("The local IP address used to communicate with the BFD peer (mandatory on multihop).")); | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The label says IPv4 but the
Suggested change
Generated by Claude Code |
||||||||||
| o.rmempty = false; | ||||||||||
| o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))'; | ||||||||||
| o.depends('multihop', '1'); | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gating on Same question for Generated by Claude Code
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bfdd itself ignores It's an inconsistence between bfdd's documentation and implementation, though I guess I should pick one interpretation and stick to it instead of carrying the inconsistency into openwrt. |
||||||||||
| o.load = function(section_id) { | ||||||||||
| return network.getDevices().then(L.bind(function(devs) { | ||||||||||
| var addrs = devs.flatMap(d => { | ||||||||||
| var linkName = d.getName(); | ||||||||||
| function addLinkName(addr) { | ||||||||||
| if (addr.startsWith("fe8")) { | ||||||||||
| addr = addr + "%" + linkName; | ||||||||||
| } | ||||||||||
| return addr; | ||||||||||
| } | ||||||||||
|
Comment on lines
+35
to
+40
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The zone-suffixed values this produces cannot pass the option's own Either drop the Separately, the prefix test is too narrow: link-local is Generated by Claude Code |
||||||||||
| var addrs4 = d.getIPAddrs().map(a => a.split('/')[0]); | ||||||||||
| var addrs6 = d.getIP6Addrs().map(a => a.split('/')[0]).map(addLinkName); | ||||||||||
| return addrs4.concat(addrs6) | ||||||||||
| }).sort() | ||||||||||
|
Comment on lines
+43
to
+44
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing statement terminators; every other statement in this file is semicolon-terminated.
Suggested change
Generated by Claude Code |
||||||||||
|
|
||||||||||
| for (var i = 0; i < addrs.length; i++) { | ||||||||||
| this.value(addrs[i]); | ||||||||||
| } | ||||||||||
| return form.Value.prototype.load.apply(this, [section_id]); | ||||||||||
| }, this)); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| o = s.taboption('general', form.Value, 'vrf_name', _("VRF Name"), _("Optional. The VRF used to communicate with the BFD peer.")); | ||||||||||
| o.optional = true; | ||||||||||
| o.datatype = 'string'; | ||||||||||
| o.depends('multihop', '1'); | ||||||||||
|
|
||||||||||
| // -- advanced --------------------------------------------------------------------- | ||||||||||
|
|
||||||||||
| o = s.taboption('advanced', form.Value, 'detect_multiplier', _("Detect Multiplier"), _("Number of consecutive missed BFD packets after which the session is considered down.")); | ||||||||||
| o.optional = true; | ||||||||||
| o.placeholder = 3; | ||||||||||
| o.datatype = 'uinteger'; | ||||||||||
|
|
||||||||||
| o = s.taboption('advanced', form.Value, 'receive_interval', _("Receive Interval (ms)"), _("Minimum number of milliseconds between BFD packets we're willing to receive from the peer.")); | ||||||||||
| o.optional = true; | ||||||||||
| o.placeholder = 300; | ||||||||||
| o.datatype = 'uinteger'; | ||||||||||
|
|
||||||||||
| o = s.taboption('advanced', form.Value, 'transmit_interval', _("Transmit Interval (ms)"), _("Minimum number of milliseconds between BFD packet we transmit.")); | ||||||||||
| o.optional = true; | ||||||||||
| o.placeholder = 300; | ||||||||||
| o.datatype = 'uinteger'; | ||||||||||
|
|
||||||||||
| o = s.taboption('advanced', form.Flag, 'echo_mode', _("Echo Mode"), _("Echo mode sends packets with ourselves as destination, hoping the peer will reflect them without noticing.")); | ||||||||||
|
|
||||||||||
| o = s.taboption('advanced', form.Value, 'echo_interval', _("Echo Interval (ms)"), _("Minimum number of milliseconds between BFD Echo packets, both for transmitting and receiving/reflecting. Set to zero to tell our peer we don't want incoming echos.")); | ||||||||||
| o.optional = true; | ||||||||||
| o.placeholder = 50; | ||||||||||
| o.datatype = 'uinteger'; | ||||||||||
| } | ||||||||||
| }); | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no
proto-bfdpackage.getPackageName()is documented as "the name of the package to download, required for the protocol to function" (network.js:2464-2477),`` and in openwrt/packages#30364 the netifd handler (/lib/netifd/proto/bfd.sh) is installed by the `bfdd` package itself — which is also what `LUCI_DEPENDS:=+bfdd` in the Makefile refers to.Generated by Claude Code