remove trailing white spaces from source code files
Trailing white spaces cause problems with git.
Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@polito.it>
diff --git a/examples/cpp/FollyRequestContextSwitch.cc b/examples/cpp/FollyRequestContextSwitch.cc
index bf3493e..fe81e3a 100644
--- a/examples/cpp/FollyRequestContextSwitch.cc
+++ b/examples/cpp/FollyRequestContextSwitch.cc
@@ -35,7 +35,7 @@
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);
diff --git a/examples/lua/sock-parse-http.lua b/examples/lua/sock-parse-http.lua
index f8918fb..477b049 100644
--- a/examples/lua/sock-parse-http.lua
+++ b/examples/lua/sock-parse-http.lua
@@ -34,7 +34,7 @@
-- 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
diff --git a/examples/networking/http_filter/http-parse-complete.c b/examples/networking/http_filter/http-parse-complete.c
index 3009729..37e54d2 100644
--- a/examples/networking/http_filter/http-parse-complete.c
+++ b/examples/networking/http_filter/http-parse-complete.c
@@ -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);
@@ -40,7 +40,7 @@
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));
@@ -69,16 +69,16 @@
//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://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
diff --git a/examples/networking/http_filter/http-parse-complete.py b/examples/networking/http_filter/http-parse-complete.py
index 808d244..f1e5e0a 100644
--- a/examples/networking/http_filter/http-parse-complete.py
+++ b/examples/networking/http_filter/http-parse-complete.py
@@ -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.
@@ -38,7 +38,7 @@
if len(hv) == 1:
hv = '0'+hv
lst.append(hv)
-
+
return reduce(lambda x,y:x+y, lst)
#print str until CR+LF
@@ -50,7 +50,7 @@
return
print ("%c" % (str[k]), end = "")
print("")
- return
+ return
#cleanup function
def cleanup():
@@ -71,7 +71,7 @@
del bpf_sessions[key]
except:
print("cleanup exception.")
- return
+ return
#args
def usage():
@@ -155,9 +155,9 @@
#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
@@ -166,18 +166,18 @@
# |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
@@ -189,18 +189,18 @@
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
@@ -209,17 +209,17 @@
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))]
@@ -238,14 +238,14 @@
#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:
@@ -253,17 +253,17 @@
#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:
@@ -284,7 +284,7 @@
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
diff --git a/examples/networking/http_filter/http-parse-simple.c b/examples/networking/http_filter/http-parse-simple.c
index 9c165db..7557e95 100644
--- a/examples/networking/http_filter/http-parse-simple.c
+++ b/examples/networking/http_filter/http-parse-simple.c
@@ -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.
@@ -20,7 +20,7 @@
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));
@@ -40,16 +40,16 @@
//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://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
diff --git a/examples/networking/http_filter/http-parse-simple.py b/examples/networking/http_filter/http-parse-simple.py
index 81fbd4d..b702393 100644
--- a/examples/networking/http_filter/http-parse-simple.py
+++ b/examples/networking/http_filter/http-parse-simple.py
@@ -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.
@@ -90,9 +90,9 @@
#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
@@ -101,34 +101,34 @@
# |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
@@ -137,10 +137,10 @@
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)
diff --git a/examples/tracing/strlen_hist.py b/examples/tracing/strlen_hist.py
index 65f7c73..dda1cb2 100755
--- a/examples/tracing/strlen_hist.py
+++ b/examples/tracing/strlen_hist.py
@@ -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
diff --git a/src/cc/frontends/clang/tp_frontend_action.cc b/src/cc/frontends/clang/tp_frontend_action.cc
index 4654b58..b8818ba 100644
--- a/src/cc/frontends/clang/tp_frontend_action.cc
+++ b/src/cc/frontends/clang/tp_frontend_action.cc
@@ -122,7 +122,7 @@
// (?: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;
diff --git a/src/cc/frontends/clang/tp_frontend_action.h b/src/cc/frontends/clang/tp_frontend_action.h
index 44522e0..fb18c67 100644
--- a/src/cc/frontends/clang/tp_frontend_action.h
+++ b/src/cc/frontends/clang/tp_frontend_action.h
@@ -53,7 +53,7 @@
clang::ASTContext &C;
clang::DiagnosticsEngine &diag_;
clang::Rewriter &rewriter_;
- llvm::raw_ostream &out_;
+ llvm::raw_ostream &out_;
};
class TracepointTypeConsumer : public clang::ASTConsumer {
diff --git a/src/cc/frontends/p4/compiler/compilationException.py b/src/cc/frontends/p4/compiler/compilationException.py
index 34f75b1..cc0e5ba 100644
--- a/src/cc/frontends/p4/compiler/compilationException.py
+++ b/src/cc/frontends/p4/compiler/compilationException.py
@@ -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
diff --git a/src/cc/frontends/p4/compiler/ebpfAction.py b/src/cc/frontends/p4/compiler/ebpfAction.py
index 49f6ebd..99bf145 100644
--- a/src/cc/frontends/p4/compiler/ebpfAction.py
+++ b/src/cc/frontends/p4/compiler/ebpfAction.py
@@ -225,10 +225,10 @@
dst.asString,
src.asString,
size / 8)
- elif (callee.name == "add" or
- callee.name == "bit_and" or
- callee.name == "bit_or" or
- callee.name == "bit_xor" or
+ elif (callee.name == "add" or
+ callee.name == "bit_and" or
+ callee.name == "bit_or" or
+ callee.name == "bit_xor" or
callee.name == "subtract"):
size = self.checkSize(callee,
[a.widthInBits() for a in args],
@@ -247,7 +247,7 @@
args[1].asString,
op,
args[2].asString)
- elif (callee.name == "add_to_field" or
+ elif (callee.name == "add_to_field" or
callee.name == "subtract_from_field"):
size = self.checkSize(callee,
[a.widthInBits() for a in args],
diff --git a/src/cc/frontends/p4/compiler/ebpfConditional.py b/src/cc/frontends/p4/compiler/ebpfConditional.py
index 2a00086..5c723d2 100644
--- a/src/cc/frontends/p4/compiler/ebpfConditional.py
+++ b/src/cc/frontends/p4/compiler/ebpfConditional.py
@@ -50,7 +50,7 @@
"{0}.{1}.{2}", base, einstance.name, node.name)
else:
raise CompilationException(True, "{0} Unexpected expression ", node)
-
+
def emitExpression(self, expression, serializer, program, toplevel):
assert isinstance(serializer, ProgramSerializer)
assert isinstance(program, ebpfProgram.EbpfProgram)
@@ -59,9 +59,9 @@
left = expression.left
op = expression.op
right = expression.right
-
+
assert isinstance(op, str)
-
+
if op == "valid":
self.emitNode(right, serializer, program)
serializer.append(".valid")
diff --git a/src/cc/frontends/p4/compiler/ebpfCounter.py b/src/cc/frontends/p4/compiler/ebpfCounter.py
index 5908d5e..5b5b396 100644
--- a/src/cc/frontends/p4/compiler/ebpfCounter.py
+++ b/src/cc/frontends/p4/compiler/ebpfCounter.py
@@ -27,7 +27,7 @@
self.dataMapName = self.name
- if ((hlircounter.binding is None) or
+ if ((hlircounter.binding is None) or
(hlircounter.binding[0] != P4_DIRECT)):
raise NotSupportedException(
"{0}: counter which is not direct", hlircounter)
diff --git a/src/cc/frontends/p4/compiler/ebpfProgram.py b/src/cc/frontends/p4/compiler/ebpfProgram.py
index c541382..1237175 100644
--- a/src/cc/frontends/p4/compiler/ebpfProgram.py
+++ b/src/cc/frontends/p4/compiler/ebpfProgram.py
@@ -19,7 +19,7 @@
class EbpfProgram(object):
def __init__(self, name, hlir, isRouter, config):
- """Representation of an EbpfProgram (in fact,
+ """Representation of an EbpfProgram (in fact,
a C program that is converted to EBPF)"""
assert isinstance(hlir, HLIR)
assert isinstance(isRouter, bool)
diff --git a/src/cc/frontends/p4/compiler/ebpfScalarType.py b/src/cc/frontends/p4/compiler/ebpfScalarType.py
index 9ab26ca..cb5db21 100644
--- a/src/cc/frontends/p4/compiler/ebpfScalarType.py
+++ b/src/cc/frontends/p4/compiler/ebpfScalarType.py
@@ -51,7 +51,7 @@
return 4
else:
return 1 # Char array
-
+
def serialize(self, serializer):
assert isinstance(serializer, ProgramSerializer)
serializer.append(self.asString())
diff --git a/src/cc/frontends/p4/compiler/ebpfTable.py b/src/cc/frontends/p4/compiler/ebpfTable.py
index 70ab7a6..eb1efd9 100644
--- a/src/cc/frontends/p4/compiler/ebpfTable.py
+++ b/src/cc/frontends/p4/compiler/ebpfTable.py
@@ -84,8 +84,8 @@
matchType = f[1]
mask = f[2]
- if ((matchType is p4_match_type.P4_MATCH_TERNARY) or
- (matchType is p4_match_type.P4_MATCH_LPM) or
+ if ((matchType is p4_match_type.P4_MATCH_TERNARY) or
+ (matchType is p4_match_type.P4_MATCH_LPM) or
(matchType is p4_match_type.P4_MATCH_RANGE)):
raise NotSupportedException(
False, "Match type {0}", matchType)
@@ -126,7 +126,7 @@
def fieldRank(field):
assert isinstance(field, EbpfTableKeyField)
return field.field.type.alignment()
-
+
def serializeType(self, serializer, keyTypeName):
assert isinstance(serializer, ProgramSerializer)
serializer.emitIndent()
@@ -193,7 +193,7 @@
assert isinstance(ctr, ebpfCounter.EbpfCounter)
self.counters.append(ctr)
- if (len(hlirtable.attached_meters) > 0 or
+ if (len(hlirtable.attached_meters) > 0 or
len(hlirtable.attached_registers) > 0):
program.emitWarning("{0}: meters/registers {1}; ignored",
hlirtable, NotSupportedException.archError)
diff --git a/src/cc/frontends/p4/compiler/p4toEbpf.py b/src/cc/frontends/p4/compiler/p4toEbpf.py
index e86ab3e..7a5bc42 100755
--- a/src/cc/frontends/p4/compiler/p4toEbpf.py
+++ b/src/cc/frontends/p4/compiler/p4toEbpf.py
@@ -6,7 +6,7 @@
# Compiler from P4 to EBPF
# (See http://www.slideshare.net/PLUMgrid/ebpf-and-linux-networking).
# This compiler in fact generates a C source file
-# which can be compiled to EBPF using the LLVM compiler
+# which can be compiled to EBPF using the LLVM compiler
# with the ebpf target.
#
# Main entry point.
diff --git a/src/cc/frontends/p4/compiler/target.py b/src/cc/frontends/p4/compiler/target.py
index 33dc0e6..6124dff 100644
--- a/src/cc/frontends/p4/compiler/target.py
+++ b/src/cc/frontends/p4/compiler/target.py
@@ -113,7 +113,7 @@
#include "bpf_helpers.h"
"""
-
+
# Represents a target compiled by bcc that uses the TC
class BccConfig(TargetConfig):
def __init__(self):
diff --git a/src/cc/frontends/p4/compiler/typeFactory.py b/src/cc/frontends/p4/compiler/typeFactory.py
index e6a0538..71a0207 100644
--- a/src/cc/frontends/p4/compiler/typeFactory.py
+++ b/src/cc/frontends/p4/compiler/typeFactory.py
@@ -13,7 +13,7 @@
name = hlirType.name
if hlirType.name in self.type_map:
retval = self.type_map[name]
- if ((not asMetadata and isinstance(retval, EbpfMetadataType)) or
+ if ((not asMetadata and isinstance(retval, EbpfMetadataType)) or
(asMetadata and isinstance(retval, EbpfHeaderType))):
raise CompilationException(
True, "Same type used both as a header and metadata {0}",
diff --git a/src/cc/frontends/p4/test/endToEndTest.py b/src/cc/frontends/p4/test/endToEndTest.py
index ddc247b..634a2ec 100755
--- a/src/cc/frontends/p4/test/endToEndTest.py
+++ b/src/cc/frontends/p4/test/endToEndTest.py
@@ -26,7 +26,7 @@
def message(self, *args):
if self.verbose:
print(*args)
-
+
class Endpoint(Base):
# a network interface really
@@ -47,7 +47,7 @@
def get_ip_address(self):
return IPAddress(self.ipaddress)
-
+
class Node(Base):
# Used to represent one of clt, sw, srv
# Each lives in its own namespace
@@ -67,7 +67,7 @@
def get_ns_name(self):
return self.name
-
+
def get_ns(self):
nsname = self.get_ns_name()
ns = NetNS(nsname)
@@ -100,7 +100,7 @@
Base.__init__(self)
self.ipr = IPRoute()
self.nodes = []
-
+
def add_node(self, node):
assert isinstance(node, Node)
self.nodes.append(node)
@@ -123,7 +123,7 @@
# Ask a node to set the specified interface address
if address is None:
return
-
+
assert isinstance(node, Node)
command = ["ip", "addr", "add", str(address) + "/" + str(mask),
"dev", str(ifname)]
@@ -132,7 +132,7 @@
def create_link(self, src, dest):
assert isinstance(src, Endpoint)
- assert isinstance(dest, Endpoint)
+ assert isinstance(dest, Endpoint)
ifname = self.get_interface_name(src.parent, dest.parent)
destname = self.get_interface_name(dest.parent, src.parent)
@@ -150,7 +150,7 @@
# lost of set prior to moving to namespace
self.set_interface_ipaddress(
src.parent, ifname, src.ipaddress , src.prefixlen)
-
+
# Sef destination endpoint information
ix = self.get_interface(destname)
self.ipr.link("set", index=ix, address=dest.mac_addr)
@@ -178,7 +178,7 @@
n.remove()
self.ipr.close()
-
+
### Here begins the concrete instantiation of the network
# Network setup:
# Each of these is a separate namespace.
@@ -191,7 +191,7 @@
# ---------- -------- ---------
# 10.0.0.11 10.0.0.10
#
-
+
class SimulatedNetwork(NetworkBase):
def __init__(self):
NetworkBase.__init__(self)
@@ -219,7 +219,7 @@
assert isinstance(node, Node)
assert isinstance(args, list)
torun = __file__
- args.insert(0, torun)
+ args.insert(0, torun)
args.insert(1, method)
return node.execute(args) # runs the command argv[0] method args
@@ -240,7 +240,7 @@
self.message("Set ARP mappings")
self.client.set_arp(self.server_endpoint)
self.server.set_arp(self.client_endpoint)
-
+
def setup_switch(self):
# This method is run in the switch namespace.
self.message("Compiling and loading BPF program")
@@ -254,7 +254,7 @@
routing_tbl = b.get_table("routing")
routing_miss_tbl = b.get_table("ebpf_routing_miss")
cnt_tbl = b.get_table("cnt")
-
+
self.message("Hooking up BPF classifiers using TC")
interfname = self.get_interface_name(self.switch, self.server)
@@ -268,7 +268,7 @@
self.ipr.tc("add", "ingress", sw_clt_idx, "ffff:")
self.ipr.tc("add-filter", "bpf", sw_clt_idx, ":1", fd=fn.fd,
name=fn.name, parent="ffff:", action="ok", classid=1)
-
+
self.message("Populating tables from the control plane")
cltip = self.client_endpoint.get_ip_address()
srvip = self.server_endpoint.get_ip_address()
@@ -276,17 +276,17 @@
# BCC does not support tbl.Leaf when the type contains a union,
# so we have to make up the value type manually. Unfortunately
# these sizes are not portable...
-
+
class Forward(ctypes.Structure):
_fields_ = [("port", ctypes.c_ushort)]
-
+
class Nop(ctypes.Structure):
_fields_ = []
-
+
class Union(ctypes.Union):
_fields_ = [("nop", Nop),
("forward", Forward)]
-
+
class Value(ctypes.Structure):
_fields_ = [("action", ctypes.c_uint),
("u", Union)]
@@ -301,14 +301,14 @@
v1 = Value()
v1.action = 1
v1.u.forward.port = sw_clt_idx
-
+
v2 = Value()
v2.action = 1;
v2.u.forward.port = sw_srv_idx
routing_tbl[routing_tbl.Key(int(cltip))] = v1
routing_tbl[routing_tbl.Key(int(srvip))] = v2
-
+
self.message("Dumping table contents")
for key, leaf in routing_tbl.items():
self.message(str(IPAddress(key.key_field_0)),
@@ -322,7 +322,7 @@
raise Exception("Test failed")
else:
print("Test succeeded!")
-
+
def prepare_switch(self):
self.message("Configuring switch")
# Re-invokes this script in the switch namespace;
@@ -331,7 +331,7 @@
# but in the switch namespace
self.run_method_in_node(self.switch, "setup_switch", [])
-
+
def compile(source, destination):
try:
status = subprocess.call(
@@ -344,7 +344,7 @@
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
raise e
-
+
def start_simulation():
compile("testprograms/simple.p4", "simple.c")
network = SimulatedNetwork()
diff --git a/src/cc/frontends/p4/test/testP4toEbpf.py b/src/cc/frontends/p4/test/testP4toEbpf.py
index fbfad04..bc6301a 100755
--- a/src/cc/frontends/p4/test/testP4toEbpf.py
+++ b/src/cc/frontends/p4/test/testP4toEbpf.py
@@ -27,7 +27,7 @@
def is_root():
# Is this code portable?
return os.getuid() == 0
-
+
def main():
testpath = "testprograms"
destFolder = "testoutputs"
@@ -40,7 +40,7 @@
print "Loading EBPF programs requires root priviledge."
print "Will only test compilation, not loading."
print "(Run with sudo to test program loading.)"
-
+
for f in files:
path = os.path.join(testpath, f)
@@ -62,14 +62,14 @@
else:
# Try to load the compiled function
if is_root():
- try:
+ try:
print("Compiling and loading BPF program")
b = BPF(src_file=destname, debug=0)
fn = b.load_func("ebpf_filter", BPF.SCHED_CLS)
except Exception as e:
print(e)
set_error("BPF error", path, str(e))
-
+
filesDone += 1
print "Compiled", filesDone, "files", errors, "errors"
@@ -78,7 +78,7 @@
for v in filesFailed[key]:
print "\t", v
exit(len(filesFailed) != 0)
-
-
+
+
if __name__ == "__main__":
main()
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
index ad8fb67..4426c2c 100644
--- a/src/cc/libbpf.c
+++ b/src/cc/libbpf.c
@@ -346,7 +346,7 @@
void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type, const char *ev_name,
const char *fn_name,
pid_t pid, int cpu, int group_fd,
- perf_reader_cb cb, void *cb_cookie)
+ perf_reader_cb cb, void *cb_cookie)
{
int kfd;
char buf[256];
@@ -367,7 +367,7 @@
goto error;
}
- snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
+ snprintf(buf, sizeof(buf), "%c:%ss/%s %s", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, new_name, fn_name);
if (write(kfd, buf, strlen(buf)) < 0) {
if (errno == EINVAL)
@@ -380,10 +380,10 @@
if (access("/sys/kernel/debug/tracing/instances", F_OK) != -1) {
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/instances/bcc_%d", getpid());
if (access(buf, F_OK) == -1) {
- if (mkdir(buf, 0755) == -1)
+ if (mkdir(buf, 0755) == -1)
goto retry;
}
- n = snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/instances/bcc_%d/events/%ss/%s",
+ n = snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/instances/bcc_%d/events/%ss/%s",
getpid(), event_type, new_name);
if (n < sizeof(buf) && bpf_attach_tracing_event(progfd, buf, reader, pid, cpu, group_fd) == 0)
goto out;
@@ -406,7 +406,7 @@
void * bpf_attach_uprobe(int progfd, enum bpf_probe_attach_type attach_type, const char *ev_name,
const char *binary_path, uint64_t offset,
pid_t pid, int cpu, int group_fd,
- perf_reader_cb cb, void *cb_cookie)
+ perf_reader_cb cb, void *cb_cookie)
{
int kfd;
char buf[PATH_MAX];
@@ -428,7 +428,7 @@
goto error;
}
- n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
+ n = snprintf(buf, sizeof(buf), "%c:%ss/%s %s:0x%lx", attach_type==BPF_PROBE_ENTRY ? 'p' : 'r',
event_type, new_name, binary_path, offset);
if (n >= sizeof(buf)) {
close(kfd);
diff --git a/src/cc/libbpf.h b/src/cc/libbpf.h
index c546604..4b885f1 100644
--- a/src/cc/libbpf.h
+++ b/src/cc/libbpf.h
@@ -50,7 +50,7 @@
typedef void (*perf_reader_raw_cb)(void *cb_cookie, void *raw, int raw_size);
typedef void (*perf_reader_lost_cb)(uint64_t lost);
-void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type,
+void * bpf_attach_kprobe(int progfd, enum bpf_probe_attach_type attach_type,
const char *ev_name, const char *fn_name,
pid_t pid, int cpu, int group_fd,
perf_reader_cb cb, void *cb_cookie);
diff --git a/src/lua/bpf/bpf.lua b/src/lua/bpf/bpf.lua
index 5c78279..f37ab57 100644
--- a/src/lua/bpf/bpf.lua
+++ b/src/lua/bpf/bpf.lua
@@ -258,7 +258,7 @@
stack_top = math.ceil(stack_top/8)*8
-- Current kernel version doesn't support ARG_PTR_TO_RAW_STACK
-- so we always need to have memory initialized, remove this when supported
- if blank then
+ if blank then
if type(blank) == 'string' then
local sp = 0
while sp < size do
@@ -276,7 +276,7 @@
emit(BPF.MEM + BPF.STX + BPF.DW, 10, 0, -sp, 0)
end
else error('NYI: will with unknown type '..type(blank)) end
- end
+ end
return stack_top
end
@@ -604,7 +604,7 @@
end
local function MAP_SET(map_var, key, key_imm, src)
- local map = V[map_var].const
+ local map = V[map_var].const
-- Delete when setting nil
if V[src].type == ffi.typeof('void') then
return MAP_DEL(map_var, key, key_imm)
diff --git a/src/lua/bpf/builtins.lua b/src/lua/bpf/builtins.lua
index 802e886..f95a608 100644
--- a/src/lua/bpf/builtins.lua
+++ b/src/lua/bpf/builtins.lua
@@ -205,7 +205,7 @@
-- TODO: identify cheap register move
-- TODO: identify copy to/from stack
error('NYI: ffi.copy(dst, src) - src is neither BPF map/socket buffer or probe')
- end
+ end
end
-- print(format, ...) builtin changes semantics from Lua print(...)
-- the first parameter has to be format and only reduced set of conversion specificers
diff --git a/src/lua/bpf/cdef.lua b/src/lua/bpf/cdef.lua
index afe78d0..ce21dfd 100644
--- a/src/lua/bpf/cdef.lua
+++ b/src/lua/bpf/cdef.lua
@@ -170,7 +170,7 @@
return string.match(tostring(ffi.typeof(v)), '<([^>]+)')
end
--- Reflect if cdata type can be pointer (accepts array or pointer)
+-- Reflect if cdata type can be pointer (accepts array or pointer)
function M.isptr(v, noarray)
local ctname = M.typename(v)
if ctname then
diff --git a/src/lua/bpf/elf.lua b/src/lua/bpf/elf.lua
index 6783827..533fe2f 100644
--- a/src/lua/bpf/elf.lua
+++ b/src/lua/bpf/elf.lua
@@ -227,7 +227,7 @@
end
-- Match symbol name against pattern
if pattern and string.match(name, k) or k == name then
- return sym[0]
+ return sym[0]
end
end
end
diff --git a/src/lua/bpf/proto.lua b/src/lua/bpf/proto.lua
index 3fb06c7..a03a520 100644
--- a/src/lua/bpf/proto.lua
+++ b/src/lua/bpf/proto.lua
@@ -222,7 +222,7 @@
-- Finalize relative offset
if mask then
e.emit(BPF.ALU + BPF.AND + BPF.K, tmp_reg, 0, 0, mask)
- end
+ end
if shift then
local op = BPF.LSH
if shift < 0 then
diff --git a/tests/python/test_bpf_log.py b/tests/python/test_bpf_log.py
index 1603f15..cb3d003 100755
--- a/tests/python/test_bpf_log.py
+++ b/tests/python/test_bpf_log.py
@@ -27,7 +27,7 @@
end = """
y = t1.lookup(&x);
x = *y;
- return 0;
+ return 0;
}
"""
for i in range(0,300):
@@ -42,7 +42,7 @@
def tearDown(self):
self.fp.close()
-
+
def test_log_debug(self):
b = BPF(text=text, debug=2)
diff --git a/tests/python/test_brb.c b/tests/python/test_brb.c
index 1dee7f6..b9e8e06 100644
--- a/tests/python/test_brb.c
+++ b/tests/python/test_brb.c
@@ -130,7 +130,7 @@
index = 0;
if (which_br == 1)
rtrif_p = br1_rtr.lookup(&index);
- else
+ else
rtrif_p = br2_rtr.lookup(&index);
if (rtrif_p)
bpf_clone_redirect(skb, *rtrif_p, 0);
diff --git a/tests/python/test_brb.py b/tests/python/test_brb.py
index 005158d..f60180b 100755
--- a/tests/python/test_brb.py
+++ b/tests/python/test_brb.py
@@ -13,7 +13,7 @@
#
# The vm1, vm2 and router are implemented as namespaces.
# The bridge is implemented with limited functionality in bpf program.
-#
+#
# vm1 and vm2 are in different subnet. For vm1 to communicate to vm2,
# the packet will have to travel from vm1 to pem, bridge1, router, bridge2, pem, and
# then come to vm2.
@@ -33,7 +33,7 @@
# 8: PING 200.1.1.1 (200.1.1.1) 56(84) bytes of data.
# 8: 64 bytes from 200.1.1.1: icmp_req=1 ttl=63 time=0.074 ms
# 8: 64 bytes from 200.1.1.1: icmp_req=2 ttl=63 time=0.061 ms
-# 8:
+# 8:
# 8: --- 200.1.1.1 ping statistics ---
# 8: 2 packets transmitted, 2 received, 0% packet loss, time 999ms
# 8: rtt min/avg/max/mdev = 0.061/0.067/0.074/0.010 ms
@@ -41,24 +41,24 @@
# 8: [ 5] 0.0- 1.0 sec 4.00 GBytes 34.3 Gbits/sec
# 8: Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
# 8: MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 200.1.1.1 (200.1.1.1) port 0 AF_INET : demo
-# 8: Recv Send Send
-# 8: Socket Socket Message Elapsed
-# 8: Size Size Size Time Throughput
-# 8: bytes bytes bytes secs. 10^6bits/sec
-# 8:
-# 8: 87380 16384 65160 1.00 41991.68
+# 8: Recv Send Send
+# 8: Socket Socket Message Elapsed
+# 8: Size Size Size Time Throughput
+# 8: bytes bytes bytes secs. 10^6bits/sec
+# 8:
+# 8: 87380 16384 65160 1.00 41991.68
# 8: MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 200.1.1.1 (200.1.1.1) port 0 AF_INET : demo : first burst 0
# 8: Local /Remote
# 8: Socket Size Request Resp. Elapsed Trans.
-# 8: Send Recv Size Size Time Rate
-# 8: bytes Bytes bytes bytes secs. per sec
-# 8:
-# 8: 16384 87380 1 1 1.00 48645.53
-# 8: 16384 87380
+# 8: Send Recv Size Size Time Rate
+# 8: bytes Bytes bytes bytes secs. per sec
+# 8:
+# 8: 16384 87380 1 1 1.00 48645.53
+# 8: 16384 87380
# 8: .
# 8: ----------------------------------------------------------------------
# 8: Ran 1 test in 11.296s
-# 8:
+# 8:
# 8: OK
from ctypes import c_uint
diff --git a/tests/python/test_brb2.py b/tests/python/test_brb2.py
index ab23884..492f381 100755
--- a/tests/python/test_brb2.py
+++ b/tests/python/test_brb2.py
@@ -14,7 +14,7 @@
# The vm1, vm2 and router are implemented as namespaces.
# The linux bridge device is used to provice bridge functionality.
# pem bpf will be attached to related network devices for vm1, vm1, bridge1 and bridge2.
-#
+#
# vm1 and vm2 are in different subnet. For vm1 to communicate to vm2,
# the packet will have to travel from vm1 to pem, bridge1, router, bridge2, pem, and
# then come to vm2.
@@ -26,7 +26,7 @@
# 9: PING 200.1.1.1 (200.1.1.1) 56(84) bytes of data.
# 9: 64 bytes from 200.1.1.1: icmp_req=1 ttl=63 time=0.090 ms
# 9: 64 bytes from 200.1.1.1: icmp_req=2 ttl=63 time=0.032 ms
-# 9:
+# 9:
# 9: --- 200.1.1.1 ping statistics ---
# 9: 2 packets transmitted, 2 received, 0% packet loss, time 999ms
# 9: rtt min/avg/max/mdev = 0.032/0.061/0.090/0.029 ms
@@ -34,24 +34,24 @@
# 9: [ 5] 0.0- 1.0 sec 3.80 GBytes 32.6 Gbits/sec
# 9: Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
# 9: MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 200.1.1.1 (200.1.1.1) port 0 AF_INET : demo
-# 9: Recv Send Send
-# 9: Socket Socket Message Elapsed
-# 9: Size Size Size Time Throughput
-# 9: bytes bytes bytes secs. 10^6bits/sec
-# 9:
-# 9: 87380 16384 65160 1.00 39940.46
+# 9: Recv Send Send
+# 9: Socket Socket Message Elapsed
+# 9: Size Size Size Time Throughput
+# 9: bytes bytes bytes secs. 10^6bits/sec
+# 9:
+# 9: 87380 16384 65160 1.00 39940.46
# 9: MIGRATED TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 200.1.1.1 (200.1.1.1) port 0 AF_INET : demo : first burst 0
# 9: Local /Remote
# 9: Socket Size Request Resp. Elapsed Trans.
-# 9: Send Recv Size Size Time Rate
-# 9: bytes Bytes bytes bytes secs. per sec
-# 9:
-# 9: 16384 87380 1 1 1.00 46387.80
-# 9: 16384 87380
+# 9: Send Recv Size Size Time Rate
+# 9: bytes Bytes bytes bytes secs. per sec
+# 9:
+# 9: 16384 87380 1 1 1.00 46387.80
+# 9: 16384 87380
# 9: .
# 9: ----------------------------------------------------------------------
# 9: Ran 1 test in 7.495s
-# 9:
+# 9:
# 9: OK
from ctypes import c_uint
@@ -87,7 +87,7 @@
ipdb.interfaces[veth_br_2_pem].up().commit()
subprocess.call(["sysctl", "-q", "-w", "net.ipv6.conf." + veth_pem_2_br + ".disable_ipv6=1"])
subprocess.call(["sysctl", "-q", "-w", "net.ipv6.conf." + veth_br_2_pem + ".disable_ipv6=1"])
-
+
# set up the bridge and add router interface as one of its slaves
with ipdb.create(ifname=br, kind="bridge") as br1:
br1.add_port(ipdb.interfaces[veth_pem_2_br])
diff --git a/tests/python/test_uprobes.py b/tests/python/test_uprobes.py
index 970a6b5..3926e35 100755
--- a/tests/python/test_uprobes.py
+++ b/tests/python/test_uprobes.py
@@ -84,7 +84,7 @@
libc = ctypes.CDLL("libc.so.6", use_errno=True)
# Need to find path to libz.so.1
- libz_path = None
+ libz_path = None
p = subprocess.Popen(["ldconfig", "-p"], stdout=subprocess.PIPE)
for l in p.stdout:
n = l.split()
@@ -102,7 +102,7 @@
if libc.unshare(0x00020000) == -1:
e = ctypes.get_errno()
raise OSError(e, errno.errorcode[e])
-
+
# Remount root MS_REC|MS_PRIVATE
if libc.mount(None, "/", None, (1<<14)|(1<<18) , None) == -1:
e = ctypes.get_errno()
@@ -119,7 +119,7 @@
libz.zlibVersion()
time.sleep(5)
os._exit(0)
-
+
libname = "/tmp/libz.so.1"
symname = "zlibVersion"
text = text.replace("PID", "%d" % child_pid)
@@ -131,6 +131,6 @@
b.detach_uretprobe(name=libname, sym=symname, pid=child_pid)
b.detach_uprobe(name=libname, sym=symname, pid=child_pid)
os.wait()
-
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/execsnoop.py b/tools/execsnoop.py
index fc086f7..770b5f1 100755
--- a/tools/execsnoop.py
+++ b/tools/execsnoop.py
@@ -30,7 +30,7 @@
./execsnoop -x # include failed exec()s
./execsnoop -t # include timestamps
./execsnoop -n main # only print command lines containing "main"
- ./execsnoop -l tpkg # only print command where arguments contains "tpkg"
+ ./execsnoop -l tpkg # only print command where arguments contains "tpkg"
"""
parser = argparse.ArgumentParser(
description="Trace exec() syscalls",