@@ -13,7 +13,7 @@ class Rule(object):
13
13
"""
14
14
15
15
# Matches m should be of the match class. Actions acts should be a set of
16
- # modify, identity, drop, and/or Controller/CountBucket/FwdBucket policies.
16
+ # modify, identity, and/or Controller/CountBucket/FwdBucket policies.
17
17
# Actions is Rule are semantically meant to run in parallel
18
18
# unlike OpenFlow rules.
19
19
def __init__ (self ,m ,acts ):
@@ -126,14 +126,13 @@ def __copy__(self):
126
126
127
127
### NEGATE ###
128
128
def __invert__ (self ):
129
- from pyretic .core .language import drop , identity
129
+ from pyretic .core .language import identity
130
130
c = copy .copy (self )
131
131
for r in c .rules :
132
- assert len (r .actions ) == 1
133
- if r .actions == {identity }:
134
- r .actions = {drop }
135
- elif r .actions == {drop }:
132
+ if len (r .actions ) == 0 :
136
133
r .actions = {identity }
134
+ elif r .actions == {identity }:
135
+ r .actions = set ()
137
136
else :
138
137
raise TypeError # TODO MAKE A CompileError TYPE
139
138
return c
@@ -149,8 +148,6 @@ def _cross(r1,r2):
149
148
# TODO (josh) logic for detecting when sets of actions can't be combined
150
149
# e.g., [modify(dstip='10.0.0.1'),fwd(1)] + [modify(srcip='10.0.0.2'),fwd(2)]
151
150
actions = r1 .actions | r2 .actions
152
- if len (actions ) > 1 :
153
- actions .discard (drop )
154
151
return Rule (intersection , actions )
155
152
else :
156
153
return None
@@ -166,7 +163,7 @@ def _cross(r1,r2):
166
163
c3 .append (crossed_r )
167
164
# if the classifier is empty, add a drop-all rule
168
165
if len (c3 ) == 0 :
169
- c3 .append (Rule (identity ,{ drop } ))
166
+ c3 .append (Rule (identity ,set () ))
170
167
# and optimize the classifier
171
168
else :
172
169
c3 = c3 .optimize ()
@@ -184,8 +181,6 @@ def _commute_test(act, pkts):
184
181
act = act .policy
185
182
if act == identity :
186
183
return pkts
187
- elif act == drop :
188
- return drop
189
184
elif act == Controller or isinstance (act , CountBucket ):
190
185
return identity
191
186
elif isinstance (act , modify ):
@@ -224,9 +219,7 @@ def _sequence_actions(a1, as2):
224
219
for a2 in as2 :
225
220
while isinstance (a2 , DerivedPolicy ):
226
221
a2 = a2 .policy
227
- if a2 == drop :
228
- new_actions .add (drop )
229
- elif a2 == Controller or isinstance (a2 , CountBucket ):
222
+ if a2 == Controller or isinstance (a2 , CountBucket ):
230
223
new_actions .add (a2 )
231
224
elif a2 == identity :
232
225
new_actions .add (a1 )
@@ -276,7 +269,7 @@ def _cross(r1,r2):
276
269
# then for each rule in the first classifier (self)
277
270
c3 = Classifier ()
278
271
for r1 in c1 .rules :
279
- if r1 .actions == { drop } :
272
+ if len ( r1 .actions ) == 0 :
280
273
c3 .append (r1 )
281
274
else :
282
275
for r2 in c2 .rules :
0 commit comments