Skip to content

Commit

Permalink
Merge pull request #228 from sbezverk/issue_#227
Browse files Browse the repository at this point in the history
fix add path capability detection logic
  • Loading branch information
sbezverk authored Jul 21, 2023
2 parents 9d732d2 + 7cae545 commit 4ca9203
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 12 additions & 0 deletions pkg/base/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ func TestUnmarshalBaseNLRI(t *testing.T) {
},
},
},
{
name: "issue #227",
input: []byte{0x1C, 0x02, 0x02, 0x02, 0x00},
pathID: false,
expect: []Route{
{
PathID: 0,
Length: 28,
Prefix: []byte{2, 2, 2, 0},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/bgp/bgp-open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ func TestAddPathCapability(t *testing.T) {
},
fail: false,
},
{
name: "test 4",
openMsgRaw: []byte{0x00, 0x5F, 0x01, 0x04, 0x00, 0x01, 0x00, 0xB4, 0x01, 0x01, 0x01, 0x01, 0x42, 0x02, 0x06, 0x01, 0x04, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x80, 0x00, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x46, 0x00, 0x02, 0x06, 0x41, 0x04, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x06, 0x00, 0x02, 0x06, 0x45, 0x04, 0x00, 0x01, 0x01, 0x01, 0x02, 0x07, 0x49, 0x05, 0x03, 0x66, 0x72, 0x72, 0x00, 0x02, 0x04, 0x40, 0x02, 0x80, 0x78, 0x02, 0x09, 0x47, 0x07, 0x00, 0x01, 0x01, 0x80, 0x00, 0x00, 0x00},
fail: false,
expectAddPath: map[int]bool{
NLRIMessageType(1, 1): false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/message/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func (p *producer) producePeerMessage(op int, msg bmp.Message) {
if rAddPath := peerUpMsg.ReceivedOpen.AddPathCapability(); len(rAddPath) != 0 {
for k := range lAddPath {
// Enable AddPath only for AFI/SAFI types existing in both local and remote maps
if _, ok := rAddPath[k]; ok {
if capable, ok := rAddPath[k]; ok {
// AFI/SAFI type exists in both maps, which means both peers support Send/Receive of AddPath
p.addPathCapable[k] = true
p.addPathCapable[k] = capable
}
}
}
Expand Down

0 comments on commit 4ca9203

Please sign in to comment.