From 94c3fa1105315520a6711d4dc9ae9230cfb07414 Mon Sep 17 00:00:00 2001 From: praveenraja1 Date: Tue, 2 Jul 2024 14:22:41 -0700 Subject: [PATCH] VxLAN tunnel oper_state fix --- .azure-pipelines/build_and_install_module.sh | 62 ++++++++++---------- orchagent/portsorch.cpp | 5 +- orchagent/vxlanorch.cpp | 9 +++ orchagent/vxlanorch.h | 1 + 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/.azure-pipelines/build_and_install_module.sh b/.azure-pipelines/build_and_install_module.sh index 493a2f04e2..d9f38cec61 100755 --- a/.azure-pipelines/build_and_install_module.sh +++ b/.azure-pipelines/build_and_install_module.sh @@ -26,15 +26,26 @@ function build_and_install_kmodule() SUBLEVEL=$(echo $KERNEL_MAINVERSION | cut -d. -f3) # Install the required debian packages to build the kernel modules + apt-get update apt-get install -y build-essential linux-headers-${KERNEL_RELEASE} autoconf pkg-config fakeroot - apt-get install -y flex bison libssl-dev libelf-dev + apt-get install -y flex bison libssl-dev libelf-dev dwarves apt-get install -y libnl-route-3-200 libnl-route-3-dev libnl-cli-3-200 libnl-cli-3-dev libnl-3-dev # Add the apt source mirrors and download the linux image source code cp /etc/apt/sources.list /etc/apt/sources.list.bk sed -i "s/^# deb-src/deb-src/g" /etc/apt/sources.list apt-get update - apt-get source linux-image-unsigned-$(uname -r) > source.log + KERNEL_PACKAGE_SOURCE=$(apt-cache show linux-image-unsigned-${KERNEL_RELEASE} | grep ^Source: | cut -d':' -f 2) + KERNEL_PACKAGE_VERSION=$(apt-cache show linux-image-unsigned-${KERNEL_RELEASE} | grep ^Version: | cut -d':' -f 2) + SOURCE_PACKAGE_VERSION=$(apt-cache showsrc ${KERNEL_PACKAGE_SOURCE} | grep ^Version: | cut -d':' -f 2) + if [ ${KERNEL_PACKAGE_VERSION} != ${SOURCE_PACKAGE_VERSION} ]; then + echo "WARNING: the running kernel version (${KERNEL_PACKAGE_VERSION}) doesn't match the source package " \ + "version (${SOURCE_PACKAGE_VERSION}) being downloaded. There's no guarantee the module being downloaded " \ + "can be loaded into the kernel or function correctly. If possible, please update your kernel and reboot " \ + "your system so that it's running the matching kernel version." >&2 + echo "Continuing with the build anyways" >&2 + fi + apt-get source linux-image-unsigned-${KERNEL_RELEASE} > source.log # Recover the original apt sources list cp /etc/apt/sources.list.bk /etc/apt/sources.list @@ -42,46 +53,33 @@ function build_and_install_kmodule() # Build the Linux kernel module drivers/net/team and vrf cd $(find . -maxdepth 1 -type d | grep -v "^.$") + if [ -e debian/debian.env ]; then + source debian/debian.env + if [ -n "${DEBIAN}" -a -e ${DEBIAN}/reconstruct ]; then + bash ${DEBIAN}/reconstruct + fi + fi make allmodconfig mv .config .config.bk cp /boot/config-$(uname -r) .config grep NET_TEAM .config.bk >> .config - echo CONFIG_NET_VRF=m >> .config - echo CONFIG_MACSEC=m >> .config - echo CONFIG_NET_VENDOR_MICROSOFT=y >> .config - echo CONFIG_MICROSOFT_MANA=m >> .config - echo CONFIG_SYSTEM_REVOCATION_LIST=n >> .config make VERSION=$VERSION PATCHLEVEL=$PATCHLEVEL SUBLEVEL=$SUBLEVEL EXTRAVERSION=-${EXTRAVERSION} LOCALVERSION=-${LOCALVERSION} modules_prepare - make M=drivers/net/team + cp /usr/src/linux-headers-$(uname -r)/Module.symvers . + make -j$(nproc) M=drivers/net/team mv drivers/net/Makefile drivers/net/Makefile.bak echo 'obj-$(CONFIG_NET_VRF) += vrf.o' > drivers/net/Makefile echo 'obj-$(CONFIG_MACSEC) += macsec.o' >> drivers/net/Makefile - make M=drivers/net + make -j$(nproc) M=drivers/net # Install the module - TEAM_DIR=$(echo /lib/modules/$(uname -r)/kernel/net/team) - NET_DIR=$(echo /lib/modules/$(uname -r)/kernel/net) - if [ ! -e "$TEAM_DIR/team.ko" ]; then - mkdir -p $TEAM_DIR - cp drivers/net/team/*.ko $TEAM_DIR/ - modinfo $TEAM_DIR/team.ko - depmod - modprobe team - fi - if [ ! -e "$NET_DIR/vrf.ko" ]; then - mkdir -p $NET_DIR - cp drivers/net/vrf.ko $NET_DIR/ - modinfo $NET_DIR/vrf.ko - depmod - modprobe vrf - fi - if [ ! -e "$NET_DIR/macsec.ko" ]; then - mkdir -p $NET_DIR - cp drivers/net/macsec.ko $NET_DIR/ - modinfo $NET_DIR/macsec.ko - depmod - modprobe macsec - fi + SONIC_MODULES_DIR=/lib/modules/$(uname -r)/updates/sonic + mkdir -p $SONIC_MODULES_DIR + cp drivers/net/team/*.ko drivers/net/vrf.ko drivers/net/macsec.ko $SONIC_MODULES_DIR/ + depmod + modinfo team vrf macsec + modprobe team + modprobe vrf + modprobe macsec cd /tmp rm -rf $WORKDIR diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index fc19e25009..798931cc2c 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -7203,7 +7203,9 @@ bool PortsOrch::addTunnel(string tunnel_alias, sai_object_id_t tunnel_id, bool h { tunnel.m_learn_mode = SAI_BRIDGE_PORT_FDB_LEARNING_MODE_DISABLE; } + tunnel.m_oper_status = SAI_PORT_OPER_STATUS_DOWN; m_portList[tunnel_alias] = tunnel; + saiOidToAlias[tunnel_id] = tunnel_alias; SWSS_LOG_INFO("addTunnel:: %" PRIx64, tunnel_id); @@ -7214,6 +7216,7 @@ bool PortsOrch::removeTunnel(Port tunnel) { SWSS_LOG_ENTER(); + saiOidToAlias.erase(tunnel.m_tunnel_id); m_portList.erase(tunnel.m_alias); return true; @@ -8087,7 +8090,7 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status) return; } - if (port.m_type == Port::PHY) + if (port.m_type == Port::PHY || port.m_type == Port::TUNNEL) { updateDbPortOperStatus(port, status); updateDbPortFlapCount(port, status); diff --git a/orchagent/vxlanorch.cpp b/orchagent/vxlanorch.cpp index 05a2d3e603..bf81e8b072 100644 --- a/orchagent/vxlanorch.cpp +++ b/orchagent/vxlanorch.cpp @@ -358,6 +358,15 @@ create_tunnel( attr.id = SAI_TUNNEL_ATTR_ENCAP_TTL_VAL; attr.value.u8 = encap_ttl; tunnel_attrs.push_back(attr); + } else { + attr.id = SAI_TUNNEL_ATTR_ENCAP_TTL_MODE; + attr.value.s32 = SAI_TUNNEL_TTL_MODE_PIPE_MODEL; + tunnel_attrs.push_back(attr); + + attr.id = SAI_TUNNEL_ATTR_ENCAP_TTL_VAL; + attr.value.u8 = DEFAULT_TUNNEL_ENCAP_TTL; + tunnel_attrs.push_back(attr); + } sai_object_id_t tunnel_id; diff --git a/orchagent/vxlanorch.h b/orchagent/vxlanorch.h index 695f7441e0..eb68d0ce70 100644 --- a/orchagent/vxlanorch.h +++ b/orchagent/vxlanorch.h @@ -46,6 +46,7 @@ typedef enum #define MAX_VLAN_ID 4095 #define MAX_VNI_ID 16777215 +#define DEFAULT_TUNNEL_ENCAP_TTL 64 typedef enum {