Re: Generic Netlink

From: Paul Moore
Date: Thu May 31 2007 - 10:53:10 EST


On Thursday, May 31 2007 5:34:30 am Edouard Thuleau wrote:
> I try to use this example source (netlabel) but it doesn't work.
> I use the svn version of libnl and if i try the same code of netlabel
> I've a segment fault on the function "nlmsg_append", so I initiate the
> nl_msg with "nlmsg_alloc". The kernel code is lunch correctly and the
> user code works but nothing happens.

Hi Edouard,

I probably should have been a bit more clear in my earlier emails, I
apologize. The latest released version of NetLabel Tools, version 0.17, only
provides support for libnl versions 1.0-pre5 and 1.0-pre6; with 1.0-pre5 used
be default. It is not uncommon for Thomas to change the libnl API between
releases so I'm not surprised that you have run into problems with the latest
snapshot of libnl from the SVN repository. My suggestion is to try building
NetLabel tools, either version 0.17 or the latest from SVN, against libnl
version 1.0-pre5 as I personally use this and know it works.

I just took a quick look at the code you attached and I have a few comments.
See below:

>>> Snippet from genl_kernel.c
int cac_discover(struct sk_buff *skb, struct genl_info *info)
{
struct sk_buff *msg;
void *hdr;
int err;

printk("Discover reçu !!!\n");
msg = nlmsg_new(NLMSG_GOODSIZE);
>>> This should probably be nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL) if you are
>>> compiling this in the kernel
if (!msg)
return -ENOBUFS;

As far as the userspace code, it looks like you just copied most of it from
libnetlabel (part of NetLabel Tools) so no real comments from me other than
the fact that it's a good idea to preserve the copyright notice taken from
the original work (GPL in this case) when doing so - it keeps the original
developer happy ;)

--
paul moore
linux security @ hp
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html