diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-07-01 17:43:18 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-07-01 21:33:39 +0900 |
commit | d43b77e0ec0f3f51cff9317db312d97a98f1df8f (patch) | |
tree | 2e05a95be9cd4b116e53bbf418fe7437c5787517 /server | |
parent | 1db97a53022a02ff3bf355909b54eb6be8dc286e (diff) |
packet: add AS_PATH validator
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/server/peer.go b/server/peer.go index 3e5888f0..fd41563a 100644 --- a/server/peer.go +++ b/server/peer.go @@ -43,6 +43,8 @@ type Peer struct { outgoing chan *bgp.BGPMessage distPolicies []*policy.Policy defaultDistributePolicy config.DefaultPolicyType + isConfederationMember bool + isEBGP bool } func NewPeer(g config.Global, config config.Neighbor) *Peer { @@ -66,6 +68,17 @@ func NewPeer(g config.Global, config config.Neighbor) *Peer { } peer.adjRib = table.NewAdjRib(peer.configuredRFlist()) peer.fsm = NewFSM(&g, &config) + + if config.PeerAs != g.As { + peer.isEBGP = true + for _, member := range g.Confederation.MemberAs { + if member == config.PeerAs { + peer.isConfederationMember = true + break + } + } + } + return peer } @@ -158,7 +171,8 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b update = true peer.config.BgpNeighborCommonState.UpdateRecvTime = time.Now().Unix() body := m.Body.(*bgp.BGPUpdate) - _, err := bgp.ValidateUpdateMsg(body, peer.rfMap) + confedCheckRequired := !peer.isConfederationMember && peer.isEBGP + _, err := bgp.ValidateUpdateMsg(body, peer.rfMap, confedCheckRequired) if err != nil { log.WithFields(log.Fields{ "Topic": "Peer", |