diff options
-rw-r--r-- | server/server.go | 6 | ||||
-rw-r--r-- | test/scenario_test/bgp_router_test.py | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go index 77c6d8fb..7efc3686 100644 --- a/server/server.go +++ b/server/server.go @@ -2652,6 +2652,12 @@ func (server *BgpServer) handleAddNeighborRequest(grpcReq *GrpcRequest) ([]*Send if a.Transport != nil { pconf.Transport.Config.LocalAddress = a.Transport.LocalAddress pconf.Transport.Config.PassiveMode = a.Transport.PassiveMode + } else { + if net.ParseIP(a.Conf.NeighborAddress).To4() != nil { + pconf.Transport.Config.LocalAddress = "0.0.0.0" + } else { + pconf.Transport.Config.LocalAddress = "::" + } } if a.EbgpMultihop != nil { pconf.EbgpMultihop.Config.Enabled = a.EbgpMultihop.Enabled diff --git a/test/scenario_test/bgp_router_test.py b/test/scenario_test/bgp_router_test.py index baae3841..8292f6d0 100644 --- a/test/scenario_test/bgp_router_test.py +++ b/test/scenario_test/bgp_router_test.py @@ -18,6 +18,7 @@ from fabric.api import local from lib import base from lib.gobgp import * from lib.quagga import * +from lib.exabgp import * import sys import os import time @@ -336,6 +337,18 @@ class GoBGPTestBase(unittest.TestCase): self.assertTrue(len(paths) == 1) self.assertTrue(paths[0]['source-id'] == '192.168.0.2') + def test_19_check_grpc_add_neighbor(self): + g1 = self.gobgp + e1 = ExaBGPContainer(name='e1', asn=65000, router_id='192.168.0.7') + time.sleep(e1.run()) + e1.add_peer(g1) + n = e1.peers[g1]['local_addr'].split('/')[0] + g1.local('gobgp n add {0} as 65000'.format(n)) + g1.add_peer(e1, reload_config=False) + + g1.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=e1) + + if __name__ == '__main__': if os.geteuid() is not 0: |