From: Aijaz Baig <aijazbaig1@gmail.com>
To: brgerst@gmail.com, peterz@infradead.org, jengelh@medozas.de,
netfilter-devel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: Fwd: help needed with EXPORT_SYMBOL
Date: Wed, 25 Aug 2010 14:57:58 +0530 [thread overview]
Message-ID: <1282728478.17044.22.camel@aijazbaig1-desktop> (raw)
In-Reply-To: <AANLkTim9nvJR0K6xJc2kHGCeoMzFLzSxR8Avx59jsEbf@mail.gmail.com>
Hi everyone
I am trying to understand if its possible to add functions dynamically
to the kernel source based on the presence of certain modules in the
running kernel image.
I did try what brian suggested with the function pointer and yeah it
does work. But I could not understand what peter was trying to say about
modular users since I suppose he mentioned one module (B in this case)
using a function pointer defined in (or by) module A. In my case, since
it is the kernel that is gonna use the function, I need to make sure
that the module doesn't get unloaded while we are using the function.
By the way Jan I couldnt find bridge.c although there is an object file
called bridge.o within /net/bridge. Nonetheless, I did check
nf_nat_ftp.c as an example to see if something similar is being done
there too. What I did find out is that nf_nat_ftp_hook is rcu assigned
in nf_nat_ftp.c however this function pointer is being used with
nf_contrack_ftp.c (im talkin 2.6.27.45 here). In this case, it still is
module1 <- module2 and not kernel <- module. Could you please elaborate
a little how it affects the latter case. Or perhaps u were commenting on
the former case since peter brought that to our notice.
thanks again for your replies and keen to hear your input
Regards,
Aijaz Baig
>
>
> ---------- Forwarded message ----------
> From: Brian Gerst <brgerst@gmail.com>
> Date: Tue, Aug 24, 2010 at 4:46 PM
> Subject: Re: help needed with EXPORT_SYMBOL
> To: aijazbaig1@gmail.com
>
>
>
> On Tue, Aug 24, 2010 at 12:44 AM, Aijaz Baig <aijazbaig1@gmail.com>
> wrote:
> > Hello everyone,
> >
> > thanks for sending in the replies with so many options. I am still a
> > relative newbie so please do bear with me guys if I sound a bit
> naive at
> > times.
> >
> > I'll first start with brian's suggestion. He said:
> > "Use an exported function pointer in the main kernel as a hook that
> the
> > module sets when it is loaded. Note, you must use module_get and
> > module_put around the call to the module to prevent it from
> unloading
> > while in use."
> >
> > I have never used such a technique and do not understand what you
> mean.
> > Could you please elaborate a little. Do you mean I should NF_HOOK
> within
> > the kernel code and then make the function that I would like to
> execute
> > as the hookfn? Well..if this is what u meant then wouldn't it also
> cause
> > all hooks at that particular position to be executed as well?
> >
> > And then peter and finally jan came up with, perhaps better
> suggestions
> > (i really cannot judge the quality of any of these suggestions..m
> too
> > much of a noob to do that). I got confused in the XY explanation by
> jan
> > since there both X and Y are modules it seems and I was talking
> about a
> > module exporting a certain symbol to be used by the kernel. Peter
> did
> > suggest notification chains. Is there a simple example that I can
> look
> > at? Will it allow the kernel to see symbols defined within the
> module?
> >
> > Lastly, will I be able to use kallsyms_lookup() to do what I can? I
> > notice that it replaced EXPORT_SYMTAB sometime back. So if yes I can
> use
> > it, does anyone know how to fill in the very first parameter of this
> > function which says address (of what exactly and how am I supposed
> to
> > know this address?)
> >
> > Keen to hear from you and once again, thank you for your inputs,
>
>
> You still haven't explained why you want to lookup a symbol in a
> module from the main kernel. There is probably a better way of doing
> it.
>
> --
> Brian Gerst
>
>
next prev parent reply other threads:[~2010-08-25 9:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-21 6:57 Aijaz Baig
2010-08-21 9:23 ` Jan Engelhardt
2010-08-23 5:14 ` Aijaz Baig
2010-08-23 11:48 ` Brian Gerst
2010-08-23 13:17 ` Peter Zijlstra
2010-08-23 13:32 ` Jan Engelhardt
2010-08-23 13:43 ` Peter Zijlstra
2010-08-23 13:44 ` Brian Gerst
2010-08-23 14:05 ` Peter Zijlstra
[not found] ` <AANLkTimQDV74kcM_84QySMKmdf-XxFOhqp48cQdQNN4s@mail.gmail.com>
[not found] ` <AANLkTinRyoHcSmmHv9tZ36X4wxVVCKGLDwGiZUTPPn+z@mail.gmail.com>
2010-08-24 4:44 ` Aijaz Baig
[not found] ` <AANLkTi=cj+qCFxeT5hq0-x-XqSUCbcqQRAwmQ9h+cOxy@mail.gmail.com>
[not found] ` <AANLkTim9nvJR0K6xJc2kHGCeoMzFLzSxR8Avx59jsEbf@mail.gmail.com>
2010-08-25 9:27 ` Aijaz Baig [this message]
2010-08-25 10:06 ` Fwd: " Jan Engelhardt
2010-08-25 10:23 ` Peter Zijlstra
2010-08-25 15:37 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282728478.17044.22.camel@aijazbaig1-desktop \
--to=aijazbaig1@gmail.com \
--cc=brgerst@gmail.com \
--cc=jengelh@medozas.de \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®