summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/table/policy.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkg/table/policy.go')
-rw-r--r--internal/pkg/table/policy.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/internal/pkg/table/policy.go b/internal/pkg/table/policy.go
index f4bcf0a4..2909c199 100644
--- a/internal/pkg/table/policy.go
+++ b/internal/pkg/table/policy.go
@@ -2566,8 +2566,9 @@ func NewAsPathPrependAction(action config.SetAsPathPrepend) (*AsPathPrependActio
}
type NexthopAction struct {
- value net.IP
- self bool
+ value net.IP
+ self bool
+ unchanged bool
}
func (a *NexthopAction) Type() ActionType {
@@ -2581,6 +2582,12 @@ func (a *NexthopAction) Apply(path *Path, options *PolicyOptions) *Path {
}
return path
}
+ if a.unchanged {
+ if options != nil && options.OldNextHop != nil {
+ path.SetNexthop(options.OldNextHop)
+ }
+ return path
+ }
path.SetNexthop(a.value)
return path
}
@@ -2589,6 +2596,9 @@ func (a *NexthopAction) ToConfig() config.BgpNextHopType {
if a.self {
return config.BgpNextHopType("self")
}
+ if a.unchanged {
+ return config.BgpNextHopType("unchanged")
+ }
return config.BgpNextHopType(a.value.String())
}
@@ -2608,6 +2618,10 @@ func NewNexthopAction(c config.BgpNextHopType) (*NexthopAction, error) {
return &NexthopAction{
self: true,
}, nil
+ case "unchanged":
+ return &NexthopAction{
+ unchanged: true,
+ }, nil
}
addr := net.ParseIP(string(c))
if addr == nil {
@@ -4049,6 +4063,11 @@ func toStatementApi(s *config.Statement) *api.Statement {
Self: true,
}
}
+ if string(s.Actions.BgpActions.SetNextHop) == "unchanged" {
+ return &api.NexthopAction{
+ Unchanged: true,
+ }
+ }
return &api.NexthopAction{
Address: string(s.Actions.BgpActions.SetNextHop),
}