From 46974b170ffeefc34655b2e0060172d7633f2d8e Mon Sep 17 00:00:00 2001 From: Bertrone Matteo Date: Thu, 18 Feb 2016 12:36:28 +0100 Subject: [PATCH] http_filter renamed, README fixed --- README.md | 1 + examples/networking/http_filter/README.md | 16 ++++++++-------- .../{http-parse-v2.c => http-parse-complete.c} | 0 .../{http-parse-v2.py => http-parse-complete.py} | 4 ++-- .../{http-parse.c => http-parse-simple.c} | 0 .../{http-parse.py => http-parse-simple.py} | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) rename examples/networking/http_filter/{http-parse-v2.c => http-parse-complete.c} (100%) rename examples/networking/http_filter/{http-parse-v2.py => http-parse-complete.py} (98%) rename examples/networking/http_filter/{http-parse.c => http-parse-simple.c} (100%) rename examples/networking/http_filter/{http-parse.py => http-parse-simple.py} (97%) diff --git a/README.md b/README.md index e333046004ef..957084b65a6c 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ Tools: Examples: - examples/networking/[distributed_bridge/](examples/networking/distributed_bridge): Distributed bridge example. +- examples/networking/[http_filter/](examples/networking/http_filter): Simple HTTP filter example. - examples/networking/[simple_tc.py](examples/networking/simple_tc.py): Simple traffic control example. - examples/networking/[simulation.py](examples/networking/simulation.py): Simulation helper. - examples/networking/neighbor_sharing/[tc_neighbor_sharing.py](examples/networking/neighbor_sharing/tc_neighbor_sharing.py) examples/networking/neighbor_sharing/[tc_neighbor_sharing.c](examples/networking/neighbor_sharing/tc_neighbor_sharing.c): Per-IP classification and rate limiting. diff --git a/examples/networking/http_filter/README.md b/examples/networking/http_filter/README.md index 40f19e642513..2150a9425873 100644 --- a/examples/networking/http_filter/README.md +++ b/examples/networking/http_filter/README.md @@ -1,13 +1,13 @@ -#Simple HTTP Filter: Project purpose +#HTTP Filter -Write an eBPF application that parses HTTP packets and extracts (and prints on screen) the URL contained in the GET/POST request. +eBPF application that parses HTTP packets and extracts (and prints on screen) the URL contained in the GET/POST request. [eBPF HTTP Filter - Short Presentation](https://github.com/iovisor/bpf-docs/blob/master/ebpf_http_filter.pdf) #Usage Example ```Shell -$ sudo python http-parse-v2.py +$ sudo python http-parse-complete.py GET /pipermail/iovisor-dev/ HTTP/1.1 HTTP/1.1 200 OK GET /favicon.ico HTTP/1.1 @@ -27,14 +27,14 @@ Matching packets are forwarded to user space, others dropped by the filter.
Python script reads filtered raw packets from the socket, if necessary reassembles packets belonging to the same session, and prints on stdout the first line of the HTTP GET/POST request.
-#v1 vs v2 +#simple vs complete -First version is the simple one: if the url is too long (splitted in more than one packet) is truncated.
-Second version is quite more complex: if necessary reassembles packets belonging to the same session and prints the complete url. +simple version: if the url is too long (splitted in more than one packet) is truncated.
+complete version: if necessary reassembles packets belonging to the same session and prints the complete url. #To run: ```Shell -$ sudo python http-parse.py -$ sudo python http-parse-v2.py +$ sudo python http-parse-simple.py +$ sudo python http-parse-complete.py ``` \ No newline at end of file diff --git a/examples/networking/http_filter/http-parse-v2.c b/examples/networking/http_filter/http-parse-complete.c similarity index 100% rename from examples/networking/http_filter/http-parse-v2.c rename to examples/networking/http_filter/http-parse-complete.c diff --git a/examples/networking/http_filter/http-parse-v2.py b/examples/networking/http_filter/http-parse-complete.py similarity index 98% rename from examples/networking/http_filter/http-parse-v2.py rename to examples/networking/http_filter/http-parse-complete.py index 5d3f75497b33..1d7788b3d97b 100644 --- a/examples/networking/http_filter/http-parse-v2.py +++ b/examples/networking/http_filter/http-parse-complete.py @@ -76,8 +76,8 @@ def cleanup(): #-----FUNCTIONS-END-------------------------# -# initialize BPF - load source code from http-parse.c -bpf = BPF(src_file = "http-parse-v2.c",debug = 0) +# initialize BPF - load source code from http-parse-complete.c +bpf = BPF(src_file = "http-parse-complete.c",debug = 0) #load eBPF program http_filter of type SOCKET_FILTER into the kernel eBPF vm #more info about eBPF program types diff --git a/examples/networking/http_filter/http-parse.c b/examples/networking/http_filter/http-parse-simple.c similarity index 100% rename from examples/networking/http_filter/http-parse.c rename to examples/networking/http_filter/http-parse-simple.c diff --git a/examples/networking/http_filter/http-parse.py b/examples/networking/http_filter/http-parse-simple.py similarity index 97% rename from examples/networking/http_filter/http-parse.py rename to examples/networking/http_filter/http-parse-simple.py index c1524b7da254..2d19d9dac27f 100644 --- a/examples/networking/http_filter/http-parse.py +++ b/examples/networking/http_filter/http-parse-simple.py @@ -19,8 +19,8 @@ import socket import os -# initialize BPF - load source code from http-parse.c -bpf = BPF(src_file = "http-parse.c",debug = 0) +# initialize BPF - load source code from http-parse-simple.c +bpf = BPF(src_file = "http-parse-simple.c",debug = 0) #load eBPF program http_filter of type SOCKET_FILTER into the kernel eBPF vm #more info about eBPF program types