Skip to content

Commit

Permalink
Merge pull request iovisor#407 from yadutaf/jt-readme
Browse files Browse the repository at this point in the history
Documentation and tcp4connect enhancements
  • Loading branch information
drzaeus77 committed Feb 22, 2016
2 parents a6f5a21 + d0764aa commit db45465
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Editor's files
*.swp
*.swo
*.pyc

# Build artefacts
/build/
3 changes: 3 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,15 @@ To build the toolchain from source, one needs:

### Install build dependencies
```
# Trusty and older
VER=trusty
echo "deb http:https://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main
deb-src http:https://llvm.org/apt/$VER/ llvm-toolchain-$VER-3.7 main" | \
sudo tee /etc/apt/sources.list.d/llvm.list
wget -O - http:https://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
# All versions
sudo apt-get -y install bison build-essential cmake flex git libedit-dev \
libllvm3.7 llvm-3.7-dev libclang-3.7-dev python zlib1g-dev
```
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ many possible capabilities.

See [INSTALL.md](INSTALL.md) for installation steps on your platform.

## FAQ

See [FAQ.txt](FAQ.txt) for the most common troubleshoot questions.

## Contents

Some of these are single files that contain both C and Python, others have a
Expand Down
17 changes: 13 additions & 4 deletions examples/tracing/tcpv4connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
bpf_probe_read(&dport, sizeof(dport), &skp->__sk_common.skc_dport);
// output
bpf_trace_printk("%x %x %d\\n", saddr, daddr, ntohs(dport));
bpf_trace_printk("trace_tcp4connect %x %x %d\\n", saddr, daddr, ntohs(dport));
currsock.delete(&pid);
Expand All @@ -86,10 +86,19 @@ def inet_ntoa(addr):
addr = addr >> 8
return dq

# format output
# filter and format output
while 1:
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
(saddr_hs, daddr_hs, dport_s) = msg.split(" ")
# Read messages from kernel pipe
try:
(task, pid, cpu, flags, ts, msg) = b.trace_fields()
(_tag, saddr_hs, daddr_hs, dport_s) = msg.split(" ")
except ValueError:
# Ignore messages from other tracers
continue

# Ignore messages from other tracers
if _tag != "trace_tcp4connect":
continue

print("%-6d %-12.12s %-16s %-16s %-4s" % (pid, task,
inet_ntoa(int(saddr_hs, 16)),
Expand Down

0 comments on commit db45465

Please sign in to comment.