@@ -186,24 +186,33 @@ func (o *OpenFlowService) AddFlowBundle(bridge string, fn func(tx *FlowTransacti
186186//
187187// If flow is nil, all flows will be deleted from the specified bridge.
188188func (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+
189193 if flow == nil {
190194 // 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 ... )
193197 return err
194198 }
195199 fb , err := flow .MarshalText ()
196200 if err != nil {
197201 return err
198202 }
199203
200- _ , err = o .exec ("del-flows" , bridge , string (fb ))
204+ args = append (args , string (fb ))
205+ _ , err = o .exec (args ... )
201206 return err
202207}
203208
204209// ModPort modifies the specified characteristics for the specified port.
205210func (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 ... )
207216 return err
208217}
209218
@@ -231,7 +240,10 @@ func (o *OpenFlowService) DumpPorts(bridge string) ([]*PortStats, error) {
231240// If a table has no active flows and has not been used for a lookup or matched
232241// by an incoming packet, it is filtered from the output.
233242func (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 ... )
235247 if err != nil {
236248 return nil , err
237249 }
@@ -259,15 +271,18 @@ func (o *OpenFlowService) DumpTables(bridge string) ([]*Table, error) {
259271// If a table has no active flows and has not been used for a lookup or matched
260272// by an incoming packet, it is filtered from the output.
261273func (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 ... )
263278 if err != nil {
264279 return nil , err
265280 }
266281
267282 var flows []* Flow
268283 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 ) {
271286 return nil
272287 }
273288
@@ -303,9 +318,12 @@ var (
303318 // the output from 'ovs-ofctl dump-tables'.
304319 dumpTablesPrefix = []byte ("OFPST_TABLE reply" )
305320
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" )
309327
310328 // dumpAggregatePrefix is a sentinel value returned at the beginning of
311329 // the output from "ovs-ofctl dump-aggregate"
@@ -387,8 +405,8 @@ func parseEachLine(in []byte, prefix []byte, fn func(b []byte) error) error {
387405 return io .ErrUnexpectedEOF
388406 }
389407
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 ) {
392410 return io .ErrUnexpectedEOF
393411 }
394412
0 commit comments