diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-08-03 04:27:33 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-04-04 22:07:46 +0900 |
commit | bba54bdaa14c1a4c13245548757b38a89531fd9b (patch) | |
tree | ee8b87c207dc489d64f0a6e55c2bca0ede3f20bf /packet/bgp | |
parent | 00f8406cb6a207341ea4f68a8fa294f31eb7bc7b (diff) |
skip asn negotiation for BGP unnumbered peers
since BGP unnumbered peers are typically trusted, skip asn negotiation
for easy configuration.
from configuration file:
```toml
[[neighbors]]
[[neighbors.config]]
neighbor-interface = "eth0"
```
from cli:
```
$ gobgp neighbor add interface eth0
```
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp')
-rw-r--r-- | packet/bgp/validate.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/packet/bgp/validate.go b/packet/bgp/validate.go index 5cf2afbb..13c66a77 100644 --- a/packet/bgp/validate.go +++ b/packet/bgp/validate.go @@ -230,9 +230,9 @@ func ValidateBGPMessage(m *BGPMessage) error { return nil } -func ValidateOpenMsg(m *BGPOpen, expectedAS uint32) error { +func ValidateOpenMsg(m *BGPOpen, expectedAS uint32) (uint32, error) { if m.Version != 4 { - return NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNSUPPORTED_VERSION_NUMBER, nil, fmt.Sprintf("upsuppored version %d", m.Version)) + return 0, NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNSUPPORTED_VERSION_NUMBER, nil, fmt.Sprintf("upsuppored version %d", m.Version)) } as := uint32(m.MyAS) @@ -248,12 +248,12 @@ func ValidateOpenMsg(m *BGPOpen, expectedAS uint32) error { } } } - if as != expectedAS { - return NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_BAD_PEER_AS, nil, fmt.Sprintf("as number mismatch expected %d, received %d", expectedAS, as)) + if expectedAS != 0 && as != expectedAS { + return 0, NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_BAD_PEER_AS, nil, fmt.Sprintf("as number mismatch expected %d, received %d", expectedAS, as)) } if m.HoldTime < 3 && m.HoldTime != 0 { - return NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNACCEPTABLE_HOLD_TIME, nil, fmt.Sprintf("unacceptable hold time %d", m.HoldTime)) + return 0, NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNACCEPTABLE_HOLD_TIME, nil, fmt.Sprintf("unacceptable hold time %d", m.HoldTime)) } - return nil + return as, nil } |