Skip to content

Commit

Permalink
EOS SDK v2.23.0 (EOS 4.32.1F)
Browse files Browse the repository at this point in the history
  • Loading branch information
prufer committed Jun 8, 2024
1 parent ad1d45d commit d96aad1
Show file tree
Hide file tree
Showing 21 changed files with 851 additions and 70 deletions.
97 changes: 50 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
# Copyright (c) 2024 Arista Networks, Inc. All rights reserved.
# Copyright (c) 2020 Arista Networks, Inc. All rights reserved.
# Arista Networks, Inc. Confidential and Proprietary.

#-----------------------------------------------------------------------------------
# This Dockerfile can be used to build a docker image that can then be used to create
# a docker container that will be able to compile EosSdk applications in exactly the
# same way as EOS native applications are compiled (and thus binary compatible with
# EOS libraries).
# This Dockerfile can be used to build a docker image.
# Docker containers of this image can be used to build EosSdk applications.
# The following build options are provided:
# arch : Use 'm32' to build a 32-bit EosSdk application otherwise use 'm64'
# to build a 64-bit EosSdk application.
# Default value is set to 'm32'.
# Example:
# Steps to build an application using EosSdk docker container.
# 1) Build Docker image with tag as arista-eossdk:latest:
# a) Docker image with a 32-bit libeos.so
# "docker build -t arista-eossdk --build-arg arch=m32 ."
# or "docker build -t arista-eossdk ."
#
# OR
# b) Docker image with a 64-bit libeos.so
# "docker build -t arista-eossdk --build-arg arch=m64 ."
#
# 1) Build Docker image (we will call it 'arista-eossdk')
# docker build . -f <this Dockerfile> -t arista-eossdk
# 2) Run Docker container:
# docker run -v /home/sdk-app:/sdk-app --name <name> -it arista-eossdk bash
# This will mount /home/sdk-app as sdk-app inside the container.
# Place the application code and necessary dependencies in /home/sdk-app
#
# 2) Create container: (assuming application code to be compiled is at /code on the
# host machine that starts the container)
# docker run -v /code:/code -itd --name arista-eossdk-c1 arista-eossdk
# 3) Compile application binary:
# Run the following command from /sdk-app.
# For 32-bit binary: "g++ -m32 --std=gnu++0x -o <target> <source file> -leos"
# For 64-bit binary: "g++ -m64 --std=gnu++0x -o <target> <source file> -leos"
# The generated binary will also be available in /home/sdk-app on the host
# machine.
#
# 3) Go into the container and build the application
# docker exec -it arista-eossdk-c1 /bin/bash
# cd /code
# g++ -std=gnu++20 -o /code/build/HelloWorld.o -c /code/HelloWorld.cpp
# g++ -std=gnu++20 -o /code/build/HelloWorld /code/HelloWorld.o -leos -lrt
# g++ -m32 -std=gnu++20 -o /code/build/HelloWorld.o -c /code/HelloWorld.cpp
# g++ -m32 -std=gnu++20 -o /code/build/HelloWorld32 /code/HelloWorld.o -leos -lrt
#
# 4) Load the application (in /code/build on your host) onto an Arista switch
#4) Load the application on Arista switch:
# Further instructions to run the application on Arista switch can be found here:
# https://github.com/aristanetworks/EosSdk/wiki/Quickstart%3A-Hello-World
#
# 5) Cleanup
# docker rm arista-eossdk-c1
# docker rmi arista-eossdk
#
# To learn more about EosSdk visit the following link.
# https://github.com/aristanetworks/EosSdk/wiki
#-----------------------------------------------------------------------------------

FROM almalinux:9
ARG version=2.22.5.2
FROM centos:7
ARG version=2.23.0
ARG arch="m32"

# Set eossdk version as label and environ variable.
LABEL version=$version
Expand All @@ -51,32 +57,29 @@ RUN \
&& yum -y install wget \
&& yum -y install patch \
&& yum -y install libtool \
&& yum -y install diffutils
&& yum -y install diffutils \
&& yum -y install swig3 \
&& yum -y install python-devel \
&& yum -y install python3-devel

