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
+
1
15
package configurator
2
16
3
17
import (
4
18
"errors"
5
19
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
+
6
23
"github.com/ligato/cn-infra/logging"
7
24
"golang.org/x/net/context"
8
25
@@ -132,8 +149,23 @@ func (svc *dumpService) Dump(context.Context, *rpc.DumpRequest) (*rpc.DumpRespon
132
149
return nil , err
133
150
}
134
151
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
+ }
137
169
138
170
return & rpc.DumpResponse {Dump : dump }, nil
139
171
}
@@ -388,38 +420,47 @@ func (svc *dumpService) DumpPuntExceptions() (punts []*vpp_punt.Exception, err e
388
420
389
421
// DumpLinuxInterfaces reads linux interfaces and returns them as an *LinuxInterfaceResponse. If reading ends up with error,
390
422
// 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 ()
394
429
if err != nil {
395
430
return nil , err
396
431
}
397
- for _, iface := range ifDetails {
398
- linuxIfs = append(linuxIfs, )
432
+ for _ , ifDetail := range ifDetails {
433
+ linuxIfs = append (linuxIfs , ifDetail . Interface )
399
434
}
400
435
401
436
return linuxIfs , nil
402
437
}
403
438
404
439
// DumpLinuxARPs reads linux ARPs and returns them as an *LinuxARPsResponse. If reading ends up with error,
405
440
// 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 ()
409
447
if err != nil {
410
448
return nil , err
411
449
}
412
- for _, arp := range arpDetails {
413
- linuxArps = append(linuxArps, arp.Arp )
450
+ for _ , arpDetail := range arpDetails {
451
+ linuxARPs = append (linuxARPs , arpDetail . ARP )
414
452
}
415
453
416
- return &rpc.LinuxARPsResponse{LinuxArpEntries: linuxArps} , nil
454
+ return linuxARPs , nil
417
455
}
418
456
419
457
// DumpLinuxRoutes reads linux routes and returns them as an *LinuxRoutesResponse. If reading ends up with error,
420
458
// 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
+
423
464
rtDetails , err := svc .linuxL3Handler .DumpRoutes ()
424
465
if err != nil {
425
466
return nil , err
@@ -428,6 +469,5 @@ func (svc *dumpService) DumpLinuxRoutes(ctx context.Context, request *rpc.DumpRe
428
469
linuxRoutes = append (linuxRoutes , rt .Route )
429
470
}
430
471
431
- return &rpc.LinuxRoutesResponse{LinuxRoutes: linuxRoutes} , nil
472
+ return linuxRoutes , nil
432
473
}
433
- */
0 commit comments