I'm experimenting with network drivers in a qemu VM running Ubuntu 16.04.1. uname -r gives 4.4.0-31-generic as the kernel version.
In linux/netdevice.h for that kernel version, I found the comment
"@netdev_ops: Includes several pointers to callbacks, if one wants to override the ndo_*() functions"
However, in my code, an assignment such as dev->netdev_ops->ndo_open = netmod_open (where netmod_open is the open method in my own driver) gives the compiler error:
assignment of member 'ndo_open' in read-only object
Further, netdev_ops is declared as const in the source:
const struct net_device_ops *netdev_ops;
How can I "override the ndo_*() functions" if the struct containing their pointers is const?
struct net_device_opsand then assigndev->netdev_opsthe address of thatstruct. So in general I need to learn more about how data structures are passed around in the kernel. Any links to such info would be appreciated. It seems like most of the tutorials I find have outdated kernel APIs.