Skip to content

Commit e2c788a

Browse files
authored
Doc fixes (#247)
* Fixed command syntax. * Updated NAT documentation * Integrated missing files in the online documentation Signed-off-by: Fulvio Risso <fulvio.risso@polito.it>
1 parent b0f900d commit e2c788a

6 files changed

Lines changed: 88 additions & 68 deletions

File tree

Documentation/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
**The polycube documentation is available on [ReadTheDocs](https://polycube-network.readthedocs.io/en/latest/).**
44

5-
The instructions below are intended if you want to generate the documentation locally.
5+
The instructions below are intended only if you want to generate the documentation locally.
66

77
## Building the documentation locally
88

99
### Installing the dependencies
1010

1111
Our documentation uses `sphinx`.
12-
In order to install the dependencies do
12+
In order to install the dependencies type:
1313

1414
```
1515
cd Documentation
16-
pip install -r Documentation/requirements.txt
16+
pip install -r requirements.txt
1717
```
1818

1919
### Build it

Documentation/architecture.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
Polycube Architecture
22
=====================
33

4-
**NOTE: this file is outdated**
5-
6-
Polycube is a framework to **create** and **deploy** arbitrary virtual network functions, such as bridges, routers, NATs, firewalls and more, and enables the creation of complex **service chains** by connecting together the above modules.
7-
8-
It is based on the eBPF technology available in the Linux kernel and leverages some companion tools developed in the Iovisor community, such as [BCC](https://github.com/iovisor/bcc/).
9-
104
The Polycube architecture is depicted below:
115

126
.. image:: images/architecture_overview.png
@@ -32,6 +26,7 @@ Each network function is implemented as a separated module and multiple flavors
3226
Each service implementation includes the `datapath`, namely the eBPF code to be injected in the kernel, the `control/management plane`, which defines the primitives that allow to configure the service behavior, and the `slow path`, which handles packets that cannot be fully processed in the kernel. While the former code runs in the Linux kernel, the latter components are executed in user-space.
3327
Given the feature-rich nature of the eBPF, the slow path should be rather small; an example can be the implementation of the spanning tree for 802.1Q bridges, which does not make sense to have in the kernel and that can stay in user space.
3428

29+
3530
Polycubectl
3631
-----------
3732
This module implements the service-agnostic command-line interface (CLI) that allows to control the entire system, such as starting/stopping services, creating service instances (e.g., bridges `br1` and `br2`), and configuring / querying the internals of each single service (e.g., enabling the spanning tree on bridge `br1`).

Documentation/developers/index.rst

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ Polycube Developers Guide
33

44
This guide represents an initial starting point for developers that want to implement new services (e.g., custom NAT, router, etc) using the Polycube software infrastructure.
55

6+
7+
.. toctree::
8+
:maxdepth: 2
9+
:caption: Contents:
10+
11+
datapath
12+
controlplane
13+
datamodel
14+
codegen
15+
debugging
16+
profiler
17+
hints
18+
19+
20+
621
How to create a new service / update an existing one
722
----------------------------------------------------
823

@@ -16,21 +31,3 @@ The process to create or update service could be summarized in these steps:
1631
Please note that steps (1) and (2) are needed only when there is a change to the the YANG data model.
1732
In case we have to slightly modify an existing service (e.g., fixing a bug in the code), only steps (3) and (4) are required.
1833

19-
20-
Debugging Polycube services
21-
---------------------------
22-
:doc:`See how to use the provided logging primitives <debugging>`
23-
24-
25-
How to benchmark code execution
26-
-------------------------------
27-
28-
To measure time taken by functions, instructions or a whole service, an internal easy to use profiling framework can be used.
29-
30-
Please follow the instructions in the guide :doc:`Profiling Polycube Framework <profiler>`.
31-
32-
33-
Some hints for programmers
34-
--------------------------
35-
36-
:doc:`hints for programmers <hints>`

Documentation/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Welcome to Polycube's documentation!
1313
intro
1414
quickstart
1515
installation
16+
architecture
1617
cubes
1718
polycubed/polycubed
1819
polycubectl/polycubectl

Documentation/installation.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Installing Polycube
22
===================
33

4-
This installation guide includes instructions to install polycube on ``Ubuntu 18.04``, however with few changes those should also work on other versions and distributions.
4+
This installation guide includes instructions to install Polycube on ``Ubuntu 18.04``.
5+
However those should also work on other versions and distributions with a few changes.
56

67
Dependencies
78
------------
89

9-
``polycube`` requires following dependencies:
10-
11-
- At least **Linux kernel v4.15** that includes a set of the eBPF features which are needed by polycube
12-
- **pistache**: a library to build rest API servers
13-
- **libints**: a library for crafting packets (needed only for some services)
14-
- **Go language**: required to run ``polycubectl`` (polycube command line interface)
10+
Polycube requires following dependencies:
11+
- At least **Linux kernel v4.15** that includes a set of the eBPF features which are needed by polycube
12+
- **pistache**: a library to build rest API servers
13+
- **libints**: a library for crafting packets (needed only for some services)
14+
- **Go language**: required to run ``polycubectl`` (polycube command line interface)
1515

1616
Following sections will detail the installation process for the above components.
1717

@@ -31,8 +31,8 @@ Use ``uname -a`` to check the kernel version you are running, if this is ``<v4.1
3131
sudo dpkg -i *.deb
3232
sudo reboot
3333

34-
Automatic installation
35-
----------------------
34+
Automatic installation from source files
35+
----------------------------------------
3636

3737
If you are running ``Ubuntu 18.04`` and you do not want to manually install polycube and its dependencies, you can use the install script available under the `scripts` folder.
3838
This is not guaranteed that the script works on versions or distributions other than ``Ubuntu 18.04``.
@@ -62,8 +62,9 @@ In this case, remove llvm 6.0 before starting the installation script:
6262
::
6363
sudo apt remove llvm-6.0 llvm-6.0-dev llvm-6.0-runtime
6464

65-
Installing from source
66-
----------------------
65+
66+
Manual installation from source files
67+
-------------------------------------
6768

6869
Install GO
6970
^^^^^^^^^^

Documentation/services/pcn-nat/nat.rst

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ Limitations
1515
-----------
1616

1717
- Unsupported IPv6
18-
- Unsupported ARP: the ARP messages will be forwarded without processing them
18+
- Unsupported ARP: ARP messages are forwarded without any processing
1919
- Incremental external port choice, starting from 1024 each time 65535 is reached
2020

2121
How to use
2222
----------
2323

24-
The nat is a transparent service, it can be attached to a cube port or to a netdev.
25-
The nat is intended to be used with a router, it could not work when attached to different services.
24+
The NAT is a transparent service, it can be attached to a cube port or to a netdev.
25+
The NAT is intended to be used with a router, it may not work when attached to different services.
2626

2727
Attached to a router
2828
^^^^^^^^^^^^^^^^^^^^
2929

30-
When a nat instance is attached to a router the external IP is automatically configured.
30+
When a NAT instance is attached to a router, the external IP is automatically configured.
3131

3232
::
3333

@@ -53,31 +53,41 @@ Attached to a netdev
5353
# TODO: there is not an API for it!
5454

5555

56-
Rules
57-
-----
56+
Working modes
57+
-------------
5858

59-
Adding rules
60-
^^^^^^^^^^^^
6159

6260
Source NAT
63-
**********
61+
^^^^^^^^^^
62+
63+
Source NAT selects a given range of hosts (i.e., the ```internal-net```) to be translated with a given public IP address (i.e., the ```external-ip```).
64+
Each time a new session originated from the internal network is recognized, the NAT creates a new binding also for return packets.
6465

65-
Available and mandatory fields for SNAT rules are
66-
- ```internal-net```: the internal network to translate (e.g 10.0.0.0/24, 10.0.0.1/32)
67-
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
66+
Source NAT enables users to specify exactly the range of addresses belonging to the ```internal-net```, e.g., excluding some hosts from being natted. In addition, it specifies exactly the external IP that has to be used, e.g., in case multiple external IP addresses are available.
67+
68+
Available and mandatory fields for SNAT rules are:
69+
- ```internal-net```: the internal network to translate (e.g 10.0.0.0/24, 10.0.0.1/32)
70+
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
6871

6972
Sample rule:
7073

7174
::
7275

7376
polycubectl nat1 rule snat append internal-net=10.0.0.0/24 external-ip=1.2.3.4
7477

78+
7579
Masquerade
76-
**********
80+
^^^^^^^^^^
7781

78-
Masquerade can be either enabled or disabled.
82+
NAT masquerading is a simpler form of source NAT: it automatically translates the traffic of all hosts coming from the internal network with the IP address currently present on the external interface.
83+
Hence, it requires a simpler configuration that is usually enough for most cases.
84+
85+
Unlike ```iptables``` in Linux, NAT masquerading in Polycube does not add extra overhead compared to SNAT.
86+
In fact, the ```external-ip``` address is kept in a dedicated table in the data plane and it is automatically updated each time the actual IP address configured on the external virtual interface is changed.
87+
This avoid to check which IP address has to be used each time a new packet is received.
7988

80-
When enabled, the source IP address of the packet is set to the external IP of the NAT, and a new source port is assigned.
89+
Masquerade can be either enabled or disabled.
90+
When enabled, the source IP address of outgoing packets is set to the external IP of the NAT, and a new source port is assigned.
8191

8292
To enable masquerade:
8393

@@ -91,12 +101,19 @@ To disable masquerade:
91101

92102
polycubectl nat1 rule masquerade disable
93103

104+
94105
Destination NAT
95-
***************
106+
^^^^^^^^^^^^^^^
96107

97-
Available and mandatory fields for DNAT rules are
98-
- ```internal-ip```: the internal IP address (e.g 10.0.0.1)
99-
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
108+
Destination NAT adds a new translation rule for traffic coming from the external network directed to the internal network. It implements what is also called `static` NAT in other contexts.
109+
This features allows external traffic to be forwarded to the internal network without having a corresponding session already established from inside.
110+
111+
The destination NAT forwards all the traffic coming to a specific ```external-ip``` to a given ```internal-ip```, without inspecting other packet fields such as TCP/UDP ports, or protocols (e.g., ICMP).
112+
Obviously, this option requires a dedicated ```external-ip``` for each mapping.
113+
114+
Available and mandatory fields for DNAT rules are:
115+
- ```internal-ip```: the internal IP address (e.g 10.0.0.1)
116+
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
100117

101118
Sample rule:
102119

@@ -106,15 +123,18 @@ Sample rule:
106123

107124
All the packets directed to ```1.2.3.4``` will be sent to ```10.0.0.1```, so use this rule carefully.
108125

126+
109127
Port Forwarding
110-
***************
128+
^^^^^^^^^^^^^^^
129+
130+
Port forwarding implements a more selective form of destination NAT, allowing to specify the exact binding by means of other parameters such as the destination TCP/UDP port. This enables the sharing of the same ```external-ip``` among many ```internal-ip``` hosts, provided that their traffic can be differentiated e.g., by means of other parameters such as the ```external-port``` in use.
111131

112-
Available and mandatory fields for Port Forwarding rules are
113-
- ```internal-ip```: the internal IP address (e.g 10.0.0.1)
114-
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
115-
- ```internal-port```: the internal port number (e.g 8080)
116-
- ```external-port```: the external port number (e.g. 80)
117-
- ```proto```: the upper layer protocol (e.g. tcp, udp, all). This field is optional: if not specified, all protocols are considered
132+
Available and mandatory fields for Port Forwarding rules are:
133+
- ```internal-ip```: the internal IP address (e.g 10.0.0.1)
134+
- ```external-ip```: the external IP address (e.g. 1.2.3.4)
135+
- ```internal-port```: the internal port number (e.g 8080)
136+
- ```external-port```: the external port number (e.g. 80)
137+
- ```proto```: the upper layer protocol (e.g. tcp, udp, all). This field is optional: if not specified, all protocols are considered
118138

119139
Sample rule:
120140

@@ -127,6 +147,10 @@ Sample rule:
127147

128148
This type of rule is especially useful to make a server in the inside network reachable from the outside.
129149

150+
151+
Other NAT operations
152+
--------------------
153+
130154
Deleting rules
131155
^^^^^^^^^^^^^^
132156

@@ -152,6 +176,7 @@ To delete a single rule (an SNAT rule in the example):
152176

153177
Deleting a rule does not affect ongoing natting sessions: to prevent a deleted rule from being applied, `flush the natting table <Natting-table>`_.
154178

179+
155180
Showing rules
156181
^^^^^^^^^^^^^
157182

@@ -169,13 +194,14 @@ To display one type of rule (SNAT in the example):
169194

170195
polycubectl nat1 rule snat show
171196

197+
172198
Rule priority
173199
^^^^^^^^^^^^^
174200

175-
It is not possible to manually set a priority for each rule, but:
176-
- SNAT rules have higher priority than Masquerade
177-
- Port Forwarding rules have higher priority than DNAT rules
178-
- Port Forwarding rules with protocol have higher priority than Port Forwarding rules without protocol
201+
Explicit rule priorities are not supported; however:
202+
- SNAT rules have higher priority than Masquerade
203+
- Port Forwarding rules have higher priority than DNAT rules
204+
- Port Forwarding rules with protocol have higher priority than Port Forwarding rules without protocol
179205

180206
Natting table
181207
-------------

0 commit comments

Comments
 (0)