diff --git a/images/sonic/Dockerfile b/images/sonic/Dockerfile index 0b7b7e28..8279514d 100644 --- a/images/sonic/Dockerfile +++ b/images/sonic/Dockerfile @@ -1,24 +1,24 @@ -FROM ubuntu:22.04 +FROM debian:bookworm-slim ENV LIBGUESTFS_BACKEND=direct # Check: https://sonic-build.azurewebsites.net/ui/sonic/pipelines -ENV SONIC_REMOTE_IMG=https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202211&platform=vs&target=target%2Fsonic-vs.img.gz +ARG SONIC_BASE_URL=https://sonic-build.azurewebsites.net/api/sonic/artifacts?branchName=202311&platform=vs +ARG SONIC_IMG_URL=${SONIC_BASE_URL}&target=target%2Fsonic-vs.img.gz +ARG FRR_RELOAD_URL=${SONIC_BASE_URL}&target=target%2Fdebs%2Fbullseye%2Ffrr-pythontools_8.5.1-sonic-0_all.deb RUN apt-get update && \ apt-get --no-install-recommends install --yes \ curl \ - linux-image-5.15.0-102-generic \ + linux-image-cloud-amd64 \ net-tools \ - ovmf \ python3 \ python3-guestfs \ qemu-system-x86 \ - telnet \ - tini && \ - curl --location --output - "${SONIC_REMOTE_IMG}" | gunzip > sonic-vs.img + telnet -ENTRYPOINT ["/usr/bin/tini", "--"] +RUN curl --location --output - "${SONIC_IMG_URL}" | gunzip > sonic-vs.img && \ + curl --location --output /frr-pythontools.deb "${FRR_RELOAD_URL}" -COPY config_db.json mirror_tap_to_eth.sh sonic_entrypoint.py / +ENTRYPOINT ["/launch.py"] -CMD ["/usr/bin/python3", "-u", "/sonic_entrypoint.py"] +COPY config_db.json mirror_tap_to_eth.sh launch.py / diff --git a/images/sonic/config_db.json b/images/sonic/config_db.json index 3c4269c5..02977d12 100644 --- a/images/sonic/config_db.json +++ b/images/sonic/config_db.json @@ -15,6 +15,9 @@ } }, "FEATURE": { + "gnmi": { + "state": "disabled" + }, "mgmt-framework": { "state": "disabled" }, @@ -24,7 +27,7 @@ "snmp": { "state": "disabled" }, - "telemetry": { + "teamd": { "state": "disabled" } }, @@ -68,5 +71,10 @@ "admin_status": "up", "mtu": "9100" } + }, + "VERSIONS": { + "DATABASE": { + "VERSION": "version_202311_03" + } } } diff --git a/images/sonic/sonic_entrypoint.py b/images/sonic/launch.py similarity index 91% rename from images/sonic/sonic_entrypoint.py rename to images/sonic/launch.py index 6b2a3803..1f3af01b 100755 --- a/images/sonic/sonic_entrypoint.py +++ b/images/sonic/launch.py @@ -17,8 +17,9 @@ class Qemu: - def __init__(self, name: str, memory: str, interfaces: int): + def __init__(self, name: str, smp: str, memory: str, interfaces: int): self._name = name + self._smp = smp self._memory = memory self._interfaces = interfaces self._p = None @@ -46,6 +47,7 @@ def start(self) -> None: cmd = [ 'qemu-system-x86_64', '-cpu', 'host', + '-smp', self._smp, '-display', 'none', '-enable-kvm', '-machine', 'q35', @@ -78,10 +80,15 @@ def initial_configuration(g: GuestFS) -> None: sonic_target_wants = systemd_system + 'sonic.target.wants/' g.mkdir_p(sonic_target_wants) + # Copy frr-pythontools into the image + g.copy_in(localpath='/frr-pythontools.deb', remotedir=image + 'rw/') + # Workaround: Speed up lldp startup by remove hardcoded wait of 90 seconds g.ln_s(linkname=systemd_system + 'aaastatsd.timer', target='/dev/null') # Radius g.ln_s(linkname=systemd_system + 'featured.timer', target='/dev/null') # Feature handling not necessary g.ln_s(linkname=systemd_system + 'hostcfgd.timer', target='/dev/null') # After boot Host configuration + g.ln_s(linkname=systemd_system + 'rasdaemon.timer', target='/dev/null') # After boot Host configuration + g.ln_s(linkname=systemd_system + 'tacacs-config.timer', target='/dev/null') # After boot Host configuration # Started by featured g.ln_s(linkname=sonic_target_wants + 'lldp.service', target='/lib/systemd/system/lldp.service') @@ -137,10 +144,11 @@ def main(): logger = logging.getLogger() name = os.getenv('CLAB_LABEL_CLAB_NODE_NAME', default='switch') - memory = os.getenv('VM_MEMORY', default='2048') + smp = os.getenv('QEMU_SMP', default='2') + memory = os.getenv('QEMU_MEMORY', default='2048') interfaces = int(os.getenv('CLAB_INTFS', 0)) + 1 - vm = Qemu(name, memory, interfaces) + vm = Qemu(name, smp, memory, interfaces) logger.info('Prepare disk') vm.prepare_overlay(BASE_IMG) diff --git a/images/sonic/mirror_tap_to_eth.sh b/images/sonic/mirror_tap_to_eth.sh index 7fefc52f..71f3bf2f 100755 --- a/images/sonic/mirror_tap_to_eth.sh +++ b/images/sonic/mirror_tap_to_eth.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Script is taken from https://netdevops.me/2021/transparently-redirecting-packets/frames-between-interfaces/ +# Script is taken from https://netdevops.me/2021/transparently-redirecting-packetsframes-between-interfaces/ # Read it for better understanding set -o errexit @@ -12,10 +12,11 @@ TAP_IF=$1 INDEX=${TAP_IF:3:3} ip link set $TAP_IF up +ip link set $TAP_IF mtu 65000 # create tc eth<->tap redirect rules tc qdisc add dev eth$INDEX ingress -tc filter add dev eth$INDEX parent ffff: protocol all matchall action mirred egress redirect dev $TAP_IF +tc filter add dev eth$INDEX parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev $TAP_IF tc qdisc add dev $TAP_IF ingress -tc filter add dev $TAP_IF parent ffff: protocol all matchall action mirred egress redirect dev eth$INDEX +tc filter add dev $TAP_IF parent ffff: protocol all u32 match u8 0 0 action mirred egress redirect dev eth$INDEX diff --git a/inventories/group_vars/sonic/main.yaml b/inventories/group_vars/sonic/main.yaml index 27182590..557f9bd3 100644 --- a/inventories/group_vars/sonic/main.yaml +++ b/inventories/group_vars/sonic/main.yaml @@ -7,6 +7,7 @@ metal_core_spine_uplinks: sonic_docker_routing_config_mode: split-unified sonic_frr_mgmt_framework_config: false +sonic_frr_render: false sonic_loopback_address: "{{ lo }}" sonic_mgmtif_ip: "{{ ansible_host }}/16`" diff --git a/roles/sonic/defaults/main.yaml b/roles/sonic/defaults/main.yaml deleted file mode 100644 index ea7b260f..00000000 --- a/roles/sonic/defaults/main.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -base_url: "https://raw.githubusercontent.com/FRRouting/frr" -branch_name: "frr-8.2.2" -frr_python_url: "{{ base_url }}/{{ branch_name }}/tools/frr-reload.py" -frr_url: "{{ base_url }}/{{ branch_name }}/tools/frr-reload" diff --git a/roles/sonic/tasks/frr-reload.yaml b/roles/sonic/tasks/frr-reload.yaml index 4afc994e..8164a1a5 100644 --- a/roles/sonic/tasks/frr-reload.yaml +++ b/roles/sonic/tasks/frr-reload.yaml @@ -4,34 +4,27 @@ port: 2605 state: started -- name: Download frr-reload.py - community.docker.docker_container_exec: +- name: Copy frr-pythontools into container + community.docker.docker_container_copy_into: container: bgp - argv: - - curl - - --location - - "{{ frr_python_url }}" - - --output - - frr-reload.py - chdir: /usr/lib/frr + path: /frr-pythontools.deb + container_path: /root/frr-pythontools.deb + mode: "0655" -- name: Download frr-reload +- name: Install frr-pythontools community.docker.docker_container_exec: container: bgp argv: - - curl - - --location - - "{{ frr_url }}" - - --output - - frr-reload - chdir: /usr/lib/frr + - dpkg + - -i + - frr-pythontools.deb + chdir: /root -- name: Change frr file permissions - community.docker.docker_container_exec: +- name: Place frr-reload + community.docker.docker_container_copy_into: container: bgp - argv: - - chmod - - "0755" - - frr-reload.py - - frr-reload - chdir: /usr/lib/frr + content: | + #!/bin/sh + exec python3 /usr/lib/frr/frr-reload.py --reload /etc/frr/frr.conf + container_path: /usr/lib/frr/frr-reload + mode: "0755"