summaryrefslogtreecommitdiffhomepage
path: root/packet
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-26 00:24:49 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-26 00:24:49 +0900
commitad706a62aba6c98c1a0a5ca39759e37c774d9775 (patch)
tree64b06f78da138d7ee24ac60889e1c2e7dcd8a560 /packet
parent5443db3093965ce5f137f7fc9d9018723c20c400 (diff)
table: validate path attribute flag
BGP_ERROR_SUB_ATTRIBUTE_FLAGS_ERROR is preferred than BGP_ERROR_SUB_ATTRIBUTE_LENGTH_ERROR so after parsing a message then validating the flag does't work. With this patch, bmp doesn't parse a message having incorrect path attribute flag. It's not ideal so need to fix later. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet')
-rw-r--r--packet/bgp.go5
-rw-r--r--packet/bgp_test.go2
2 files changed, 6 insertions, 1 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index 5131a284..a5fd715c 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1134,6 +1134,7 @@ func (p *PathAttribute) getType() BGPAttrType {
}
func (p *PathAttribute) DecodeFromBytes(data []byte) error {
+ odata := data
eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR)
eSubCode := uint8(BGP_ERROR_SUB_ATTRIBUTE_LENGTH_ERROR)
if len(data) < 2 {
@@ -1160,6 +1161,10 @@ func (p *PathAttribute) DecodeFromBytes(data []byte) error {
}
p.Value = data[:p.Length]
+ ok, eMsg := ValidateFlags(p.Type, p.Flags)
+ if !ok {
+ return NewMessageError(eCode, BGP_ERROR_SUB_ATTRIBUTE_FLAGS_ERROR, odata[:p.Len()], eMsg)
+ }
return nil
}
diff --git a/packet/bgp_test.go b/packet/bgp_test.go
index 5b2e1736..8fd734eb 100644
--- a/packet/bgp_test.go
+++ b/packet/bgp_test.go
@@ -108,7 +108,7 @@ func update() *BGPMessage {
NewPathAttributeMpUnreachNLRI([]AddrPrefixInterface{}),
&PathAttributeUnknown{
PathAttribute: PathAttribute{
- Flags: 1,
+ Flags: BGP_ATTR_FLAG_TRANSITIVE,
Type: 100,
Value: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
},