-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instructions' Actions not Available after Reading #133
Instructions' Actions not Available after Reading #133
Conversation
… using pass-by-value instead of pass-by-pointer for the action list. Also fixed a related bug where action lists' padding wasn't read, leading to an off-by-4 read error.
@kent-h, nice, could you, please also fix the unit test tests := []encodingtest.MU{
{&InstructionApplyActions{
Actions: Actions{
&ActionGroup{Group: GroupAll},
&ActionCopyTTLOut{},
},
}, []byte{
0x00, 0x04, // Instruction type.
0x00, 0x18, // Instruction length.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8-byte padding.
// Actions.
0x00, 0x16, // Action group.
0x00, 0x08, // Action lenght.
0xff, 0xff, 0xff, 0xfc,
0x00, 0xb, // Action type.
0x00, 0x08, // Action lenght.
0x00, 0x00, 0x00, 0x00, // 4-byte padding.
}},
} Could you, also check that writing of this message puts padding of the appropriate length? Thanks! |
@ybubnov |
You're right. Ah, I see the reason of test failures, as long as test use the same slice of diff --git a/ofp/action.go b/ofp/action.go
index 191871e..899276e 100644
--- a/ofp/action.go
+++ b/ofp/action.go
@@ -196,6 +196,7 @@ func (a *Actions) WriteTo(w io.Writer) (int64, error) {
// the list of types that implement Action interface.
func (a *Actions) ReadFrom(r io.Reader) (int64, error) {
var actionType ActionType
+ *a = nil
rm := func() (io.ReaderFrom, error) {
if rm, ok := actionMap[actionType]; ok { Could you, please, incorporate these changes in your PR? |
Added requested changes. |
Fixes a bug where actions for instructions were not properly read due to using pass-by-value instead of pass-by-pointer for the action list.
Also fixed a related bug where action lists' padding wasn't read, leading to an off-by-4 read error.