summaryrefslogtreecommitdiffhomepage
path: root/config/util.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-09-20 13:32:25 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-07 21:53:46 +0900
commit9d90d038a703f9e37e6fae4c1d035e889161a9c4 (patch)
tree2b49e9837efb26715cf170d448cd70697e978f73 /config/util.go
parente541ede1b5e4d08aaa3fffd1ee13744cc1b69c59 (diff)
packet/bgp: Add Validation for BGP Confederations
RFC 5065 says that: "It is a error for a BGP speaker to receive an update message from a confederation peer that is not in the same Member-AS that does not have AS_CONFED_SEQUENCE as the first segment." Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'config/util.go')
-rw-r--r--config/util.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/config/util.go b/config/util.go
index 915b55b4..3bbddca9 100644
--- a/config/util.go
+++ b/config/util.go
@@ -40,19 +40,24 @@ func detectConfigFileType(path, def string) string {
}
}
-func IsConfederationMember(g *Global, p *Neighbor) bool {
- if p.Config.PeerAs != g.Config.As {
- for _, member := range g.Confederation.Config.MemberAsList {
- if member == p.Config.PeerAs {
- return true
- }
+func (n *Neighbor) IsConfederationMember(g *Global) bool {
+ for _, member := range g.Confederation.Config.MemberAsList {
+ if member == n.Config.PeerAs {
+ return true
}
}
return false
}
-func IsEBGPPeer(g *Global, p *Neighbor) bool {
- return p.Config.PeerAs != g.Config.As
+func (n *Neighbor) IsConfederation(g *Global) bool {
+ if n.Config.PeerAs == g.Config.As {
+ return true
+ }
+ return n.IsConfederationMember(g)
+}
+
+func (n *Neighbor) IsEBGPPeer(g *Global) bool {
+ return n.Config.PeerAs != g.Config.As
}
type AfiSafis []AfiSafi