Skip to content

Commit aea3d93

Browse files
committed
ovs: allow for MTU configuration of interfaces
1 parent ce0f183 commit aea3d93

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ovs/vswitch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ type InterfaceOptions struct {
236236
// Peer specifies an interface to peer with when creating a patch interface.
237237
Peer string
238238

239+
// MTURequest specifies the maximum transmission unit associated with an
240+
// interface.
241+
MTURequest int
242+
239243
// Ingress Policing
240244
//
241245
// These settings control ingress policing for packets received on this
@@ -285,6 +289,10 @@ func (i InterfaceOptions) slice() []string {
285289
s = append(s, fmt.Sprintf("options:peer=%s", i.Peer))
286290
}
287291

292+
if i.MTURequest > 0 {
293+
s = append(s, fmt.Sprintf("mtu_request=%d", i.MTURequest))
294+
}
295+
288296
if i.IngressRatePolicing == DefaultIngressRatePolicing {
289297
// Set to 0 (the default) to disable policing.
290298
s = append(s, "ingress_policing_rate=0")

ovs/vswitch_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ func TestClientVSwitchSetInterfaceOK(t *testing.T) {
656656
peer := "eth0"
657657
ratePolicing := DefaultIngressRatePolicing
658658
burstPolicing := DefaultIngressBurstPolicing
659+
requestedMTU := 9000
659660

660661
// Apply Timeout option to verify arguments
661662
c := testClient([]OptionFunc{Timeout(1)}, func(cmd string, args ...string) ([]byte, error) {
@@ -672,6 +673,7 @@ func TestClientVSwitchSetInterfaceOK(t *testing.T) {
672673
string(ifi),
673674
fmt.Sprintf("type=%s", ifiType),
674675
fmt.Sprintf("options:peer=%s", peer),
676+
"mtu_request=9000",
675677
"ingress_policing_rate=0",
676678
"ingress_policing_burst=0",
677679
}
@@ -688,6 +690,7 @@ func TestClientVSwitchSetInterfaceOK(t *testing.T) {
688690
Peer: peer,
689691
IngressRatePolicing: ratePolicing,
690692
IngressBurstPolicing: burstPolicing,
693+
MTURequest: requestedMTU,
691694
})
692695
if err != nil {
693696
t.Fatalf("unexpected error for Client.VSwitch.Set.Interface: %v", err)
@@ -787,6 +790,15 @@ func TestInterfaceOptions_slice(t *testing.T) {
787790
"options:peer=bond0",
788791
},
789792
},
793+
{
794+
desc: "only MTURequest",
795+
i: InterfaceOptions{
796+
MTURequest: 9000,
797+
},
798+
out: []string{
799+
"mtu_request=9000",
800+
},
801+
},
790802
{
791803
desc: "only ingress policing rate",
792804
i: InterfaceOptions{
@@ -852,10 +864,12 @@ func TestInterfaceOptions_slice(t *testing.T) {
852864
Peer: "bond0",
853865
IngressRatePolicing: 2000000,
854866
IngressBurstPolicing: 200000,
867+
MTURequest: 9000,
855868
},
856869
out: []string{
857870
"type=patch",
858871
"options:peer=bond0",
872+
"mtu_request=9000",
859873
"ingress_policing_rate=2000000",
860874
"ingress_policing_burst=200000",
861875
},

0 commit comments

Comments
 (0)