#if defined(__KERNEL__) /* Kernel code 영역 */ #else /* User side application 영역 */ #endif
#include <linux/version.h> #include <linux/kernel.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) /* Kernel version 4.15 이상에서 작동하는 코드 */ #else /* Kernel version 4.15 미만에서 작동하는 코드 */ #endif
#if IS_ENABLED(CONFIG_VLAN_8021Q) /* CONFIG_VLAN_8021Q 가 Kernel config에서 y 또는 m으로 설정되었음 */ #endif
printk(KERN_INFO "this dev's ifname is %s\n", netdev_name(dev));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) /* rcu ifalias */ const struct dev_ifalias *alias = rcu_dereference(dev->ifalias); if(alias) { printk(KERN_INFO "ifalias=%s\n", alias->ifalias); } #else if(dev->ifalias) { printk(KERN_INFO "ifalias=%s\n", dev->ifalias); } #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,7) /* netif_has_l3_rx_handler */ if(netif_has_l3_rx_handler(dev)) { /* IFF_L3MDEV_RX_HANDLER */ printk(KERN_INFO "this dev is l3mdev_rx\n"); } #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0) /* netif_is_failover/netif_is_failover_slave IFF_FAILOVER/IFF_FAILOVER_SLAVE */ if(netif_is_failover(dev)) { /* IFF_FAILOVER */ printk(KERN_INFO "this dev is failover\n"); } if(netif_is_failover_slave(dev)) { /* IFF_FAILOVER_SLAVE */ printk(KERN_INFO "this dev is failover_port\n"); } #endif
#if IS_ENABLED(CONFIG_VLAN_8021Q) if(is_vlan_dev(dev)) { /* IFF_802_1Q_VLAN */ printk(KERN_INFO "this dev is vlan\n"); } #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0) /* LLTX flag */ if(!!dev->lltx) { printk(KERN_INFO "this dev is lltx\n"); } #else if(!!(dev->features & NETIF_F_LLTX)) { printk(KERN_INFO "this dev is lltx\n"); } #endif