WORKDIR /usr/src/EosSdk-stubs-$version
ADD ./ ./

# Download cross-compiler.
RUN wget -O /tmp/arista-cross-compiler.rpm \
https://github.com/aristanetworks/EosSdk-cross-compiler/releases/download/v4.32.0/arista-gcc-11.i686.rpm
RUN \
wget -O /tmp/arista-cross-compiler.rpm \
https://github.com/aristanetworks/EosSdk-cross-compiler/releases/download/v4.25.0/arista-centos7.5-gcc8.4.0-glibc2.17-1.0-0.i686.rpm

# Install the cross compiler.
RUN rpm --force --nodeps -Uvh /tmp/arista-cross-compiler.rpm
RUN yum -y install /tmp/arista-cross-compiler.rpm

# Delete the cross compiler rpm.
RUN rm -f /tmp/arista-cross-compiler.rpm

ENV PATH=/opt/arista/gcc11/bin:$PATH
ENV PATH=/opt/arista/centos7.5-gcc8.4.0-glibc2.17/bin:$PATH

# Download the EosSdk stubs
RUN wget -O /tmp/stubs.tar.gz \
https://github.com/aristanetworks/EosSdk/archive/refs/tags/v$version.tar.gz
RUN test -f Makefile && rm -f Makefile
RUN test -f configure && rm -f configure
# Build EosSdk stubs.
RUN ./build.sh --$arch
RUN make install

# Build EosSdk stubs and install libeos and headerfiles for both m32 and m64
RUN cd /tmp; tar -xzf stubs.tar.gz; cd EosSdk-* ;\
./build.sh -m32 >& ../build32.log ;\
make install >& ../install32.log ;\
rm -rf /tmp/EosSdk-* ;\
cd /tmp; tar -xzf stubs.tar.gz; cd EosSdk-* ;\
./build.sh -m64 >& ../build64.log ;\
make install >& ../install64.log ;\
cd .. ;\
rm -rf /tmp/EosSdk-* ;\
rm stubs.tar.gz
# Delete the cross compiler rpm.
RUN rm -f /tmp/arista-cross-compiler.rpm
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libeos.la
AM_CXXFLAGS = -fvisibility=hidden
AM_CXXFLAGS += $(EXTRA_CFLAGS)
AM_CXXFLAGS += -Wextra -Wall -Wnon-virtual-dtor -Werror -Wno-unused-parameter -Wno-error=unused-value -fPIC -fPIE -fvisibility-inlines-hidden
AM_CXXFLAGS += -DTRAFFIC_POLICY_ENABLED
AM_LDFLAGS = -Wl,--no-undefined -fPIC -fPIE

