LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   New for 2.6.31: net_device_ops structure. How do I set function pointers? (https://www.linuxquestions.org/questions/linux-software-2/new-for-2-6-31-net_device_ops-structure-how-do-i-set-function-pointers-762688/)

jhwilliams 10-17-2009 10:36 PM

New for 2.6.31: net_device_ops structure. How do I set function pointers?
 
Hello,

In kernel 2.6.31 it appears that a bunch of the function pointers to net_device operations disappeared from the net_device structure, and were put into a new net_device_ops structure which is a const member of the new copy of net_device.

...If netdev_ops is declared const (and unitialized) in net_device, how am I supposed to do things like:

Code:

mynet_device->netdev_ops->ndo_open = my_drivers_open_function();
Thanks for any ideas!!

jhwilliams 10-19-2009 02:17 AM

I was able to resolve this.

In the net_device struct (2.6.31+) the mew net_device_ops member is declared as:
Code:

const struct net_device_ops *netdev_ops;
As such, you can easily instantiate a net_device_ops struct with whatever function pointer assignments you desire, and then change the pointer reference to the new struct. Suppose that your net_device_opts struct is instantiated as "mynetdev_ops." The solution is:

Code:

mynet_dev->netdev_ops = &mynetdev_ops;
I felt silly having to reference this again, but this is relevant: http://blog.voidnish.com/?p=37


All times are GMT -5. The time now is 05:14 AM.