diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index e9243923..42806bc9 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -1023,6 +1023,14 @@ Accept prefixes up to /24 and /48 from covering parent IRR objects |------|---------|------------| | bool | false | | +### `gateway` + +The mode in which the gateway is defined for received routes (direct|recursive). + +| Type | Default | Validation | +|------|---------|------------| +| string | | | + ### `add-on-import` List of communities to add to all imported routes diff --git a/pkg/config/config.go b/pkg/config/config.go index 881360b8..70ce91c5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -141,6 +141,7 @@ type Peer struct { DisableAfterError *bool `yaml:"disable-after-error" description:"Disable peer after error" default:"false"` PreferOlderRoutes *bool `yaml:"prefer-older-routes" description:"Prefer older routes instead of comparing router IDs (RFC 5004)" default:"false"` IRRAcceptChildPrefixes *bool `yaml:"irr-accept-child-prefixes" description:"Accept prefixes up to /24 and /48 from covering parent IRR objects" default:"false"` + Gateway *string `yaml:"gateway" description:"The mode in which the gateway is defined for received routes (direct|recursive)." default:"-"` ImportCommunities *[]string `yaml:"add-on-import" description:"List of communities to add to all imported routes" default:"-"` ExportCommunities *[]string `yaml:"add-on-export" description:"List of communities to add to all exported routes" default:"-"` diff --git a/pkg/embed/templates/peer.tmpl b/pkg/embed/templates/peer.tmpl index 88a04c72..e7f72cbd 100644 --- a/pkg/embed/templates/peer.tmpl +++ b/pkg/embed/templates/peer.tmpl @@ -83,6 +83,7 @@ protocol bgp {{ UniqueProtocolName $peer.ProtocolName $peerName $af $peer.ASN $p {{ if BoolDeref $peer.AddPathRx }}add paths rx;{{ end }} {{ if BoolDeref $peer.AdvertiseHostname }}advertise hostname on;{{ end }} {{ if BoolDeref $peer.DisableAfterError }}disable after error on;{{ end }} + {{ if StrDeref $peer.Gateway }}gateway "{{ StrDeref $peer.Gateway }}";{{ end }} import filter { {{ if $global.NoAccept }}reject; # no-accept: true{{ end }} {{ if (not (BoolDeref $peer.Import)) }}reject; # import: false{{ end }} diff --git a/pkg/process/process.go b/pkg/process/process.go index 286ab556..f8fa347f 100644 --- a/pkg/process/process.go +++ b/pkg/process/process.go @@ -629,6 +629,12 @@ func Load(configBlob []byte) (*config.Config, error) { } } + if peerData.Gateway != nil { + peerData.Gateway = util.Ptr(strings.ReplaceAll(*peerData.Gateway, "-", "_")) + if *peerData.Gateway != "direct" && *peerData.Gateway != "recursive" { + return nil, errors.New("invalid gateway type") + } + } // Check for no originated prefixes but announce-originated enabled if len(c.Prefixes) < 1 && *peerData.AnnounceOriginated { // No locally originated prefixes are defined, so there's nothing to originate