All of lore.kernel.org
 help / color / mirror / Atom feed
* l_genl_family_new() successfully returns if generic netlink family doesn't exist.
@ 2017-03-15 20:38 Othman, Ossama
  2017-03-16  3:08 ` Denis Kenzior
  0 siblings, 1 reply; 3+ messages in thread
From: Othman, Ossama @ 2017-03-15 20:38 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]

Hi,

The function l_genl_family_new() successfully returns if the desired
generic netlink family isn't available in the kernel.  For example,
suppose one does the following:

    struct l_genl_family * family = l_genl_family_new(genl, "foo");

If the "foo" generic netlink family doesn't exist in the kernel, for
whatever reason, l_genl_family_new() will still return a valid
pointer.  Is this the expected behavior?

It looks like some code exists in the implementation that would have
allowed one to be notified of such a problem by calling a
user-specified "vanished" watch callback.  Specifically,
l_genl_family_new() constructs a CTRL_ATTR_FAMILY_NAME generic netlink
message with a callback function get_family_callback().  The latter
detects and handles an error like so:

    error = l_genl_msg_get_error(msg);
        if (error < 0) {
            if (family->watch_vanished)
                family->watch_vanished(family->watch_data);
               return;
    }

A "vanished" watch never gets called since there is apparently no way
to set it beforehand.  Is that correct?

Thanks!
-Ossama

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: l_genl_family_new() successfully returns if generic netlink family doesn't exist.
  2017-03-15 20:38 l_genl_family_new() successfully returns if generic netlink family doesn't exist Othman, Ossama
@ 2017-03-16  3:08 ` Denis Kenzior
  2017-03-16 16:59   ` Othman, Ossama
  0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2017-03-16  3:08 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1782 bytes --]

Hi Ossama,

On 03/15/2017 03:38 PM, Othman, Ossama wrote:
> Hi,
>
> The function l_genl_family_new() successfully returns if the desired
> generic netlink family isn't available in the kernel.  For example,
> suppose one does the following:
>
>     struct l_genl_family * family = l_genl_family_new(genl, "foo");
>
> If the "foo" generic netlink family doesn't exist in the kernel, for
> whatever reason, l_genl_family_new() will still return a valid
> pointer.  Is this the expected behavior?

Yes.  The family detection is asynchronous, so the object is created, 
but you can't assume the family is valid until the appeared callback has 
been called.  This can be used to detect families that can come and go 
in the kernel.  E.g. via module loading / unloading.

>
> It looks like some code exists in the implementation that would have
> allowed one to be notified of such a problem by calling a
> user-specified "vanished" watch callback.  Specifically,
> l_genl_family_new() constructs a CTRL_ATTR_FAMILY_NAME generic netlink
> message with a callback function get_family_callback().  The latter
> detects and handles an error like so:
>
>     error = l_genl_msg_get_error(msg);
>         if (error < 0) {
>             if (family->watch_vanished)
>                 family->watch_vanished(family->watch_data);
>                return;
>     }
>
> A "vanished" watch never gets called since there is apparently no way
> to set it beforehand.  Is that correct?

You set it after-hand.  E.g.
l_genl_family_new();
l_genl_family_set_watches(family, family_appeared, family_vanished, ...);

This works because the underlying CTRL_CMD_GETFAMILY is not actually 
sent over the socket until the next event loop iteration.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: l_genl_family_new() successfully returns if generic netlink family doesn't exist.
  2017-03-16  3:08 ` Denis Kenzior
@ 2017-03-16 16:59   ` Othman, Ossama
  0 siblings, 0 replies; 3+ messages in thread
From: Othman, Ossama @ 2017-03-16 16:59 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]

Hi Denis,

On Wed, Mar 15, 2017 at 8:08 PM, Denis Kenzior <denkenz@gmail.com> wrote:
>> A "vanished" watch never gets called since there is apparently no way
>> to set it beforehand.  Is that correct?
>
>
> You set it after-hand.  E.g.
> l_genl_family_new();
> l_genl_family_set_watches(family, family_appeared, family_vanished, ...);
>
> This works because the underlying CTRL_CMD_GETFAMILY is not actually sent
> over the socket until the next event loop iteration.

I figured I was missing something, and just confirmed that this works
as you described.

Thanks for your patience with my ELL newbie questions, Denis!  :)
-Ossama

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-16 16:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 20:38 l_genl_family_new() successfully returns if generic netlink family doesn't exist Othman, Ossama
2017-03-16  3:08 ` Denis Kenzior
2017-03-16 16:59   ` Othman, Ossama

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.