Study and respond to PyLint

Add a reasonably tolerant .pylintrc and fix most pylint errors and
warnings.

------------------------------------------------------------------
Your code has been rated at 9.78/10
This commit is contained in:
Pim van Pelt
2022-04-22 19:31:38 +00:00
parent f8a6c3eba7
commit bc0310e088
21 changed files with 343 additions and 330 deletions

View File

@ -11,6 +11,8 @@ class Applier(VPPApi):
and will ensure that the local cache is consistent after creations and
modifications."""
# pylint: disable=unnecessary-pass
def __init__(self, address="/run/vpp/api.sock", clientname="vppcfg"):
VPPApi.__init__(self, address, clientname)
self.logger.info("VPP Applier: changing the dataplane is enabled")
@ -47,9 +49,6 @@ class Applier(VPPApi):
"""'config' is the YAML configuration for the vxlan_tunnels: entry"""
pass
def delete_subinterface(self, ifname):
pass
def set_interface_link_mtu(self, ifname, link_mtu):
pass

View File

@ -3,10 +3,10 @@ The functions in this file interact with the VPP API to retrieve certain
interface metadata and write it to a YAML file.
"""
from vpp.vppapi import VPPApi
import sys
import yaml
import config.bondethernet as bondethernet
from vpp.vppapi import VPPApi
from config import bondethernet
class Dumper(VPPApi):
@ -15,17 +15,17 @@ class Dumper(VPPApi):
def write(self, outfile):
if outfile and outfile == "-":
fh = sys.stdout
file = sys.stdout
outfile = "(stdout)"
else:
fh = open(outfile, "w")
file = open(outfile, "w", encoding="utf-8")
config = self.cache_to_config()
print(yaml.dump(config), file=fh)
print(yaml.dump(config), file=file)
if fh is not sys.stdout:
fh.close()
if file is not sys.stdout:
file.close()
self.logger.info(f"Wrote YAML config to {outfile}")
def cache_to_config(self):

View File

