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
19b37b04
Commit
19b37b04
authored
6 years ago
by
Maximilian Wilhelm
Browse files
Options
Downloads
Patches
Plain Diff
Don't propagate path with detected AS loops to LocRIB or other clients.
Signed-off-by:
Maximilian Wilhelm
<
max@sdn.clinic
>
parent
b67c2b5d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
routingtable/adjRIBIn/adj_rib_in.go
+28
-5
28 additions, 5 deletions
routingtable/adjRIBIn/adj_rib_in.go
routingtable/contributing_asn_list.go
+11
-0
11 additions, 0 deletions
routingtable/contributing_asn_list.go
with
39 additions
and
5 deletions
routingtable/adjRIBIn/adj_rib_in.go
+
28
−
5
View file @
19b37b04
...
...
@@ -3,6 +3,7 @@ package adjRIBIn
import
(
"sync"
"github.com/bio-routing/bio-rd/protocols/bgp/packet"
"github.com/bio-routing/bio-rd/routingtable/filter"
"github.com/bio-routing/bio-rd/net"
...
...
@@ -14,16 +15,18 @@ import (
// AdjRIBIn represents an Adjacency RIB In as described in RFC4271
type
AdjRIBIn
struct
{
routingtable
.
ClientManager
rt
*
routingtable
.
RoutingTable
mu
sync
.
RWMutex
exportFilter
*
filter
.
Filter
rt
*
routingtable
.
RoutingTable
mu
sync
.
RWMutex
exportFilter
*
filter
.
Filter
contributingASNs
*
routingtable
.
ContributingASNs
}
// New creates a new Adjacency RIB In
func
New
(
exportFilter
*
filter
.
Filter
,
contributingASNs
*
routingtable
.
ContributingASNs
)
*
AdjRIBIn
{
a
:=
&
AdjRIBIn
{
rt
:
routingtable
.
NewRoutingTable
(),
exportFilter
:
exportFilter
,
rt
:
routingtable
.
NewRoutingTable
(),
exportFilter
:
exportFilter
,
contributingASNs
:
contributingASNs
,
}
a
.
ClientManager
=
routingtable
.
NewClientManager
(
a
)
return
a
...
...
@@ -65,12 +68,32 @@ func (a *AdjRIBIn) AddPath(pfx net.Prefix, p *route.Path) error {
return
nil
}
// Bail out - for all clients for now - if any of our ASNs is within the path
if
a
.
ourASNsInPath
(
p
)
{
return
nil
}
for
_
,
client
:=
range
a
.
ClientManager
.
Clients
()
{
client
.
AddPath
(
pfx
,
p
)
}
return
nil
}
func
(
a
*
AdjRIBIn
)
ourASNsInPath
(
p
*
route
.
Path
)
bool
{
// Don't accept path via iBGP which contain our ASN
ASPathAttr
,
_
:=
packet
.
ParseASPathStr
(
p
.
BGPPath
.
ASPath
)
for
_
,
pathSegment
:=
range
ASPathAttr
.
Value
.
(
packet
.
ASPath
)
{
for
_
,
asn
:=
range
pathSegment
.
ASNs
{
if
a
.
contributingASNs
.
IsContributingASN
(
asn
)
{
return
true
}
}
}
return
false
}
// RemovePath removes the path for prefix `pfx`
func
(
a
*
AdjRIBIn
)
RemovePath
(
pfx
net
.
Prefix
,
p
*
route
.
Path
)
bool
{
a
.
mu
.
Lock
()
...
...
This diff is collapsed.
Click to expand it.
routingtable/contributing_asn_list.go
+
11
−
0
View file @
19b37b04
...
...
@@ -62,3 +62,14 @@ func (c *ContributingASNs) Remove(asn uint32) {
}
}
}
// IsContributingASN checks if a given ASN is part of the contributing ASNs
func
(
c
*
ContributingASNs
)
IsContributingASN
(
asn
uint32
)
bool
{
for
_
,
cASN
:=
range
c
.
contributingASNs
{
if
asn
==
cASN
.
asn
{
return
true
}
}
return
false
}
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