From 98cd0c6f710ed831b2c8a773a7ca77867e4816c0 Mon Sep 17 00:00:00 2001 From: Fulvio Risso Date: Thu, 25 Jul 2019 14:08:04 +0200 Subject: [PATCH 1/3] Removed duplicated file --- .../datamodel/transparent-helloworld.yang | 38 ------------------- .../src/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 src/services/pcn-transparent-helloworld/datamodel/transparent-helloworld.yang diff --git a/src/services/pcn-transparent-helloworld/datamodel/transparent-helloworld.yang b/src/services/pcn-transparent-helloworld/datamodel/transparent-helloworld.yang deleted file mode 100644 index dcfe44158..000000000 --- a/src/services/pcn-transparent-helloworld/datamodel/transparent-helloworld.yang +++ /dev/null @@ -1,38 +0,0 @@ -module transparenthelloworld { - yang-version 1.1; - namespace "http://polycube.network/transparenthelloworld"; - prefix "transparenthelloworld"; - - import polycube-base { prefix "polycube-base"; } - import polycube-transparent-base { prefix "polycube-transparent-base"; } - - organization "Polycube open source project"; - description "YANG data model for the Polycube Transparent-Helloworld service"; - - polycube-base:service-description "Transparent-Helloworld Service"; - polycube-base:service-version "1.0"; - polycube-base:service-name "transparenthelloworld"; - polycube-base:service-min-kernel-version "4.14.0"; - - uses "polycube-transparent-base:transparent-base-yang-module"; - - leaf ingress-action { - type enumeration { - enum DROP; - enum PASS; - enum SLOWPATH; - } - default PASS; - description "Action performed on ingress packets"; - } - - leaf egress-action { - type enumeration { - enum DROP; - enum PASS; - enum SLOWPATH; - } - default PASS; - description "Action performed on egress packets"; - } -} diff --git a/src/services/pcn-transparent-helloworld/src/CMakeLists.txt b/src/services/pcn-transparent-helloworld/src/CMakeLists.txt index 4f63f64f3..ae80cced6 100644 --- a/src/services/pcn-transparent-helloworld/src/CMakeLists.txt +++ b/src/services/pcn-transparent-helloworld/src/CMakeLists.txt @@ -30,7 +30,7 @@ load_file_as_variable(pcn-transparenthelloworld # load datamodel in a variable load_file_as_variable(pcn-transparenthelloworld - ../datamodel/transparent-helloworld.yang transparenthelloworld_datamodel) + ../datamodel/transparenthelloworld.yang transparenthelloworld_datamodel) # Specify shared library install directory From 96d3a4c3eecdb1efa610f5acfa8cc3eb702bd787 Mon Sep 17 00:00:00 2001 From: Fulvio Risso Date: Thu, 25 Jul 2019 14:18:06 +0200 Subject: [PATCH 2/3] Updated service with a shorter name and added usage example Signed-off-by: Fulvio Risso --- .../datamodel/transparenthelloworld.yang | 12 +++++++----- .../src/Transparenthelloworld-lib.cpp | 2 +- .../src/api/TransparenthelloworldApi.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/services/pcn-transparent-helloworld/datamodel/transparenthelloworld.yang b/src/services/pcn-transparent-helloworld/datamodel/transparenthelloworld.yang index dcfe44158..2ff8adeb8 100644 --- a/src/services/pcn-transparent-helloworld/datamodel/transparenthelloworld.yang +++ b/src/services/pcn-transparent-helloworld/datamodel/transparenthelloworld.yang @@ -1,17 +1,17 @@ module transparenthelloworld { yang-version 1.1; - namespace "http://polycube.network/transparenthelloworld"; - prefix "transparenthelloworld"; + namespace "http://polycube.network/trhelloworld"; + prefix "trhelloworld"; import polycube-base { prefix "polycube-base"; } import polycube-transparent-base { prefix "polycube-transparent-base"; } organization "Polycube open source project"; - description "YANG data model for the Polycube Transparent-Helloworld service"; + description "YANG data model for the Polycube Transparent Helloworld service"; - polycube-base:service-description "Transparent-Helloworld Service"; + polycube-base:service-description "Transparent Helloworld Service"; polycube-base:service-version "1.0"; - polycube-base:service-name "transparenthelloworld"; + polycube-base:service-name "trhelloworld"; polycube-base:service-min-kernel-version "4.14.0"; uses "polycube-transparent-base:transparent-base-yang-module"; @@ -24,6 +24,7 @@ module transparenthelloworld { } default PASS; description "Action performed on ingress packets"; + polycube-base:cli-example "DROP/PASS/SLOWPATH (default: PASS)"; } leaf egress-action { @@ -34,5 +35,6 @@ module transparenthelloworld { } default PASS; description "Action performed on egress packets"; + polycube-base:cli-example "DROP/PASS/SLOWPATH (default: PASS)"; } } diff --git a/src/services/pcn-transparent-helloworld/src/Transparenthelloworld-lib.cpp b/src/services/pcn-transparent-helloworld/src/Transparenthelloworld-lib.cpp index 87dd9ca9d..a938d3c96 100644 --- a/src/services/pcn-transparent-helloworld/src/Transparenthelloworld-lib.cpp +++ b/src/services/pcn-transparent-helloworld/src/Transparenthelloworld-lib.cpp @@ -13,7 +13,7 @@ /* Do not edit this file manually */ #include "api/TransparenthelloworldApiImpl.h" -#include "../datamodel/transparent-helloworld.h" // generated from datamodel +#include "../datamodel/transparenthelloworld.h" // generated from datamodel #define SERVICE_PYANG_GIT "" #define SERVICE_SWAGGER_CODEGEN_GIT "implement_help_in_framework/be2c60c" diff --git a/src/services/pcn-transparent-helloworld/src/api/TransparenthelloworldApi.h b/src/services/pcn-transparent-helloworld/src/api/TransparenthelloworldApi.h index 5cc562675..5d2a1d273 100644 --- a/src/services/pcn-transparent-helloworld/src/api/TransparenthelloworldApi.h +++ b/src/services/pcn-transparent-helloworld/src/api/TransparenthelloworldApi.h @@ -19,7 +19,7 @@ #pragma once -#define POLYCUBE_SERVICE_NAME "transparenthelloworld" +#define POLYCUBE_SERVICE_NAME "trhelloworld" #include "polycube/services/response.h" From b8eff81a754054666da873c045a2ec5c9c7e727d Mon Sep 17 00:00:00 2001 From: Fulvio Risso Date: Thu, 25 Jul 2019 14:16:37 +0200 Subject: [PATCH 3/3] Added documentation for Transparent HelloWorld Signed-off-by: Fulvio Risso --- Documentation/services/index.rst | 1 + .../services/pcn-helloworld/helloworld.rst | 13 ++--- .../transparenthelloworld.rst | 50 +++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100755 Documentation/services/pcn-transparenthelloworld/transparenthelloworld.rst diff --git a/Documentation/services/index.rst b/Documentation/services/index.rst index d63dbd75b..13205b7de 100644 --- a/Documentation/services/index.rst +++ b/Documentation/services/index.rst @@ -11,6 +11,7 @@ This folder contains the list of services (a.k.a. *cubes*) currently available i pcn-ddosmitigator/ddosmitigator pcn-firewall/firewall pcn-helloworld/helloworld + pcn-transparenthelloworld/transparenthelloworld pcn-iptables/iptables pcn-k8sfilter/k8sfilter pcn-k8switch/k8switch diff --git a/Documentation/services/pcn-helloworld/helloworld.rst b/Documentation/services/pcn-helloworld/helloworld.rst index d8a84aa42..03978d23e 100755 --- a/Documentation/services/pcn-helloworld/helloworld.rst +++ b/Documentation/services/pcn-helloworld/helloworld.rst @@ -1,9 +1,7 @@ Helloworld ========== -**Note**: documentation of the current release is focused on the final user and not in developers. This service is intended to be used only by developers, so this documentation could be incomplete and have some inacuracies. - -This service demonstrates how to create a minimal cube, which includes both the dataplane `fast path` and the control/management `slow path` parts +This service is oriented to demonstrate to developers how to create a minimal cube, which includes both the dataplane `fast path` and the control/management `slow path`. Helloworld is a simple service that receives the traffic on a network interface and can either: @@ -18,8 +16,10 @@ How to use :: - # create network namespaces - # TODO. + # create network namespaces with usual commands + # we assume you have two interfaces (veth1 + # and veth2 already working here) + # create the instance polycubectl helloworld add hw0 @@ -33,7 +33,7 @@ How to use # send packets to the service - # try another actions, forward, slowpath + # try another action, such as forward polycubectl hw0 set action=forward @@ -49,6 +49,7 @@ Helloworld includes the minimum amount of code that a service requires to be run - **src/helloworld-lib.cpp** contains the implementation of interface that is used when the service is compiled as a shared library. - **datamodel/helloworld.yang** contains the service datamodel. + Compile and install ------------------- diff --git a/Documentation/services/pcn-transparenthelloworld/transparenthelloworld.rst b/Documentation/services/pcn-transparenthelloworld/transparenthelloworld.rst new file mode 100755 index 000000000..65ee34ba1 --- /dev/null +++ b/Documentation/services/pcn-transparenthelloworld/transparenthelloworld.rst @@ -0,0 +1,50 @@ +Transparent Helloworld +====================== + +This service is oriented to demonstrate to developers how to create a minimal transparent cube, which includes both the dataplane `fast path` and the control/management `slow path`. + +The behaviour of this service is very similar as :doc:`Helloworld `; however, it attaches to an existing interface (in fact, it is *transparent*) instead of having its own set of interfaces. +From the developer point of view, it inherits from the ``polycube-transparent-base`` datamodel instead of ``polycube-standard-base``. + +Transparent Helloworld is a simple service that receives the traffic on a network interface and can either: + +- allow packets to pass +- send packets to the slow path +- drop packets + +The behavior of this service can be changed by setting the ``ingress-action`` and ``egress-action`` flags, which tell the data plane how packets have to be processed. +In fact, this service can distinguish between *ingress* (i.e., from the network device up to the TCP/IP stack) or *egress* (vice versa) packets, enabling to set different actions for them. + + +How to use +---------- + +:: + + # we assume a physical interface named 'eth0' + # is available in the system + + # create a transparent hello world + polycubectl transparenthelloworld add thw0 + + # attach to eth0 + polycubectl attach thw0 eth0 + + # you can ping the Internet from your host + # e.g., ping 8.8.8.8 + # and see that the ping works properly + + # now let's change action in the ingress-path + polycubectl thw0 set ingress-action=slowpath + + # now you can see that the ping does no longer work + # + # in exchange, polycubed prints a log message each + # time it receives a new packet in the slow path + + # restore 'pass' behavior + polycubectl thw0 set ingress-action=pass + + # now the 'ping' works again + +