* netlink stats: Ability to get stats for a single device?
@ 2010-10-26 19:31 Ben Greear
2010-10-26 19:35 ` Eric Dumazet
2010-10-26 19:38 ` David Miller
0 siblings, 2 replies; 7+ messages in thread
From: Ben Greear @ 2010-10-26 19:31 UTC (permalink / raw)
To: NetDev
From what I can tell, it's impossible to request stats for a single
network device via netlink. When you have thousands of interfaces,
this means a lot of wasted effort to get stats for a particular
device.
Am I missing something, or do I just need to write up a patch
to have netlink pay attention to the ifindex?
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 19:31 netlink stats: Ability to get stats for a single device? Ben Greear
@ 2010-10-26 19:35 ` Eric Dumazet
2010-10-26 19:38 ` David Miller
1 sibling, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2010-10-26 19:35 UTC (permalink / raw)
To: Ben Greear; +Cc: NetDev
Le mardi 26 octobre 2010 à 12:31 -0700, Ben Greear a écrit :
> From what I can tell, it's impossible to request stats for a single
> network device via netlink. When you have thousands of interfaces,
> this means a lot of wasted effort to get stats for a particular
> device.
>
> Am I missing something, or do I just need to write up a patch
> to have netlink pay attention to the ifindex?
>
Its already done
rtnl_register(PF_UNSPEC, RTM_GETLINK, rtnl_getlink, rtnl_dump_ifinfo);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 19:31 netlink stats: Ability to get stats for a single device? Ben Greear
2010-10-26 19:35 ` Eric Dumazet
@ 2010-10-26 19:38 ` David Miller
2010-10-26 19:56 ` Eric Dumazet
1 sibling, 1 reply; 7+ messages in thread
From: David Miller @ 2010-10-26 19:38 UTC (permalink / raw)
To: greearb; +Cc: netdev
From: Ben Greear <greearb@candelatech.com>
Date: Tue, 26 Oct 2010 12:31:12 -0700
> Am I missing something, or do I just need to write up a patch
> to have netlink pay attention to the ifindex?
Setting the ->ifi_index or IFLA_IFNAME attribute values appropriately
in the getlink request doesn't work?
That should give you back, amonst other things, the rtnl_link_stats
for the device in the netlink response.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 19:38 ` David Miller
@ 2010-10-26 19:56 ` Eric Dumazet
2010-10-26 20:29 ` Ben Greear
0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2010-10-26 19:56 UTC (permalink / raw)
To: David Miller; +Cc: greearb, netdev
Le mardi 26 octobre 2010 à 12:38 -0700, David Miller a écrit :
> From: Ben Greear <greearb@candelatech.com>
> Date: Tue, 26 Oct 2010 12:31:12 -0700
>
> > Am I missing something, or do I just need to write up a patch
> > to have netlink pay attention to the ifindex?
>
> Setting the ->ifi_index or IFLA_IFNAME attribute values appropriately
> in the getlink request doesn't work?
>
> That should give you back, amonst other things, the rtnl_link_stats
> for the device in the netlink response.
> --
Yep, it should be easy to change iproute2 to not ask a full dump
in ip/ipaddress.c :
if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK) < 0) ...
and instead use rtnl_send() or something like that, if user provided one
specific interface name (or index)
ip link show dev eth0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 19:56 ` Eric Dumazet
@ 2010-10-26 20:29 ` Ben Greear
2010-10-26 20:37 ` Eric Dumazet
0 siblings, 1 reply; 7+ messages in thread
From: Ben Greear @ 2010-10-26 20:29 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
On 10/26/2010 12:56 PM, Eric Dumazet wrote:
> Le mardi 26 octobre 2010 à 12:38 -0700, David Miller a écrit :
>> From: Ben Greear<greearb@candelatech.com>
>> Date: Tue, 26 Oct 2010 12:31:12 -0700
>>
>>> Am I missing something, or do I just need to write up a patch
>>> to have netlink pay attention to the ifindex?
>>
>> Setting the ->ifi_index or IFLA_IFNAME attribute values appropriately
>> in the getlink request doesn't work?
>>
>> That should give you back, amonst other things, the rtnl_link_stats
>> for the device in the netlink response.
>> --
>
> Yep, it should be easy to change iproute2 to not ask a full dump
> in ip/ipaddress.c :
>
> if (rtnl_wilddump_request(&rth, preferred_family, RTM_GETLINK)< 0) ...
>
> and instead use rtnl_send() or something like that, if user provided one
> specific interface name (or index)
>
> ip link show dev eth0
I'm trying to craft my own netlink message...basically:
memset(&snl, 0, sizeof(snl));
snl.nl_family = AF_NETLINK;
snl.nl_pid = 0;
snl.nl_groups = 0;
memset(&buffer, 0, sizeof(buffer));
nlh->nlmsg_type = msg_type;
nlh->nlmsg_flags = NLM_F_MATCH|NLM_F_REQUEST;
static unsigned int nl_seqno = 1;
nlh->nlmsg_seq = nl_seqno++;
nlh->nlmsg_pid = nl_pid;
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(*ifinfomsg));
ifinfomsg = (struct ifinfomsg*)(NLMSG_DATA(nlh));
ifinfomsg->ifi_family = AF_UNSPEC;
ifinfomsg->ifi_type = IFLA_UNSPEC;
ifinfomsg->ifi_index = if_index;
ifinfomsg->ifi_flags = 0;
ifinfomsg->ifi_change = 0xffffffff;
It's possible that I'm somehow messing this up. But, looking at the
static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
method, I cannot see how it would bail out properly after a single dev
has been processed, either.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 20:29 ` Ben Greear
@ 2010-10-26 20:37 ` Eric Dumazet
2010-10-26 20:43 ` Ben Greear
0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2010-10-26 20:37 UTC (permalink / raw)
To: Ben Greear; +Cc: David Miller, netdev
Le mardi 26 octobre 2010 à 13:29 -0700, Ben Greear a écrit :
> I'm trying to craft my own netlink message...basically:
>
> memset(&snl, 0, sizeof(snl));
> snl.nl_family = AF_NETLINK;
> snl.nl_pid = 0;
> snl.nl_groups = 0;
>
> memset(&buffer, 0, sizeof(buffer));
> nlh->nlmsg_type = msg_type;
> nlh->nlmsg_flags = NLM_F_MATCH|NLM_F_REQUEST;
dont use F_MATCH : check net/core/rtnetlink.c
vi +1660 net/core/rtnetlink.c
You _dont_ want to call 'dumpit' : so dont use a bit present in
NLM_F_DUMP at all:
if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
struct sock *rtnl;
rtnl_dumpit_func dumpit;
dumpit = rtnl_get_dumpit(family, type);
if (dumpit == NULL)
return -EOPNOTSUPP;
__rtnl_unlock();
rtnl = net->rtnl;
err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
rtnl_lock();
return err;
}
You want instead to call the 'doit' handler (one device only)
doit = rtnl_get_doit(family, type);
if (doit == NULL)
return -EOPNOTSUPP;
return doit(skb, nlh, (void *)&rta_buf[0]);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: netlink stats: Ability to get stats for a single device?
2010-10-26 20:37 ` Eric Dumazet
@ 2010-10-26 20:43 ` Ben Greear
0 siblings, 0 replies; 7+ messages in thread
From: Ben Greear @ 2010-10-26 20:43 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
On 10/26/2010 01:37 PM, Eric Dumazet wrote:
> Le mardi 26 octobre 2010 à 13:29 -0700, Ben Greear a écrit :
>
>> I'm trying to craft my own netlink message...basically:
>>
>> memset(&snl, 0, sizeof(snl));
>> snl.nl_family = AF_NETLINK;
>> snl.nl_pid = 0;
>> snl.nl_groups = 0;
>>
>> memset(&buffer, 0, sizeof(buffer));
>> nlh->nlmsg_type = msg_type;
>> nlh->nlmsg_flags = NLM_F_MATCH|NLM_F_REQUEST;
>
> dont use F_MATCH : check net/core/rtnetlink.c
>
> vi +1660 net/core/rtnetlink.c
>
> You _dont_ want to call 'dumpit' : so dont use a bit present in
> NLM_F_DUMP at all:
That was exactly my problem. It works as expected with that NLM_F_MATCH
removed.
Thanks!
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-10-26 20:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-26 19:31 netlink stats: Ability to get stats for a single device? Ben Greear
2010-10-26 19:35 ` Eric Dumazet
2010-10-26 19:38 ` David Miller
2010-10-26 19:56 ` Eric Dumazet
2010-10-26 20:29 ` Ben Greear
2010-10-26 20:37 ` Eric Dumazet
2010-10-26 20:43 ` Ben Greear
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).