Re: CORE feature request: support checking field type directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Daniel,

On Tue, Jan 17, 2023 at 2:22 PM Daniel Müller <deso@xxxxxxxxxx> wrote:
>
> I apologize for the response. Somehow Andrii's reply and the entire thread was
> lost on me. Anyway, glad it's working for you.
>

Andrii helped me get it work. TYPE_MATCHES is a solution to my
problem. Now I have a better understanding on how
bpf_core_type_matches works.

For the record, the following works on my old kernel and new kernels:

struct rw_semaphore___old {
        struct task_struct *owner;
};

struct rw_semaphore___new {
        atomic_long_t owner;
};

u64 owner;
if (bpf_core_type_matches(struct rw_semaphore___old)) { /* owner is
task_struct pointer */
        struct rw_semaphore___old *old = (struct rw_semaphore___old *)sem;
        owner = (u64)sem->owner;
} else if (bpf_core_type_matches(struct rw_semaphore___new)) { /*
owner field is atomic_long_t */
        struct rw_semaphore___new *new = (struct rw_semaphore___new *)sem;
        owner = (u64)new->owner.counter;
}

Thanks for your response!
Hao




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux