netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
To: aijazbaig1@gmail.com
Cc: netfilter-devel@vger.kernel.org, jengelh@medozas.de,
	linux-kernel@vger.kernel.org
Subject: Re: help needed with EXPORT_SYMBOL
Date: Mon, 23 Aug 2010 07:48:06 -0400	[thread overview]
Message-ID: <AANLkTimtNOyJCbLxAW8Ebsftb58EWoNFW7Xkevqb6oGo@mail.gmail.com> (raw)
In-Reply-To: <1282540448.4080.86.camel@aijazbaig1-desktop>

On Mon, Aug 23, 2010 at 1:14 AM, Aijaz Baig <aijazbaig1@gmail.com> wrote:
> Hello,
>
> Yeah I do understand that part, but there has to be a way to do what I
> am trying to do here isn't it?
>
> And can anyone tell me can kallsyms_lookup() be used in such a
> situation? If yes than how do I use it?
>
> Regards,
> Aijaz
>
> On Sat, Aug 21, 2010 at 2:53 PM, Jan  Engelhardt <jengelh@medozas.de>
> wrote:
> On Saturday 2010-08-21 08:57, Aijaz Baig wrote:
>
>>So why is it that when my netfilter module is exporting something to
>>the kernel and im tryin to use it from within a core kernel file, the
>>compiler flags a 'undefined reference to' error?
>
> There, you answered yourself. Exports only go one way. And that is
> core -> module -> module.
>
> On Sat, 2010-08-21 at 12:27 +0530, Aijaz Baig wrote:
>> Hello,
>>
>> Ive been trying to EXPORT a SYMBOL from a netfilter module (actually a
>> hook) to the KERNEL. Various modules seem to export various symbols to
>> the kernel (or so it seems), an example being x_tables which exports a
>> whole lot of functions like xt_register_target and so on and all other
>> netfilter modules which use these functions dont seem to have any
>> problems.
>>
>> So why is it that when my netfilter module is exporting something to the
>> kernel and im tryin to use it from within a core kernel file, the
>> compiler flags a 'undefined reference to' error?
>>
>> I googled and came to the conclusion from the kernelnewbies mailing list
>> that using kallsyms_lookup() seems to be the answer or is it?
>> So, if I do intend to use kallsyms_lookup how do I use it? There aren't
>> so many instances of it being used it seems.
>>
>> Ive seen it being used in dev/core.c like so:
>> symname = kallsyms_lookup((unsigned long)sym, &symsize,&offset,&modname,
>> namebuf);
>>
>> I am basically trying to call a function that MY module EXPORTs inside
>> one of the core linux routines. This would also mean that my netfilter
>> module must be compiled (and linked also maybe?..not so sound with link
>> time stuff) before the address becomes visible so that kallsyms_lookup
>> can find it. So do I really shd be using it and if so, how?
>>
>> Any input is appreciated.
>>
>> Regards,
>> Aijaz Baig.
>>
>>

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.

--
Brian Gerst
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-08-23 11:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-21  6:57 help needed with EXPORT_SYMBOL Aijaz Baig
2010-08-21  9:23 ` Jan Engelhardt
2010-08-23  5:14 ` Aijaz Baig
2010-08-23 11:48   ` Brian Gerst [this message]
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                     ` Fwd: " Aijaz Baig
2010-08-25 10:06                       ` 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=AANLkTimtNOyJCbLxAW8Ebsftb58EWoNFW7Xkevqb6oGo@mail.gmail.com \
    --to=brgerst@gmail.com \
    --cc=aijazbaig1@gmail.com \
    --cc=jengelh@medozas.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).