Skip to content

Commit f55a2f6

Browse files
authored
Removing trailing white spaces and fixing typo (#5383)
* Remove trailing white spaces Trailing whitespaces are removed from all files, empty lines and image files are preserved. This patch is created using the following shell commands: find . -type f -not -path '*/\.*' -exec sed -i '/^$/!s/[ \t]*$//' {} \; * docs/reference_guide.md: Fix typo
1 parent 0b53e33 commit f55a2f6

File tree

98 files changed

+413
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+413
-413
lines changed

FAQ.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A: The so-called Kernel lockdown might be the root cause. Try disabling it with
2929
echo 1 > /proc/sys/kernel/sysrq
3030
echo x > /proc/sysrq-trigger
3131
Also see https://github.com/iovisor/bcc/issues/2525
32-
32+
3333
If you have Secure Boot enabled you need to press Alt-PrintScr-x on the keyboard instead:
3434
```
3535
This sysrq operation is disabled from userspace.

INSTALL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ mv /lib/modules/$KERNEL_VERSION-microsoft-standard-WSL2+/ /lib/modules/$KERNEL_V
311311
312312
Then you can install bcc tools package according your distribution.
313313
314-
If you met some problems, try to
314+
If you met some problems, try to
315315
```
316316
sudo mount -t debugfs debugfs /sys/kernel/debug
317317
```
@@ -387,7 +387,7 @@ sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
387387
sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
388388
libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \
389389
liblzma-dev libdebuginfod-dev arping netperf iperf
390-
390+
391391
# For Lunar Lobster (23.04)
392392
sudo apt install -y zip bison build-essential cmake flex git libedit-dev \
393393
libllvm15 llvm-15-dev libclang-15-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools \
@@ -433,7 +433,7 @@ suppose you're running with root or add sudo first
433433
### Install build dependencies
434434
```
435435
dnf install -y bison cmake ethtool flex git iperf3 libstdc++-devel python3-netaddr python3-pip gcc gcc-c++ make zlib-devel elfutils-libelf-devel
436-
# dnf install -y luajit luajit-devel ## if use luajit, will report some lua function(which in lua5.3) undefined problem
436+
# dnf install -y luajit luajit-devel ## if use luajit, will report some lua function(which in lua5.3) undefined problem
437437
dnf install -y clang clang-devel llvm llvm-devel llvm-static ncurses-devel
438438
dnf -y install netperf
439439
pip3 install pyroute2
@@ -449,7 +449,7 @@ cd bcc-build/
449449
## here llvm should always link shared library
450450
cmake ../bcc -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_LLVM_SHARED=1
451451
make -j10
452-
make install
452+
make install
453453

454454
```
455455
after install, you may add bcc directory to your $PATH, which you can add to ~/.bashrc
@@ -460,20 +460,20 @@ export PATH=$bcctools:$bccexamples:$PATH
460460
```
461461
### let path take effect
462462
```
463-
source ~/.bashrc
463+
source ~/.bashrc
464464
```
465-
then run
465+
then run
466466
```
467467
hello_world.py
468468
```
469-
Or
469+
Or
470470
```
471471
cd /usr/share/bcc/examples
472472
./hello_world.py
473473
./tracing/bitehist.py
474474

475475
cd /usr/share/bcc/tools
476-
./bitesize
476+
./bitesize
477477

478478
```
479479

docker/build/Dockerfile.ubuntu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ do \
7777
then \
7878
apt-get install -y libpolly-${version}-dev; \
7979
fi; \
80-
done \
80+
done \
8181
&& \
8282
apt-get -y clean'
8383

docs/reference_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ cannot call GPL only function from proprietary program
26162616

26172617
eBPF program compilation needs kernel sources or kernel headers with headers
26182618
compiled. In case your kernel sources are at a non-standard location where BCC
2619-
cannot find then, its possible to provide BCC the absolute path of the location
2619+
cannot find then, it's possible to provide BCC the absolute path of the location
26202620
by setting `BCC_KERNEL_SOURCE` to it.
26212621

26222622
## 2. Kernel version overriding

docs/tutorial_bcc_python_developer.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ if BPF.get_kprobe_functions(b'blk_start_request'):
229229
b.attach_kprobe(event="blk_mq_start_request", fn_name="trace_start")
230230

231231
if BPF.get_kprobe_functions(b'__blk_account_io_done'):
232-
# __blk_account_io_done is available before kernel v6.4.
232+
# __blk_account_io_done is available before kernel v6.4.
233233
b.attach_kprobe(event="__blk_account_io_done", fn_name="trace_completion")
234234
elif BPF.get_kprobe_functions(b'blk_account_io_done'):
235-
# blk_account_io_done is traceable (not inline) before v5.16.
235+
# blk_account_io_done is traceable (not inline) before v5.16.
236236
b.attach_kprobe(event="blk_account_io_done", fn_name="trace_completion")
237237
else:
238238
b.attach_kprobe(event="blk_mq_end_request", fn_name="trace_completion")
@@ -531,7 +531,7 @@ print("%-14s %-12s %-6s %s" % ("TIME(s)", "COMMAND", "PID", "UID"))
531531

532532
def print_event(cpu, data, size):
533533
event = b["events"].event(data)
534-
printb(b"%-14.3f %-12s %-6d %d" % ((event.ts/1000000000),
534+
printb(b"%-14.3f %-12s %-6d %d" % ((event.ts/1000000000),
535535
event.comm, event.pid, event.uid))
536536

537537
# loop with callback to print_event
@@ -553,8 +553,8 @@ list``` for a list of tracepoints. Linux >= 4.7 is required to attach BPF
553553
programs to tracepoints.
554554
1. ```args->uid```: ```args``` is auto-populated to be a structure of the
555555
tracepoint arguments. The comment above says where you can see that structure.
556-
Eg:
557-
556+
Eg:
557+
558558
```
559559
# sudo cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_setuid/format
560560
name: sys_enter_setuid
@@ -564,10 +564,10 @@ Eg:
564564
field:unsigned char common_flags; offset:2; size:1; signed:0;
565565
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
566566
field:int common_pid; offset:4; size:4; signed:1;
567-
567+
568568
field:int __syscall_nr; offset:8; size:4; signed:1;
569569
field:uid_t uid; offset:16; size:8; signed:0;
570-
570+
571571
print fmt: "uid: 0x%08lx", ((unsigned long)(REC->uid))
572572
```
573573
In this case, there are only one member `uid` to be printed.

examples/networking/http_filter/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ eBPF application that parses HTTP packets and extracts (and prints on screen) th
77
## Usage Example
88

99

10-
$ sudo python http-parse-complete.py
10+
$ sudo python http-parse-complete.py
1111
GET /pipermail/iovisor-dev/ HTTP/1.1
1212
HTTP/1.1 200 OK
1313
GET /favicon.ico HTTP/1.1
@@ -42,6 +42,6 @@ Two versions of this code are available in this repository:
4242
## How to execute this sample
4343

4444
This sample can be executed by typing either one the two commands below:
45-
45+
4646
$ sudo python http-parse-simple.py
4747
$ sudo python http-parse-complete.py

examples/networking/net_monitor.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#
33
# net_monitor.py Aggregates incoming network traffic
44
# outputs source ip, destination ip, the number of their network traffic, and current time
5-
# how to use : net_monitor.py <net_interface>
6-
#
5+
# how to use : net_monitor.py <net_interface>
6+
#
77
# Copyright (c) 2020 YoungEun Choe
88

99
from bcc import BPF
@@ -34,36 +34,36 @@ def help():
3434
#define ETH_HLEN 14
3535
3636
BPF_PERF_OUTPUT(skb_events);
37-
BPF_HASH(packet_cnt, u64, long, 256);
37+
BPF_HASH(packet_cnt, u64, long, 256);
3838
3939
int packet_monitor(struct __sk_buff *skb) {
4040
u8 *cursor = 0;
4141
u32 saddr, daddr;
4242
long* count = 0;
4343
long one = 1;
4444
u64 pass_value = 0;
45-
45+
4646
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
4747
struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));
4848
if (ip->ver != 4)
4949
return 0;
50-
if (ip->nextp != IP_TCP)
50+
if (ip->nextp != IP_TCP)
5151
{
52-
if (ip -> nextp != IP_UDP)
52+
if (ip -> nextp != IP_UDP)
5353
{
54-
if (ip -> nextp != IP_ICMP)
55-
return 0;
54+
if (ip -> nextp != IP_ICMP)
55+
return 0;
5656
}
5757
}
58-
58+
5959
saddr = ip -> src;
6060
daddr = ip -> dst;
6161
6262
pass_value = saddr;
6363
pass_value = pass_value << 32;
6464
pass_value = pass_value + daddr;
6565
66-
count = packet_cnt.lookup(&pass_value);
66+
count = packet_cnt.lookup(&pass_value);
6767
if (count) // check if this map exists
6868
*count += 1;
6969
else // if the map for the key doesn't exist, create one
@@ -113,7 +113,7 @@ def decimal_to_human(input_value):
113113
formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
114114
if output_len != 0:
115115
print('\ncurrent packet nums:')
116-
116+
117117
for i in range(0,output_len):
118118
srcdst = packet_cnt_output[i][0].value
119119
src = (srcdst >> 32) & 0xFFFFFFFF
@@ -124,8 +124,8 @@ def decimal_to_human(input_value):
124124
decimal_to_human(str(dst)) + ' ' + str(pkt_num) + ' ' + 'time : ' + formatted_time
125125
print(monitor_result)
126126

127-
packet_cnt.clear() # delete map entries after printing output. confirmed it deletes values and keys too
128-
127+
packet_cnt.clear() # delete map entries after printing output. confirmed it deletes values and keys too
128+
129129
except KeyboardInterrupt:
130130
sys.stdout.close()
131131
pass

examples/networking/tcp_mon_block/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# eBPF tcp_mon_block
22

3-
This eBPF program uses netlink TC, kernel tracepoints and kprobes to monitor outgoing connections from given PIDs (usually HTTP web servers) and block connections to all addresses initiated from them, unless they are listed in allow_list.json
3+
This eBPF program uses netlink TC, kernel tracepoints and kprobes to monitor outgoing connections from given PIDs (usually HTTP web servers) and block connections to all addresses initiated from them, unless they are listed in allow_list.json
44

55
To run the example:
66

77
1. Run python3 web_server.py . Note the server's PID (will be printed to stdout)
88
2. Add the server's PID to allow_list.json . You can replace the first entry on the JSON file and put your PID instead
99
3. Run tcp_mon_block.py -i network_interface_name (-v for verbose output). For example: python3 tcp_mon_block.py -i eth0
10-
4. Put your web_server's listening IP in 'server_address' variable in http_client.py and run python3 http_client.py
10+
4. Put your web_server's listening IP in 'server_address' variable in http_client.py and run python3 http_client.py
1111

1212
**Explanation**:
1313

1414
web_server.py is a simple HTTP web server built with flask. It has a SSRF vulnerability in the route to /public_ip (you can read more about this vulnerability here https://portswigger.net/web-security/ssrf).
1515

16-
This route demonstrates a web server which connects to some remote API server (which is pretty common behavior) and receives some data. The attached POC simply connects to https://api.ipify.org and fetches the server's public IP, then sends it back to the client.
17-
However, this specific route receives the API address to connect to from the user (http_client.py is used as the client in this POC, but in real life scenarios it will probably be a web browser).
16+
This route demonstrates a web server which connects to some remote API server (which is pretty common behavior) and receives some data. The attached POC simply connects to https://api.ipify.org and fetches the server's public IP, then sends it back to the client.
17+
However, this specific route receives the API address to connect to from the user (http_client.py is used as the client in this POC, but in real life scenarios it will probably be a web browser).
1818

1919
This creates a SSRF vulnerability as an attacker can put any address he/she wishes to force the web server to connect to it instead of the intended API address (https://api.ipify.org)
2020

21-
**Run the POC twice:**
21+
**Run the POC twice:**
2222

2323
**First**, run only web_server.py and http_client.py . http_client.py will send 2 requests to the web server:
2424

@@ -28,7 +28,7 @@ This creates a SSRF vulnerability as an attacker can put any address he/she wish
2828

2929
**Now run the POC again**
3030

31-
First run web_server.py but this time add the web server's PID to allow_list.json and then run tcp_mon_block.py as mentioned earlier.
31+
First run web_server.py but this time add the web server's PID to allow_list.json and then run tcp_mon_block.py as mentioned earlier.
3232

3333
This will make sure the web server will only connect to the predefined allow_list of addresses (this can be either an IPv4, URL or domain name), essentially blocking any connection to any address not listed in the allow_list.
3434

@@ -49,7 +49,7 @@ After web_server.py initiated a connection to a non-allowed address:
4949

5050

5151

52-
**Prerequisites**:
52+
**Prerequisites**:
5353

5454
1. BCC and pyroute2 for tcp_mon_block
5555
2. Python3 flask and requests in order to run the web_server.py and http_client.py POC

examples/networking/tunnel_monitor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dependencies. You will need nodejs+npm installed on the system to run this, but
2727
the setup script will only install packages in the local directory.
2828

2929
```
30-
[user@localhost tunnel_monitor]$ ./setup.sh
30+
[user@localhost tunnel_monitor]$ ./setup.sh
3131
Cloning into 'chord-transitions'...
3232
remote: Counting objects: 294, done.
3333
...
@@ -40,7 +40,7 @@ fastclick#1.0.6 bower_components/fastclick
4040
Then, start the simulation by running main.py:
4141

4242
```
43-
[root@bcc-dev tunnel_monitor]# python main.py
43+
[root@bcc-dev tunnel_monitor]# python main.py
4444
Launching host 1 of 9
4545
Launching host 2 of 9
4646
...

examples/networking/vlan_filter/data-plane-tracing.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#define IP_TCP 6
66
#define IP_UDP 17
77
#define IP_ICMP 1
8-
/*
8+
/*
99
In 802.3, both the source and destination addresses are 48 bits (4 bytes) MAC address.
10-
6 bytes (src) + 6 bytes (dst) + 2 bytes (type) = 14 bytes
10+
6 bytes (src) + 6 bytes (dst) + 2 bytes (type) = 14 bytes
1111
*/
1212
#define ETH_HLEN 14
1313

@@ -18,18 +18,18 @@
1818
return 0 -> DROP the packet
1919
return -1 -> KEEP the packet and return it to user space (userspace can read it from the socket_fd )
2020
*/
21-
int vlan_filter(struct __sk_buff *skb) {
22-
u8 *cursor = 0;
21+
int vlan_filter(struct __sk_buff *skb) {
22+
u8 *cursor = 0;
2323

2424
struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet));
25-
25+
2626
//filter IP packets (ethernet type = 0x0800) 0x0800 is IPv4 packet
2727
switch(ethernet->type){
2828
case 0x0800: goto IP;
2929
default: goto DROP;
3030
}
3131

32-
32+
3333
IP: ;
3434
struct ip_t *ip = cursor_advance(cursor, sizeof(*ip)); // IP header (datagram)
3535
switch (ip->nextp){

0 commit comments

Comments
 (0)