Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:35:17+00:00 2026-05-24T11:35:17+00:00

i’m trying to register a new net_device in linux…i can alloc and register it

  • 0

i’m trying to register a new net_device in linux…i can alloc and register it correctly and ifconfig shows it. The problem arrives when i try to put the interface up:

ifconfig my_dev up

A kernel freeze occurs…the problem is present only on x86 machines and i can’t figure out the reason…on a pcc machine all works well. The code is very simple:

static struct net_device *my_dev;

static int veth_dev_init(struct net_device *dev);
static int veth_open(struct net_device *dev);
static int veth_close(struct net_device *dev);
static int veth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);

static struct veth_priv
{
   ...
};

static struct net_device_ops veth_ops =
{
  .ndo_init = veth_dev_init,
  .ndo_open = veth_open,
  .ndo_stop = veth_close,
  .ndo_do_ioctl = veth_ioctl
};

static int __init veth_init()
{
  my_dev = alloc_netdev(sizeof(struct veth_priv), "my_dev", ether_setup);
  if (my_dev == NULL)
    return -ENOMEM;

  my_dev->netdev_ops = &veth_ops;

  register_netdev(my_dev);
  return 0;
}

static void __exit veth_exit()
{
  unregister_netdev(my_dev);
  free_netdev(my_dev);
}

module_init(veth_init);
module_exit(veth_exit);

The first four functions veth_dev_init, veth_open, veth_close and veth_ioctl simply return 0.
Maybe is there a missing field in veth_ops structure?

Thank you all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:35:18+00:00Added an answer on May 24, 2026 at 11:35 am

    Yea, you missed one element in struct net_device_ops

    Add .ndo_start_xmit also, And the function must return NETDEV_TX_OK or NETDEV_TX_BUSY.

    use as follows

    static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
    {
        return NETDEV_TX_OK;
    }
    

    And also change the open as

    static int veth_open(struct net_device *dev)
    {
         memcpy(dev->dev_addr, "\0ABCD0", ETH_ALEN);
         netif_start_queue(dev);
         return 0;
    }
    

    Then in veth_ops

    static struct net_device_ops veth_ops = {
         .ndo_init         = veth_dev_init,
         .ndo_open         = veth_open,
         .ndo_stop         = veth_close,
         .ndo_start_xmit   = veth_xmit,
         .ndo_do_ioctl     = veth_ioctl,
    };
    

    Then after inserting the module

    give ifconfig my_dev 192.168.10.98 …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.