From 65de792e35fa5fb1dcac2c269555bbce757954fd Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sun, 3 Apr 2022 22:24:59 +0000 Subject: [PATCH] Implement workaround for endianness issue in linux-cp --- vpp/vppapi.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vpp/vppapi.py b/vpp/vppapi.py index d019439..7ff47eb 100644 --- a/vpp/vppapi.py +++ b/vpp/vppapi.py @@ -152,9 +152,6 @@ class VPPApi(): try: self.logger.debug("Retrieving LCPs (lcpng)") r = self.vpp.api.lcpng_itf_pair_get() - if isinstance(r, tuple) and r[0].retval == 0: - for lcp in r[1]: - self.cache['lcps'][lcp.phy_sw_if_index] = lcp self.lcp_enabled = True except: self.logger.warning("lcpng not found, trying linux-cp") @@ -162,15 +159,23 @@ class VPPApi(): try: self.logger.debug("Retrieving LCPs (linux-cp)") r = self.vpp.api.lcp_itf_pair_get() - if isinstance(r, tuple) and r[0].retval == 0: - for lcp in r[1]: - self.cache['lcps'][lcp.phy_sw_if_index] = lcp self.lcp_enabled = True except: pass if not self.lcp_enabled: self.logger.warning("lcpng nor linux-cp found, will not reconcile Linux Control Plane") + else: + if isinstance(r, tuple) and r[0].retval == 0: + for lcp in r[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 + lcp = lcp._replace(phy_sw_if_index=socket.ntohl(lcp.phy_sw_if_index)) + lcp = lcp._replace(host_sw_if_index=socket.ntohl(lcp.host_sw_if_index)) + lcp = lcp._replace(vif_index=socket.ntohl(lcp.vif_index)) + self.logger.warning("LCP workaround for endianness issue on %s" % lcp.host_if_name) + self.cache['lcps'][lcp.phy_sw_if_index] = lcp self.logger.debug("Retrieving interfaces") r = self.vpp.api.sw_interface_dump()