PUBLISHED_HEADER_FILES := $(wildcard eos/*.h) $(wildcard eos/inline/*.h) $(wildcard eos/types/*.h) $(wildcard eos/inline/types/*.h)
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
LANG=C
export LANG
unset DISPLAY
Expand Down Expand Up @@ -46,8 +46,8 @@ if $target_32b; then
CFLAGS="$CFLAGS $CFLAGS_32B"
CXXFLAGS="$CXXFLAGS $CXXFLAGS_32B"
LDFLAGS="$LDFLAGS $LDFLAGS_32B"
configure_flags='--host=x86_64-pc-linux-gnu'
fi
configure_flags='--host=x86_64-pc-linux-gnu'

sysroot=$($(which gcc) --print-sysroot) || sysroot = ""
inst_prefix="--prefix=$sysroot/usr"
Expand Down
22 changes: 22 additions & 0 deletions eos/inline/types/nexthop_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ uint16_t
nexthop_group_t::size() const {
return pimpl->size();
}
uint16_t
nexthop_group_t::backup_size() const {
return pimpl->backup_size();
}
std::map<uint16_t, nexthop_group_entry_t> const &
nexthop_group_t::nexthops() const {
return pimpl->nexthops();
Expand All @@ -281,6 +285,24 @@ void
nexthop_group_t::nexthop_del(uint16_t key) {
pimpl->nexthop_del(key);
}
std::map<uint16_t, nexthop_group_entry_t> const &
nexthop_group_t::backup_nexthops() const {
return pimpl->backup_nexthops();
}
void
nexthop_group_t::backup_nexthops_is(
std::map<uint16_t, nexthop_group_entry_t> const & backup_nexthops) {
pimpl->backup_nexthops_is(backup_nexthops);
}
void
nexthop_group_t::backup_nexthop_set(uint16_t key,
nexthop_group_entry_t const & value) {
pimpl->backup_nexthop_set(key, value);
}
void
nexthop_group_t::backup_nexthop_del(uint16_t key) {
pimpl->backup_nexthop_del(key);
}
std::map<uint16_t, ip_addr_t> const &
nexthop_group_t::destination_ips() const {
return pimpl->destination_ips();
Expand Down
71 changes: 61 additions & 10 deletions eos/inline/types/nexthop_group_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,41 +378,41 @@ operator<<(std::ostream& os, const nexthop_group_entry_impl_t& obj) {
nexthop_group_impl_t::nexthop_group_impl_t() :
name_(), type_(), gre_key_type_(NEXTHOP_GROUP_GRE_KEY_NULL), ttl_(64),
source_ip_(), source_intf_(), autosize_(false), nexthops_(),
destination_ips_(), counters_unshared_(), hierarchical_fecs_enabled_(false),
counters_persistent_(), version_id_() {
backup_nexthops_(), destination_ips_(), counters_unshared_(),
hierarchical_fecs_enabled_(false), counters_persistent_(), version_id_() {
}

nexthop_group_impl_t::nexthop_group_impl_t(std::string name,
nexthop_group_encap_t type) :
name_(name), type_(type), gre_key_type_(NEXTHOP_GROUP_GRE_KEY_NULL),
ttl_(64), source_ip_(), source_intf_(), autosize_(false), nexthops_(),
destination_ips_(), counters_unshared_(), hierarchical_fecs_enabled_(false),
counters_persistent_(), version_id_() {
backup_nexthops_(), destination_ips_(), counters_unshared_(),
hierarchical_fecs_enabled_(false), counters_persistent_(), version_id_() {
}

nexthop_group_impl_t::nexthop_group_impl_t(
std::string name, nexthop_group_encap_t type,
nexthop_group_gre_key_t gre_key_type) :
name_(name), type_(type), gre_key_type_(gre_key_type), ttl_(64),
source_ip_(), source_intf_(), autosize_(false), nexthops_(),
destination_ips_(), counters_unshared_(), hierarchical_fecs_enabled_(false),
counters_persistent_(), version_id_() {
backup_nexthops_(), destination_ips_(), counters_unshared_(),
hierarchical_fecs_enabled_(false), counters_persistent_(), version_id_() {
}

nexthop_group_impl_t::nexthop_group_impl_t(std::string name,
ip_addr_t const & source_ip) :
name_(name), type_(), gre_key_type_(), ttl_(), source_ip_(source_ip),
source_intf_(), autosize_(), nexthops_(), destination_ips_(),
counters_unshared_(), hierarchical_fecs_enabled_(false),
source_intf_(), autosize_(), nexthops_(), backup_nexthops_(),
destination_ips_(), counters_unshared_(), hierarchical_fecs_enabled_(false),
counters_persistent_(), version_id_() {
}

nexthop_group_impl_t::nexthop_group_impl_t(
std::string name, ip_addr_t const & source_ip,
std::map<uint16_t, nexthop_group_entry_t> const & nexthops) :
name_(name), type_(), gre_key_type_(), ttl_(), source_ip_(source_ip),
source_intf_(), autosize_(), nexthops_(nexthops), destination_ips_(),
counters_unshared_(), hierarchical_fecs_enabled_(false),
source_intf_(), autosize_(), nexthops_(nexthops), backup_nexthops_(),
destination_ips_(), counters_unshared_(), hierarchical_fecs_enabled_(false),
counters_persistent_(), version_id_() {
}

Expand Down Expand Up @@ -494,6 +494,15 @@ nexthop_group_impl_t::size() const {
return nexthops_.rbegin()->first + 1;
}

uint16_t
nexthop_group_impl_t::backup_size() const {

if (backup_nexthops_.empty()) {
return 0;
}
return backup_nexthops_.rbegin()->first + 1;
}

std::map<uint16_t, nexthop_group_entry_t> const &
nexthop_group_impl_t::nexthops() const {
return nexthops_;
Expand All @@ -516,6 +525,28 @@ nexthop_group_impl_t::nexthop_del(uint16_t key) {
nexthops_.erase(key);
}

std::map<uint16_t, nexthop_group_entry_t> const &
nexthop_group_impl_t::backup_nexthops() const {
return backup_nexthops_;
}

void
nexthop_group_impl_t::backup_nexthops_is(
std::map<uint16_t, nexthop_group_entry_t> const & backup_nexthops) {
backup_nexthops_ = backup_nexthops;
}

void
nexthop_group_impl_t::backup_nexthop_set(uint16_t key,
nexthop_group_entry_t const & value) {
backup_nexthops_[key] = value;
}

void
nexthop_group_impl_t::backup_nexthop_del(uint16_t key) {
backup_nexthops_.erase(key);
}

std::map<uint16_t, ip_addr_t> const &
nexthop_group_impl_t::destination_ips() const {
return destination_ips_;
Expand Down Expand Up @@ -587,6 +618,7 @@ nexthop_group_impl_t::operator==(nexthop_group_impl_t const & other) const {
source_intf_ == other.source_intf_ &&
autosize_ == other.autosize_ &&
nexthops_ == other.nexthops_ &&
backup_nexthops_ == other.backup_nexthops_ &&
destination_ips_ == other.destination_ips_ &&
counters_unshared_ == other.counters_unshared_ &&
hierarchical_fecs_enabled_ == other.hierarchical_fecs_enabled_ &&
Expand Down Expand Up @@ -617,6 +649,8 @@ nexthop_group_impl_t::operator<(nexthop_group_impl_t const & other) const {
return autosize_ < other.autosize_;
} else if(nexthops_ != other.nexthops_) {
return nexthops_ < other.nexthops_;
} else if(backup_nexthops_ != other.backup_nexthops_) {
return backup_nexthops_ < other.backup_nexthops_;
} else if(destination_ips_ != other.destination_ips_) {
return destination_ips_ < other.destination_ips_;
} else if(counters_unshared_ != other.counters_unshared_) {
Expand Down Expand Up @@ -652,6 +686,11 @@ nexthop_group_impl_t::mix_me(hash_mix & h) const {
h.mix(it->first); // uint16_t
h.mix(it->second); // nexthop_group_entry_t
}
for (auto it=backup_nexthops_.cbegin();
it!=backup_nexthops_.cend(); ++it) {
h.mix(it->first); // uint16_t
h.mix(it->second); // nexthop_group_entry_t
}
for (auto it=destination_ips_.cbegin();
it!=destination_ips_.cend(); ++it) {
h.mix(it->first); // uint16_t
Expand Down Expand Up @@ -686,6 +725,18 @@ nexthop_group_impl_t::to_string() const {
}
}
ss << "'";
ss << ", backup_nexthops=" <<"'";
bool first_backup_nexthops = true;
for (auto it=backup_nexthops_.cbegin();
it!=backup_nexthops_.cend(); ++it) {
if (first_backup_nexthops) {
ss << it->first << "=" << it->second;
first_backup_nexthops = false;
} else {
ss << "," << it->first << "=" << it->second;
}
}
ss << "'";
ss << ", destination_ips=" <<"'";
bool first_destination_ips = true;
for (auto it=destination_ips_.cbegin();
Expand Down
Loading

0 comments on commit d96aad1

Please sign in to comment.