Unable to create netlink socket in centos
Thomas Haller
thaller at redhat.com
Wed Oct 29 01:16:50 PDT 2014
On Tue, 2014-10-28 at 16:53 +0530, Nikesh Kumar Mahalka wrote:
> Hi,
> I am using a CentOS Linux release 7.0.1406 (Core)
> I am using kernel version 3.10.0-123.el7.x86_64
>
> When i am creating a netlink socket,it is getting failed.
> int sock_fd = socket(PF_NETLINK, SOCK_RAW, 1)
> value of sock_fd is -1
did you check errno?
#include <errno.h>
sock_fd = socket(PF_NETLINK, SOCK_RAW, 1);
if (socket_fd == -1)
perror ("failed to create socket");
also, seems like your protocol parameter is wrong.
/usr/include/linux/netlink.h:#define NETLINK_ROUTE 0 /* Routing/device hook */
/usr/include/linux/netlink.h-#define NETLINK_UNUSED 1 /* Unused number
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
Note that this mailing list is for libnl library. And not using netlink
in general.
Also, try to consult the manual pages first.
man socket
man 7 netlink
good luck
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20141029/ab5204ef/attachment.sig>
More information about the libnl
mailing list