forked from contiv/vpp
/
data_change_grpc.go
594 lines (516 loc) · 18.8 KB
/
data_change_grpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
// Copyright (c) 2017 Cisco and/or its affiliates.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv2
import (
"golang.org/x/net/context"
"github.com/americanbinary/vpp/plugins/grpc/rpc"
"go.ligato.io/vpp-agent/v3/clientv2/linux"
"go.ligato.io/vpp-agent/v3/clientv2/vpp"
"go.ligato.io/vpp-agent/v3/proto/ligato/linux/interfaces"
"go.ligato.io/vpp-agent/v3/proto/ligato/linux/iptables"
"go.ligato.io/vpp-agent/v3/proto/ligato/linux/l3"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/abf"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/acl"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipsec"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt"
"go.ligato.io/vpp-agent/v3/proto/ligato/vpp/stn"
)
const (
notImplemented = "not implemented in v.2 yet"
deprecated = "deprecated in v.2"
)
// NewDataChangeDSL is a constructor
func NewDataChangeDSL(client rpc.DataChangeServiceClient) *DataChangeDSL {
return &DataChangeDSL{
client: client,
putReq: &rpc.DataRequest{},
delReq: &rpc.DataRequest{},
}
}
// DataChangeDSL is used to conveniently assign all the data that are needed for the DataChange.
// This is an implementation of Domain Specific Language (DSL) for a change of the VPP/Linux configuration.
type DataChangeDSL struct {
client rpc.DataChangeServiceClient
withPut bool
withDel bool
putReq *rpc.DataRequest
delReq *rpc.DataRequest
}
// PutDSL allows to add or edit configuration via GRPC.
type PutDSL struct {
parent *DataChangeDSL
}
// DeleteDSL allows to remove configuration via GRPC.
type DeleteDSL struct {
parent *DataChangeDSL
}
// Put enables creating Interface/BD...
func (dsl *DataChangeDSL) Put() linuxclient.PutDSL {
return &PutDSL{dsl}
}
// Delete enables deleting Interface/BD...
func (dsl *DataChangeDSL) Delete() linuxclient.DeleteDSL {
return &DeleteDSL{dsl}
}
// LinuxInterface adds a request to create or update Linux network interface.
func (dsl *PutDSL) LinuxInterface(val *linux_interfaces.Interface) linuxclient.PutDSL {
dsl.parent.putReq.LinuxInterfaces = append(dsl.parent.putReq.LinuxInterfaces, val)
dsl.parent.withPut = true
return dsl
}
// Span adds VPP span to the Put request.
func (dsl *PutDSL) Span(span *vpp_interfaces.Span) linuxclient.PutDSL {
dsl.parent.putReq.Spans = append(dsl.parent.putReq.Spans, span)
dsl.parent.withPut = true
return dsl
}
// ABF adds a request to create or update VPP ACL-based forwarding.
func (dsl *PutDSL) ABF(abf *vpp_abf.ABF) linuxclient.PutDSL {
dsl.parent.putReq.Forwardings = append(dsl.parent.putReq.Forwardings, abf)
dsl.parent.withPut = true
return dsl
}
// IptablesRuleChain adds request to create or update iptables rule chain.
func (dsl *PutDSL) IptablesRuleChain(val *linux_iptables.RuleChain) linuxclient.PutDSL {
dsl.parent.putReq.RuleChains = append(dsl.parent.putReq.RuleChains, val)
dsl.parent.withPut = true
return dsl
}
// VrfTable adds a request to create or update VPP VRF table.
func (dsl *PutDSL) VrfTable(val *vpp_l3.VrfTable) linuxclient.PutDSL {
dsl.parent.putReq.VrfTables = append(dsl.parent.putReq.VrfTables, val)
dsl.parent.withPut = true
return dsl
}
// NAT44Interface adds a request to create or update NAT44 interface configuration.
func (dsl *PutDSL) NAT44Interface(natIf *vpp_nat.Nat44Interface) linuxclient.PutDSL {
dsl.parent.putReq.Nat44Interfaces = append(dsl.parent.putReq.Nat44Interfaces, natIf)
dsl.parent.withPut = true
return dsl
}
// NAT44AddressPool adds a request to create or update NAT44 address pool.
func (dsl *PutDSL) NAT44AddressPool(pool *vpp_nat.Nat44AddressPool) linuxclient.PutDSL {
dsl.parent.putReq.Nat44AddressPools = append(dsl.parent.putReq.Nat44AddressPools, pool)
dsl.parent.withPut = true
return dsl
}
// PuntException adds request to create or update exception to punt specific packets.
func (dsl *PutDSL) PuntException(val *vpp_punt.Exception) linuxclient.PutDSL {
dsl.parent.putReq.Exceptions = append(dsl.parent.putReq.Exceptions, val)
dsl.parent.withPut = true
return dsl
}
// LinuxArpEntry adds a request to crete or update Linux ARP entry
func (dsl *PutDSL) LinuxArpEntry(val *linux_l3.ARPEntry) linuxclient.PutDSL {
dsl.parent.putReq.LinuxArpEntries = append(dsl.parent.putReq.LinuxArpEntries, val)
dsl.parent.withPut = true
return dsl
}
// LinuxRoute adds a request to crete or update Linux route
func (dsl *PutDSL) LinuxRoute(val *linux_l3.Route) linuxclient.PutDSL {
dsl.parent.putReq.LinuxRoutes = append(dsl.parent.putReq.LinuxRoutes, val)
dsl.parent.withPut = true
return dsl
}
// VppInterface adds a request to create or update VPP network interface.
func (dsl *PutDSL) VppInterface(val *vpp_interfaces.Interface) linuxclient.PutDSL {
dsl.parent.putReq.Interfaces = append(dsl.parent.putReq.Interfaces, val)
dsl.parent.withPut = true
return dsl
}
// ACL adds a request to create or update VPP Access Control List.
func (dsl *PutDSL) ACL(val *vpp_acl.ACL) linuxclient.PutDSL {
dsl.parent.putReq.AccessLists = append(dsl.parent.putReq.AccessLists, val)
dsl.parent.withPut = true
return dsl
}
// BD adds a request to create or update VPP Bridge Domain.
func (dsl *PutDSL) BD(val *vpp_l2.BridgeDomain) linuxclient.PutDSL {
dsl.parent.putReq.BridgeDomains = append(dsl.parent.putReq.BridgeDomains, val)
dsl.parent.withPut = true
return dsl
}
// BDFIB adds a request to create or update VPP L2 Forwarding Information Base.
func (dsl *PutDSL) BDFIB(val *vpp_l2.FIBEntry) linuxclient.PutDSL {
dsl.parent.putReq.FIBs = append(dsl.parent.putReq.FIBs, val)
dsl.parent.withPut = true
return dsl
}
// XConnect adds a request to create or update VPP Cross Connect.
func (dsl *PutDSL) XConnect(val *vpp_l2.XConnectPair) linuxclient.PutDSL {
dsl.parent.putReq.XCons = append(dsl.parent.putReq.XCons, val)
dsl.parent.withPut = true
return dsl
}
// StaticRoute adds a request to create or update VPP L3 Static Route.
func (dsl *PutDSL) StaticRoute(val *vpp_l3.Route) linuxclient.PutDSL {
dsl.parent.putReq.StaticRoutes = append(dsl.parent.putReq.StaticRoutes, val)
dsl.parent.withPut = true
return dsl
}
// Arp adds a request to create or update VPP L3 ARP.
func (dsl *PutDSL) Arp(val *vpp_l3.ARPEntry) linuxclient.PutDSL {
dsl.parent.putReq.ArpEntries = append(dsl.parent.putReq.ArpEntries, val)
dsl.parent.withPut = true
return dsl
}
// ProxyArp adds a request to create or update VPP L3 proxy ARP.
func (dsl *PutDSL) ProxyArp(val *vpp_l3.ProxyARP) linuxclient.PutDSL {
dsl.parent.putReq.ProxyArp = val
dsl.parent.withPut = true
return dsl
}
// IPScanNeighbor adds L3 IP Scan Neighbor to the RESYNC request.
func (dsl *PutDSL) IPScanNeighbor(val *vpp_l3.IPScanNeighbor) linuxclient.PutDSL {
dsl.parent.putReq.IPScanNeighbor = val
dsl.parent.withPut = true
return dsl
}
// StnRule adds a request to create or update VPP Stn rule.
func (dsl *PutDSL) StnRule(val *vpp_stn.Rule) linuxclient.PutDSL {
defer func() { panic(deprecated) }()
return dsl
}
// NAT44Global adds a request to set global configuration for NAT44
func (dsl *PutDSL) NAT44Global(val *vpp_nat.Nat44Global) linuxclient.PutDSL {
dsl.parent.putReq.NatGlobal = val
dsl.parent.withPut = true
return dsl
}
// DNAT44 adds a request to create or update DNAT44 configuration
func (dsl *PutDSL) DNAT44(val *vpp_nat.DNat44) linuxclient.PutDSL {
dsl.parent.putReq.DNATs = append(dsl.parent.putReq.DNATs, val)
dsl.parent.withPut = true
return dsl
}
// IPSecSA adds request to create a new Security Association
func (dsl *PutDSL) IPSecSA(val *vpp_ipsec.SecurityAssociation) linuxclient.PutDSL {
dsl.parent.putReq.SAs = append(dsl.parent.putReq.SAs, val)
dsl.parent.withPut = true
return dsl
}
// IPSecSPD adds request to create a new Security Policy Database
func (dsl *PutDSL) IPSecSPD(val *vpp_ipsec.SecurityPolicyDatabase) linuxclient.PutDSL {
dsl.parent.putReq.SPDs = append(dsl.parent.putReq.SPDs, val)
dsl.parent.withPut = true
return dsl
}
// PuntIPRedirect adds request to create or update rule to punt L3 traffic via interface.
func (dsl *PutDSL) PuntIPRedirect(val *vpp_punt.IPRedirect) linuxclient.PutDSL {
dsl.parent.putReq.IPRedirectPunts = append(dsl.parent.putReq.IPRedirectPunts, val)
dsl.parent.withPut = true
return dsl
}
// PuntToHost adds request to create or update rule to punt L4 traffic to a host.
func (dsl *PutDSL) PuntToHost(val *vpp_punt.ToHost) linuxclient.PutDSL {
dsl.parent.putReq.ToHostPunts = append(dsl.parent.putReq.ToHostPunts, val)
dsl.parent.withPut = true
return dsl
}
// Delete enables deleting Interface/BD...
func (dsl *PutDSL) Delete() linuxclient.DeleteDSL {
return &DeleteDSL{dsl.parent}
}
// Send propagates changes to the channels.
func (dsl *PutDSL) Send() vppclient.Reply {
return dsl.parent.Send()
}
// LinuxInterface adds a request to delete an existing Linux network
// interface.
func (dsl *DeleteDSL) LinuxInterface(ifaceName string) linuxclient.DeleteDSL {
dsl.parent.delReq.LinuxInterfaces = append(dsl.parent.delReq.LinuxInterfaces,
&linux_interfaces.Interface{
Name: ifaceName,
})
dsl.parent.withDel = true
return dsl
}
// IptablesRuleChain adds request to delete iptables rule chain.
func (dsl *DeleteDSL) IptablesRuleChain(name string) linuxclient.DeleteDSL {
dsl.parent.delReq.RuleChains = append(dsl.parent.delReq.RuleChains,
&linux_iptables.RuleChain{
Name: name,
})
dsl.parent.withDel = true
return dsl
}
// Span adds VPP span to the Delete request.
func (dsl *DeleteDSL) Span(span *vpp_interfaces.Span) linuxclient.DeleteDSL {
dsl.parent.delReq.Spans = append(dsl.parent.delReq.Spans, span)
dsl.parent.withDel = true
return dsl
}
// ABF adds a request to delete an existing VPP ACL-based forwarding.
func (dsl *DeleteDSL) ABF(abfIndex uint32) linuxclient.DeleteDSL {
dsl.parent.delReq.Forwardings = append(dsl.parent.delReq.Forwardings,
&vpp_abf.ABF{
Index: abfIndex,
})
dsl.parent.withDel = true
return dsl
}
// VrfTable adds a request to delete existing VPP VRF table.
func (dsl *DeleteDSL) VrfTable(id uint32, proto vpp_l3.VrfTable_Protocol) linuxclient.DeleteDSL {
dsl.parent.delReq.VrfTables = append(dsl.parent.delReq.VrfTables,
&vpp_l3.VrfTable{
Id: id,
Protocol: proto,
})
dsl.parent.withDel = true
return dsl
}
// NAT44Interface adds a request to delete NAT44 interface configuration.
func (dsl *DeleteDSL) NAT44Interface(natIf *vpp_nat.Nat44Interface) linuxclient.DeleteDSL {
dsl.parent.delReq.Nat44Interfaces = append(dsl.parent.delReq.Nat44Interfaces, natIf)
dsl.parent.withDel = true
return dsl
}
// NAT44AddressPool adds a request to delete NAT44 address pool.
func (dsl *DeleteDSL) NAT44AddressPool(pool *vpp_nat.Nat44AddressPool) linuxclient.DeleteDSL {
dsl.parent.delReq.Nat44AddressPools = append(dsl.parent.delReq.Nat44AddressPools, pool)
dsl.parent.withDel = true
return dsl
}
// PuntException adds request to delete exception to punt specific packets.
func (dsl *DeleteDSL) PuntException(reason string) linuxclient.DeleteDSL {
dsl.parent.delReq.Exceptions = append(dsl.parent.delReq.Exceptions,
&vpp_punt.Exception{
Reason: reason,
})
dsl.parent.withDel = true
return dsl
}
// LinuxArpEntry adds a request to delete Linux ARP entry
func (dsl *DeleteDSL) LinuxArpEntry(ifaceName string, ipAddr string) linuxclient.DeleteDSL {
dsl.parent.delReq.LinuxArpEntries = append(dsl.parent.delReq.LinuxArpEntries,
&linux_l3.ARPEntry{
Interface: ifaceName,
IpAddress: ipAddr,
})
dsl.parent.withDel = true
return dsl
}
// LinuxRoute adds a request to delete Linux route
func (dsl *DeleteDSL) LinuxRoute(dstNet, outIfaceName string) linuxclient.DeleteDSL {
dsl.parent.delReq.LinuxRoutes = append(dsl.parent.delReq.LinuxRoutes,
&linux_l3.Route{
DstNetwork: dstNet,
OutgoingInterface: outIfaceName,
})
dsl.parent.withDel = true
return dsl
}
// VppInterface adds a request to delete an existing VPP network interface.
func (dsl *DeleteDSL) VppInterface(ifaceName string) linuxclient.DeleteDSL {
dsl.parent.delReq.Interfaces = append(dsl.parent.delReq.Interfaces,
&vpp_interfaces.Interface{
Name: ifaceName,
})
dsl.parent.withDel = true
return dsl
}
// ACL adds a request to delete an existing VPP Access Control List.
func (dsl *DeleteDSL) ACL(aclName string) linuxclient.DeleteDSL {
dsl.parent.delReq.AccessLists = append(dsl.parent.delReq.AccessLists,
&vpp_acl.ACL{
Name: aclName,
})
dsl.parent.withDel = true
return dsl
}
// BfdSession adds a request to delete an existing VPP bidirectional
// forwarding detection session.
func (dsl *DeleteDSL) BfdSession(bfdSessionIfaceName string) linuxclient.DeleteDSL {
defer func() { panic(notImplemented) }()
return dsl
}
// BfdAuthKeys adds a request to delete an existing VPP bidirectional
// forwarding detection key.
func (dsl *DeleteDSL) BfdAuthKeys(bfdKey string) linuxclient.DeleteDSL {
defer func() { panic(notImplemented) }()
return dsl
}
// BfdEchoFunction adds a request to delete an existing VPP bidirectional
// forwarding detection echo function.
func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) linuxclient.DeleteDSL {
defer func() { panic(notImplemented) }()
return dsl
}
// BD adds a request to delete an existing VPP Bridge Domain.
func (dsl *DeleteDSL) BD(bdName string) linuxclient.DeleteDSL {
dsl.parent.delReq.BridgeDomains = append(dsl.parent.delReq.BridgeDomains,
&vpp_l2.BridgeDomain{
Name: bdName,
})
dsl.parent.withDel = true
return dsl
}
// BDFIB adds a request to delete an existing VPP L2 Forwarding Information
// Base.
func (dsl *DeleteDSL) BDFIB(bdName string, mac string) linuxclient.DeleteDSL {
dsl.parent.delReq.FIBs = append(dsl.parent.delReq.FIBs,
&vpp_l2.FIBEntry{
BridgeDomain: bdName,
PhysAddress: mac,
})
dsl.parent.withDel = true
return dsl
}
// XConnect adds a request to delete an existing VPP Cross Connect.
func (dsl *DeleteDSL) XConnect(rxIfaceName string) linuxclient.DeleteDSL {
dsl.parent.delReq.XCons = append(dsl.parent.delReq.XCons,
&vpp_l2.XConnectPair{
ReceiveInterface: rxIfaceName,
})
dsl.parent.withDel = true
return dsl
}
// StaticRoute adds a request to delete an existing VPP L3 Static Route.
func (dsl *DeleteDSL) StaticRoute(iface string, vrf uint32, dstAddr string, nextHopAddr string) linuxclient.DeleteDSL {
dsl.parent.delReq.StaticRoutes = append(dsl.parent.delReq.StaticRoutes,
&vpp_l3.Route{
NextHopAddr: nextHopAddr,
VrfId: vrf,
DstNetwork: dstAddr,
})
dsl.parent.withDel = true
return dsl
}
// Arp adds a request to delete an existing VPP L3 ARP.
func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) linuxclient.DeleteDSL {
dsl.parent.delReq.ArpEntries = append(dsl.parent.delReq.ArpEntries,
&vpp_l3.ARPEntry{
Interface: ifaceName,
IpAddress: ipAddr,
})
dsl.parent.withDel = true
return dsl
}
// ProxyArp adds a request to delete an existing VPP L3 proxy ARP
func (dsl *DeleteDSL) ProxyArp() linuxclient.DeleteDSL {
dsl.parent.delReq.ProxyArp = &vpp_l3.ProxyARP{}
dsl.parent.withDel = true
return dsl
}
// IPScanNeighbor adds a request to delete an existing VPP L3 IP Scan Neighbor.
func (dsl *DeleteDSL) IPScanNeighbor() linuxclient.DeleteDSL {
dsl.parent.delReq.IPScanNeighbor = &vpp_l3.IPScanNeighbor{}
dsl.parent.withDel = true
return dsl
}
// L4Features adds a request to enable or disable L4 features
func (dsl *DeleteDSL) L4Features() linuxclient.DeleteDSL {
defer func() { panic(notImplemented) }()
return dsl
}
// AppNamespace adds a request to delete VPP Application namespace
func (dsl *DeleteDSL) AppNamespace(id string) linuxclient.DeleteDSL {
defer func() { panic(notImplemented) }()
return dsl
}
// StnRule adds a request to delete an existing VPP Stn rule.
func (dsl *DeleteDSL) StnRule(iface, addr string) linuxclient.DeleteDSL {
defer func() { panic(deprecated) }()
return dsl
}
// NAT44Global adds a request to remove global configuration for NAT44
func (dsl *DeleteDSL) NAT44Global() linuxclient.DeleteDSL {
dsl.parent.delReq.NatGlobal = &vpp_nat.Nat44Global{}
dsl.parent.withDel = true
return dsl
}
// DNAT44 adds a request to delete an existing DNAT-44 configuration
func (dsl *DeleteDSL) DNAT44(label string) linuxclient.DeleteDSL {
dsl.parent.delReq.DNATs = append(dsl.parent.delReq.DNATs,
&vpp_nat.DNat44{
Label: label,
})
dsl.parent.withDel = true
return dsl
}
// IPSecSA adds request to delete a Security Association
func (dsl *DeleteDSL) IPSecSA(saIndex string) linuxclient.DeleteDSL {
dsl.parent.delReq.SAs = append(dsl.parent.delReq.SAs,
&vpp_ipsec.SecurityAssociation{
Index: saIndex,
})
dsl.parent.withDel = true
return dsl
}
// IPSecSPD adds request to delete a Security Policy Database
func (dsl *DeleteDSL) IPSecSPD(spdIndex string) linuxclient.DeleteDSL {
dsl.parent.delReq.SPDs = append(dsl.parent.delReq.SPDs,
&vpp_ipsec.SecurityPolicyDatabase{
Index: spdIndex,
})
dsl.parent.withDel = true
return dsl
}
// PuntIPRedirect adds request to delete a rule used to punt L3 traffic via interface.
func (dsl *DeleteDSL) PuntIPRedirect(l3Proto vpp_punt.L3Protocol, txInterface string) linuxclient.DeleteDSL {
dsl.parent.delReq.IPRedirectPunts = append(dsl.parent.delReq.IPRedirectPunts,
&vpp_punt.IPRedirect{
L3Protocol: l3Proto,
TxInterface: txInterface,
})
dsl.parent.withDel = true
return dsl
}
// PuntToHost adds request to delete a rule used to punt L4 traffic to a host.
func (dsl *DeleteDSL) PuntToHost(l3Proto vpp_punt.L3Protocol, l4Proto vpp_punt.L4Protocol, port uint32) linuxclient.DeleteDSL {
dsl.parent.delReq.ToHostPunts = append(dsl.parent.delReq.ToHostPunts,
&vpp_punt.ToHost{
L3Protocol: l3Proto,
L4Protocol: l4Proto,
Port: port,
})
dsl.parent.withDel = true
return dsl
}
// Put enables creating Interface/BD...
func (dsl *DeleteDSL) Put() linuxclient.PutDSL {
return &PutDSL{dsl.parent}
}
// Send propagates changes to the channels.
func (dsl *DeleteDSL) Send() vppclient.Reply {
return dsl.parent.Send()
}
// Send propagates changes to the channels.
func (dsl *DataChangeDSL) Send() vppclient.Reply {
var wasErr error
ctx := context.Background()
if dsl.withDel {
if _, err := dsl.client.Del(ctx, dsl.delReq); err != nil {
wasErr = err
}
}
if dsl.withPut {
if _, err := dsl.client.Put(ctx, dsl.putReq); err != nil {
wasErr = err
}
}
return &Reply{wasErr}
}
// Reply enables waiting for the reply and getting result (success/error).
type Reply struct {
err error
}
// ReceiveReply returns error or nil.
func (dsl Reply) ReceiveReply() error {
return dsl.err
}