LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-04-2005, 02:12 AM   #1
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Rep: Reputation: 15
what is the function?


when you look in the source code of linux kernel, you can see
that skb->dst->output(skb) will be invoke after NF_HOOK.

but, i can't find the function exactly.

where the func is ,and how to find it.

thx
 
Old 11-05-2005, 12:48 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

SUGGESTION:

The "id-utils" tools can be ENORMOUSLY helpful for finding stuff in large code bases - it's a bit like having your own private "google" for a source tree:

http://directory.fsf.org/GNU/idutils.html

All you have to do to use it is:

1) Install the GNU "id-utils" on your system (if it's not already there)
2) cd to your toplevel directory (e.g. "/usr/src/linux") and run "mkid" (no arguments, nothing special)
3) Whever you want to look up a function, variable name, constant, struct definition - just run "gid <NAME> | grep <FILTER>"

In this case:

cd /usr/src/linux-2.6.11.4-20a
gid NF_HOOK|less
include/linux/netfilter.h:156:#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) \
... <= MANY OTHER HITS: BUT THIS LINE IS OUR "BINGO!"

or:
gid output|grep skb|less

include/net/dst.h:228: err = skb->dst->output(skb);
net/bridge/br_netfilter.c:160: * skb->dst->output() which will make the packet enter br_nf_local_out()
net/bridge/br_netfilter.c:200: skb->dst->output(skb);
net/ipv4/ip_output.c:217: return dst->neighbour->output(skb);
net/ipv6/ip6_output.c:89: return dst->neighbour->output(skb);

And, finally, we look at line 160 in source file "net/bridge/br_netfilter" (as in "Bridge Netfilter"), and we see:
Quote:
* If skb->dst->dev equals the logical bridge device the packet
* came in on, we can consider this bridging. We then call
* skb->dst->output() which will make the packet enter br_nf_local_out()
* not much later. In that function it is assured that the iptables
* FORWARD chain is traversed for the packet.
 
Old 11-06-2005, 06:41 PM   #3
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Original Poster
Rep: Reputation: 15
so many thans to you.

but, i don't think so. the output is a pointer of a function.
and, what the pointer point to exactly should be exposed
clearly.

in my opinion, for different struct dst_entry the pointer will
point to different function. because, after the NF_HOOK
NF_IP_LOCAL_OUT, the packet maybe will be passed to route
process or other functions which can invoke the NF_HOOK
NF_IP_POST_ROUTING, and no NF_IP_FORWARD will be
invoked, so i think, we should find the exactly source code
where the callback function be registered for pointer output.

but, it is a little more difficult for me. i try it for two days but ...
 
Old 11-06-2005, 08:08 PM   #4
wangjinyi
Member
 
Registered: Sep 2004
Posts: 60

Original Poster
Rep: Reputation: 15
Hi, i have find the function used. that is the ip_output(struct sk_buff*) in
ip_output.c.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling another function from a function using GTK geminigal Programming 4 07-11-2005 03:15 PM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 01:44 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM
Is the wait function is the same as the sleep function ? Linh Programming 3 04-28-2004 12:39 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration