[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210917202338.1810837-1-gokulkumar792@gmail.com>
Date: Sat, 18 Sep 2021 01:53:38 +0530
From: Gokul Sivakumar <gokulkumar792@...il.com>
To: netdev@...r.kernel.org
Cc: Gokul Sivakumar <gokulkumar792@...il.com>,
David Ahern <dsahern@...il.com>, stephen@...workplumber.org
Subject: [PATCH iproute2-next] lib: bpf_legacy: add prog name, load time, uid and btf id in prog info dump
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@...il.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
Powered by blists - more mailing lists