Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Suse Enterprise Server: ifconfig does not call my Network Device 's open function

    Hello Experts,

    I have a little Network Device driver. I can insert it into the Kernel (2.6.27-5) of Suse Enterprise Server 11 without problems but I get these messages in /var/log/messages:

    "ifup: Test"
    "ifup: No configuration found for Test".

    Then when I try to assign the IP address to it using "ifconfig Test", the open function of my Network Device driver does not get called. Instead I get this error message "SIOCSIFFLAGS: Cannot assign requested address". Do I make any mistake in registering the Device Driver? This works fine on readhat 5.0 ( kernel 2.6.18 ). Thanks.

    #include <linux/module.h>
    #include <linux/netdevice.h>
    #include <linux/skbuff.h>
    #include <linux/init.h>

    /*================================================= ===============
    Function Prototypes
    ================================================== ================*/
    int My_Init_Module(void);
    int My_open(struct net_device*);
    int My_release(struct net_device*);
    void My_Cleanup_Module(void);
    static int My_xmit(struct sk_buff*,struct net_device*);
    int My_func(struct sk_buff*,struct net_device*,struct packet_type*);
    void My_Init(struct net_device *dev);

    struct net_device *test;
    struct packet_type *mypkt;

    int My_Init_Module(void)
    int result;

    test = alloc_netdev(0, "Test", My_Init);
    if(test == NULL)
    goto out;

    if((result = register_netdev(test))){
    printk(KERN_ALERT "Error %d : network Device Test could not initialized\n",result);
    } else {
    printk(KERN_INFO " Test is inserted successfully\n");

    return result;

    printk(KERN_ALERT "\n Error Initializing the Device\n");
    return 0;

    void My_Init(struct net_device *dev)
    dev->open = My_open;
    dev->stop = My_release;
    dev->hard_start_xmit= My_xmit;
    printk(KERN_ALERT "Network Device Test Initialized\n");

    int My_open(struct net_device *dev)

    printk(KERN_ALERT "Network Device Test is UP\n");
    return 0;

    int My_release(struct net_device *dev)
    printk(KERN_ALERT "Network Device Test Closed \n");
    return 0;

    int My_func(struct sk_buff *skb,struct net_device *dev,struct packet_type *pkt)
    return 0;

    static int My_xmit(struct sk_buff *sk, struct net_device *net)
    return 0;

    void My_Cleanup_Module(void)
    printk(KERN_ALERT "Network Device Test Uninitialized\n");

    module_init (My_Init_Module);
    module_exit (My_Cleanup_Module);

  2. #2
    I resolved the problem by myself. You need to set the MAC address in My_Init() function so that ifconfig can call the My_open() function. Hope that this helps somebody.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts