Skip to content

Commit ac19182

Browse files
authored
Merge pull request #236 from DavideAG/packetcapture_service
Documentation updated; fixed IP parsing in pbforwarder
2 parents 0951ca4 + ce82ecf commit ac19182

9 files changed

Lines changed: 18 additions & 13 deletions

File tree

Documentation/components/k8s/pcn-kubernetes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ In case you hit any problems, please follow the next steps to recover from a fai
269269
kubectl -n kube-system scale --replicas=1 deployment/kube-dns
270270
271271
Inspect cube status inside pcn-k8s
272-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
272+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
273273
``pcn-k8s`` is deployed as container in each node, sometimes it is helpful to inspect the cube(s) status
274274
within the container for debugging or other purposes. You can login into each node where the pcn-k8s container
275275
is running and get the information via :doc:`polycubectl<../../quickstart#docker>` command locally.
@@ -324,6 +324,6 @@ Developing
324324
Refer to :doc:`Developers <developers>`
325325

326326
Compatibility
327-
----------
327+
-------------
328328

329329
Pcn-k8s is compatible with all versions equal or greater than 1.9, although we recommend the latest version of Kubernetes.

Documentation/services/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ This folder contains the list of services (a.k.a. *cubes*) currently available i
2222
pcn-simplebridge/simplebridge
2323
pcn-simpleforwarder/simpleforwarder
2424
pcn-synflood/synflood
25+
pcn-packetcapture/packetcapture

Documentation/services/pcn-bridge/example1/example1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Example 1 - Connectivity
2-
=========
2+
========================
33

44
In this example two network namespaces will be connected together by a bridge instance.
55

Documentation/services/pcn-bridge/example2/example2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Example 2 - VLAN
2-
=========
2+
=================
33

44
In this example we will test the VLAN support.
55
We will configure two bridges, and four network namespaces connected to them.

Documentation/services/pcn-bridge/example3/example3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Example 3 - Spanning Tree
2-
=========
2+
=========================
33

44
In this example we will test the Spanning Tree configuration.
55
We will have three bridges connected each other in a triangle.

Documentation/services/pcn-packetcapture/Packetcapture.rst renamed to Documentation/services/pcn-packetcapture/packetcapture.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Attach to a cube port
5151

5252
Now the packetcapture service is attached to the port *toveth1* of the bridge *br1*
5353

54-
+----------+
55-
veth1 ---**x**-| br1 |------ veth2
56-
+----------+
54+
55+
veth1 ---**x**- | br1 | ------ veth2
56+
5757

5858

5959
Filters

Documentation/services/pcn-pbforwarder/pbforwarder.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Supported features:
1515
- IPv4 source/destination
1616
- L4 protocol (TCP/UDP)
1717
- L4 source/destination port
18+
1819
- Possible actions:
1920
- Forward packet on a given output port
2021
- Send packet to slow path

src/services/pcn-packetcapture/src/Packetcapture.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,13 @@ void Packetcapture::writeDump(const std::vector<uint8_t> &packet){
131131
if (folder == 0){
132132
folder = getenv("TEMPDIR");
133133
if (folder == 0){
134-
folder = "/tmp/";
134+
folder = "/tmp";
135135
}
136136
}
137137
}
138138
}
139139
temp_folder = std::string(folder);
140+
temp_folder.append("/");
140141
random_number = std::to_string(rand()%1000); //to avoid two files that using the same name
141142
}
142143

src/services/pcn-pbforwarder/src/Pbforwarder_dp_parsing.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,18 @@ static __always_inline int handle_rx(struct CTXTYPE *ctx,
9090
pkt->srcIp = ip->saddr;
9191
pkt->dstIp = ip->daddr;
9292
#if LEVEL == 4
93+
uint8_t header_len = 4 * ip->ihl;
9394
if (ip->protocol == IPPROTO_TCP) {
94-
tcp = data + sizeof(*ethernet) + sizeof(*ip);
95-
if (data + sizeof(*ethernet) + sizeof(*ip) + sizeof(*tcp) > data_end)
95+
tcp = data + sizeof(*ethernet) + header_len;
96+
if (data + sizeof(*ethernet) + header_len + sizeof(*tcp) > data_end)
9697
return RX_DROP;
9798
pkt->l4proto = IPPROTO_TCP;
9899
pkt->srcPort = tcp->source;
99100
pkt->dstPort = tcp->dest;
100101
} else if (ip->protocol == IPPROTO_UDP) {
101-
udp = data + sizeof(*ethernet) + sizeof(*ip);
102-
if (data + sizeof(*ethernet) + sizeof(*ip) + sizeof(*udp) > data_end)
102+
uint8_t header_len = 4 * ip->ihl; //we have to redefine this to avoid errors
103+
udp = data + sizeof(*ethernet) + header_len;
104+
if (data + sizeof(*ethernet) + header_len + sizeof(*udp) > data_end)
103105
return RX_DROP;
104106
pkt->l4proto = IPPROTO_UDP;
105107
pkt->srcPort = udp->source;

0 commit comments

Comments
 (0)