Skip to content

Commit ca8f301

Browse files
Add the Shadow + Span documentation
Signed-off-by: francescomessina <francescomessina92@hotmail.com>
1 parent 66fb5d7 commit ca8f301

3 files changed

Lines changed: 60 additions & 3 deletions

File tree

Documentation/cubes.rst

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A standard cube:
2525
| +----------+ |
2626
port1---|-| |-|---port3
2727
| | core | |
28-
port2---|-| |-|---port3
28+
port2---|-| |-|---port4
2929
| +----------+ |
3030
| |
3131
+--------------+
@@ -71,6 +71,44 @@ Following is example topology composed by standard and transparent cubes.
7171

7272
``polycubectl ?`` shows available cubes installed on your system.
7373

74+
75+
A shadow cube:
76+
Only a standard cube can be **Shadow** type;
77+
- ``polycubectl <cubetype> add <cubename> shadow=true``.
78+
79+
A shadow cube is associated with a Linux network namespace;
80+
81+
The parameters between the shadow cube and the namespace are aligned;
82+
83+
A port defined on a shadow cube is also visible from the network namespace:
84+
- the user can decide to configure the ports using Linux (e.g. ifconfig or the ip command) or polycubectl;
85+
86+
for example: "``polycubectl <cubename> ports <PortName> set ip=<IpAddress>``" it is the same as "``ip netns exec pcn-<cubename> ifconfig <PortName> <IpAddress>``".
87+
- the developer can let Linux handle some traffic by sending it to the namespace (e.g. ARP, ICMP, but in general all those protocols able to be managed by a tool running inside the namespace);
88+
89+
::
90+
91+
+--------------+
92+
port1---| |---port3
93+
| namespace |
94+
port2---| |---port4
95+
Linux +--------------+
96+
____________________________________________________________
97+
98+
::
99+
100+
Polycube shadow cube
101+
+--------------+
102+
| |
103+
| +----------+ |
104+
port1---|-| |-|---port3
105+
| | core | |
106+
port2---|-| |-|---port4
107+
| +----------+ |
108+
| |
109+
+--------------+
110+
111+
74112
Cubes structure
75113
---------------
76114

@@ -177,3 +215,19 @@ These primitives allow to associate transparent cubes to standard cube's ports o
177215
polycubectl attach firewall1 r1:port2
178216

179217
polycubectl attach firewall0 veth1
218+
219+
220+
Span Mode
221+
---------
222+
223+
The shadow cubes have a mode called **span**.
224+
225+
The span mode when activated shows all the traffic seen by the service also to the namespace.
226+
- To activate the span mode the command used is "``polycubectl <cubename> set span=true``".
227+
228+
Span mode is very useful for debugging; On a shadow cube in span mode programs such as Wireshark or Tcpdump can sniff the traffic.
229+
230+
However, the span mode consumes many resources when it is active, so it is disabled by default and it is recommended to use it only when necessary.
231+
232+
N.B. Span mode duplicates traffic so that it is shown by the namespace, the cube continues to handle traffic.
233+
For this reason, for example, if we have a shadow router with active span mode we should not have Ip forwarding active on Linux, otherwise the router service forwards packets and copies them to the namespace, the namespace forwards again packets and there will be duplications.

Documentation/developers/controlplane.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ Generating PacketOut events
9595

9696
The ``Port`` class contains the ``send_packet_out(EthernetII &packet, bool recirculate = false)`` method that allows to inject packets into the datapath, the recirculate parameter allows to specify if the packet should be sent out of the port (`recirculate = false`) or received through the port (`recirculate = true`).
9797

98+
Only in shadow services the ``Port`` class contains the ``send_packet_ns(EthernetII &packet)`` method that allows to send packets into the service namespace.
99+
98100
A reference to a port can be got using the `get_port` function of the Cube base class.
99101

100102
Debugging and logging in the control plane
@@ -106,4 +108,4 @@ Usage example:
106108

107109
::
108110

109-
logger()->info("Connected port {0}", port_name);
111+
logger()->info("Connected port {0}", port_name);

Documentation/developers/datapath.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Polycube architecture adds a wrapper around the user's code, this wrapper calls
2222

2323
- **pcn_pkt_controller_with_metadata(struct __sk_buff *skb, struct pkt_metadata *md, u16 reason, u32 metadata[3])**: Sends the packet to the custom code running in the control path. In addition to the reason the user can also send some additional medatada.
2424

25+
- **pcn_pkt_redirect_ns(struct __sk_buff *skb, struct pkt_metadata *md, u16 port)**: (it is only available for shadow services) sends the packet to the namespace as if it came from the port indicated as parameter
26+
2527
Checksum calculation
2628
********************
2729

@@ -107,4 +109,3 @@ Usage example:
107109
::
108110

109111
pcn_pkt_log(ctx, LOG_DEBUG);
110-

0 commit comments

Comments
 (0)