From: Yonghong Song <yhs@fb.com>
To: Andrey Ignatov <rdna@fb.com>
Cc: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
<kernel-team@fb.com>
Subject: Re: [PATCH v2 bpf-next 3/5] bpf: Introduce bpf_sk_{,ancestor_}cgroup_id helpers
Date: Thu, 14 May 2020 10:24:51 -0700 [thread overview]
Message-ID: <6cc5f0a5-b6af-e74f-2266-d5c85a0205f7@fb.com> (raw)
In-Reply-To: <20200514165549.GA22366@rdna-mbp>
On 5/14/20 9:55 AM, Andrey Ignatov wrote:
> Yonghong Song <yhs@fb.com> [Thu, 2020-05-14 08:16 -0700]:
>> On 5/13/20 2:38 PM, Andrey Ignatov wrote:
>
>>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>>> index bfb31c1be219..e3cbc2790cdf 100644
>>> --- a/include/uapi/linux/bpf.h
>>> +++ b/include/uapi/linux/bpf.h
>>> @@ -3121,6 +3121,37 @@ union bpf_attr {
>>> * 0 on success, or a negative error in case of failure:
>>> *
>>> * **-EOVERFLOW** if an overflow happened: The same object will be tried again.
>>> + *
>>> + * u64 bpf_sk_cgroup_id(struct bpf_sock *sk)
>>> + * Description
>>> + * Return the cgroup v2 id of the socket *sk*.
>>> + *
>>> + * *sk* must be a non-**NULL** pointer that was returned from
>>> + * **bpf_sk_lookup_xxx**\ (). The format of returned id is same
>>
>> It should also include bpf_skc_lookup_tcp(), right?
>
> From what I see it should not.
>
> cgroup id is available from sk->sk_cgrp_data that is a field of `struct
> sock', i.e. `struct sock_common' doesn't have this field.
>
> bpf_skc_lookup_tcp() returns RET_PTR_TO_SOCK_COMMON_OR_NULL and it can
> be for example `struct request_sock` that has only `struct sock_common`
> member, i.e. it doesn't have cgroup id.
So you can do bpf_skc_lookup_tcp() and then do tcp_sock() to get a full
socket which will have cgroup_id. I think maybe this is the reason you
added bpf_skc_lookup_tcp() in patch #1, right?
If this is the case, maybe rewording a little bit for the description
to include bpf_skc_lookup_tcp() + bpf_tcp_sock() as another input
to bpf_sk_cgroup_id()?
next prev parent reply other threads:[~2020-05-14 17:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-13 21:38 [PATCH v2 bpf-next 0/5] bpf: sk lookup, cgroup id helpers in cgroup skb Andrey Ignatov
2020-05-13 21:38 ` [PATCH v2 bpf-next 1/5] bpf: Allow sk lookup " Andrey Ignatov
2020-05-14 15:06 ` Yonghong Song
2020-05-13 21:38 ` [PATCH v2 bpf-next 2/5] bpf: Allow skb_ancestor_cgroup_id helper " Andrey Ignatov
2020-05-14 15:06 ` Yonghong Song
2020-05-13 21:38 ` [PATCH v2 bpf-next 3/5] bpf: Introduce bpf_sk_{,ancestor_}cgroup_id helpers Andrey Ignatov
2020-05-14 15:16 ` Yonghong Song
2020-05-14 16:55 ` Andrey Ignatov
2020-05-14 17:24 ` Yonghong Song [this message]
2020-05-14 18:01 ` Andrey Ignatov
2020-05-14 18:15 ` Yonghong Song
2020-05-13 21:38 ` [PATCH v2 bpf-next 4/5] selftests/bpf: Add connect_fd_to_fd, connect_wait net helpers Andrey Ignatov
2020-05-14 15:56 ` Yonghong Song
2020-05-14 17:42 ` Andrey Ignatov
2020-05-13 21:38 ` [PATCH v2 bpf-next 5/5] selftests/bpf: Test for sk helpers in cgroup skb Andrey Ignatov
2020-05-14 16:07 ` Yonghong Song
2020-05-14 17:46 ` Andrey Ignatov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6cc5f0a5-b6af-e74f-2266-d5c85a0205f7@fb.com \
--to=yhs@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=rdna@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox