On Thu, 2016-06-23 at 15:25 +0200, Alfonso Sanchez-Beato wrote:

Hi again.



> Add statistics interface to all device instances. When active, the
> properties of this interface are refreshed whenever there is network
> activity for the device.
> +static int
> +send_getlink (NMDeviceStatistics *self)
> +{
> +     struct rtnl_request req = { 0 };
> +     struct sockaddr_nl addr = { 0 };
> +     int sk;
> +
> +     req.hdr.nlmsg_len = RTNL_REQUEST_SIZE;
> +     req.hdr.nlmsg_type = RTM_GETLINK;
> +     req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
> +     req.hdr.nlmsg_pid = 0;
> +     req.hdr.nlmsg_seq = self->request_seq++;
> +     req.msg.rtgen_family = AF_UNSPEC;
> +
> +     _LOGD ("Sending %s len %d type %d flags 0x%04x seq %d",
> +            type_to_string (req.hdr.nlmsg_type),
> +            req.hdr.nlmsg_len, req.hdr.nlmsg_type,
> +            req.hdr.nlmsg_flags, req.hdr.nlmsg_seq);
> +
> +     sk = g_io_channel_unix_get_fd(self->channel);
> +
> +     addr.nl_family = AF_NETLINK;
> +
> +     self->req_pending = TRUE;
> +
> +     return sendto (sk, &req, req.hdr.nlmsg_len, 0,
> +                    (struct sockaddr *) &addr, sizeof (addr));


Hm, rethinking...

This message does not look much different from what NMLinuxPlatform
sends when requesting one link [1] or all links [2].


[1] 
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/src/platform/nm-linux-platform.c#n3524
[2] 
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/src/platform/nm-linux-platform.c#n3561


NMLinuxPlatform already has a netlink socket open, it sends very similar 
get-requests,
does parsing of the RTM_NEWLINK and caches the result in a NMPObjectLink 
instance.

I think we should extend platform instead to 

If you need to poll, you can call nm_platform_link_refresh().


Thomas

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to