diff --git a/protocols/bgp/packet/path_attributes.go b/protocols/bgp/packet/path_attributes.go index 8175f0400e343ed97653a0f0555c482b3a354927..4db07c1d9f89b69ff292c7167228b3bfd47df3cf 100644 --- a/protocols/bgp/packet/path_attributes.go +++ b/protocols/bgp/packet/path_attributes.go @@ -467,6 +467,10 @@ func ParseASPathStr(asPathString string) (*PathAttribute, error) { newSegmentNeeded := true currentSegment := -1 for _, asn := range strings.Split(asPathString, " ") { + if asn == "" { + continue + } + if isBeginOfASSet(asn) { currentType = ASSet newSegmentNeeded = true diff --git a/protocols/bgp/packet/path_attributes_test.go b/protocols/bgp/packet/path_attributes_test.go index 15f78fe39a763b86eb31281cbee5e30e54a84585..a547178a7c2422ba5dc1b653735d590f3b69973b 100644 --- a/protocols/bgp/packet/path_attributes_test.go +++ b/protocols/bgp/packet/path_attributes_test.go @@ -1298,6 +1298,15 @@ func TestParseASPathStr(t *testing.T) { wantFail bool expected *PathAttribute }{ + { + name: "Empty AS Path", + input: "", + wantFail: false, + expected: &PathAttribute{ + TypeCode: ASPathAttr, + Value: ASPath{}, + }, + }, { name: "Simple AS_SEQUENCE", input: "3320 15169",