Optionally ignore LACP activity bit in port check

If the LACP bond on the switch side is configured in passive mode,
the activity mode bit on the port states will usually be mismatched.

Add an option to the charm config to inform when this is expected,
so that the charm will ignore this mismatched bit when checking ports.

Closes-Bug: #1958327

Change-Id: I784bb410110813472e14b3477247fe138db5c214
This commit is contained in:
Samuel Walladge
2022-06-16 14:55:20 +09:30
parent 7792a16d82
commit abb21efbae
3 changed files with 98 additions and 1 deletions

View File

@@ -517,12 +517,24 @@ def check_aggregator_id(bond_iface, slave_iface):
def check_lacp_port_state(iface):
cfg = hookenv.config()
iface_dir = "/sys/class/net/{}/bonding_slave".format(iface)
with open("{}/ad_actor_oper_port_state".format(iface_dir)) as fos:
actor_port_state = fos.read()
with open("{}/ad_partner_oper_port_state".format(iface_dir)) as fos:
partner_port_state = fos.read()
if actor_port_state != partner_port_state:
if (
actor_port_state != partner_port_state
# check if this is an acceptable mismatch in the LACP activity mode
and not (
cfg.get('lacp_passive_mode')
# and the only difference is the LACP activity bit
# (1111_1110 bitmask to ignore LACP activity bit in comparison)
and (int(actor_port_state) & 254) ==
(int(partner_port_state) & 254)
)
):
return "lacp_port_state_mismatch"
return None