diff --git a/Documentation/services/index.rst b/Documentation/services/index.rst index 78ba19f08..f04a1c3f1 100644 --- a/Documentation/services/index.rst +++ b/Documentation/services/index.rst @@ -7,6 +7,7 @@ This folder contains the list of services (a.k.a. *cubes*) currently available i :maxdepth: 2 pcn-helloworld/helloworld + pcn-transparenthelloworld/transparenthelloworld pcn-simplebridge/simplebridge pcn-bridge/bridge pcn-simpleforwarder/simpleforwarder diff --git a/Documentation/services/pcn-helloworld/helloworld.rst b/Documentation/services/pcn-helloworld/helloworld.rst index cc196b596..fda82ecb6 100755 --- a/Documentation/services/pcn-helloworld/helloworld.rst +++ b/Documentation/services/pcn-helloworld/helloworld.rst @@ -1,10 +1,6 @@ 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 the dataplane `fast path`, the `slow path`, running in user-space, and the control/management portions (e.g., to configure the service). - Helloworld is a simple service that receives the traffic on a network interface and can either: - send packets to a second interface @@ -13,13 +9,16 @@ Helloworld is a simple service that receives the traffic on a network interface The behavior of this service can be changed by setting the ``action`` flag, which tells the data plane how the packets have to be processed. +This service demonstrates how to create a minimal cube, which includes the dataplane `fast path`, the `slow path`, running in user-space, and the control/management portions (e.g., to configure the service). + How to use ---------- :: - # create network namespaces - # DO IT YOURSELF + # create network namespaces with usual commands + # we assume you have two interfaces (veth1 and veth2 already working here) + # PLEASE DO IT YOURSELF # create the instance polycubectl helloworld add hw0 @@ -33,7 +32,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 +48,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 + + 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/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/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 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"