Skip to content

Commit 9ca022d

Browse files
authored
Merge pull request #96 from digitalocean/nbouliane/learn_options
ovs: use the limit= option only when the value is > 0
2 parents 71913f4 + 35e0263 commit 9ca022d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ovs/action_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func TestLearn(t *testing.T) {
682682
Matches: []Match{DataLinkType(0x800)},
683683
Actions: []Action{OutputField("in_port"), Load("2", "tp_dst")},
684684
}),
685-
action: `learn(priority=0,dl_type=0x0800,table=0,idle_timeout=0,fin_hard_timeout=10,hard_timeout=0,limit=0,delete_learned,output:in_port,load:2->tp_dst)`,
685+
action: `learn(priority=0,dl_type=0x0800,table=0,idle_timeout=0,fin_hard_timeout=10,hard_timeout=0,delete_learned,output:in_port,load:2->tp_dst)`,
686686
},
687687
{
688688
desc: "learn ok",

ovs/flow.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,13 @@ func (f *LearnedFlow) MarshalText() ([]byte, error) {
269269
b = append(b, ","+hardTimeout+"="...)
270270
b = strconv.AppendInt(b, int64(f.HardTimeout), 10)
271271

272-
b = append(b, ","+limit+"="...)
273-
b = strconv.AppendInt(b, int64(f.Limit), 10)
272+
if f.Limit > 0 {
273+
// On older version of OpenVSwitch, the limit option doesn't exist.
274+
// Make sure we don't use it if the value is not set.
275+
b = append(b, ","+limit+"="...)
276+
b = strconv.AppendInt(b, int64(f.Limit), 10)
277+
}
278+
274279
if f.DeleteLearned {
275280
b = append(b, ","+deleteLearned...)
276281
}

ovs/flow_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func TestFlowMarshalText(t *testing.T) {
352352
Output(4),
353353
},
354354
},
355-
s: `priority=5000,tcp,in_port=3,nw_dst=169.254.169.254,tp_dst=80,table=0,idle_timeout=0,actions=learn(priority=5000,in_port=4,dl_type=0x0800,nw_proto=6,NXM_OF_IP_SRC[]=NXM_OF_IP_DST[],NXM_OF_TCP_SRC[]=NXM_OF_TCP_DST[],nw_dst=1.2.3.4,tp_dst=567,table=0,idle_timeout=60,fin_hard_timeout=1,hard_timeout=0,limit=0,delete_learned,load:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],load:NXM_OF_IP_SRC[]->NXM_OF_IP_DST[],load:NXM_OF_TCP_SRC[]->NXM_OF_TCP_DST[],output:NXM_OF_IN_PORT[]),mod_nw_src:1.2.3.4,mod_tp_src:567,output:4`,
355+
s: `priority=5000,tcp,in_port=3,nw_dst=169.254.169.254,tp_dst=80,table=0,idle_timeout=0,actions=learn(priority=5000,in_port=4,dl_type=0x0800,nw_proto=6,NXM_OF_IP_SRC[]=NXM_OF_IP_DST[],NXM_OF_TCP_SRC[]=NXM_OF_TCP_DST[],nw_dst=1.2.3.4,tp_dst=567,table=0,idle_timeout=60,fin_hard_timeout=1,hard_timeout=0,delete_learned,load:NXM_OF_ETH_SRC[]->NXM_OF_ETH_DST[],load:NXM_OF_IP_SRC[]->NXM_OF_IP_DST[],load:NXM_OF_TCP_SRC[]->NXM_OF_TCP_DST[],output:NXM_OF_IN_PORT[]),mod_nw_src:1.2.3.4,mod_tp_src:567,output:4`,
356356
},
357357
{
358358
desc: "Flow with LearnedFlow in Learn action with hard_timeout and limit options",

0 commit comments

Comments
 (0)