Skip to content
Snippets Groups Projects
Commit c5c2e391 authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

AS_PATH parsing with 4 octet support

parent 1eff34e0
Branches
Tags
No related merge requests found
...@@ -9,14 +9,18 @@ import ( ...@@ -9,14 +9,18 @@ import (
"github.com/taktv6/tflow2/convert" "github.com/taktv6/tflow2/convert"
) )
type DecodingOptions struct {
Supports4OctetASN bool
}
// Decode decodes a BGP message // Decode decodes a BGP message
func Decode(buf *bytes.Buffer) (*BGPMessage, error) { func Decode(buf *bytes.Buffer, opt *DecodingOptions) (*BGPMessage, error) {
hdr, err := decodeHeader(buf) hdr, err := decodeHeader(buf)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to decode header: %v", err) return nil, fmt.Errorf("Failed to decode header: %v", err)
} }
body, err := decodeMsgBody(buf, hdr.Type, hdr.Length-MinLen) body, err := decodeMsgBody(buf, hdr.Type, hdr.Length-MinLen, opt)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to decode message: %v", err) return nil, fmt.Errorf("Failed to decode message: %v", err)
} }
...@@ -27,12 +31,12 @@ func Decode(buf *bytes.Buffer) (*BGPMessage, error) { ...@@ -27,12 +31,12 @@ func Decode(buf *bytes.Buffer) (*BGPMessage, error) {
}, nil }, nil
} }
func decodeMsgBody(buf *bytes.Buffer, msgType uint8, l uint16) (interface{}, error) { func decodeMsgBody(buf *bytes.Buffer, msgType uint8, l uint16, opt *DecodingOptions) (interface{}, error) {
switch msgType { switch msgType {
case OpenMsg: case OpenMsg:
return decodeOpenMsg(buf) return decodeOpenMsg(buf)
case UpdateMsg: case UpdateMsg:
return decodeUpdateMsg(buf, l) return decodeUpdateMsg(buf, l, opt)
case KeepaliveMsg: case KeepaliveMsg:
return nil, nil // Nothing to decode in Keepalive message return nil, nil // Nothing to decode in Keepalive message
case NotificationMsg: case NotificationMsg:
...@@ -41,7 +45,7 @@ func decodeMsgBody(buf *bytes.Buffer, msgType uint8, l uint16) (interface{}, err ...@@ -41,7 +45,7 @@ func decodeMsgBody(buf *bytes.Buffer, msgType uint8, l uint16) (interface{}, err
return nil, fmt.Errorf("Unknown message type: %d", msgType) return nil, fmt.Errorf("Unknown message type: %d", msgType)
} }
func decodeUpdateMsg(buf *bytes.Buffer, l uint16) (*BGPUpdate, error) { func decodeUpdateMsg(buf *bytes.Buffer, l uint16, opt *DecodingOptions) (*BGPUpdate, error) {
msg := &BGPUpdate{} msg := &BGPUpdate{}
err := decode(buf, []interface{}{&msg.WithdrawnRoutesLen}) err := decode(buf, []interface{}{&msg.WithdrawnRoutesLen})
...@@ -59,7 +63,7 @@ func decodeUpdateMsg(buf *bytes.Buffer, l uint16) (*BGPUpdate, error) { ...@@ -59,7 +63,7 @@ func decodeUpdateMsg(buf *bytes.Buffer, l uint16) (*BGPUpdate, error) {
return msg, err return msg, err
} }
msg.PathAttributes, err = decodePathAttrs(buf, msg.TotalPathAttrLen) msg.PathAttributes, err = decodePathAttrs(buf, msg.TotalPathAttrLen, opt)
if err != nil { if err != nil {
return msg, err return msg, err
} }
......
...@@ -3,6 +3,7 @@ package packet ...@@ -3,6 +3,7 @@ package packet
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"strconv"
"testing" "testing"
"github.com/bio-routing/bio-rd/net" "github.com/bio-routing/bio-rd/net"
...@@ -70,7 +71,7 @@ func BenchmarkDecodeUpdateMsg(b *testing.B) { ...@@ -70,7 +71,7 @@ func BenchmarkDecodeUpdateMsg(b *testing.B) {
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
buf := bytes.NewBuffer(input) buf := bytes.NewBuffer(input)
_, err := decodeUpdateMsg(buf, uint16(len(input))) _, err := decodeUpdateMsg(buf, uint16(len(input)), &DecodingOptions{})
if err != nil { if err != nil {
fmt.Printf("decodeUpdateMsg failed: %v\n", err) fmt.Printf("decodeUpdateMsg failed: %v\n", err)
} }
...@@ -251,7 +252,7 @@ func TestDecode(t *testing.T) { ...@@ -251,7 +252,7 @@ func TestDecode(t *testing.T) {
for _, test := range tests { for _, test := range tests {
buf := bytes.NewBuffer(test.input) buf := bytes.NewBuffer(test.input)
msg, err := Decode(buf) msg, err := Decode(buf, &DecodingOptions{})
if err != nil && !test.wantFail { if err != nil && !test.wantFail {
t.Errorf("Unexpected error in test %d: %v", test.testNum, err) t.Errorf("Unexpected error in test %d: %v", test.testNum, err)
...@@ -1369,9 +1370,9 @@ func TestDecodeUpdateMsg(t *testing.T) { ...@@ -1369,9 +1370,9 @@ func TestDecodeUpdateMsg(t *testing.T) {
}, },
{ {
// 2 withdraws with four path attributes (Communities + AS4Path +AS4Aggregator + Origin), valid update // 2 withdraws with four path attributes (Communities + AS4Path +AS4Aggregator + Origin), valid update
testNum: 19, testNum: 20,
input: []byte{0, 5, 8, 10, 16, 192, 168, input: []byte{0, 5, 8, 10, 16, 192, 168,
0, 30, // Total Path Attribute Length 0, 32, // Total Path Attribute Length
0, // Attribute flags 0, // Attribute flags
8, // Attribute Type code (Community) 8, // Attribute Type code (Community)
...@@ -1381,8 +1382,10 @@ func TestDecodeUpdateMsg(t *testing.T) { ...@@ -1381,8 +1382,10 @@ func TestDecodeUpdateMsg(t *testing.T) {
128, // Attribute flags 128, // Attribute flags
17, // Attribute Type code (AS4Path) 17, // Attribute Type code (AS4Path)
4, // Length 6, // Length
0, 0, 2, 3, // Arbitrary Bytes 2, // AS_SEQUENCE
1, // Number of ASNs
0x00, 0x03, 0x17, 0xf3, // 202739
128, // Attribute flags 128, // Attribute flags
18, // Attribute Type code (AS4Aggregator) 18, // Attribute Type code (AS4Aggregator)
...@@ -1406,7 +1409,7 @@ func TestDecodeUpdateMsg(t *testing.T) { ...@@ -1406,7 +1409,7 @@ func TestDecodeUpdateMsg(t *testing.T) {
Pfxlen: 16, Pfxlen: 16,
}, },
}, },
TotalPathAttrLen: 30, TotalPathAttrLen: 32,
PathAttributes: &PathAttribute{ PathAttributes: &PathAttribute{
Optional: false, Optional: false,
Transitive: false, Transitive: false,
...@@ -1420,9 +1423,15 @@ func TestDecodeUpdateMsg(t *testing.T) { ...@@ -1420,9 +1423,15 @@ func TestDecodeUpdateMsg(t *testing.T) {
Transitive: false, Transitive: false,
Partial: false, Partial: false,
ExtendedLength: false, ExtendedLength: false,
Length: 4, Length: 6,
TypeCode: 17, TypeCode: 17,
Value: uint32(515), Value: ASPath{
ASPathSegment{
Type: 2,
Count: 1,
ASNs: []uint32{202739},
},
},
Next: &PathAttribute{ Next: &PathAttribute{
Optional: true, Optional: true,
Transitive: false, Transitive: false,
...@@ -1447,29 +1456,31 @@ func TestDecodeUpdateMsg(t *testing.T) { ...@@ -1447,29 +1456,31 @@ func TestDecodeUpdateMsg(t *testing.T) {
}, },
} }
t.Parallel()
for _, test := range tests { for _, test := range tests {
t.Run(strconv.Itoa(test.testNum), func(t *testing.T) {
buf := bytes.NewBuffer(test.input) buf := bytes.NewBuffer(test.input)
l := test.explicitLength l := test.explicitLength
if l == 0 { if l == 0 {
l = uint16(len(test.input)) l = uint16(len(test.input))
} }
msg, err := decodeUpdateMsg(buf, l) msg, err := decodeUpdateMsg(buf, l, &DecodingOptions{})
if err != nil && !test.wantFail { if err != nil && !test.wantFail {
t.Errorf("Unexpected error in test %d: %v", test.testNum, err) t.Fatalf("Unexpected error in test %d: %v", test.testNum, err)
continue
} }
if err == nil && test.wantFail { if err == nil && test.wantFail {
t.Errorf("Expected error did not happen in test %d", test.testNum) t.Fatalf("Expected error did not happen in test %d", test.testNum)
continue
} }
if err != nil && test.wantFail { if err != nil && test.wantFail {
continue return
} }
assert.Equalf(t, test.expected, msg, "%d", test.testNum) assert.Equalf(t, test.expected, msg, "%d", test.testNum)
})
} }
} }
...@@ -1490,7 +1501,7 @@ func TestDecodeMsgBody(t *testing.T) { ...@@ -1490,7 +1501,7 @@ func TestDecodeMsgBody(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
res, err := decodeMsgBody(test.buffer, test.msgType, test.length) res, err := decodeMsgBody(test.buffer, test.msgType, test.length, &DecodingOptions{})
if test.wantFail && err == nil { if test.wantFail && err == nil {
t.Errorf("Expected error dit not happen in test %q", test.name) t.Errorf("Expected error dit not happen in test %q", test.name)
} }
......
...@@ -70,7 +70,7 @@ func TestSerializeOpenMsg(t *testing.T) { ...@@ -70,7 +70,7 @@ func TestSerializeOpenMsg(t *testing.T) {
name: "Valid #1", name: "Valid #1",
input: &BGPOpen{ input: &BGPOpen{
Version: 4, Version: 4,
AS: 15169, ASN: 15169,
HoldTime: 120, HoldTime: 120,
BGPIdentifier: convert.Uint32([]byte{100, 111, 120, 130}), BGPIdentifier: convert.Uint32([]byte{100, 111, 120, 130}),
OptParmLen: 0, OptParmLen: 0,
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/taktv6/tflow2/convert" "github.com/taktv6/tflow2/convert"
) )
func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) { func decodePathAttrs(buf *bytes.Buffer, tpal uint16, opt *DecodingOptions) (*PathAttribute, error) {
var ret *PathAttribute var ret *PathAttribute
var eol *PathAttribute var eol *PathAttribute
var pa *PathAttribute var pa *PathAttribute
...@@ -18,7 +18,7 @@ func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) { ...@@ -18,7 +18,7 @@ func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) {
p := uint16(0) p := uint16(0)
for p < tpal { for p < tpal {
pa, consumed, err = decodePathAttr(buf) pa, consumed, err = decodePathAttr(buf, opt)
if err != nil { if err != nil {
return nil, fmt.Errorf("Unable to decode path attr: %v", err) return nil, fmt.Errorf("Unable to decode path attr: %v", err)
} }
...@@ -36,7 +36,7 @@ func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) { ...@@ -36,7 +36,7 @@ func decodePathAttrs(buf *bytes.Buffer, tpal uint16) (*PathAttribute, error) {
return ret, nil return ret, nil
} }
func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err error) { func decodePathAttr(buf *bytes.Buffer, opt *DecodingOptions) (pa *PathAttribute, consumed uint16, err error) {
pa = &PathAttribute{} pa = &PathAttribute{}
err = decodePathAttrFlags(buf, pa) err = decodePathAttrFlags(buf, pa)
...@@ -63,9 +63,18 @@ func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err ...@@ -63,9 +63,18 @@ func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err
return nil, consumed, fmt.Errorf("Failed to decode Origin: %v", err) return nil, consumed, fmt.Errorf("Failed to decode Origin: %v", err)
} }
case ASPathAttr: case ASPathAttr:
if err := pa.decodeASPath(buf); err != nil { asnLength := uint8(2)
if opt.Supports4OctetASN {
asnLength = 4
}
if err := pa.decodeASPath(buf, asnLength); err != nil {
return nil, consumed, fmt.Errorf("Failed to decode AS Path: %v", err) return nil, consumed, fmt.Errorf("Failed to decode AS Path: %v", err)
} }
case AS4PathAttr:
if err := pa.decodeASPath(buf, 4); err != nil {
return nil, consumed, fmt.Errorf("Failed to decode AS4 Path: %v", err)
}
case NextHopAttr: case NextHopAttr:
if err := pa.decodeNextHop(buf); err != nil { if err := pa.decodeNextHop(buf); err != nil {
return nil, consumed, fmt.Errorf("Failed to decode Next-Hop: %v", err) return nil, consumed, fmt.Errorf("Failed to decode Next-Hop: %v", err)
...@@ -88,10 +97,6 @@ func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err ...@@ -88,10 +97,6 @@ func decodePathAttr(buf *bytes.Buffer) (pa *PathAttribute, consumed uint16, err
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 AS4PathAttr:
if err := pa.decodeAS4Path(buf); err != nil {
return nil, consumed, fmt.Errorf("Failed to skip not supported AS4Path: %v", err)
}
case AS4AggregatorAttr: case AS4AggregatorAttr:
if err := pa.decodeAS4Aggregator(buf); err != nil { if err := pa.decodeAS4Aggregator(buf); err != nil {
return nil, consumed, fmt.Errorf("Failed to skip not supported AS4Aggregator: %v", err) return nil, consumed, fmt.Errorf("Failed to skip not supported AS4Aggregator: %v", err)
...@@ -139,14 +144,11 @@ func (pa *PathAttribute) decodeOrigin(buf *bytes.Buffer) error { ...@@ -139,14 +144,11 @@ func (pa *PathAttribute) decodeOrigin(buf *bytes.Buffer) error {
return dumpNBytes(buf, pa.Length-p) return dumpNBytes(buf, pa.Length-p)
} }
func (pa *PathAttribute) decodeASPath(buf *bytes.Buffer) error { func (pa *PathAttribute) decodeASPath(buf *bytes.Buffer, asnLength uint8) error {
pa.Value = make(ASPath, 0) pa.Value = make(ASPath, 0)
p := uint16(0) p := uint16(0)
for p < pa.Length { for p < pa.Length {
segment := ASPathSegment{ segment := ASPathSegment{}
ASNs: make([]uint32, 0),
}
err := decode(buf, []interface{}{&segment.Type, &segment.Count}) err := decode(buf, []interface{}{&segment.Type, &segment.Count})
if err != nil { if err != nil {
...@@ -162,23 +164,51 @@ func (pa *PathAttribute) decodeASPath(buf *bytes.Buffer) error { ...@@ -162,23 +164,51 @@ func (pa *PathAttribute) decodeASPath(buf *bytes.Buffer) error {
return fmt.Errorf("Invalid AS Path segment length: %d", segment.Count) return fmt.Errorf("Invalid AS Path segment length: %d", segment.Count)
} }
segment.ASNs = make([]uint32, segment.Count)
for i := uint8(0); i < segment.Count; i++ { for i := uint8(0); i < segment.Count; i++ {
asn := uint16(0) asn, err := pa.decodeASN(buf, asnLength)
err := decode(buf, []interface{}{&asn})
if err != nil { if err != nil {
return err return err
} }
p += 2 p += uint16(asnLength)
segment.ASNs = append(segment.ASNs, uint32(asn)) segment.ASNs[i] = asn
} }
pa.Value = append(pa.Value.(ASPath), segment) pa.Value = append(pa.Value.(ASPath), segment)
} }
return nil return nil
} }
func (pa *PathAttribute) decodeASN(buf *bytes.Buffer, asnSize uint8) (asn uint32, err error) {
if asnSize == 4 {
return pa.decode4ByteASN(buf)
}
return pa.decode2ByteASN(buf)
}
func (pa *PathAttribute) decode4ByteASN(buf *bytes.Buffer) (asn uint32, err error) {
asn4 := uint32(0)
err = decode(buf, []interface{}{&asn4})
if err != nil {
return 0, err
}
return uint32(asn4), nil
}
func (pa *PathAttribute) decode2ByteASN(buf *bytes.Buffer) (asn uint32, err error) {
asn4 := uint16(0)
err = decode(buf, []interface{}{&asn4})
if err != nil {
return 0, err
}
return uint32(asn4), nil
}
func (pa *PathAttribute) decodeNextHop(buf *bytes.Buffer) error { func (pa *PathAttribute) decodeNextHop(buf *bytes.Buffer) error {
return pa.decodeUint32(buf, "next hop") return pa.decodeUint32(buf, "next hop")
} }
...@@ -273,10 +303,6 @@ func (pa *PathAttribute) decodeLargeCommunities(buf *bytes.Buffer) error { ...@@ -273,10 +303,6 @@ func (pa *PathAttribute) decodeLargeCommunities(buf *bytes.Buffer) error {
return nil return nil
} }
func (pa *PathAttribute) decodeAS4Path(buf *bytes.Buffer) error {
return pa.decodeUint32(buf, "AS4Path")
}
func (pa *PathAttribute) decodeAS4Aggregator(buf *bytes.Buffer) error { func (pa *PathAttribute) decodeAS4Aggregator(buf *bytes.Buffer) error {
return pa.decodeUint32(buf, "AS4Aggregator") return pa.decodeUint32(buf, "AS4Aggregator")
} }
......
...@@ -50,7 +50,7 @@ func TestDecodePathAttrs(t *testing.T) { ...@@ -50,7 +50,7 @@ func TestDecodePathAttrs(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
res, err := decodePathAttrs(bytes.NewBuffer(test.input), uint16(len(test.input))) res, err := decodePathAttrs(bytes.NewBuffer(test.input), uint16(len(test.input)), &DecodingOptions{})
if test.wantFail && err == nil { if test.wantFail && err == nil {
t.Errorf("Expected error did not happen for test %q", test.name) t.Errorf("Expected error did not happen for test %q", test.name)
...@@ -173,7 +173,7 @@ func TestDecodePathAttr(t *testing.T) { ...@@ -173,7 +173,7 @@ func TestDecodePathAttr(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
res, _, err := decodePathAttr(bytes.NewBuffer(test.input)) res, _, err := decodePathAttr(bytes.NewBuffer(test.input), &DecodingOptions{})
if test.wantFail && err == nil { if test.wantFail && err == nil {
t.Errorf("Expected error did not happen for test %q", test.name) t.Errorf("Expected error did not happen for test %q", test.name)
...@@ -264,6 +264,7 @@ func TestDecodeASPath(t *testing.T) { ...@@ -264,6 +264,7 @@ func TestDecodeASPath(t *testing.T) {
input []byte input []byte
wantFail bool wantFail bool
explicitLength uint16 explicitLength uint16
use4OctetASNs bool
expected *PathAttribute expected *PathAttribute
}{ }{
{ {
...@@ -308,6 +309,28 @@ func TestDecodeASPath(t *testing.T) { ...@@ -308,6 +309,28 @@ func TestDecodeASPath(t *testing.T) {
}, },
}, },
}, },
{
name: "32 bit ASNs in AS_PATH",
input: []byte{
1, // AS_SEQUENCE
3, // Path Length
0, 0, 0, 100, 0, 0, 0, 222, 0, 0, 0, 240,
},
wantFail: false,
use4OctetASNs: true,
expected: &PathAttribute{
Length: 14,
Value: ASPath{
ASPathSegment{
Type: 1,
Count: 3,
ASNs: []uint32{
100, 222, 240,
},
},
},
},
},
{ {
name: "Empty input", name: "Empty input",
input: []byte{}, input: []byte{},
...@@ -326,6 +349,7 @@ func TestDecodeASPath(t *testing.T) { ...@@ -326,6 +349,7 @@ func TestDecodeASPath(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
l := uint16(len(test.input)) l := uint16(len(test.input))
if test.explicitLength != 0 { if test.explicitLength != 0 {
l = test.explicitLength l = test.explicitLength
...@@ -333,7 +357,13 @@ func TestDecodeASPath(t *testing.T) { ...@@ -333,7 +357,13 @@ func TestDecodeASPath(t *testing.T) {
pa := &PathAttribute{ pa := &PathAttribute{
Length: l, Length: l,
} }
err := pa.decodeASPath(bytes.NewBuffer(test.input))
asnLength := uint8(2)
if test.use4OctetASNs {
asnLength = 4
}
err := pa.decodeASPath(bytes.NewBuffer(test.input), asnLength)
if test.wantFail && err == nil { if test.wantFail && err == nil {
t.Errorf("Expected error did not happen for test %q", test.name) t.Errorf("Expected error did not happen for test %q", test.name)
...@@ -344,10 +374,11 @@ func TestDecodeASPath(t *testing.T) { ...@@ -344,10 +374,11 @@ func TestDecodeASPath(t *testing.T) {
} }
if err != nil { if err != nil {
continue return
} }
assert.Equal(t, test.expected, pa) assert.Equal(t, test.expected, pa)
})
} }
} }
......
...@@ -56,6 +56,8 @@ type FSM struct { ...@@ -56,6 +56,8 @@ type FSM struct {
capAddPathSend bool capAddPathSend bool
capAddPathRecv bool capAddPathRecv bool
decodingOptions *packet.DecodingOptions
local net.IP local net.IP
ribsInitialized bool ribsInitialized bool
...@@ -99,6 +101,7 @@ func newFSM2(peer *Peer) *FSM { ...@@ -99,6 +101,7 @@ func newFSM2(peer *Peer) *FSM {
msgRecvFailCh: make(chan error), msgRecvFailCh: make(chan error),
stopMsgRecvCh: make(chan struct{}), stopMsgRecvCh: make(chan struct{}),
rib: peer.rib, rib: peer.rib,
decodingOptions: &packet.DecodingOptions{},
} }
} }
......
...@@ -143,7 +143,7 @@ func (s *establishedState) keepaliveTimerExpired() (state, string) { ...@@ -143,7 +143,7 @@ func (s *establishedState) keepaliveTimerExpired() (state, string) {
} }
func (s *establishedState) msgReceived(data []byte) (state, string) { func (s *establishedState) msgReceived(data []byte) (state, string) {
msg, err := packet.Decode(bytes.NewBuffer(data)) msg, err := packet.Decode(bytes.NewBuffer(data), s.fsm.decodingOptions)
if err != nil { if err != nil {
switch bgperr := err.(type) { switch bgperr := err.(type) {
case packet.BGPError: case packet.BGPError:
......
...@@ -82,7 +82,7 @@ func (s *openConfirmState) keepaliveTimerExpired() (state, string) { ...@@ -82,7 +82,7 @@ func (s *openConfirmState) keepaliveTimerExpired() (state, string) {
} }
func (s *openConfirmState) msgReceived(data []byte) (state, string) { func (s *openConfirmState) msgReceived(data []byte) (state, string) {
msg, err := packet.Decode(bytes.NewBuffer(data)) msg, err := packet.Decode(bytes.NewBuffer(data), s.fsm.decodingOptions)
if err != nil { if err != nil {
switch bgperr := err.(type) { switch bgperr := err.(type) {
case packet.BGPError: case packet.BGPError:
......
...@@ -74,7 +74,7 @@ func (s *openSentState) holdTimerExpired() (state, string) { ...@@ -74,7 +74,7 @@ func (s *openSentState) holdTimerExpired() (state, string) {
} }
func (s *openSentState) msgReceived(data []byte) (state, string) { func (s *openSentState) msgReceived(data []byte) (state, string) {
msg, err := packet.Decode(bytes.NewBuffer(data)) msg, err := packet.Decode(bytes.NewBuffer(data), s.fsm.decodingOptions)
if err != nil { if err != nil {
switch bgperr := err.(type) { switch bgperr := err.(type) {
case packet.BGPError: case packet.BGPError:
...@@ -199,6 +199,8 @@ func (s *openSentState) processAddPathCapability(addPathCap packet.AddPathCapabi ...@@ -199,6 +199,8 @@ func (s *openSentState) processAddPathCapability(addPathCap packet.AddPathCapabi
} }
func (s *openSentState) processASN4Capability(cap packet.ASN4Capability) { func (s *openSentState) processASN4Capability(cap packet.ASN4Capability) {
s.fsm.decodingOptions.Supports4OctetASN = true
if s.peerASNRcvd == packet.ASTransASN { if s.peerASNRcvd == packet.ASTransASN {
s.peerASNRcvd = cap.ASN4 s.peerASNRcvd = cap.ASN4
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment