最近在创建netlink 的时候,发现其版本的修改太频繁了,查了一些资料,修改如下
转载请注明出处 [By SELinux+]
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) nl_sock = netlink_kernel_create( NETLINK_MKM, 0, recv_msg, THIS_MODULE); #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) nl_sock = netlink_kernel_create( NETLINK_MKM, 0, recv_msg, NULL, THIS_MODULE); #elif(LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) nl_sock = netlink_kernel_create(&init_net, NETLINK_MKM, 0, recv_msg, NULL, THIS_MODULE); #else { struct netlink_kernel_cfg cfg ={ .input = recv_msg, .groups = 1, }; #if(LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) nl_sock = netlink_kernel_create(&init_net, NETLINK_MKM,THIS_MODULE, &cfg); #else nl_sock = netlink_kernel_create(&init_net, NETLINK_MKM, &cfg); #endif } #endif