开发者

How can I access network device counters such as tx/rcv packets/bytes from kernel code?

开发者 https://www.devze.com 2023-01-04 10:59 出处:网络
I\'m writing a driver and I want to get network counters of some device within it. What data str开发者_JAVA百科ucture holds that information and how can I access it?First, use dev_get_by_name to get a

I'm writing a driver and I want to get network counters of some device within it. What data str开发者_JAVA百科ucture holds that information and how can I access it?


First, use dev_get_by_name to get a pointer to the struct net_device of the interface.

Then, the net_device structure has a pointer to the stats function, which is declared as:

struct net_device_stats *(*get_stats)(struct net_device *dev);

The net_device_stats structure contains the information you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消