From a9c0ea7a91d95d8fbb827ccacf8bd5c59dd70d2f Mon Sep 17 00:00:00 2001 From: Antonin Bas Date: Wed, 16 Aug 2023 10:57:47 -0700 Subject: [PATCH] Change default max_len to 65535 for controller action (#69) Instead of 128. 65535 means that there is no buffering and that the full packet is sent to the controller. This is actually the only value supported by OVS, even though OVS will not reject other values. This can create confusion as the flows will show `max_len=128`, but the controller will always receive the full packet. Another value for max_len can be explicitly provided using the new `MaxLen` field in the `NXController` struct, but there should be no reason to do so when using OVS. See https://github.com/openvswitch/ovs-issues/issues/295 Signed-off-by: Antonin Bas --- VERSION | 2 +- ofctrl/ofAction.go | 12 ++++++++++-- ofctrl/ofpacket_test.go | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index f979adec..bf057dbf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.9.0 +v0.10.0 diff --git a/ofctrl/ofAction.go b/ofctrl/ofAction.go index a075b4bc..b81bc3b7 100644 --- a/ofctrl/ofAction.go +++ b/ofctrl/ofAction.go @@ -657,21 +657,29 @@ type NXController struct { UserData []byte MeterID uint32 Pause bool + MaxLen *uint16 } func (a *NXController) GetActionMessage() openflow15.Action { + // By default, do not buffer, i.e., send the full packet to the controller. + // Note that OVS does not support buffering and always sends the full + // packet; it will ignore other values of max_len. + maxLen := uint16(openflow15.OFPCML_NO_BUFFER) + if a.MaxLen != nil { + maxLen = *a.MaxLen + } if a.Version2 { action := openflow15.NewNXActionController2() action.AddControllerID(a.ControllerID) action.AddReason(a.Reason) action.AddUserdata(a.UserData) - action.AddMaxLen(128) + action.AddMaxLen(maxLen) action.AddMeterID(a.MeterID) action.AddPause(a.Pause) return action } action := openflow15.NewNXActionController(a.ControllerID) - action.MaxLen = 128 + action.MaxLen = maxLen action.Reason = a.Reason return action } diff --git a/ofctrl/ofpacket_test.go b/ofctrl/ofpacket_test.go index 311e236d..7e5832c3 100644 --- a/ofctrl/ofpacket_test.go +++ b/ofctrl/ofpacket_test.go @@ -148,7 +148,7 @@ func TestNxOutputAndSendController(t *testing.T) { flow1.Send(openflow15.FC_ADD) verifyFlowInstallAndDelete(t, flow1, NewEmptyElem(), brName, table0.TableId, "priority=100,ip,dl_src=11:22:33:44:55:66", - fmt.Sprintf("output:NXM_NX_REG0[],controller(max_len=128,id=%d)", app.Switch.ctrlID)) + fmt.Sprintf("output:NXM_NX_REG0[],controller(id=%d)", app.Switch.ctrlID)) } func testPacketInOut(t *testing.T, ofApp *packetApp, ipv6 bool, reason uint8, controllerV2 bool, dstPort uint16, userData []byte, pause bool) {