Coder Social home page Coder Social logo

Comments (5)

alessandrod avatar alessandrod commented on June 8, 2024

This is a bug in TcContext, it should return the skb.pid and not use the helper. Want to try to make a patch? 😊

from aya.

emanuele-em avatar emanuele-em commented on June 8, 2024

@alessandrod sure! You can assign the issue if you want

from aya.

alessandrod avatar alessandrod commented on June 8, 2024

As per discord conversation, I was wrong, there's no way to directly get the pid from an egress tc program. The only way is to correlate local_port with a pid manually.

from aya.

gotoolkits avatar gotoolkits commented on June 8, 2024

use aya_bpf::helpers::bpf_get_current_pid_tgid
...
let pid = bpf_get_current_pid_tgid() as u32;

The same error has occurred. May I ask what the reason is?

15: (15) if r1 == 0x7 goto pc-8
R0_w=inv0 R1_w=inv(id=0) R2_w=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R6_w=ctx(id=0,off=0,imm=0) R7_w=inv2 R10=fp0 fp-16=??mmmmmm fp-24=mmmmmmmm
16: (55) if r1 != 0x8 goto pc+62
R0=inv0 R1=inv8 R2=inv(id=0,umax_value=255,var_off=(0x0; 0xff)) R6=ctx(id=0,off=0,imm=0) R7=inv2 R10=fp0 fp-16=??mmmmmm fp-24=mmmmmmmm
17: (85) call bpf_get_current_pid_tgid#14
unknown func bpf_get_current_pid_tgid#14

verification time 48 usec
stack depth 24
processed 18 insns (limit 1000000) max_states_per_insn 0 total_states 2 peak_states 2 mark_read 1

from aya.

gotoolkits avatar gotoolkits commented on June 8, 2024

Oh, I misunderstood. You can use TracepointContext to correct it.

#[tracepoint]
pub fn tracepoint_demo(ctx: TracePointContext) -> u32 {
match try_tracepoint_demo(ctx) {
Ok(ret) => ret,
Err(ret) => ret,
}
}

fn try_tracepoint_demo(ctx: TracePointContext) -> Result<u32, u32> {
let pid = ctx.pid();
info!(&ctx, "tracepoint inet_sock_set_state called, pid: {}",pid);
Ok(0)
}

from aya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.