Find the answer to your Linux question:
Results 1 to 3 of 3
Hi,all , I am making a kernel module now , it works fine in 2.4 kernel , now I am porting it to readhat es 5 (2.6.18. ,something puzzled me ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Location
    Shenzhen/China
    Posts
    3

    Linux Kernel module programming help


    Hi,all , I am making a kernel module now , it works fine in 2.4 kernel , now I am porting it to readhat es 5 (2.6.18. ,something puzzled me for about 2 weeks.

    in my module

    ......
    #include <net/pkt_sched.h> /*for use the qdisc_run and*/

    int ip_packet_send_skb(struct rtp_sock *sk , struct sk_buff *skb1)
    {
    .....................

    if (q->enqueue) {
    q->enqueue(skb, q);
    qdisc_run(sk->dev);
    }
    .....................

    }

    when i ma comping the module ,there is always a warning of __qdisc_run undefined symbol .
    i look this symbol up in the /proc/kallsyms , there is a __qdisc_run ,
    and the kernel I am runing is build by the source code under /usr/src/kernel/2.6.18..... ,when I use modinfo iphook.ko , the version info is the same as the result of uname -r .

    qdisc_run is defined in the "pkt_sched.h"
    like the folowing (kernel souce code ):
    #include <net/sch_general.h>
    extern void __qdisc_run(struct net_device *dev);

    static inline void qdisc_run(struct net_device *dev)
    {
    if (!netif_queue_stopped(dev) &&
    !test_and_set_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
    __qdisc_run(dev);
    }

    in net/sch_general.h:
    extern void qdisc_lock_tree(struct net_device *dev);
    extern void qdisc_unlock_tree(struct net_device *dev);

    /*here there is no declare of __disc_run , but I think it no the problem ,since in pkt_sched.h , there is a extern void __qdisc_run(struct net_device *dev);
    */


    in sch_general.c
    #include <net/sch_general.h>
    void qdisc_lock_tree(struct net_device *dev)
    {
    write_lock(&qdisc_tree_lock);
    spin_lock_bh(&dev->queue_lock);
    }

    void qdisc_unlock_tree(struct net_device *dev)
    {
    spin_unlock_bh(&dev->queue_lock);
    write_unlock(&qdisc_tree_lock);
    }

    void __qdisc_run(struct net_device *dev)
    {
    if (unlikely(dev->qdisc == &noop_qdisc))
    goto out;

    while (qdisc_restart(dev) < 0 && !netif_queue_stopped(dev))
    /* NOTHING */;

    out:
    clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
    }



    what puzzled me is :
    these 3 function (_disc_run , disc_lock_tree, disc_unlock_tree)
    1. implemented in the same c file
    2. all in the /proc/kallsyms
    3 all included in the pkt_sched.h
    (disc_lock_tree, disc_unlock_tree included by include sch_general.h , __disc_run inclued by explicit "extern")

    but why when I am compling my module , only the __qdisc_run undefined (when I use disc_lock_tree , disc_unlock_tree , it is ok )

  2. #2
    Just Joined!
    Join Date
    Feb 2009
    Location
    Shenzhen/China
    Posts
    3
    anybody help?
    eager to know why

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Location
    Shenzhen/China
    Posts
    3
    I got the answer by reading the kernel code .
    the result is :
    no all the symbols in the kallsyms can be called by kernel modules , only those symbols exported by (export_symbols)can be called .

    another question , is there any other way to know the subset of the symbols can be called in the kallsyms?

Posting Permissions

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