Skip to content

Commit 124cc0e

Browse files
authored
Merge pull request #51 from amorenoz/load
ofp_act: support src specification in load action
2 parents 0514fb4 + b82b735 commit 124cc0e

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ovs_dbg/ofp_act.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ def decode_load_field(value):
9696
if len(parts) != 2:
9797
raise ValueError("Malformed load action : %s" % value)
9898

99-
return {"value": int(parts[0], 0), "dst": decode_field(parts[1])}
99+
# If the load action is performed within a learn() action,
100+
# The value can be specified as another field.
101+
try:
102+
return {"value": int(parts[0], 0), "dst": decode_field(parts[1])}
103+
except ValueError:
104+
return {"src": decode_field(parts[0]), "dst": decode_field(parts[1])}
100105

101106

102107
def decode_set_field(field_decoders, value):

tests/test_ofp.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@
127127
)
128128
],
129129
),
130+
(
131+
"actions=learn(load:NXM_NX_TUN_ID[]->NXM_NX_TUN_ID[])",
132+
[
133+
KeyValue(
134+
"learn",
135+
[
136+
{
137+
"load": {
138+
"src": {"field": "NXM_NX_TUN_ID"},
139+
"dst": {"field": "NXM_NX_TUN_ID"},
140+
}
141+
}
142+
],
143+
),
144+
],
145+
),
130146
(
131147
"actions=set_field:00:11:22:33:44:55->eth_src",
132148
[

0 commit comments

Comments
 (0)