All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump
@ 2021-09-17 20:23 Gokul Sivakumar
  2021-09-21 14:53 ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Gokul Sivakumar @ 2021-09-17 20:23 UTC (permalink / raw)
  To: netdev; +Cc: Gokul Sivakumar, David Ahern, stephen

The BPF program name is included when dumping the BPF program info and the
kernel only stores the first (BPF_PROG_NAME_LEN - 1) bytes for the program
name.

$ sudo ip link show dev docker0
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
    link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff
    prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited

The BPF program load time (ns since boottime), UID of the user who loaded
the program and the BTF ID are also included when dumping the BPF program
information when the user expects a detailed ip link info output.

$ sudo ip -details link show dev docker0
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
    link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535
    bridge forward_delay 1500 hello_time 200 max_age 2000 ageing_time 30000 stp_state 0 priority 32768 vlan_filt
ering 0 vlan_protocol 802.1Q bridge_id 8000.2:42:4c:df:a4:54 designated_root 8000.2:42:4c:df:a4:54 root_port 0 r
oot_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.00 tcn_timer    0.00 topology_chan
ge_timer    0.00 gc_timer  265.36 vlan_default_pvid 1 vlan_stats_enabled 0 vlan_stats_per_port 0 group_fwd_mask
0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast
_hash_elasticity 16 mcast_hash_max 4096 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_
interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query
_response_interval 1000 mcast_startup_query_interval 3124 mcast_stats_enabled 0 mcast_igmp_version 2 mcast_mld_v
ersion 1 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues
1 gso_max_size 65536 gso_max_segs 65535
    prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited load_time 2676682607316255 created_by_uid 0 btf_id 708

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
---
 lib/bpf_legacy.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
