diff options
-rw-r--r-- | api/gobgp.pb.go | 2 | ||||
-rw-r--r-- | api/gobgp.proto | 2 | ||||
-rw-r--r-- | gobgp/mrt.go | 2 | ||||
-rw-r--r-- | server/server.go | 22 |
4 files changed, 21 insertions, 7 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 876d5218..e76bc45c 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -209,6 +209,8 @@ type ModPathArguments struct { Resource Resource `protobuf:"varint,1,opt,name=resource,enum=api.Resource" json:"resource,omitempty"` Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` Path *Path `protobuf:"bytes,3,opt,name=path" json:"path,omitempty"` + Asn uint32 `protobuf:"varint,4,opt,name=asn" json:"asn,omitempty"` + Id string `protobuf:"bytes,5,opt,name=id" json:"id,omitempty"` } func (m *ModPathArguments) Reset() { *m = ModPathArguments{} } diff --git a/api/gobgp.proto b/api/gobgp.proto index 024f699a..80b88c02 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -63,6 +63,8 @@ message ModPathArguments { Resource resource = 1; string name = 2; Path path = 3; + uint32 asn = 4; + string id = 5; } message PolicyArguments { diff --git a/gobgp/mrt.go b/gobgp/mrt.go index 6a5f3df8..d3f89f48 100644 --- a/gobgp/mrt.go +++ b/gobgp/mrt.go @@ -296,6 +296,8 @@ func injectMrt(r string, filename string, count int) error { ch <- &api.ModPathArguments{ Resource: resource, Path: path, + Asn: peers[e.PeerIndex].AS, + Id: peers[e.PeerIndex].BgpId.String(), } } diff --git a/server/server.go b/server/server.go index 64db3420..af85883b 100644 --- a/server/server.go +++ b/server/server.go @@ -858,7 +858,7 @@ func getMacMobilityExtendedCommunity(etag uint32, mac net.HardwareAddr, evpnPath return nil } -func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *table.PeerInfo) []*table.Path { +func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest) []*table.Path { var nlri bgp.AddrPrefixInterface result := &GrpcResponse{} @@ -868,12 +868,24 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta var rf bgp.RouteFamily var path *api.Path seen := make(map[bgp.BGPAttrType]bool) + var pi *table.PeerInfo arg, ok := grpcReq.Data.(*api.ModPathArguments) if !ok { result.ResponseErr = fmt.Errorf("type assertion failed") goto ERR } + if arg.Asn != 0 { + pi = &table.PeerInfo{ + AS: arg.Asn, + LocalID: net.ParseIP(arg.Id), + } + } else { + pi = &table.PeerInfo{ + AS: server.bgpConfig.Global.GlobalConfig.As, + LocalID: server.bgpConfig.Global.GlobalConfig.RouterId, + } + } path = arg.Path if len(path.Nlri) > 0 { @@ -985,7 +997,7 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta pattr = append(pattr, bgp.NewPathAttributeExtendedCommunities(extcomms)) } - return []*table.Path{table.NewPath(peerInfo, nlri, path.IsWithdraw, pattr, false, time.Now(), path.NoImplicitWithdraw)} + return []*table.Path{table.NewPath(pi, nlri, path.IsWithdraw, pattr, false, time.Now(), path.NoImplicitWithdraw)} ERR: grpcReq.ResponseCh <- result close(grpcReq.ResponseCh) @@ -1151,11 +1163,7 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg { } case REQ_MOD_PATH: - pi := &table.PeerInfo{ - AS: server.bgpConfig.Global.GlobalConfig.As, - LocalID: server.bgpConfig.Global.GlobalConfig.RouterId, - } - pathList := server.handleModPathRequest(grpcReq, pi) + pathList := server.handleModPathRequest(grpcReq) if len(pathList) > 0 { msgs = server.propagateUpdate("", false, pathList) grpcReq.ResponseCh <- &GrpcResponse{} |