gobgp
gobgp copied to clipboard
BGP-LS Problem:why cannot LsTLVIgpRouterID support length of 4 when decodeFromByte ?
func (l *LsTLVIgpRouterID) DecodeFromBytes(data []byte) error { value, err := l.LsTLV.DecodeFromBytes(data) if err != nil { return err }
if l.Type != LS_TLV_IGP_ROUTER_ID {
return malformedAttrListErr("Unexpected TLV type")
}
// https://tools.ietf.org/html/rfc7752#section-3.2.1.4
// 6, 7, and 8 are the only valid
Why don't support length 4 ? but it can be 4 in RFC7752.. Misunderstanding or any other thinking ?
if len(value) < 6 || len(value) > 8 {
return malformedAttrListErr("Incorrect IGP Router ID length")
}
l.RouterID = value
return nil
}
https://tools.ietf.org/html/rfc7752#section-3.2.1.4
in order to support length of 4,I modify this code ,
but when gobgpd run, it report many errors:
You probably need to look into:
func (l *LsNodeNLRI) String() string {
if l.LocalNodeDesc == nil {
return "NODE { EMPTY }"
}
local := l.LocalNodeDesc.(*LsTLVNodeDescriptor).Extract()
return fmt.Sprintf("NODE { AS:%v BGP-LS ID:%v %v %v:%v }", local.Asn, local.BGPLsID, local.IGPRouterID, l.ProtocolID.String(), l.Identifier)
}
The fmt.Sprintf most likely returns a a string which makes the below try to marshal malformed json.
func (l *LsAddrPrefix) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
Type LsNLRIType `json:"type"`
Length uint16 `json:"length"`
NLRI string `json:"nlri"`
}{
l.Type,
l.Length,
l.String(),
})
}