Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
97bef766
Commit
97bef766
authored
Dec 01, 2016
by
shodoco
Committed by
GitHub
Dec 01, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into lruhash
parents
e69f7646
5647de0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
tools/profile.py
tools/profile.py
+1
-1
tools/tcplife.py
tools/tcplife.py
+26
-22
No files found.
tools/profile.py
View file @
97bef766
...
...
@@ -132,7 +132,7 @@ BPF_STACK_TRACE(stack_traces, STACK_STORAGE_SIZE)
// This code gets a bit complex. Probably not suitable for casual hacking.
int do_perf_event(struct bpf_perf_event_data *ctx) {
u32 pid = bpf_get_current_pid_tgid();
u32 pid = bpf_get_current_pid_tgid()
>> 32
;
if (!(THREAD_FILTER))
return 0;
...
...
tools/tcplife.py
View file @
97bef766
...
...
@@ -127,44 +127,49 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state)
* fetch task context if cached, or use current task
*/
// capture birth time
if (state < TCP_FIN_WAIT1) {
/*
* Matching just ESTABLISHED may be sufficient, provided no code-path
* sets ESTABLISHED without a tcp_set_state() call. Until we know
* that for sure, match all early states to increase chances a
* timestamp is set.
* Note that this needs to be set before the PID filter later on,
* since the PID isn't reliable for these early stages, so we must
* save all timestamps and do the PID filter later when we can.
*/
u64 ts = bpf_ktime_get_ns();
birth.update(&sk, &ts);
}
// record PID & comm on SYN_SENT
if (state == TCP_SYN_SENT || state == TCP_LAST_ACK) {
// now we can PID filter, both here and a little later on for CLOSE
FILTER_PID
struct id_t me = {.pid = pid};
bpf_get_current_comm(&me.task, sizeof(me.task));
whoami.update(&sk, &me);
}
// capture birth time
if (state < TCP_FIN_WAIT1) {
// matching just ESTABLISHED may be sufficient, provided no code-path
// sets ESTABLISHED without a tcp_set_state() call. Until we know
// that for sure, match all early states to increase chances a
// timestamp is set.
u64 ts = bpf_ktime_get_ns();
birth.update(&sk, &ts);
}
if (state != TCP_CLOSE)
return 0;
// fetch possible cached data
struct id_t *mep;
mep = whoami.lookup(&sk);
// fetch PID and filter
if (mep == 0) {
pid = mep->pid;
FILTER_PID
}
// calculate lifespan
u64 *tsp, delta_us;
tsp = birth.lookup(&sk);
if (tsp == 0) {
whoami.delete(&sk); // may not exist
return 0; // missed create
}
delta_us = (bpf_ktime_get_ns() - *tsp) / 1000;
birth.delete(&sk);
// fetch possible cached data, and filter
struct id_t *mep;
mep = whoami.lookup(&sk);
if (mep != 0)
pid = mep->pid;
FILTER_PID
// get throughput stats. see tcp_get_info().
u64 rx_b = 0, tx_b = 0, sport = 0;
...
...
@@ -209,7 +214,6 @@ int kprobe__tcp_set_state(struct pt_regs *ctx, struct sock *sk, int state)
ipv6_events.perf_submit(ctx, &data6, sizeof(data6));
}
birth.delete(&sk);
if (mep != 0)
whoami.delete(&sk);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment