1+ // Copyright (c) 2019 Cisco and/or its affiliates.
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at:
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
115package configurator
216
317import (
418 "errors"
519
20+ linux_interfaces "github.com/ligato/vpp-agent/api/models/linux/interfaces"
21+ linux_l3 "github.com/ligato/vpp-agent/api/models/linux/l3"
22+
623 "github.com/ligato/cn-infra/logging"
724 "golang.org/x/net/context"
825
@@ -132,8 +149,23 @@ func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpRespon
132149 return nil , err
133150 }
134151
135- // FIXME: linux interfaces should return known proto instead of netlink
136- // state.LinuxData.Interfaces, _ = svc.DumpLinuxInterfaces()
152+ dump .LinuxConfig .Interfaces , err = svc .DumpLinuxInterfaces ()
153+ if err != nil {
154+ svc .log .Errorf ("DumpLinuxInterfaces failed: %v" , err )
155+ return nil , err
156+ }
157+
158+ dump .LinuxConfig .ArpEntries , err = svc .DumpLinuxARPs ()
159+ if err != nil {
160+ svc .log .Errorf ("DumpLinuxARPs failed: %v" , err )
161+ return nil , err
162+ }
163+
164+ dump .LinuxConfig .Routes , err = svc .DumpLinuxRoutes ()
165+ if err != nil {
166+ svc .log .Errorf ("DumpLinuxRoutes failed: %v" , err )
167+ return nil , err
168+ }
137169
138170 return & rpc.DumpResponse {Dump : dump }, nil
139171}
@@ -388,38 +420,47 @@ func (svc *dumpService) DumpPuntExceptions() (punts []*vpp_punt.Exception, err e
388420
389421// DumpLinuxInterfaces reads linux interfaces and returns them as an *LinuxInterfaceResponse. If reading ends up with error,
390422// only error is send back in response
391- /*func (svc *dumpService) DumpLinuxInterfaces() ([]*linux_interfaces.Interface, error) {
392- var linuxIfs []*linux_interfaces.Interface
393- ifDetails, err := svc.linuxIfHandler.GetLinkList()
423+ func (svc * dumpService ) DumpLinuxInterfaces () (linuxIfs []* linux_interfaces.Interface , err error ) {
424+ if svc .linuxIfHandler == nil {
425+ return nil , errors .New ("linuxIfHandler is not available" )
426+ }
427+
428+ ifDetails , err := svc .linuxIfHandler .DumpInterfaces ()
394429 if err != nil {
395430 return nil , err
396431 }
397- for _, iface := range ifDetails {
398- linuxIfs = append(linuxIfs, )
432+ for _ , ifDetail := range ifDetails {
433+ linuxIfs = append (linuxIfs , ifDetail . Interface )
399434 }
400435
401436 return linuxIfs , nil
402437}
403438
404439// DumpLinuxARPs reads linux ARPs and returns them as an *LinuxARPsResponse. If reading ends up with error,
405440// only error is send back in response
406- func (svc *dumpService) DumpLinuxARPs(ctx context.Context, request *rpc.DumpRequest) (*rpc.LinuxARPsResponse, error) {
407- var linuxArps []*linuxL3.LinuxStaticArpEntries_ArpEntry
408- arpDetails, err := svc.linuxL3Handler.DumpArpEntries()
441+ func (svc * dumpService ) DumpLinuxARPs () (linuxARPs []* linux_l3.ARPEntry , err error ) {
442+ if svc .linuxL3Handler == nil {
443+ return nil , errors .New ("linuxL3Handler is not available" )
444+ }
445+
446+ arpDetails , err := svc .linuxL3Handler .DumpARPEntries ()
409447 if err != nil {
410448 return nil , err
411449 }
412- for _, arp := range arpDetails {
413- linuxArps = append(linuxArps, arp.Arp )
450+ for _ , arpDetail := range arpDetails {
451+ linuxARPs = append (linuxARPs , arpDetail . ARP )
414452 }
415453
416- return &rpc.LinuxARPsResponse{LinuxArpEntries: linuxArps} , nil
454+ return linuxARPs , nil
417455}
418456
419457// DumpLinuxRoutes reads linux routes and returns them as an *LinuxRoutesResponse. If reading ends up with error,
420458// only error is send back in response
421- func (svc *dumpService) DumpLinuxRoutes(ctx context.Context, request *rpc.DumpRequest) (*rpc.LinuxRoutesResponse, error) {
422- var linuxRoutes []*linuxL3.LinuxStaticRoutes_Route
459+ func (svc * dumpService ) DumpLinuxRoutes () (linuxRoutes []* linux_l3.Route , err error ) {
460+ if svc .linuxL3Handler == nil {
461+ return nil , errors .New ("linuxL3Handler is not available" )
462+ }
463+
423464 rtDetails , err := svc .linuxL3Handler .DumpRoutes ()
424465 if err != nil {
425466 return nil , err
@@ -428,6 +469,5 @@ func (svc *dumpService) DumpLinuxRoutes(ctx context.Context, request *rpc.DumpRe
428469 linuxRoutes = append (linuxRoutes , rt .Route )
429470 }
430471
431- return &rpc.LinuxRoutesResponse{LinuxRoutes: linuxRoutes} , nil
472+ return linuxRoutes , nil
432473}
433- */
0 commit comments