Skip to content

Commit

Permalink
Merge pull request #236 from DavideAG/packetcapture_service
Browse files Browse the repository at this point in the history
Documentation updated; fixed IP parsing in pbforwarder
  • Loading branch information
frisso committed Nov 17, 2019
2 parents 0951ca4 + ce82ecf commit ac19182
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Documentation/components/k8s/pcn-kubernetes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ In case you hit any problems, please follow the next steps to recover from a fai
kubectl -n kube-system scale --replicas=1 deployment/kube-dns
Inspect cube status inside pcn-k8s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
``pcn-k8s`` is deployed as container in each node, sometimes it is helpful to inspect the cube(s) status
within the container for debugging or other purposes. You can login into each node where the pcn-k8s container
is running and get the information via :doc:`polycubectl<../../quickstart#docker>` command locally.
Expand Down Expand Up @@ -324,6 +324,6 @@ Developing
Refer to :doc:`Developers <developers>`

Compatibility
----------
-------------

Pcn-k8s is compatible with all versions equal or greater than 1.9, although we recommend the latest version of Kubernetes.
1 change: 1 addition & 0 deletions Documentation/services/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ This folder contains the list of services (a.k.a. *cubes*) currently available i
pcn-simplebridge/simplebridge
pcn-simpleforwarder/simpleforwarder
pcn-synflood/synflood
pcn-packetcapture/packetcapture
2 changes: 1 addition & 1 deletion Documentation/services/pcn-bridge/example1/example1.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example 1 - Connectivity
=========
========================

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

Expand Down
2 changes: 1 addition & 1 deletion Documentation/services/pcn-bridge/example2/example2.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example 2 - VLAN
=========
=================

In this example we will test the VLAN support.
We will configure two bridges, and four network namespaces connected to them.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/services/pcn-bridge/example3/example3.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example 3 - Spanning Tree
=========
=========================

In this example we will test the Spanning Tree configuration.
We will have three bridges connected each other in a triangle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ Attach to a cube port

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

+----------+
veth1 ---**x**-| br1 |------ veth2
+----------+

veth1 ---**x**- | br1 | ------ veth2



Filters
Expand Down
1 change: 1 addition & 0 deletions Documentation/services/pcn-pbforwarder/pbforwarder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Supported features:
- IPv4 source/destination
- L4 protocol (TCP/UDP)
- L4 source/destination port

- Possible actions:
- Forward packet on a given output port
- Send packet to slow path
Expand Down
3 changes: 2 additions & 1 deletion src/services/pcn-packetcapture/src/Packetcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ void Packetcapture::writeDump(const std::vector<uint8_t> &packet){
if (folder == 0){
folder = getenv("TEMPDIR");
if (folder == 0){
folder = "/tmp/";
folder = "/tmp";
}
}
}
}
temp_folder = std::string(folder);
temp_folder.append("/");
random_number = std::to_string(rand()%1000); //to avoid two files that using the same name
}

Expand Down
10 changes: 6 additions & 4 deletions src/services/pcn-pbforwarder/src/Pbforwarder_dp_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ static __always_inline int handle_rx(struct CTXTYPE *ctx,
pkt->srcIp = ip->saddr;
pkt->dstIp = ip->daddr;
#if LEVEL == 4
uint8_t header_len = 4 * ip->ihl;
if (ip->protocol == IPPROTO_TCP) {
tcp = data + sizeof(*ethernet) + sizeof(*ip);
if (data + sizeof(*ethernet) + sizeof(*ip) + sizeof(*tcp) > data_end)
tcp = data + sizeof(*ethernet) + header_len;
if (data + sizeof(*ethernet) + header_len + sizeof(*tcp) > data_end)
return RX_DROP;
pkt->l4proto = IPPROTO_TCP;
pkt->srcPort = tcp->source;
pkt->dstPort = tcp->dest;
} else if (ip->protocol == IPPROTO_UDP) {
udp = data + sizeof(*ethernet) + sizeof(*ip);
if (data + sizeof(*ethernet) + sizeof(*ip) + sizeof(*udp) > data_end)
uint8_t header_len = 4 * ip->ihl; //we have to redefine this to avoid errors
udp = data + sizeof(*ethernet) + header_len;
if (data + sizeof(*ethernet) + header_len + sizeof(*udp) > data_end)
return RX_DROP;
pkt->l4proto = IPPROTO_UDP;
pkt->srcPort = udp->source;
Expand Down

0 comments on commit ac19182

Please sign in to comment.