summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/peer.go40
-rw-r--r--table/path.go14
2 files changed, 47 insertions, 7 deletions
diff --git a/server/peer.go b/server/peer.go
index 8687b106..2a4e71a0 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -162,14 +162,40 @@ func (peer *Peer) sendPathsToSiblings(pathList []table.Path) {
if len(pathList) == 0 {
return
}
- pm := &peerMsg{
- msgType: PEER_MSG_PATH,
- msgData: pathList,
- }
for _, s := range peer.siblings {
- if peer.peerConfig.RouteServer.RouteServerClient && peer.peerConfig.PeerAs == s.As {
- // don't send to a peer having the same AS number.
- continue
+ var pm *peerMsg
+ if peer.peerConfig.RouteServer.RouteServerClient {
+ checkas := func(asnum uint32, p []table.Path) []table.Path {
+ plist := []table.Path{}
+ for _, path := range p {
+ asList := path.GetAsList()
+ send := true
+ for _, as := range asList {
+ if as == asnum {
+ send = false
+ break
+ }
+ }
+ if send {
+ plist = append(plist, path)
+ }
+ }
+ return plist
+ }
+ p := checkas(s.As, pathList)
+ if len(p) == 0 {
+ continue
+ } else {
+ pm = &peerMsg{
+ msgType: PEER_MSG_PATH,
+ msgData: p,
+ }
+ }
+ } else {
+ pm = &peerMsg{
+ msgType: PEER_MSG_PATH,
+ msgData: pathList,
+ }
}
s.peerMsgCh <- pm
}
diff --git a/table/path.go b/table/path.go
index 0d52d343..ffbdd902 100644
--- a/table/path.go
+++ b/table/path.go
@@ -34,6 +34,7 @@ type Path interface {
updatePathAttrs(global *config.Global, peer *config.Neighbor)
GetRouteFamily() bgp.RouteFamily
GetAsPathLen() int
+ GetAsList() []uint32
setSource(source *PeerInfo)
GetSource() *PeerInfo
GetSourceAs() uint32
@@ -361,6 +362,19 @@ func (pd *PathDefault) GetAsPathLen() int {
return length
}
+func (pd *PathDefault) GetAsList() []uint32 {
+ asList := []uint32{}
+ if _, attr := pd.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
+ aspath := attr.(*bgp.PathAttributeAsPath)
+ for _, paramIf := range aspath.Value {
+ segment := paramIf.(*bgp.As4PathParam)
+ asList = append(asList, segment.AS...)
+ }
+
+ }
+ return asList
+}
+
// create Path object based on route family
func CreatePath(source *PeerInfo, nlri bgp.AddrPrefixInterface, attrs []bgp.PathAttributeInterface, isWithdraw bool, now time.Time) (Path, error) {