@@ -149,12 +149,15 @@ def parse_dpg(dpg, hname):
149
149
pcintfs = child .find (str (QName (ns , "PortChannelInterfaces" )))
150
150
pc_intfs = []
151
151
pcs = {}
152
+ intfs_inpc = [] # List to hold all the LAG member interfaces
152
153
for pcintf in pcintfs .findall (str (QName (ns , "PortChannel" ))):
153
154
pcintfname = pcintf .find (str (QName (ns , "Name" ))).text
154
155
pcintfmbr = pcintf .find (str (QName (ns , "AttachTo" ))).text
155
156
pcmbr_list = pcintfmbr .split (';' )
157
+ pc_intfs .append (pcintfname )
156
158
for i , member in enumerate (pcmbr_list ):
157
159
pcmbr_list [i ] = port_alias_map .get (member , member )
160
+ intfs_inpc .append (pcmbr_list [i ])
158
161
if pcintf .find (str (QName (ns , "Fallback" ))) != None :
159
162
pcs [pcintfname ] = {'members' : pcmbr_list , 'fallback' : pcintf .find (str (QName (ns , "Fallback" ))).text }
160
163
else :
@@ -202,15 +205,26 @@ def parse_dpg(dpg, hname):
202
205
for member in aclattach :
203
206
member = member .strip ()
204
207
if pcs .has_key (member ):
205
- acl_intfs .extend (pcs [member ]['members' ]) # For ACL attaching to port channels, we break them into port channel members
208
+ # If try to attach ACL to a LAG interface then we shall add the LAG to
209
+ # to acl_intfs directly instead of break it into member ports, ACL attach
210
+ # to LAG will be applied to all the LAG members internally by SAI/SDK
211
+ acl_intfs .append (member )
206
212
elif vlans .has_key (member ):
207
213
print >> sys .stderr , "Warning: ACL " + aclname + " is attached to a Vlan interface, which is currently not supported"
208
214
elif port_alias_map .has_key (member ):
209
215
acl_intfs .append (port_alias_map [member ])
216
+ # Give a warning if trying to attach ACL to a LAG member interface, correct way is to attach ACL to the LAG interface
217
+ if port_alias_map [member ] in intfs_inpc :
218
+ print >> sys .stderr , "Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map [member ] + ", instead of LAG interface"
210
219
elif member .lower () == 'erspan' :
211
220
is_mirror = True ;
212
- # Erspan session will be attached to all front panel ports
213
- acl_intfs = port_alias_map .values ()
221
+ # Erspan session will be attached to all front panel ports,
222
+ # if panel ports is a member port of LAG, should add the LAG
223
+ # to acl table instead of the panel ports
224
+ acl_intfs = pc_intfs
225
+ for panel_port in port_alias_map .values ():
226
+ if panel_port not in intfs_inpc :
227
+ acl_intfs .append (panel_port )
214
228
break ;
215
229
if acl_intfs :
216
230
acls [aclname ] = {'policy_desc' : aclname ,
0 commit comments