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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
02ba36de
Unverified
Commit
02ba36de
authored
May 29, 2018
by
takt
Committed by
GitHub
May 29, 2018
Browse files
Options
Downloads
Plain Diff
Merge pull request #25 from bio-routing/feature/unknownAttrSupport
Adding support for unknown attributes
parents
1013e996
e1f27987
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
protocols/bgp/packet/decoder_test.go
+19
-0
19 additions, 0 deletions
protocols/bgp/packet/decoder_test.go
protocols/bgp/packet/path_attributes.go
+20
-5
20 additions, 5 deletions
protocols/bgp/packet/path_attributes.go
with
39 additions
and
5 deletions
protocols/bgp/packet/decoder_test.go
+
19
−
0
View file @
02ba36de
...
...
@@ -1243,6 +1243,25 @@ func TestDecodeUpdateMsg(t *testing.T) {
explicitLength
:
5
,
wantFail
:
true
,
},
{
// Unknown attribute
testNum
:
16
,
input
:
[]
byte
{
0
,
0
,
// No Withdraws
0
,
7
,
// Total Path Attributes Length
64
,
111
,
4
,
1
,
1
,
1
,
1
,
// Unknown attribute
},
wantFail
:
false
,
expected
:
&
BGPUpdate
{
TotalPathAttrLen
:
7
,
PathAttributes
:
&
PathAttribute
{
Length
:
4
,
Transitive
:
true
,
TypeCode
:
111
,
Value
:
[]
byte
{
1
,
1
,
1
,
1
},
},
},
},
}
for
_
,
test
:=
range
tests
{
...
...
...
...
This diff is collapsed.
Click to expand it.
protocols/bgp/packet/path_attributes.go
+
20
−
5
View file @
02ba36de
...
...
@@ -6,7 +6,6 @@ import (
"strconv"
"strings"
"github.com/sirupsen/logrus"
"github.com/taktv6/tflow2/convert"
)
...
...
@@ -20,11 +19,10 @@ func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) {
p
:=
uint16
(
0
)
for
p
<
tpal
{
pa
,
consumed
,
err
=
decodePathAttr
(
buf
)
p
+=
consumed
if
err
!=
nil
{
logrus
.
Errorf
(
"Unable to decode path attr: %v"
,
err
)
continue
return
nil
,
fmt
.
Errorf
(
"Unable to decode path attr: %v"
,
err
)
}
p
+=
consumed
if
ret
==
nil
{
ret
=
pa
...
...
@@ -87,12 +85,29 @@ func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err
case
AtomicAggrAttr
:
// Nothing to do for 0 octet long attribute
default
:
return
nil
,
consumed
,
fmt
.
Errorf
(
"Invalid Attribute Type Code: %v"
,
pa
.
TypeCode
)
if
err
:=
pa
.
decodeUnknown
(
buf
);
err
!=
nil
{
return
nil
,
consumed
,
fmt
.
Errorf
(
"Failed to decode unknown attribute: %v"
,
err
)
}
}
return
pa
,
consumed
+
pa
.
Length
,
nil
}
func
(
pa
*
PathAttribute
)
decodeUnknown
(
buf
*
bytes
.
Buffer
)
error
{
u
:=
make
([]
byte
,
pa
.
Length
)
p
:=
uint16
(
0
)
err
:=
decode
(
buf
,
[]
interface
{}{
&
u
})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Unable to decode: %v"
,
err
)
}
pa
.
Value
=
u
p
+=
pa
.
Length
return
nil
}
func
(
pa
*
PathAttribute
)
decodeOrigin
(
buf
*
bytes
.
Buffer
)
error
{
origin
:=
uint8
(
0
)
...
...
...
...
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
sign in
to comment