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
12c07528
Commit
12c07528
authored
6 years ago
by
Maximilian Wilhelm
Browse files
Options
Downloads
Patches
Plain Diff
Decode and store OriginatorID and ClusterList attributes.
Signed-off-by:
Maximilian Wilhelm
<
max@sdn.clinic
>
parent
0b4d858e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
protocols/bgp/packet/bgp.go
+3
-0
3 additions, 0 deletions
protocols/bgp/packet/bgp.go
protocols/bgp/packet/path_attributes.go
+32
-0
32 additions, 0 deletions
protocols/bgp/packet/path_attributes.go
protocols/bgp/server/fsm_established.go
+4
-0
4 additions, 0 deletions
protocols/bgp/server/fsm_established.go
with
39 additions
and
0 deletions
protocols/bgp/packet/bgp.go
+
3
−
0
View file @
12c07528
...
@@ -14,6 +14,7 @@ const (
...
@@ -14,6 +14,7 @@ const (
NLRIMaxLen
=
5
NLRIMaxLen
=
5
CommunityLen
=
4
CommunityLen
=
4
LargeCommunityLen
=
12
LargeCommunityLen
=
12
ClusterIDLen
=
4
OpenMsg
=
1
OpenMsg
=
1
UpdateMsg
=
2
UpdateMsg
=
2
...
@@ -66,6 +67,8 @@ const (
...
@@ -66,6 +67,8 @@ const (
AtomicAggrAttr
=
6
AtomicAggrAttr
=
6
AggregatorAttr
=
7
AggregatorAttr
=
7
CommunitiesAttr
=
8
CommunitiesAttr
=
8
OriginatorIDAttr
=
9
ClusterListAttr
=
10
AS4PathAttr
=
17
AS4PathAttr
=
17
AS4AggregatorAttr
=
18
AS4AggregatorAttr
=
18
LargeCommunitiesAttr
=
32
LargeCommunitiesAttr
=
32
...
...
This diff is collapsed.
Click to expand it.
protocols/bgp/packet/path_attributes.go
+
32
−
0
View file @
12c07528
...
@@ -99,6 +99,14 @@ func decodePathAttr(buf *bytes.Buffer, opt *types.Options) (pa *PathAttribute, c
...
@@ -99,6 +99,14 @@ func decodePathAttr(buf *bytes.Buffer, opt *types.Options) (pa *PathAttribute, c
if
err
:=
pa
.
decodeCommunities
(
buf
);
err
!=
nil
{
if
err
:=
pa
.
decodeCommunities
(
buf
);
err
!=
nil
{
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to decode Community: %v"
,
err
)
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to decode Community: %v"
,
err
)
}
}
case
OriginatorIDAttr
:
if
err
:=
pa
.
decodeOriginatorID
(
buf
);
err
!=
nil
{
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to decode OriginatorID: %v"
,
err
)
}
case
ClusterListAttr
:
if
err
:=
pa
.
decodeClusterList
(
buf
);
err
!=
nil
{
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to decode OriginatorID: %v"
,
err
)
}
case
MultiProtocolReachNLRICode
:
case
MultiProtocolReachNLRICode
:
if
err
:=
pa
.
decodeMultiProtocolReachNLRI
(
buf
);
err
!=
nil
{
if
err
:=
pa
.
decodeMultiProtocolReachNLRI
(
buf
);
err
!=
nil
{
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to multi protocol reachable NLRI: %v"
,
err
)
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to multi protocol reachable NLRI: %v"
,
err
)
...
@@ -364,6 +372,30 @@ func (pa *PathAttribute) decodeUint32(buf *bytes.Buffer, attrName string) error
...
@@ -364,6 +372,30 @@ func (pa *PathAttribute) decodeUint32(buf *bytes.Buffer, attrName string) error
return
nil
return
nil
}
}
func
(
pa
*
PathAttribute
)
decodeOriginatorID
(
buf
*
bytes
.
Buffer
)
error
{
return
pa
.
decodeUint32
(
buf
,
"OriginatorID"
)
}
func
(
pa
*
PathAttribute
)
decodeClusterList
(
buf
*
bytes
.
Buffer
)
error
{
if
pa
.
Length
%
ClusterIDLen
!=
0
{
return
fmt
.
Errorf
(
"Unable to read ClusterList path attribute. Length %d is not divisible by %d"
,
pa
.
Length
,
ClusterIDLen
)
}
count
:=
pa
.
Length
/
ClusterIDLen
cids
:=
make
([]
uint32
,
count
)
for
i
:=
uint16
(
0
);
i
<
count
;
i
++
{
v
,
err
:=
read4BytesAsUint32
(
buf
)
if
err
!=
nil
{
return
err
}
cids
[
i
]
=
v
}
pa
.
Value
=
cids
return
nil
}
func
(
pa
*
PathAttribute
)
setLength
(
buf
*
bytes
.
Buffer
)
(
int
,
error
)
{
func
(
pa
*
PathAttribute
)
setLength
(
buf
*
bytes
.
Buffer
)
(
int
,
error
)
{
bytesRead
:=
0
bytesRead
:=
0
if
pa
.
ExtendedLength
{
if
pa
.
ExtendedLength
{
...
...
This diff is collapsed.
Click to expand it.
protocols/bgp/server/fsm_established.go
+
4
−
0
View file @
12c07528
...
@@ -293,6 +293,10 @@ func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *
...
@@ -293,6 +293,10 @@ func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *
path
.
BGPPath
.
Communities
=
pa
.
Value
.
([]
uint32
)
path
.
BGPPath
.
Communities
=
pa
.
Value
.
([]
uint32
)
case
packet
.
LargeCommunitiesAttr
:
case
packet
.
LargeCommunitiesAttr
:
path
.
BGPPath
.
LargeCommunities
=
pa
.
Value
.
([]
types
.
LargeCommunity
)
path
.
BGPPath
.
LargeCommunities
=
pa
.
Value
.
([]
types
.
LargeCommunity
)
case
packet
.
OriginatorIDAttr
:
path
.
BGPPath
.
OriginatorID
=
pa
.
Value
.
(
uint32
)
case
packet
.
ClusterListAttr
:
path
.
BGPPath
.
ClusterList
=
pa
.
Value
.
([]
uint32
)
default
:
default
:
unknownAttr
:=
s
.
processUnknownAttribute
(
pa
)
unknownAttr
:=
s
.
processUnknownAttribute
(
pa
)
if
unknownAttr
!=
nil
{
if
unknownAttr
!=
nil
{
...
...
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