index 91086aa2..a0643000 100644
--- a/lib/bpf_legacy.c
+++ b/lib/bpf_legacy.c
@@ -203,12 +203,32 @@ int bpf_dump_prog_info(FILE *f, uint32_t id)
 	if (!ret && len) {
 		int jited = !!info.jited_prog_len;
 
+		if (info.name)
+			print_string(PRINT_ANY, "name", "name %s ", info.name);
+
 		print_string(PRINT_ANY, "tag", "tag %s ",
 			     hexstring_n2a(info.tag, sizeof(info.tag),
 					   tmp, sizeof(tmp)));
 		print_uint(PRINT_JSON, "jited", NULL, jited);
 		if (jited && !is_json_context())
 			fprintf(f, "jited ");
+
+		if (show_details) {
+			if (info.load_time) {
+				/* ns since boottime */
+				print_lluint(PRINT_ANY, "load_time",
+					     "load_time %llu ", info.load_time);
+
+				print_luint(PRINT_ANY, "created_by_uid",
+					    "created_by_uid %lu ",
+					    info.created_by_uid);
+			}
+
+			if (info.btf_id)
+				print_luint(PRINT_ANY, "btf_id", "btf_id %lu ",
+					    info.btf_id);
+		}
+
 		dump_ok = 1;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump
  2021-09-17 20:23 [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump Gokul Sivakumar
@ 2021-09-21 14:53 ` David Ahern
  2021-09-21 15:05   ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2021-09-21 14:53 UTC (permalink / raw)
  To: Gokul Sivakumar, netdev; +Cc: stephen

On 9/17/21 2:23 PM, Gokul Sivakumar wrote:
> The BPF program name is included when dumping the BPF program info and the
> kernel only stores the first (BPF_PROG_NAME_LEN - 1) bytes for the program
> name.
> 
> $ sudo ip link show dev docker0
> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff
>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited
> 
> The BPF program load time (ns since boottime), UID of the user who loaded
> the program and the BTF ID are also included when dumping the BPF program
> information when the user expects a detailed ip link info output.
> 
> $ sudo ip -details link show dev docker0
> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535
>     bridge forward_delay 1500 hello_time 200 max_age 2000 ageing_time 30000 stp_state 0 priority 32768 vlan_filt
> ering 0 vlan_protocol 802.1Q bridge_id 8000.2:42:4c:df:a4:54 designated_root 8000.2:42:4c:df:a4:54 root_port 0 r
> oot_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.00 tcn_timer    0.00 topology_chan
> ge_timer    0.00 gc_timer  265.36 vlan_default_pvid 1 vlan_stats_enabled 0 vlan_stats_per_port 0 group_fwd_mask
> 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast
> _hash_elasticity 16 mcast_hash_max 4096 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_
> interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query
> _response_interval 1000 mcast_startup_query_interval 3124 mcast_stats_enabled 0 mcast_igmp_version 2 mcast_mld_v
> ersion 1 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues
> 1 gso_max_size 65536 gso_max_segs 65535
>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited load_time 2676682607316255 created_by_uid 0 btf_id 708

what kernel is this? I was not aware bridge devices support XDP and do
not see that support in net-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump
  2021-09-21 14:53 ` David Ahern
@ 2021-09-21 15:05   ` Toke Høiland-Jørgensen
  2021-09-21 15:14     ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-09-21 15:05 UTC (permalink / raw)
  To: David Ahern, Gokul Sivakumar, netdev; +Cc: stephen

David Ahern <dsahern@gmail.com> writes:

> On 9/17/21 2:23 PM, Gokul Sivakumar wrote:
>> The BPF program name is included when dumping the BPF program info and the
>> kernel only stores the first (BPF_PROG_NAME_LEN - 1) bytes for the program
>> name.
>> 
>> $ sudo ip link show dev docker0
>> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff
>>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited
>> 
>> The BPF program load time (ns since boottime), UID of the user who loaded
>> the program and the BTF ID are also included when dumping the BPF program
>> information when the user expects a detailed ip link info output.
>> 
>> $ sudo ip -details link show dev docker0
>> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535
>>     bridge forward_delay 1500 hello_time 200 max_age 2000 ageing_time 30000 stp_state 0 priority 32768 vlan_filt
>> ering 0 vlan_protocol 802.1Q bridge_id 8000.2:42:4c:df:a4:54 designated_root 8000.2:42:4c:df:a4:54 root_port 0 r
>> oot_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.00 tcn_timer    0.00 topology_chan
>> ge_timer    0.00 gc_timer  265.36 vlan_default_pvid 1 vlan_stats_enabled 0 vlan_stats_per_port 0 group_fwd_mask
>> 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast
>> _hash_elasticity 16 mcast_hash_max 4096 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_
>> interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query
>> _response_interval 1000 mcast_startup_query_interval 3124 mcast_stats_enabled 0 mcast_igmp_version 2 mcast_mld_v
>> ersion 1 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues
>> 1 gso_max_size 65536 gso_max_segs 65535
>>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited load_time 2676682607316255 created_by_uid 0 btf_id 708
>
> what kernel is this? I was not aware bridge devices support XDP and do
> not see that support in net-next.

It's loaded in generic mode (note 'xdpgeneric') :)

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump
  2021-09-21 15:05   ` Toke Høiland-Jørgensen
@ 2021-09-21 15:14     ` David Ahern
  0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2021-09-21 15:14 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Gokul Sivakumar, netdev; +Cc: stephen

On 9/21/21 9:05 AM, Toke Høiland-Jørgensen wrote:
> David Ahern <dsahern@gmail.com> writes:
> 
>> On 9/17/21 2:23 PM, Gokul Sivakumar wrote:
>>> The BPF program name is included when dumping the BPF program info and the
>>> kernel only stores the first (BPF_PROG_NAME_LEN - 1) bytes for the program
>>> name.
>>>
>>> $ sudo ip link show dev docker0
>>> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>>>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff
>>>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited
>>>
>>> The BPF program load time (ns since boottime), UID of the user who loaded
>>> the program and the BTF ID are also included when dumping the BPF program
>>> information when the user expects a detailed ip link info output.
>>>
>>> $ sudo ip -details link show dev docker0
>>> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 xdpgeneric qdisc noqueue state UP mode DEFAULT group default
>>>     link/ether 02:42:4c:df:a4:54 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 65535
>>>     bridge forward_delay 1500 hello_time 200 max_age 2000 ageing_time 30000 stp_state 0 priority 32768 vlan_filt
>>> ering 0 vlan_protocol 802.1Q bridge_id 8000.2:42:4c:df:a4:54 designated_root 8000.2:42:4c:df:a4:54 root_port 0 r
>>> oot_path_cost 0 topology_change 0 topology_change_detected 0 hello_timer    0.00 tcn_timer    0.00 topology_chan
>>> ge_timer    0.00 gc_timer  265.36 vlan_default_pvid 1 vlan_stats_enabled 0 vlan_stats_per_port 0 group_fwd_mask
>>> 0 group_address 01:80:c2:00:00:00 mcast_snooping 1 mcast_router 1 mcast_query_use_ifaddr 0 mcast_querier 0 mcast
>>> _hash_elasticity 16 mcast_hash_max 4096 mcast_last_member_count 2 mcast_startup_query_count 2 mcast_last_member_
>>> interval 100 mcast_membership_interval 26000 mcast_querier_interval 25500 mcast_query_interval 12500 mcast_query
>>> _response_interval 1000 mcast_startup_query_interval 3124 mcast_stats_enabled 0 mcast_igmp_version 2 mcast_mld_v
>>> ersion 1 nf_call_iptables 0 nf_call_ip6tables 0 nf_call_arptables 0 addrgenmode eui64 numtxqueues 1 numrxqueues
>>> 1 gso_max_size 65536 gso_max_segs 65535
>>>     prog/xdp id 789 name xdp_drop_func tag 57cd311f2e27366b jited load_time 2676682607316255 created_by_uid 0 btf_id 708
>>
>> what kernel is this? I was not aware bridge devices support XDP and do
>> not see that support in net-next.
> 
> It's loaded in generic mode (note 'xdpgeneric') :)
> 

ah, thanks for the reminder. I keep forgetting about xdpgeneric (brain
is pretending it does not exist ?!? :-)).

There's a lot of distance -- and characters -- between 'xdpgeneric' and
the 'prog/xdp' line. :-(


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-21 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 20:23 [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump Gokul Sivakumar
2021-09-21 14:53 ` David Ahern
2021-09-21 15:05   ` Toke Høiland-Jørgensen
2021-09-21 15:14     ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.