Subject: Re: Netlink for kernel<->user space communication?

From: Arvid Brodin <[email-masked]>
Date: Mon, 7 May 2012 18:43:23 +0000

On Tue, 24 Apr 2012 16:57:55 -0700
Stephen Hemminger <shemminger@xxxxxxxxxx> wrote:
> On Tue, 24 Apr 2012 23:52:34 +0000
> Arvid Brodin <Arvid.Brodin@xxxxxxxx> wrote:
> 
>> Hi.
>> 
>> I'm writing a kernel driver for the HSR protocol, a standard for high availability
>> networks. I want to send messages from the kernel to user space about broken network
>> links. I also want user space to be able to ask the kernel about its view of the status of
>> nodes on the network.
>> 
>> Netlink seems like a good tool for this. (Is it?)
> 
> Yes.
> 
>> But do I use raw netlink? (Described here: http://www.linuxjournal.com/article/7356 - but
>> this seems a bit out of date, the kernel API description differs from today's kernel
>> implementation.)
> 
> No. Your driver probably looks like a device so you should be
> using rtnetlink messages.

I'm already using rtnetlink messages to add and remove my device, which works fine (see
e.g. http://www.spinics.net/lists/netdev/msg192817.html - although I didn't think it
meaningful to include the iproute2 patch here, until the kernel part is ready).

The protocol specifies transmission of "supervision frames" every 2 seconds, e.g. to check
link integrity. Every such frame should be received from two directions in the ring - if
only one is received, then there is a link problem.

I'd like to notify user space about every such occurence. Is there a rtnetlink message
type that fits this? The stuff in rtnetlink.h seems to be mostly concerned with specific
user space commands (there is something called RTNLGRP_NOTIFY but I couldn't find any
instances of it being used in the kernel, nor any documentation).

>> Or do I use the "Kernel Connector" (Documentation/connector/connector.txt)?
> no.

Your reply didn't reach me for some reason - I found it just yesterday on spinics - and in
the meantime I've implemented the notification using the connector protocol... :-|

-- 
Arvid Brodin
Enea Services Stockholm AB - since February 16 a part of Xdin in the Alten Group. Soon we
will be working under the common brand name Xdin. Read more at www.xdin.com.