@@ -186,24 +186,33 @@ func (o *OpenFlowService) AddFlowBundle(bridge string, fn func(tx *FlowTransacti
186
186
//
187
187
// If flow is nil, all flows will be deleted from the specified bridge.
188
188
func (o * OpenFlowService ) DelFlows (bridge string , flow * MatchFlow ) error {
189
+ args := []string {"del-flows" }
190
+ args = append (args , o .c .ofctlFlags ... )
191
+ args = append (args , bridge )
192
+
189
193
if flow == nil {
190
194
// This means we'll flush the entire flows
191
- // from the specifided bridge.
192
- _ , err := o .exec ("del-flows" , bridge )
195
+ // from the specified bridge.
196
+ _ , err := o .exec (args ... )
193
197
return err
194
198
}
195
199
fb , err := flow .MarshalText ()
196
200
if err != nil {
197
201
return err
198
202
}
199
203
200
- _ , err = o .exec ("del-flows" , bridge , string (fb ))
204
+ args = append (args , string (fb ))
205
+ _ , err = o .exec (args ... )
201
206
return err
202
207
}
203
208
204
209
// ModPort modifies the specified characteristics for the specified port.
205
210
func (o * OpenFlowService ) ModPort (bridge string , port string , action PortAction ) error {
206
- _ , err := o .exec ("mod-port" , bridge , string (port ), string (action ))
211
+ args := []string {"mod-port" }
212
+ args = append (args , o .c .ofctlFlags ... )
213
+ args = append (args , []string {bridge , port , string (action )}... )
214
+
215
+ _ , err := o .exec (args ... )
207
216
return err
208
217
}
209
218
@@ -231,7 +240,10 @@ func (o *OpenFlowService) DumpPorts(bridge string) ([]*PortStats, error) {
231
240
// If a table has no active flows and has not been used for a lookup or matched
232
241
// by an incoming packet, it is filtered from the output.
233
242
func (o * OpenFlowService ) DumpTables (bridge string ) ([]* Table , error ) {
234
- out , err := o .exec ("dump-tables" , bridge )
243
+ args := []string {"dump-tables" , bridge }
244
+ args = append (args , o .c .ofctlFlags ... )
245
+
246
+ out , err := o .exec (args ... )
235
247
if err != nil {
236
248
return nil , err
237
249
}
@@ -259,15 +271,18 @@ func (o *OpenFlowService) DumpTables(bridge string) ([]*Table, error) {
259
271
// If a table has no active flows and has not been used for a lookup or matched
260
272
// by an incoming packet, it is filtered from the output.
261
273
func (o * OpenFlowService ) DumpFlows (bridge string ) ([]* Flow , error ) {
262
- out , err := o .exec ("dump-flows" , bridge )
274
+ args := []string {"dump-flows" , bridge }
275
+ args = append (args , o .c .ofctlFlags ... )
276
+
277
+ out , err := o .exec (args ... )
263
278
if err != nil {
264
279
return nil , err
265
280
}
266
281
267
282
var flows []* Flow
268
283
err = parseEachLine (out , dumpFlowsPrefix , func (b []byte ) error {
269
- // Do not attempt to parse NXST_FLOW messages.
270
- if bytes .HasPrefix (b , dumpFlowsPrefix ) {
284
+ // Do not attempt to parse ST_FLOW messages.
285
+ if bytes .Contains (b , dumpFlowsPrefix ) {
271
286
return nil
272
287
}
273
288
@@ -303,9 +318,12 @@ var (
303
318
// the output from 'ovs-ofctl dump-tables'.
304
319
dumpTablesPrefix = []byte ("OFPST_TABLE reply" )
305
320
306
- // dumpFlowsPrefix is a sentinel value returned at the beginning of
307
- // the output from 'ovs-ofctl dump-flows'.
308
- dumpFlowsPrefix = []byte ("NXST_FLOW reply" )
321
+ // dumpFlowsPrefix is a sentinel value returned at the beginning of the output
322
+ // from 'ovs-ofctl dump-flows'. The value returned when using protocol version
323
+ // 1.0 is "NXST_FLOW reply". The value returned when using protocol version > 1.1
324
+ // is "OFPST_FLOW reply". However, we use ST_FLOW here to be able to match both
325
+ // of these.
326
+ dumpFlowsPrefix = []byte ("ST_FLOW reply" )
309
327
310
328
// dumpAggregatePrefix is a sentinel value returned at the beginning of
311
329
// the output from "ovs-ofctl dump-aggregate"
@@ -387,8 +405,8 @@ func parseEachLine(in []byte, prefix []byte, fn func(b []byte) error) error {
387
405
return io .ErrUnexpectedEOF
388
406
}
389
407
390
- // First line must contain prefix returned by OVS
391
- if ! bytes .HasPrefix (scanner .Bytes (), prefix ) {
408
+ // First line must contain the prefix returned by OVS
409
+ if ! bytes .Contains (scanner .Bytes (), prefix ) {
392
410
return io .ErrUnexpectedEOF
393
411
}
394
412
0 commit comments