Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,30 @@ jobs:
exit 1
fi
echo "Tag is $TAG"
echo "::set-output name=tag::$TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image to registry
- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
load: true
tags: p4lang/pi:${{ steps.get-tag.outputs.tag }}
cache-from: type=gha
# A cache write must not fail the build.
cache-to: type=gha,mode=max,ignore-error=true
- name: Smoke test Docker image
run: |
docker run --rm p4lang/pi:${{ steps.get-tag.outputs.tag }} pi_convert_p4info -h
- name: Push Docker image to registry
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: p4lang/pi:${{ steps.get-tag.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ jobs:
include:
- cxx: g++
cc: gcc
- cxx: clang++-8
cc: clang-8
- cxx: clang++-10
cc: clang-10
- cxx: clang++
cc: clang
steps:
- uses: actions/checkout@v7
with:
Expand All @@ -54,7 +52,7 @@ jobs:
run: |
docker run -w /PI pi bash -c \
'apt-get update && apt-get install -y python3-pip && \
python3 -m pip install ptf scapy grpcio googleapis-common-protos protobuf==3.20 && \
python3 -m pip install --break-system-packages ptf scapy grpcio googleapis-common-protos protobuf==3.20 && \
python3 ./proto/ptf/base_test.py'
- name: Run tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ ENV PI_DEPS automake \
libboost-thread-dev \
libtool \
pkg-config
ENV PI_RUNTIME_DEPS libboost-system1.74.0 \
libboost-thread1.74.0 \
ENV PI_RUNTIME_DEPS libboost-system1.83.0 \
libboost-thread1.83.0 \
python3 \
python-is-python3

Expand Down
22 changes: 12 additions & 10 deletions Dockerfile.bmv2
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ ARG MAKEFLAGS=-j2
ARG IMAGE_TYPE=build

# Select the compiler to use.
# We install the default version of GCC (GCC 9), as well as clang 8 and clang 10.
# We install the default versions of GCC and clang.
ARG CC=gcc
ARG CXX=g++

ENV PI_DEPS automake \
build-essential \
clang-8 \
clang-10 \
clang-format-8 \
clang \
clang-format \
g++ \
libboost-dev \
libboost-system-dev \
Expand All @@ -54,8 +53,8 @@ ENV PI_DEPS automake \
libmicrohttpd-dev \
doxygen \
valgrind
ENV PI_RUNTIME_DEPS libboost-system1.71.0 \
libboost-thread1.71.0 \
ENV PI_RUNTIME_DEPS libboost-system1.83.0 \
libboost-thread1.83.0 \
libpcap0.8 \
python3 \
python-is-python3
Expand All @@ -70,13 +69,16 @@ RUN apt-get update && \
./proto/sysrepo/install_yangs.sh && \
make && \
make install-strip && \
(test "$IMAGE_TYPE" = "build" && \
if test "$IMAGE_TYPE" = "build"; then \
apt-get purge -y $PI_DEPS && \
apt-get autoremove --purge -y && \
rm -rf /PI /var/cache/apt/* /var/lib/apt/lists/* && \
echo 'Build image ready') || \
(test "$IMAGE_TYPE" = "test" && \
echo 'Test image ready')
echo 'Build image ready'; \
elif test "$IMAGE_TYPE" = "test"; then \
echo 'Test image ready'; \
else \
echo "Unknown IMAGE_TYPE: $IMAGE_TYPE" && exit 1; \
fi

# start sysrepo daemon (sysrepod)
ENTRYPOINT ["/docker_entry_point.sh"]
31 changes: 19 additions & 12 deletions proto/demo_grpc/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

namespace {

#if MHD_VERSION >= 0x00097002
using mhd_result = MHD_Result;
#else
using mhd_result = int;
#endif

struct connection_info_struct {
int connectiontype;
WebServer *web_server;
Expand Down Expand Up @@ -90,8 +96,8 @@ char *generate_page(WebServer *web_server,
return answerstring;
}

int send_page(struct MHD_Connection *connection, const char *page) {
int ret;
mhd_result send_page(struct MHD_Connection *connection, const char *page) {
mhd_result ret;
struct MHD_Response *response;
response = MHD_create_response_from_buffer(strlen(page), (void *)page,
MHD_RESPMEM_PERSISTENT);
Expand All @@ -101,10 +107,11 @@ int send_page(struct MHD_Connection *connection, const char *page) {
return ret;
}

int iterate_post(void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
const char *filename, const char *content_type,
const char *transfer_encoding, const char *data, uint64_t off,
size_t size) {
mhd_result iterate_post(void *coninfo_cls, enum MHD_ValueKind kind,
const char *key, const char *filename,
const char *content_type,
const char *transfer_encoding, const char *data,
uint64_t off, size_t size) {
connection_info_struct *con_info = static_cast<connection_info_struct *>(
coninfo_cls);
if (!strncmp(key, "counter_name", sizeof "counter_name")) {
Expand Down Expand Up @@ -145,8 +152,8 @@ void request_completed(void *cls, struct MHD_Connection *connection,
*con_cls = NULL;
}

int perform_requested_ops_and_respond(struct MHD_Connection *connection,
connection_info_struct *con_info) {
mhd_result perform_requested_ops_and_respond(
struct MHD_Connection *connection, connection_info_struct *con_info) {
WebServer *server = con_info->web_server;
if (con_info->new_json_name != "") {
std::string *p4info_buffer_ = nullptr;
Expand Down Expand Up @@ -177,10 +184,10 @@ int perform_requested_ops_and_respond(struct MHD_Connection *connection,
return send_page(connection, generate_page(con_info->web_server, con_info));
}

int answer_to_connection(void *cls, struct MHD_Connection *connection,
const char *url, const char *method,
const char *version, const char *upload_data,
size_t *upload_data_size, void **con_cls) {
mhd_result answer_to_connection(void *cls, struct MHD_Connection *connection,
const char *url, const char *method,
const char *version, const char *upload_data,
size_t *upload_data_size, void **con_cls) {
WebServer *server = static_cast<WebServer *>(cls);
if (!*con_cls) {
struct connection_info_struct *con_info;
Expand Down
Loading