Skip to content
Snippets Groups Projects
Commit 3356dafb authored by Oliver Herms's avatar Oliver Herms
Browse files

Adding support for empty AS paths

parent 1013e996
No related branches found
No related tags found
No related merge requests found
...@@ -452,6 +452,10 @@ func ParseASPathStr(asPathString string) (*PathAttribute, error) { ...@@ -452,6 +452,10 @@ func ParseASPathStr(asPathString string) (*PathAttribute, error) {
newSegmentNeeded := true newSegmentNeeded := true
currentSegment := -1 currentSegment := -1
for _, asn := range strings.Split(asPathString, " ") { for _, asn := range strings.Split(asPathString, " ") {
if asn == "" {
continue
}
if isBeginOfASSet(asn) { if isBeginOfASSet(asn) {
currentType = ASSet currentType = ASSet
newSegmentNeeded = true newSegmentNeeded = true
......
...@@ -1298,6 +1298,15 @@ func TestParseASPathStr(t *testing.T) { ...@@ -1298,6 +1298,15 @@ func TestParseASPathStr(t *testing.T) {
wantFail bool wantFail bool
expected *PathAttribute expected *PathAttribute
}{ }{
{
name: "Empty AS Path",
input: "",
wantFail: false,
expected: &PathAttribute{
TypeCode: ASPathAttr,
Value: ASPath{},
},
},
{ {
name: "Simple AS_SEQUENCE", name: "Simple AS_SEQUENCE",
input: "3320 15169", input: "3320 15169",
......
...@@ -41,6 +41,10 @@ func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error { ...@@ -41,6 +41,10 @@ func (u *UpdateSenderAddPath) AddPath(pfx net.Prefix, p *route.Path) error {
Next: &packet.PathAttribute{ Next: &packet.PathAttribute{
TypeCode: packet.NextHopAttr, TypeCode: packet.NextHopAttr,
Value: p.BGPPath.NextHop, Value: p.BGPPath.NextHop,
Next: &packet.PathAttribute{
TypeCode: packet.LocalPrefAttr,
Value: p.BGPPath.LocalPref,
},
}, },
}, },
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment