1

I have written a kernel module where I want to send interface up/down notifications to the user space program. I have assigned the message group as RTMGRP_LINK and also included linux/rtnetlink.h header file. But still when I compile the module I receive the following error:

abc.c: In function âevent_handlerâ:
abc.c:63: error: âRTMGRP_LINKâ undeclared (first use in this function)
abc.c:63: error: (Each undeclared identifier is reported only once
abc.c:63: error: for each function it appears in.)

Can somebody suggest why?

iqstatic
  • 2,322
  • 3
  • 21
  • 39
  • 2
    RTMGRP_LINK macro is defined only to be used by user-mode programs. I could see that it is defined under "#ifndef \_\_KERNEL\_\_" macro – Icarus3 Jul 14 '14 at 09:57
  • @Icarus3 Correct. After going through the kernel header once again I observed that RTMGRP_LINK is confined to user-space programs only as you said. For kernel modules RTNLGRP_LINK is to be used. – iqstatic Jul 14 '14 at 10:54

1 Answers1

1

After going through the linux/rtnetlink.h header. I observed that RTMGRP_LINK is defined under #ifndef __KERNEL__ which means that it can only be used by user-space programs. For Kernel modules RTNLGRP_LINK should be used to use the NETLINK_ROUTE family of Netlink Sockets for communication.

iqstatic
  • 2,322
  • 3
  • 21
  • 39