Skip to content

Commit

Permalink
remove trailing white spaces from source code files
Browse files Browse the repository at this point in the history
Trailing white spaces cause problems with git.

Signed-off-by: Mauricio Vasquez B <[email protected]>
  • Loading branch information
mauriciovasquezbernal committed May 18, 2017
1 parent fc4d464 commit d1324ac
Show file tree
Hide file tree
Showing 34 changed files with 153 additions and 153 deletions.
2 changes: 1 addition & 1 deletion examples/cpp/FollyRequestContextSwitch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int on_context_switch(struct pt_regs *ctx) {
event.pid = bpf_get_current_pid_tgid();
bpf_get_current_comm(&event.name, sizeof(event.name));
bpf_usdt_readarg(1, ctx, &event.old_addr);
bpf_usdt_readarg(2, ctx, &event.new_addr);
Expand Down
2 changes: 1 addition & 1 deletion examples/lua/sock-parse-http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local prog = bpf.socket('lo', function (skb)
-- Fetch 4 bytes of TCP data and compare
local h = data(0, 4)
if h == 'HTTP' or h == 'GET ' or
h == 'POST' or h == 'PUT ' or
h == 'POST' or h == 'PUT ' or
h == 'HEAD' or h == 'DELE' then
-- If hash key doesn't exist, create it
-- otherwise increment counter
Expand Down
14 changes: 7 additions & 7 deletions examples/networking/http_filter/http-parse-complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
#include <net/sock.h>
#include <bcc/proto.h>

#define IP_TCP 6
#define IP_TCP 6
#define ETH_HLEN 14

struct Key {
u32 src_ip; //source ip
u32 dst_ip; //destination ip
unsigned short src_port; //source port
unsigned short dst_port; //destination port
unsigned short dst_port; //destination port
};

struct Leaf {
int timestamp; //timestamp in ns
};

//BPF_TABLE(map_type, key_type, leaf_type, table_name, num_entry)
//BPF_TABLE(map_type, key_type, leaf_type, table_name, num_entry)
//map <Key, Leaf>
//tracing sessions having same Key(dst_ip, src_ip, dst_port,src_port)
BPF_HASH(sessions, struct Key, struct Leaf, 1024);
Expand All @@ -40,7 +40,7 @@ int http_filter(struct __sk_buff *skb) {
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
//filter IP packets (ethernet type = 0x0800)
if (!(ethernet->type == 0x0800)) {
goto DROP;
goto DROP;
}

struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));
Expand Down Expand Up @@ -69,16 +69,16 @@ int http_filter(struct __sk_buff *skb) {
//value to multiply * 4
//e.g. ip->hlen = 5 ; IP Header Length = 5 x 4 byte = 20 byte
ip_header_length = ip->hlen << 2; //SHL 2 -> *4 multiply

//calculate tcp header length
//value to multiply *4
//e.g. tcp->offset = 5 ; TCP Header Length = 5 x 4 byte = 20 byte
tcp_header_length = tcp->offset << 2; //SHL 2 -> *4 multiply

//calculate patload offset and length
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length;
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length;
payload_length = ip->tlen - ip_header_length - tcp_header_length;

//http:https://stackoverflow.com/questions/25047905/http-request-minimum-size-in-bytes
//minimum length of http request is always geater than 7 bytes
//avoid invalid access memory
Expand Down
50 changes: 25 additions & 25 deletions examples/networking/http_filter/http-parse-complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#Bertrone Matteo - Polytechnic of Turin
#November 2015
#
#eBPF application that parses HTTP packets
#eBPF application that parses HTTP packets
#and extracts (and prints on screen) the URL contained in the GET/POST request.
#
#eBPF program http_filter is used as SOCKET_FILTER attached to eth0 interface.
Expand Down Expand Up @@ -38,7 +38,7 @@ def toHex(s):
if len(hv) == 1:
hv = '0'+hv
lst.append(hv)

return reduce(lambda x,y:x+y, lst)

#print str until CR+LF
Expand All @@ -50,7 +50,7 @@ def printUntilCRLF(str):
return
print ("%c" % (str[k]), end = "")
print("")
return
return

#cleanup function
def cleanup():
Expand All @@ -71,7 +71,7 @@ def cleanup():
del bpf_sessions[key]
except:
print("cleanup exception.")
return
return

#args
def usage():
Expand Down Expand Up @@ -155,9 +155,9 @@ def help():

#convert packet into bytearray
packet_bytearray = bytearray(packet_str)

#ethernet header length
ETH_HLEN = 14
ETH_HLEN = 14

#IP HEADER
#https://tools.ietf.org/html/rfc791
Expand All @@ -166,18 +166,18 @@ def help():
# |Version| IHL |Type of Service| Total Length |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
#IHL : Internet Header Length is the length of the internet header
#IHL : Internet Header Length is the length of the internet header
#value to multiply * 4 byte
#e.g. IHL = 5 ; IP Header Length = 5 * 4 byte = 20 byte
#
#Total length: This 16-bit field defines the entire packet size,
#Total length: This 16-bit field defines the entire packet size,
#including header and data, in bytes.

#calculate packet total length
total_length = packet_bytearray[ETH_HLEN + 2] #load MSB
total_length = total_length << 8 #shift MSB
total_length = total_length + packet_bytearray[ETH_HLEN+3] #add LSB

#calculate ip header length
ip_header_length = packet_bytearray[ETH_HLEN] #load Byte
ip_header_length = ip_header_length & 0x0F #mask bits 0..3
Expand All @@ -189,18 +189,18 @@ def help():

ip_src = int(toHex(ip_src_str),16)
ip_dst = int(toHex(ip_dst_str),16)
#TCP HEADER

#TCP HEADER
#https://www.rfc-editor.org/rfc/rfc793.txt
# 12 13 14 15
# 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
# 12 13 14 15
# 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | Data | |U|A|P|R|S|F| |
# | Offset| Reserved |R|C|S|S|Y|I| Window |
# | | |G|K|H|T|N|N| |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
#Data Offset: This indicates where the data begins.
#Data Offset: This indicates where the data begins.
#The TCP header is an integral number of 32 bits long.
#value to multiply * 4 byte
#e.g. DataOffset = 5 ; TCP Header Length = 5 * 4 byte = 20 byte
Expand All @@ -209,17 +209,17 @@ def help():
tcp_header_length = packet_bytearray[ETH_HLEN + ip_header_length + 12] #load Byte
tcp_header_length = tcp_header_length & 0xF0 #mask bit 4..7
tcp_header_length = tcp_header_length >> 2 #SHR 4 ; SHL 2 -> SHR 2

#retrieve port source/dest
port_src_str = packet_str[ETH_HLEN+ip_header_length:ETH_HLEN+ip_header_length+2]
port_dst_str = packet_str[ETH_HLEN+ip_header_length+2:ETH_HLEN+ip_header_length+4]

port_src = int(toHex(port_src_str),16)
port_dst = int(toHex(port_dst_str),16)

#calculate payload offset
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length

#payload_string contains only packet payload
payload_string = packet_str[(payload_offset):(len(packet_bytearray))]

Expand All @@ -238,32 +238,32 @@ def help():
#url entirely contained in first packet -> print it all
printUntilCRLF(payload_string)

#delete current_Key from bpf_sessions, url already printed. current session not useful anymore
#delete current_Key from bpf_sessions, url already printed. current session not useful anymore
try:
del bpf_sessions[current_Key]
except:
print ("error during delete from bpf map ")
else:
#url NOT entirely contained in first packet
#not found \r\n in payload.
else:
#url NOT entirely contained in first packet
#not found \r\n in payload.
#save current part of the payload_string in dictionary <key(ips,ipd,ports,portd),payload_string>
local_dictionary[binascii.hexlify(current_Key)] = payload_string
else:
#NO match: HTTP GET/POST NOT found

#check if the packet belong to a session saved in bpf_sessions
if (current_Key in bpf_sessions):
#check id the packet belong to a session saved in local_dictionary
#check id the packet belong to a session saved in local_dictionary
#(local_dictionary mantains HTTP GET/POST url not printed yet because splitted in N packets)
if (binascii.hexlify(current_Key) in local_dictionary):
#first part of the HTTP GET/POST url is already present in local dictionary (prev_payload_string)
prev_payload_string = local_dictionary[binascii.hexlify(current_Key)]
#looking for CR+LF in current packet.
#looking for CR+LF in current packet.
if (crlf in payload_string):
#last packet. containing last part of HTTP GET/POST url splitted in N packets.
#append current payload
prev_payload_string += payload_string
#print HTTP GET/POST url
#print HTTP GET/POST url
printUntilCRLF(prev_payload_string)
#clean bpf_sessions & local_dictionary
try:
Expand All @@ -284,7 +284,7 @@ def help():
except:
print ("error deleting from map or dict")
#update dictionary
local_dictionary[binascii.hexlify(current_Key)] = prev_payload_string
local_dictionary[binascii.hexlify(current_Key)] = prev_payload_string
else:
#first part of the HTTP GET/POST url is NOT present in local dictionary
#bpf_sessions contains invalid entry -> delete it
Expand Down
10 changes: 5 additions & 5 deletions examples/networking/http_filter/http-parse-simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <net/sock.h>
#include <bcc/proto.h>

#define IP_TCP 6
#define IP_TCP 6
#define ETH_HLEN 14

/*eBPF program.
Expand All @@ -20,7 +20,7 @@ int http_filter(struct __sk_buff *skb) {
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
//filter IP packets (ethernet type = 0x0800)
if (!(ethernet->type == 0x0800)) {
goto DROP;
goto DROP;
}

struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));
Expand All @@ -40,16 +40,16 @@ int http_filter(struct __sk_buff *skb) {
//value to multiply * 4
//e.g. ip->hlen = 5 ; IP Header Length = 5 x 4 byte = 20 byte
ip_header_length = ip->hlen << 2; //SHL 2 -> *4 multiply

//calculate tcp header length
//value to multiply *4
//e.g. tcp->offset = 5 ; TCP Header Length = 5 x 4 byte = 20 byte
tcp_header_length = tcp->offset << 2; //SHL 2 -> *4 multiply

//calculate patload offset and length
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length;
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length;
payload_length = ip->tlen - ip_header_length - tcp_header_length;

//http:https://stackoverflow.com/questions/25047905/http-request-minimum-size-in-bytes
//minimum length of http request is always geater than 7 bytes
//avoid invalid access memory
Expand Down
24 changes: 12 additions & 12 deletions examples/networking/http_filter/http-parse-simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#Bertrone Matteo - Polytechnic of Turin
#November 2015
#
#eBPF application that parses HTTP packets
#eBPF application that parses HTTP packets
#and extracts (and prints on screen) the URL contained in the GET/POST request.
#
#eBPF program http_filter is used as SOCKET_FILTER attached to eth0 interface.
Expand Down Expand Up @@ -90,9 +90,9 @@ def help():

#convert packet into bytearray
packet_bytearray = bytearray(packet_str)

#ethernet header length
ETH_HLEN = 14
ETH_HLEN = 14

#IP HEADER
#https://tools.ietf.org/html/rfc791
Expand All @@ -101,34 +101,34 @@ def help():
# |Version| IHL |Type of Service| Total Length |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
#IHL : Internet Header Length is the length of the internet header
#IHL : Internet Header Length is the length of the internet header
#value to multiply * 4 byte
#e.g. IHL = 5 ; IP Header Length = 5 * 4 byte = 20 byte
#
#Total length: This 16-bit field defines the entire packet size,
#Total length: This 16-bit field defines the entire packet size,
#including header and data, in bytes.

#calculate packet total length
total_length = packet_bytearray[ETH_HLEN + 2] #load MSB
total_length = total_length << 8 #shift MSB
total_length = total_length + packet_bytearray[ETH_HLEN+3] #add LSB

#calculate ip header length
ip_header_length = packet_bytearray[ETH_HLEN] #load Byte
ip_header_length = ip_header_length & 0x0F #mask bits 0..3
ip_header_length = ip_header_length << 2 #shift to obtain length

#TCP HEADER
#TCP HEADER
#https://www.rfc-editor.org/rfc/rfc793.txt
# 12 13 14 15
# 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
# 12 13 14 15
# 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | Data | |U|A|P|R|S|F| |
# | Offset| Reserved |R|C|S|S|Y|I| Window |
# | | |G|K|H|T|N|N| |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
#Data Offset: This indicates where the data begins.
#Data Offset: This indicates where the data begins.
#The TCP header is an integral number of 32 bits long.
#value to multiply * 4 byte
#e.g. DataOffset = 5 ; TCP Header Length = 5 * 4 byte = 20 byte
Expand All @@ -137,10 +137,10 @@ def help():
tcp_header_length = packet_bytearray[ETH_HLEN + ip_header_length + 12] #load Byte
tcp_header_length = tcp_header_length & 0xF0 #mask bit 4..7
tcp_header_length = tcp_header_length >> 2 #SHR 4 ; SHL 2 -> SHR 2

#calculate payload offset
payload_offset = ETH_HLEN + ip_header_length + tcp_header_length

#print first line of the HTTP GET/POST request
#line ends with 0xOD 0xOA (\r\n)
#(if we want to print all the header print until \r\n\r\n)
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing/strlen_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
#
#
# Example output:
# $ sudo ./strlen_hist.py
# 22:12:52
Expand Down
2 changes: 1 addition & 1 deletion src/cc/frontends/clang/tp_frontend_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static inline bool _is_tracepoint_struct_type(string const& type_name,
// (?:struct|class)\s+tracepoint__(\S+)__(\S+)
// Not using std::regex because older versions of GCC don't support it yet.
// E.g., the libstdc++ that ships with Ubuntu 14.04.

auto first_space_pos = type_name.find_first_of("\t ");
if (first_space_pos == string::npos)
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/cc/frontends/clang/tp_frontend_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TracepointTypeVisitor :
clang::ASTContext &C;
clang::DiagnosticsEngine &diag_;
clang::Rewriter &rewriter_;
llvm::raw_ostream &out_;
llvm::raw_ostream &out_;
};

class TracepointTypeConsumer : public clang::ASTConsumer {
Expand Down
4 changes: 2 additions & 2 deletions src/cc/frontends/p4/compiler/compilationException.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

class CompilationException(Exception):
"""Signals an error during compilation"""
def __init__(self, isBug, format, *message):
def __init__(self, isBug, format, *message):
# isBug: indicates that this is a compiler bug
super(CompilationException, self).__init__()

assert isinstance(format, str)
assert isinstance(isBug, bool)
self.message = message
Expand Down
Loading

0 comments on commit d1324ac

Please sign in to comment.