Skip to content

Commit

Permalink
Merge pull request #64 from sanfern/sanfern-dev-env-r2
Browse files Browse the repository at this point in the history
Update dev environments to kernel version 5.15
  • Loading branch information
dthaler committed Aug 8, 2023
2 parents 97b72c7 + e56da23 commit 4434e24
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
21 changes: 20 additions & 1 deletion dev_environment/Vagrantfile
Expand Up @@ -25,6 +25,25 @@ Vagrant.configure("2") do |config|
end

l3af.vm.box = "ubuntu/focal64"
if cfg['host_distro_codename'] == "jammy"
config.vm.provision "shell", privileged: false, inline: <<-EOF
echo "Vagrant Box jammy provisioned!"
EOF
l3af.vm.box = "ubuntu/jammy64"
else
# upgrading focal to v5.15 kernel as minimum version requirement for R2
l3af.vm.provision "shell", inline: <<-SHELL
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
chmod +x ubuntu-mainline-kernel.sh
sudo mv ubuntu-mainline-kernel.sh /usr/local/bin/
sudo ubuntu-mainline-kernel.sh -i 5.15.0
apt --fix-broken -y install
SHELL

# restart after upgrade
l3af.vm.provision :reload
end

if cfg['traffic_mirroring'] == "true"
l3af.vm.network :private_network, ip: "192.168.10.40", :netmask => "255.255.255.0"
end
Expand All @@ -51,7 +70,7 @@ Vagrant.configure("2") do |config|
curl \
exuberant-ctags \
flex \
gcc-8 \
gcc-9 \
gcc-multilib \
gnutls-bin \
grafana \
Expand Down
1 change: 1 addition & 0 deletions dev_environment/config.yaml
Expand Up @@ -7,3 +7,4 @@ configs:
host_l3af_debug_port: '38899'
host_l3afd_code_dir: '/code/l3afd'
traffic_mirroring: 'false'
host_distro_codename: 'jammy'
7 changes: 5 additions & 2 deletions dev_environment/provision.sh
Expand Up @@ -29,7 +29,7 @@ if [ -d "/usr/src/linux" ]
then
echo "Directory /usr/src/linux exists."
else
git clone --branch v5.1 --depth 1 https://github.com/torvalds/linux.git /usr/src/linux
git clone --branch v5.15 --depth 1 https://github.com/torvalds/linux.git /usr/src/linux
fi
LINUX_SRC_DIR=/usr/src/linux
cd $LINUX_SRC_DIR
Expand Down Expand Up @@ -58,12 +58,15 @@ cd eBPF-Package-Repository
# declare an array variable
declare -a progs=("xdp-root" "ratelimiting" "connection-limit" "tc-root" "ipfix-flow-exporter" "traffic-mirroring")

# Distribution code name
distro=`cat /etc/os-release | grep UBUNTU_CODENAME | awk -F= '{print $2}'`

# now loop through the above array and build the L3AF eBPF programs
for prog in "${progs[@]}"
do
cd $prog
make
PROG_ARTIFACT_DIR=$BUILD_ARTIFACT_DIR/$prog/latest/focal
PROG_ARTIFACT_DIR=$BUILD_ARTIFACT_DIR/$prog/latest/$distro
mkdir -p $PROG_ARTIFACT_DIR
mv *.tar.gz $PROG_ARTIFACT_DIR
cd ../
Expand Down
30 changes: 20 additions & 10 deletions dev_environment/setup_linux_dev_env.sh
Expand Up @@ -8,14 +8,24 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

# Make sure it is focal version 20.04
VER=$(uname -v | cut -d. -f1 | cut -d~ -f2)
VER2=$(lsb_release -sr | cut -d '.' -f1)

if [ "$VER" != "20" ]; then
if [ "$VER2" != "20" ]; then
echo "The Ubuntu version $VER i.e $VER2 is not supported by the script"
exit 1
# Check for kernel version 5.15
CURRENT_KERNEL_VERSION=$(uname -r | cut -d"." -f1-2)
CURRENT_KERNEL_MAJOR_VERSION=$(echo "${CURRENT_KERNEL_VERSION}" | cut -d"." -f1)
CURRENT_KERNEL_MINOR_VERSION=$(echo "${CURRENT_KERNEL_VERSION}" | cut -d"." -f2)
ALLOWED_KERNEL_VERSION="5.15"
ALLOWED_KERNEL_MAJOR_VERSION=$(echo ${ALLOWED_KERNEL_VERSION} | cut -d"." -f1)
ALLOWED_KERNEL_MINOR_VERSION=$(echo ${ALLOWED_KERNEL_VERSION} | cut -d"." -f2)
if [ "${CURRENT_KERNEL_MAJOR_VERSION}" -lt "${ALLOWED_KERNEL_MAJOR_VERSION}" ]; then
# If the current major version is less than the allowed major version, show an error message and exit.
echo "Error: Kernel ${CURRENT_KERNEL_VERSION} not supported, please update to ${ALLOWED_KERNEL_VERSION}."
exit
fi
if [ "${CURRENT_KERNEL_MAJOR_VERSION}" == "${ALLOWED_KERNEL_MAJOR_VERSION}" ]; then
# If the current major version is equal to the allowed major version, check the minor version.
if [ "${CURRENT_KERNEL_MINOR_VERSION}" -lt "${ALLOWED_KERNEL_MINOR_VERSION}" ]; then
# If the current minor version is less than the allowed minor version, show an error message and exit.
echo "Error: Kernel ${CURRENT_KERNEL_VERSION} not supported, please update to ${ALLOWED_KERNEL_VERSION}."
exit
fi
fi

Expand Down Expand Up @@ -82,7 +92,7 @@ apt-get install -y bc \
curl \
exuberant-ctags \
flex \
gcc-8 \
gcc-9 \
gnutls-bin \
grafana \
jq \
Expand Down Expand Up @@ -169,7 +179,7 @@ if [ -d "/usr/src/linux" ];
then
echo "Linux source code already exists, skipping download"
else
git clone --branch v5.1 --depth 1 https://github.com/torvalds/linux.git /usr/src/linux
git clone --branch v5.15 --depth 1 https://github.com/torvalds/linux.git /usr/src/linux
fi

LINUX_SRC_DIR=/usr/src/linux
Expand Down

0 comments on commit 4434e24

Please sign in to comment.