19
19
20
20
#include " acltable.h"
21
21
22
+ #include " saiattr.h"
23
+
22
24
#define RULE_PRIORITY " PRIORITY"
23
25
#define MATCH_IN_PORTS " IN_PORTS"
24
26
#define MATCH_OUT_PORTS " OUT_PORTS"
93
95
#define ACL_COUNTER_FLEX_COUNTER_GROUP " ACL_STAT_COUNTER"
94
96
95
97
typedef map<string, sai_acl_entry_attr_t > acl_rule_attr_lookup_t ;
98
+ typedef map<string, sai_acl_range_type_t > acl_range_type_lookup_t ;
96
99
typedef map<string, sai_acl_ip_type_t > acl_ip_type_lookup_t ;
97
100
typedef map<string, sai_acl_dtel_flow_op_t > acl_dtel_flow_op_type_lookup_t ;
98
101
typedef map<string, sai_packet_action_t > acl_packet_action_lookup_t ;
@@ -102,6 +105,13 @@ typedef map<sai_acl_action_type_t, set<int32_t>> acl_action_enum_values_capabili
102
105
103
106
class AclOrch ;
104
107
108
+ struct AclRangeConfig
109
+ {
110
+ sai_acl_range_type_t rangeType;
111
+ uint32_t min;
112
+ uint32_t max;
113
+ };
114
+
105
115
class AclRange
106
116
{
107
117
public:
@@ -130,7 +140,7 @@ class AclRule
130
140
AclRule (AclOrch *pAclOrch, string rule, string table, acl_table_type_t type, bool createCounter = true );
131
141
virtual bool validateAddPriority (string attr_name, string attr_value);
132
142
virtual bool validateAddMatch (string attr_name, string attr_value);
133
- virtual bool validateAddAction (string attr_name, string attr_value);
143
+ virtual bool validateAddAction (string attr_name, string attr_value) = 0 ;
134
144
virtual bool validate () = 0;
135
145
bool processIpType (string type, sai_uint32_t &ip_type);
136
146
inline static void setRulePriorities (sai_uint32_t min, sai_uint32_t max)
@@ -140,8 +150,9 @@ class AclRule
140
150
}
141
151
142
152
virtual bool create ();
153
+ virtual bool update (const AclRule& updatedRule);
143
154
virtual bool remove ();
144
- virtual void update (SubjectType, void *) = 0;
155
+ virtual void onUpdate (SubjectType, void *) = 0;
145
156
virtual void updateInPorts ();
146
157
147
158
virtual bool enableCounter ();
@@ -167,16 +178,13 @@ class AclRule
167
178
return m_counterOid;
168
179
}
169
180
181
+ vector<sai_object_id_t > getInPorts () const ;
182
+
170
183
bool hasCounter () const
171
184
{
172
185
return getCounterOid () != SAI_NULL_OBJECT_ID;
173
186
}
174
187
175
- vector<sai_object_id_t > getInPorts ()
176
- {
177
- return m_inPorts;
178
- }
179
-
180
188
static shared_ptr<AclRule> makeShared (acl_table_type_t type, AclOrch *acl, MirrorOrch *mirror, DTelOrch *dtel, const string& rule, const string& table, const KeyOpFieldsValuesTuple&);
181
189
virtual ~AclRule () {}
182
190
@@ -187,6 +195,17 @@ class AclRule
187
195
virtual bool removeRanges ();
188
196
virtual bool removeRule ();
189
197
198
+ virtual bool updatePriority (const AclRule& updatedRule);
199
+ virtual bool updateMatches (const AclRule& updatedRule);
200
+ virtual bool updateActions (const AclRule& updatedRule);
201
+ virtual bool updateCounter (const AclRule& updatedRule);
202
+
203
+ virtual bool setPriority (const sai_uint32_t &value);
204
+ virtual bool setAction (sai_acl_entry_attr_t actionId, sai_acl_action_data_t actionData);
205
+ virtual bool setMatch (sai_acl_entry_attr_t matchId, sai_acl_field_data_t matchData);
206
+
207
+ virtual bool setAttribute (sai_attribute_t attr);
208
+
190
209
void decreaseNextHopRefCount ();
191
210
192
211
bool isActionSupported (sai_acl_entry_attr_t ) const ;
@@ -201,13 +220,13 @@ class AclRule
201
220
sai_object_id_t m_ruleOid;
202
221
sai_object_id_t m_counterOid;
203
222
uint32_t m_priority;
204
- map <sai_acl_entry_attr_t , sai_attribute_value_t > m_matches ;
205
- map <sai_acl_entry_attr_t , sai_attribute_value_t > m_actions ;
223
+ map <sai_acl_entry_attr_t , SaiAttrWrapper> m_actions ;
224
+ map <sai_acl_entry_attr_t , SaiAttrWrapper> m_matches ;
206
225
string m_redirect_target_next_hop;
207
226
string m_redirect_target_next_hop_group;
208
227
209
- vector<sai_object_id_t > m_inPorts ;
210
- vector<sai_object_id_t > m_outPorts ;
228
+ vector<AclRangeConfig> m_rangeConfig ;
229
+ vector<AclRange*> m_ranges ;
211
230
212
231
private:
213
232
bool m_createCounter;
@@ -221,7 +240,8 @@ class AclRuleL3: public AclRule
221
240
bool validateAddAction (string attr_name, string attr_value);
222
241
bool validateAddMatch (string attr_name, string attr_value);
223
242
bool validate ();
224
- void update (SubjectType, void *);
243
+ void onUpdate (SubjectType, void *) override ;
244
+
225
245
protected:
226
246
sai_object_id_t getRedirectObjectId (const string& redirect_param);
227
247
};
@@ -256,11 +276,12 @@ class AclRuleMirror: public AclRule
256
276
bool validate ();
257
277
bool createRule ();
258
278
bool removeRule ();
259
- void update (SubjectType, void *);
279
+ void onUpdate (SubjectType, void *) override ;
260
280
261
281
bool activate ();
262
282
bool deactivate ();
263
283
284
+ bool update (const AclRule& updatedRule) override ;
264
285
protected:
265
286
bool m_state {false };
266
287
string m_sessionName;
@@ -275,11 +296,12 @@ class AclRuleDTelFlowWatchListEntry: public AclRule
275
296
bool validate ();
276
297
bool createRule ();
277
298
bool removeRule ();
278
- void update (SubjectType, void *);
299
+ void onUpdate (SubjectType, void *) override ;
279
300
280
301
bool activate ();
281
302
bool deactivate ();
282
303
304
+ bool update (const AclRule& updatedRule) override ;
283
305
protected:
284
306
DTelOrch *m_pDTelOrch;
285
307
string m_intSessionId;
@@ -293,8 +315,7 @@ class AclRuleDTelDropWatchListEntry: public AclRule
293
315
AclRuleDTelDropWatchListEntry (AclOrch *m_pAclOrch, DTelOrch *m_pDTelOrch, string rule, string table, acl_table_type_t type);
294
316
bool validateAddAction (string attr_name, string attr_value);
295
317
bool validate ();
296
- void update (SubjectType, void *);
297
-
318
+ void onUpdate (SubjectType, void *) override ;
298
319
protected:
299
320
DTelOrch *m_pDTelOrch;
300
321
};
@@ -342,12 +363,14 @@ class AclTable
342
363
void unlink (sai_object_id_t portOid);
343
364
// Add or overwrite a rule into the ACL table
344
365
bool add (shared_ptr<AclRule> newRule);
366
+ // Update existing ACL rule
367
+ bool updateRule (shared_ptr<AclRule> updatedRule);
345
368
// Remove a rule from the ACL table
346
369
bool remove (string rule_id);
347
370
// Remove all rules from the ACL table
348
371
bool clear ();
349
372
// Update table subject to changes
350
- void update (SubjectType, void *);
373
+ void onUpdate (SubjectType, void *);
351
374
352
375
public:
353
376
string id;
@@ -403,6 +426,7 @@ class AclOrch : public Orch, public Observer
403
426
bool updateAclTable (string table_id, AclTable &table);
404
427
bool addAclRule (shared_ptr<AclRule> aclRule, string table_id);
405
428
bool removeAclRule (string table_id, string rule_id);
429
+ bool updateAclRule (shared_ptr<AclRule> updatedAclRule);
406
430
bool updateAclRule (string table_id, string rule_id, string attr_name, void *data, bool oper);
407
431
bool updateAclRule (string table_id, string rule_id, bool enableCounter);
408
432
AclRule* getAclRule (string table_id, string rule_id);
0 commit comments