Skip to content

Commit 3d4e206

Browse files
committed
fix: add bpf_field_exists check for netdev_hw
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
1 parent dff4c54 commit 3d4e206

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bpf/netdev_hw.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ int BPF_KPROBE(carrier_down_count_show, struct device *dev)
3030
{
3131
struct net_device *netdev = container_of(dev, struct net_device, dev);
3232
u32 key = BPF_CORE_READ(netdev, ifindex);
33-
u64 value = BPF_CORE_READ(netdev, rx_dropped.counter);
33+
u64 value = 0;
34+
35+
if (bpf_core_field_exists(netdev->rx_dropped))
36+
value = BPF_CORE_READ(netdev, rx_dropped.counter);
3437

3538
bpf_map_update_elem(&rx_sw_dropped_stats, &key, &value, COMPAT_BPF_ANY);
3639
return 0;

0 commit comments

Comments
 (0)