R&D/OS

kernel version check in C

sunshout 2015. 4. 29. 09:20

In a program or code, it is necessary to identify kernel version.

For example, vlan_tx_tag_get is changed to skb_vlan_tag_get in kernel 4.0.0.

We can do by using LINUX_VERSION_CODE and KERNEL_VERSION(a,b,c).


In these case, we need to switch to new API.


#include <linux/version.h>



#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) )
/* vlan_tx_xx functions got renamed to skb_vlan */
#define vlan_tx_tag_get skb_vlan_tag_get