Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VxLAN fix tunnel oper_state issue #3216

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions .azure-pipelines/build_and_install_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,62 +26,60 @@ 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
apt-get update

# 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
Expand Down
5 changes: 4 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only calling for updateDbPortOperStatus is relevant for tunnel case, everything else (like autoneg, link training, ...) is physical port specific.
Maybe moving updateDbPortOperStatus outside of this "if", should be more correct ?

updateDbPortFlapCount(port, status);
Expand Down
9 changes: 9 additions & 0 deletions orchagent/vxlanorch.cpp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would better to use DEFAULT_TUNNEL_ENCAP_TTL as default value for the encap_ttl (instead of 0). It will reuse the existing code and you could also remove the "if (encap_ttl != 0)".

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions orchagent/vxlanorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum
#define MAX_VLAN_ID 4095

#define MAX_VNI_ID 16777215
#define DEFAULT_TUNNEL_ENCAP_TTL 64

typedef enum
{
Expand Down