forked from contiv/libOpenflow
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to set selection_method in GroupMod (#43)
Add support for setting selection_method, selection_method_param and fields in a GroupMod message, the supported selection_method including "hash" and "dp_hash". When using "dp_hash", fields is supposed to be empty. "fields" could use a mask value or not, all bits in the value should be 1 if no mask is specified. Signed-off-by: wenyingd <[email protected]>
- Loading branch information
Showing
3 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v0.11.0 | ||
v0.12.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package openflow15 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNTRSelectionMethod(t *testing.T) { | ||
tcpSrcField, _ := FindFieldHeaderByName("OXM_OF_TCP_SRC", false) | ||
tcpSrcField.Value = NewPortField(443) | ||
selectionParam := uint64(13689348814713) | ||
for _, tc := range []struct { | ||
name string | ||
mt NTRSelectionMethodType | ||
param uint64 | ||
fields []MatchField | ||
}{ | ||
{ | ||
name: "dp_hash", | ||
mt: NTR_DP_HASH, | ||
param: selectionParam, | ||
}, | ||
{ | ||
name: "hash without fields", | ||
mt: NTR_HASH, | ||
param: selectionParam, | ||
}, | ||
{ | ||
name: "hash with fields", | ||
mt: NTR_HASH, | ||
param: selectionParam, | ||
fields: []MatchField{*tcpSrcField}, | ||
}, | ||
} { | ||
t.Run(tc.name, func(t *testing.T) { | ||
method := NewNTRSelectionMethod(tc.mt, tc.param, tc.fields...) | ||
data, err := method.MarshalBinary() | ||
require.NoError(t, err, "Unable to marshal selectionMethod") | ||
newMethod := new(NTRSelectionMethod) | ||
err = newMethod.UnmarshalBinary(data) | ||
require.NoError(t, err) | ||
assert.Equal(t, method.Type, newMethod.Type) | ||
assert.Equal(t, method.Length, newMethod.Length) | ||
assert.Equal(t, method.ExperimenterID, newMethod.ExperimenterID) | ||
assert.Equal(t, method.ExperimenterType, newMethod.ExperimenterType) | ||
assert.Equal(t, method.SelectionMethod, newMethod.SelectionMethod) | ||
assert.Equal(t, method.SelectionParam, newMethod.SelectionParam) | ||
assert.Equal(t, len(method.Fields), len(newMethod.Fields)) | ||
for i := range method.Fields { | ||
assert.Equal(t, method.Fields[i], newMethod.Fields[i]) | ||
} | ||
}) | ||
} | ||
} |