@ -15,13 +15,13 @@
# -*- coding: utf-8 -*-
import sys
import logging
import config.loopback as loopback
import config.interface as interface
import config.bondethernet as bondethernet
import config.bridgedomain as bridgedomain
import config.vxlan_tunnel as vxlan_tunnel
import config.lcp as lcp
import config.tap as tap
from config import loopback
from config import interface
from config import bondethernet
from config import bridgedomain
from config import vxlan_tunnel
from config import lcp
from config import tap
from vpp.vppapi import VPPApi
@ -117,26 +117,26 @@ class Reconciler:
"""
idx = self.vpp.cache["interface_names"][ifname].sw_if_index
removed_addresses = []
for a in self.vpp.cache["interface_addresses"][idx]:
if not a in address_list:
cli = f"set interface ip address del {ifname} {a}"
for addr in self.vpp.cache["interface_addresses"][idx]:
if not addr in address_list:
cli = f"set interface ip address del {ifname} {addr}"
self.cli["prune"].append(cli)
removed_addresses.append(a)
removed_addresses.append(addr)
else:
self.logger.debug(f"Address OK: {ifname} {a}")
for a in removed_addresses:
self.vpp.cache["interface_addresses"][idx].remove(a)
self.logger.debug(f"Address OK: {ifname} {addr}")
for addr in removed_addresses:
self.vpp.cache["interface_addresses"][idx].remove(addr)
def prune_loopbacks(self):
"""Remove loopbacks from VPP, if they do not occur in the config."""
removed_interfaces = []
for numtags in [2, 1, 0]:
for idx, vpp_iface in self.vpp.cache["interfaces"].items():
for _idx, vpp_iface in self.vpp.cache["interfaces"].items():
if vpp_iface.interface_dev_type != "Loopback":
continue
if vpp_iface.sub_number_of_tags != numtags:
continue
config_ifname, config_iface = loopback.get_by_name(
_config_ifname, config_iface = loopback.get_by_name(
self.cfg, vpp_iface.interface_name
)
if not config_iface:
@ -166,8 +166,9 @@ class Reconciler:
found in to-be removed bridge-domains, they are returned to L3 mode, and tag-rewrites removed."""
for idx, bridge in self.vpp.cache["bridgedomains"].items():
bridgename = f"bd{int(idx)}"
config_ifname, config_iface = bridgedomain.get_by_name(self.cfg, bridgename)
members = []
_config_ifname, config_iface = bridgedomain.get_by_name(
self.cfg, bridgename
)
if not config_iface:
for member in bridge.sw_if_details:
if member.sw_if_index == bridge.bvi_sw_if_index:
@ -222,7 +223,7 @@ class Reconciler:
but are crossconnected to a different interface name, also remove them. Interfaces are put
back into L3 mode, and their tag-rewrites removed."""
removed_l2xcs = []
for idx, l2xc in self.vpp.cache["l2xcs"].items():
for _idx, l2xc in self.vpp.cache["l2xcs"].items():
vpp_rx_ifname = self.vpp.cache["interfaces"][
l2xc.rx_sw_if_index
].interface_name
@ -276,7 +277,7 @@ class Reconciler:
return True
vpp_vxlan = self.vpp.cache["vxlan_tunnels"][vpp_iface.sw_if_index]
config_ifname, config_iface = vxlan_tunnel.get_by_name(self.cfg, ifname)
_config_ifname, config_iface = vxlan_tunnel.get_by_name(self.cfg, ifname)
if not config_iface:
return True
@ -299,7 +300,7 @@ class Reconciler:
vpp_iface = self.vpp.cache["interface_names"][ifname]
vpp_tap = self.vpp.cache["taps"][vpp_iface.sw_if_index]
config_ifname, config_iface = tap.get_by_name(self.cfg, ifname)
_config_ifname, config_iface = tap.get_by_name(self.cfg, ifname)
if not config_iface:
return True
@ -352,10 +353,12 @@ class Reconciler:
vpp_bond = self.vpp.cache["bondethernets"][vpp_iface.sw_if_index]
mode = bondethernet.mode_to_int(bondethernet.get_mode(self.cfg, config_ifname))
if mode != -1 and mode != vpp_bond.mode:
if mode not in (-1, vpp_bond.mode):
return True
lb = bondethernet.lb_to_int(bondethernet.get_lb(self.cfg, config_ifname))
if lb != -1 and lb != vpp_bond.lb:
loadbalance = bondethernet.lb_to_int(
bondethernet.get_lb(self.cfg, config_ifname)
)
if loadbalance not in (-1, vpp_bond.lb):
return True
return False
@ -365,7 +368,7 @@ class Reconciler:
TAPs which are a part of Linux Control Plane, are left alone, to be handled
by prune_lcps() later."""
removed_taps = []
for idx, vpp_tap in self.vpp.cache["taps"].items():
for _idx, vpp_tap in self.vpp.cache["taps"].items():
vpp_iface = self.vpp.cache["interfaces"][vpp_tap.sw_if_index]
vpp_ifname = vpp_iface.interface_name
if self.vpp.tap_is_lcp(vpp_ifname):
@ -388,7 +391,9 @@ class Reconciler:
removed_bondethernet_members = []
for idx, bond in self.vpp.cache["bondethernets"].items():
vpp_ifname = bond.interface_name
config_ifname, config_iface = bondethernet.get_by_name(self.cfg, vpp_ifname)
_config_ifname, config_iface = bondethernet.get_by_name(
self.cfg, vpp_ifname
)
if self.__bond_has_diff(vpp_ifname):
self.prune_addresses(vpp_ifname, [])
@ -478,7 +483,7 @@ class Reconciler:
continue
prune = False
config_ifname, config_iface = interface.get_by_name(
_config_ifname, config_iface = interface.get_by_name(
self.cfg, vpp_ifname
)
if not config_iface:
@ -489,7 +494,7 @@ class Reconciler:
):
(
config_parent_ifname,
config_parent_iface,
_config_parent_iface,
) = interface.get_parent_by_name(self.cfg, vpp_ifname)
if self.__bond_has_diff(config_parent_ifname):
prune = True
@ -521,7 +526,7 @@ class Reconciler:
"""Set default MTU and remove IPs for PHYs that are not in the config."""
for vpp_ifname in self.vpp.get_phys():
vpp_iface = self.vpp.cache["interface_names"][vpp_ifname]
config_ifname, config_iface = interface.get_by_name(self.cfg, vpp_ifname)
_config_ifname, config_iface = interface.get_by_name(self.cfg, vpp_ifname)
if not config_iface:
## Interfaces were sent DOWN in the prune_admin_state() step previously
self.prune_addresses(vpp_ifname, [])
@ -589,25 +594,25 @@ class Reconciler:
removed_lcps = []
for numtags in [2, 1, 0]:
for idx, lcp in lcps.items():
vpp_iface = self.vpp.cache["interfaces"][lcp.phy_sw_if_index]
for _idx, lcp_iface in lcps.items():
vpp_iface = self.vpp.cache["interfaces"][lcp_iface.phy_sw_if_index]
if vpp_iface.sub_number_of_tags != numtags:
continue
if vpp_iface.interface_dev_type == "Loopback":
config_ifname, config_iface = loopback.get_by_lcp_name(
self.cfg, lcp.host_if_name
self.cfg, lcp_iface.host_if_name
)
else:
config_ifname, config_iface = interface.get_by_lcp_name(
self.cfg, lcp.host_if_name
self.cfg, lcp_iface.host_if_name
)
if not config_iface:
## Interface doesn't exist in the config
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if not "lcp" in config_iface:
## Interface doesn't have an LCP
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if vpp_iface.sub_number_of_tags == 2:
vpp_parent_idx = self.__parent_iface_by_encap(
@ -623,15 +628,15 @@ class Reconciler:
) = interface.get_by_lcp_name(self.cfg, parent_lcp.host_if_name)
if not config_parent_iface:
## QinX's parent doesn't exist in the config
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if not "lcp" in config_parent_iface:
## QinX's parent doesn't have an LCP
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if parent_lcp.host_if_name != config_parent_iface["lcp"]:
## QinX's parent LCP name mismatch
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
config_parent_encap = interface.get_encapsulation(
self.cfg, config_parent_ifname
@ -639,7 +644,7 @@ class Reconciler:
vpp_parent_encap = self.__get_encapsulation(vpp_parent_iface)
if config_parent_encap != vpp_parent_encap:
## QinX's parent encapsulation mismatch
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if vpp_iface.sub_number_of_tags > 0:
@ -647,7 +652,7 @@ class Reconciler:
vpp_encap = self.__get_encapsulation(vpp_iface)
if config_encap != vpp_encap:
## Encapsulation mismatch
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if vpp_iface.interface_dev_type == "Loopback":
@ -657,37 +662,37 @@ class Reconciler:
bond_iface = self.vpp.cache["interfaces"][vpp_iface.sup_sw_if_index]
if self.__bond_has_diff(bond_iface.interface_name):
## If BondEthernet changed, it has to be re-created, so all LCPs must be removed.
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
phy_lcp = lcps[vpp_iface.sup_sw_if_index]
config_phy_ifname, config_phy_iface = interface.get_by_lcp_name(
_config_phy_ifname, config_phy_iface = interface.get_by_lcp_name(
self.cfg, phy_lcp.host_if_name
)
if not config_phy_iface:
## Phy doesn't exist in the config
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if not "lcp" in config_phy_iface:
## Phy doesn't have an LCP
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
if phy_lcp.host_if_name != config_phy_iface["lcp"]:
## Phy LCP name mismatch
removed_lcps.append(lcp)
removed_lcps.append(lcp_iface)
continue
self.logger.debug(
f"LCP OK: {lcp.host_if_name} -> (vpp={vpp_iface.interface_name}, config={config_ifname})"
f"LCP OK: {lcp_iface.host_if_name} -> (vpp={vpp_iface.interface_name}, config={config_ifname})"
)
for lcp in removed_lcps:
for lcp_iface in removed_lcps:
vpp_ifname = self.vpp.cache["interfaces"][
lcp.phy_sw_if_index
lcp_iface.phy_sw_if_index
].interface_name
cli = f"lcp delete {vpp_ifname}"
self.cli["prune"].append(cli)
self.vpp.cache_remove_lcp(lcp.host_if_name)
self.vpp.cache_remove_lcp(lcp_iface.host_if_name)
return True
def prune_admin_state(self):
@ -762,9 +767,9 @@ class Reconciler:
instance = int(ifname[12:])
mode = bondethernet.get_mode(self.cfg, ifname)
cli = f"create bond id {int(instance)} mode {mode}"
lb = bondethernet.get_lb(self.cfg, ifname)
if lb:
cli += f" load-balance {lb}"
loadbalance = bondethernet.get_lb(self.cfg, ifname)
if loadbalance:
cli += f" load-balance {loadbalance}"
if "mac" in iface:
cli += f" hw-addr {iface['mac']}"
self.cli["create"].append(cli)
@ -790,7 +795,7 @@ class Reconciler:
if not do_qinx == interface.is_qinx(self.cfg, ifname):
continue
ifname, iface = interface.get_by_name(self.cfg, ifname)
ifname, _iface = interface.get_by_name(self.cfg, ifname)
if ifname in self.vpp.cache["interface_names"]:
continue
@ -802,7 +807,7 @@ class Reconciler:
encapstr = f"dot1q {int(encap['dot1q'])}"
if do_qinx:
encapstr += f" inner-dot1q {int(encap['inner-dot1q'])}"
if encap["exact-match"] == True:
if encap["exact-match"]:
encapstr += " exact-match"
parent, subid = ifname.split(".")
cli = f"create sub {parent} {int(int(subid))} {encapstr}"
@ -834,7 +839,7 @@ class Reconciler:
def create_bridgedomains(self):
for ifname in bridgedomain.get_bridgedomains(self.cfg):
ifname, iface = bridgedomain.get_by_name(self.cfg, ifname)
ifname, _iface = bridgedomain.get_by_name(self.cfg, ifname)
instance = int(ifname[2:])
settings = bridgedomain.get_settings(self.cfg, ifname)
if instance in self.vpp.cache["bridgedomains"]:
@ -1076,7 +1081,7 @@ class Reconciler:
if not "interfaces" in config_bridge_iface:
continue
for member_ifname in config_bridge_iface["interfaces"]:
member_ifname, member_iface = interface.get_by_name(
member_ifname, _member_iface = interface.get_by_name(
self.cfg, member_ifname
)
if not member_ifname in bridge_members:
@ -1094,7 +1099,7 @@ class Reconciler:
def sync_l2xcs(self):
for ifname in interface.get_l2xc_interfaces(self.cfg):
config_rx_ifname, config_rx_iface = interface.get_by_name(self.cfg, ifname)
config_tx_ifname, config_tx_iface = interface.get_by_name(
config_tx_ifname, _config_tx_iface = interface.get_by_name(
self.cfg, config_rx_iface["l2xc"]
)
vpp_rx_iface = None
@ -1171,13 +1176,13 @@ class Reconciler:
return True
def sync_link_mtu_direction(self, shrink=True):
for idx, vpp_iface in self.vpp.cache["interfaces"].items():
for _idx, vpp_iface in self.vpp.cache["interfaces"].items():
if vpp_iface.sub_number_of_tags != 0:
continue
if vpp_iface.interface_dev_type in ["local", "Loopback", "VXLAN", "virtio"]:
continue
config_ifname, config_iface = interface.get_by_name(
_config_ifname, config_iface = interface.get_by_name(
self.cfg, vpp_iface.interface_name
)
if not config_iface:
@ -1266,10 +1271,10 @@ class Reconciler:
str(x)
for x in self.vpp.cache["interface_addresses"][sw_if_index]
]
for a in config_addresses:
if a in vpp_addresses:
for addr in config_addresses:
if addr in vpp_addresses:
continue
cli = f"set interface ip address {vpp_ifname} {a}"
cli = f"set interface ip address {vpp_ifname} {addr}"
self.cli["sync"].append(cli)
return True
@ -1278,10 +1283,10 @@ class Reconciler:
self.cfg
):
if ifname.startswith("loop"):
vpp_ifname, config_iface = loopback.get_by_name(self.cfg, ifname)
vpp_ifname, _config_iface = loopback.get_by_name(self.cfg, ifname)
config_admin_state = 1
else:
vpp_ifname, config_iface = interface.get_by_name(self.cfg, ifname)
vpp_ifname, _config_iface = interface.get_by_name(self.cfg, ifname)
config_admin_state = interface.get_admin_state(self.cfg, ifname)
vpp_admin_state = 0
@ -1298,39 +1303,39 @@ class Reconciler:
self.cli["sync"].append(cli)
return True
def write(self, outfile, ok=False):
def write(self, outfile, emit_ok=False):
"""Emit the CLI contents to stdout (if outfile=='-') or a named file otherwise.
If the 'ok' flag is False, emit a warning at the top and bottom of the file.
If the 'emit_ok' flag is False, emit a warning at the top and bottom of the file.
"""
# Assemble the intended output into a list
output = []
if not ok:
if not emit_ok:
output.append(
"comment { vppcfg: Planning failed, be careful with this output! }"
)
for phase in ["prune", "create", "sync"]:
n = len(self.cli[phase])
if n > 0:
ncount = len(self.cli[phase])
if ncount > 0:
output.append(
f"comment {{ vppcfg {phase}: {n} CLI statement(s) follow }}"
f"comment {{ vppcfg {phase}: {ncount} CLI statement(s) follow }}"
)
output.extend(self.cli[phase])
if not ok:
if not emit_ok:
output.append(
"comment { vppcfg: Planning failed, be careful with this output! }"
)
# Emit the output list to stdout or a file
if outfile and outfile == "-":
fh = sys.stdout
file = sys.stdout
outfile = "(stdout)"
else:
fh = open(outfile, "w")
file = open(outfile, "w", encoding="utf-8")
if len(output) > 0:
print("\n".join(output), file=fh)
if fh is not sys.stdout:
fh.close()
print("\n".join(output), file=file)
if file is not sys.stdout:
file.close()
self.logger.info(f"Wrote {len(output)} lines to {outfile}")

View File

@ -4,10 +4,11 @@ interface metadata. Its base class will never change state. See the
derived classes VPPApiDumper() and VPPApiApplier()
"""
from vpp_papi import VPPApiClient
import os
import fnmatch
import logging
import socket
from vpp_papi import VPPApiClient
class VPPApi:
@ -32,7 +33,7 @@ class VPPApi:
# construct a list of all the json api files
jsonfiles = []
for root, dirnames, filenames in os.walk(vpp_json_dir):
for root, _dirnames, filenames in os.walk(vpp_json_dir):
for filename in fnmatch.filter(filenames, "*.api.json"):
jsonfiles.append(os.path.join(root, filename))
@ -47,8 +48,9 @@ class VPPApi:
except:
return False
v = self.vpp.api.show_version()
self.logger.info(f"VPP version is {v.version}")
# pylint: disable=no-member
api_response = self.vpp.api.show_version()
self.logger.info(f"VPP version is {api_response.version}")
self.connected = True
return True
@ -78,22 +80,15 @@ class VPPApi:
def cache_remove_lcp(self, lcpname):
"""Removes the LCP and TAP interface, identified by lcpname, from the config."""
found = False
for idx, lcp in self.cache["lcps"].items():
for _idx, lcp in self.cache["lcps"].items():
if lcp.host_if_name == lcpname:
found = True
break
if not found:
self.logger.warning(
f"Trying to remove an LCP which is not in the config: {lcpname}"
)
return False
ifname = self.cache["interfaces"][lcp.host_sw_if_index].interface_name
del self.cache["lcps"][lcp.phy_sw_if_index]
# Remove the TAP interface and its dependencies
return self.cache_remove_interface(ifname)
ifname = self.cache["interfaces"][lcp.host_sw_if_index].interface_name
del self.cache["lcps"][lcp.phy_sw_if_index]
return self.cache_remove_interface(ifname)
self.logger.warning(
f"Trying to remove an LCP which is not in the config: {lcpname}"
)
return False
def cache_remove_bondethernet_member(self, ifname):
"""Removes the bonderthernet member interface, identified by name, from the config."""
@ -159,6 +154,7 @@ class VPPApi:
return True
def readconfig(self):
# pylint: disable=no-member
if not self.connected and not self.connect():
self.logger.error("Could not connect to VPP")
return False
@ -169,9 +165,9 @@ class VPPApi:
self.lcp_enabled = False
try:
self.logger.debug("Retrieving LCPs")
r = self.vpp.api.lcp_itf_pair_get()
if isinstance(r, tuple) and r[0].retval == 0:
for lcp in r[1]:
api_response = self.vpp.api.lcp_itf_pair_get()
if isinstance(api_response, tuple) and api_response[0].retval == 0:
for lcp in api_response[1]:
if lcp.phy_sw_if_index > 65535 or lcp.host_sw_if_index > 65535:
## Work around endianness bug: https://gerrit.fd.io/r/c/vpp/+/35479
## TODO(pim) - remove this when 22.06 ships
@ -193,8 +189,8 @@ class VPPApi:
)
self.logger.debug("Retrieving interfaces")
r = self.vpp.api.sw_interface_dump()
for iface in r:
api_response = self.vpp.api.sw_interface_dump()
for iface in api_response:
self.cache["interfaces"][iface.sw_if_index] = iface
self.cache["interface_names"][iface.interface_name] = iface
self.cache["interface_addresses"][iface.sw_if_index] = []
@ -202,22 +198,22 @@ class VPPApi:
ipr = self.vpp.api.ip_address_dump(
sw_if_index=iface.sw_if_index, is_ipv6=False
)
for ip in ipr:
for addr in ipr:
self.cache["interface_addresses"][iface.sw_if_index].append(
str(ip.prefix)
str(addr.prefix)
)
self.logger.debug(f"Retrieving IPv6 addresses for {iface.interface_name}")
ipr = self.vpp.api.ip_address_dump(
sw_if_index=iface.sw_if_index, is_ipv6=True
)
for ip in ipr:
for addr in ipr:
self.cache["interface_addresses"][iface.sw_if_index].append(
str(ip.prefix)
str(addr.prefix)
)
self.logger.debug("Retrieving bondethernets")
r = self.vpp.api.sw_bond_interface_dump()
for iface in r:
api_response = self.vpp.api.sw_bond_interface_dump()
for iface in api_response:
self.cache["bondethernets"][iface.sw_if_index] = iface
self.cache["bondethernet_members"][iface.sw_if_index] = []
for member in self.vpp.api.sw_member_interface_dump(
@ -228,23 +224,23 @@ class VPPApi:
)
self.logger.debug("Retrieving bridgedomains")
r = self.vpp.api.bridge_domain_dump()
for bridge in r:
api_response = self.vpp.api.bridge_domain_dump()
for bridge in api_response:
self.cache["bridgedomains"][bridge.bd_id] = bridge
self.logger.debug("Retrieving vxlan_tunnels")
r = self.vpp.api.vxlan_tunnel_v2_dump()
for vxlan in r:
api_response = self.vpp.api.vxlan_tunnel_v2_dump()
for vxlan in api_response:
self.cache["vxlan_tunnels"][vxlan.sw_if_index] = vxlan
self.logger.debug("Retrieving L2 Cross Connects")
r = self.vpp.api.l2_xconnect_dump()
for l2xc in r:
api_response = self.vpp.api.l2_xconnect_dump()
for l2xc in api_response:
self.cache["l2xcs"][l2xc.rx_sw_if_index] = l2xc
self.logger.debug("Retrieving TAPs")
r = self.vpp.api.sw_interface_tap_v2_dump()
for tap in r:
api_response = self.vpp.api.sw_interface_tap_v2_dump()
for tap in api_response:
self.cache["taps"][tap.sw_if_index] = tap
self.cache_read = True
@ -322,7 +318,7 @@ class VPPApi:
return vxlan_tunnels
def get_lcp_by_interface(self, sw_if_index):
for idx, lcp in self.cache["lcps"].items():
for _idx, lcp in self.cache["lcps"].items():
if lcp.phy_sw_if_index == sw_if_index:
return lcp
return None
@ -337,7 +333,7 @@ class VPPApi:
if not vpp_iface.interface_dev_type == "virtio":
return False
for idx, lcp in self.cache["lcps"].items():
for _idx, lcp in self.cache["lcps"].items():
if vpp_iface.sw_if_index == lcp.host_sw_if_index:
return True
return False