From 007e16bfff8c012446408934c30f2ed19923d24a Mon Sep 17 00:00:00 2001 From: sferna1 Date: Thu, 22 Jun 2023 01:36:49 +0530 Subject: [PATCH 1/2] Update vagrant to kernel version 5.15 Signed-off-by: sferna1 --- dev_environment/Vagrantfile | 10 ++++++++++ dev_environment/setup_linux_dev_env.sh | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index be009f6..78f7923 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -33,6 +33,16 @@ Vagrant.configure("2") do |config| l3af.vm.synced_folder cfg['host_l3afd_code_dir'], "/home/vagrant/code/l3afd" + 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 + SHELL + + # restart after upgrade + l3af.vm.provision :reload + # Add Grafana apt repo l3af.vm.provision "shell", inline: <<-SHELL sudo apt-get install -y apt-transport-https diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index bef8d32..724ec5b 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -19,6 +19,27 @@ if [ "$VER" != "20" ]; then fi fi +# 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 + # Get cpu architecture, arm or amd ARCH=$(uname -p) From e56da23611a5a7f70d1f91041929ad4cbcf95a30 Mon Sep 17 00:00:00 2001 From: sferna1 Date: Tue, 11 Jul 2023 03:50:00 -0700 Subject: [PATCH 2/2] update jammy vm support Signed-off-by: sferna1 --- dev_environment/Vagrantfile | 31 +++++++++++++++++--------- dev_environment/config.yaml | 1 + dev_environment/provision.sh | 7 ++++-- dev_environment/setup_linux_dev_env.sh | 15 ++----------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index 78f7923..954b834 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -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 @@ -33,16 +52,6 @@ Vagrant.configure("2") do |config| l3af.vm.synced_folder cfg['host_l3afd_code_dir'], "/home/vagrant/code/l3afd" - 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 - SHELL - - # restart after upgrade - l3af.vm.provision :reload - # Add Grafana apt repo l3af.vm.provision "shell", inline: <<-SHELL sudo apt-get install -y apt-transport-https @@ -61,7 +70,7 @@ Vagrant.configure("2") do |config| curl \ exuberant-ctags \ flex \ - gcc-8 \ + gcc-9 \ gcc-multilib \ gnutls-bin \ grafana \ diff --git a/dev_environment/config.yaml b/dev_environment/config.yaml index b5d18ef..ed4904b 100644 --- a/dev_environment/config.yaml +++ b/dev_environment/config.yaml @@ -7,3 +7,4 @@ configs: host_l3af_debug_port: '38899' host_l3afd_code_dir: '/code/l3afd' traffic_mirroring: 'false' + host_distro_codename: 'jammy' diff --git a/dev_environment/provision.sh b/dev_environment/provision.sh index 09ce87d..dce4f4e 100755 --- a/dev_environment/provision.sh +++ b/dev_environment/provision.sh @@ -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 @@ -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 ../ diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index 724ec5b..3df3655 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -8,17 +8,6 @@ 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 - fi -fi - # 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) @@ -103,7 +92,7 @@ apt-get install -y bc \ curl \ exuberant-ctags \ flex \ - gcc-8 \ + gcc-9 \ gnutls-bin \ grafana \ jq \ @@ -190,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