Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
b6b2fdcb
Commit
b6b2fdcb
authored
6 years ago
by
Daniel Czerwonk
Browse files
Options
Downloads
Patches
Plain Diff
added local pref modification to filters
parent
9ab336b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
routingtable/filter/actions/set_local_pref_action.go
+28
-0
28 additions, 0 deletions
routingtable/filter/actions/set_local_pref_action.go
routingtable/filter/actions/set_local_pref_action_test.go
+47
-0
47 additions, 0 deletions
routingtable/filter/actions/set_local_pref_action_test.go
with
75 additions
and
0 deletions
routingtable/filter/actions/set_local_pref_action.go
0 → 100644
+
28
−
0
View file @
b6b2fdcb
package
actions
import
(
"github.com/bio-routing/bio-rd/net"
"github.com/bio-routing/bio-rd/route"
"github.com/bio-routing/bio-rd/routingtable/filter"
)
type
setLocalPrefAction
struct
{
pref
uint32
}
func
NewSetLocalPrefAction
(
pref
uint32
)
filter
.
FilterAction
{
return
&
setLocalPrefAction
{
pref
:
pref
,
}
}
func
(
a
*
setLocalPrefAction
)
Do
(
p
net
.
Prefix
,
pa
*
route
.
Path
)
(
modPath
*
route
.
Path
,
reject
bool
)
{
if
pa
.
BGPPath
==
nil
{
return
pa
,
false
}
modified
:=
*
pa
modified
.
BGPPath
.
LocalPref
=
a
.
pref
return
&
modified
,
false
}
This diff is collapsed.
Click to expand it.
routingtable/filter/actions/set_local_pref_action_test.go
0 → 100644
+
47
−
0
View file @
b6b2fdcb
package
actions
import
(
"testing"
"github.com/bio-routing/bio-rd/net"
"github.com/bio-routing/bio-rd/route"
"github.com/stretchr/testify/assert"
)
func
TestSetLocalPref
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
bgpPath
*
route
.
BGPPath
expectedLocalPref
uint32
}{
{
name
:
"BGPPath is nil"
,
expectedLocalPref
:
0
,
},
{
name
:
"modify path"
,
bgpPath
:
&
route
.
BGPPath
{
LocalPref
:
100
,
},
expectedLocalPref
:
150
,
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
te
*
testing
.
T
)
{
a
:=
NewSetLocalPrefAction
(
150
)
p
,
_
:=
a
.
Do
(
net
.
NewPfx
(
strAddr
(
"10.0.0.0"
),
8
),
&
route
.
Path
{
BGPPath
:
test
.
bgpPath
,
})
if
test
.
expectedLocalPref
>
0
{
assert
.
Equal
(
te
,
test
.
expectedLocalPref
,
p
.
BGPPath
.
LocalPref
)
}
})
}
}
func
strAddr
(
s
string
)
uint32
{
ret
,
_
:=
net
.
StrToAddr
(
s
)
return
ret
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment