LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-09-2005, 02:19 AM   #1
sidra
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116

Rep: Reputation: 15
Packet Transmission in the Kernel


Dear All,

I'm doing linux kernel programming for my senior year project at college. I've studied the tcp/ip implementation in kernel 2.4 to some extent, since i'm working on 2.4. So i was trying to transmit a test IP packet from scratch. This is being done as an extension to the kernel, in a file of my own. My implementation follows the way a packet is being transmitted in the kernel, specifically in the ip_output.c file. The problem i'm having is that when i try to find out the route for my destination using the ip_route_output() function i always get a null and hence the packet transmission doesn't occur. Here's where the problem occurs:

/* Get dst_entry if not present */
ip_route_output(&rt, dest, src, 0, dev-ifindex);

if(rt == NULL)
{
// some error and exit code
}

It turns out that rt is null. src and dest are the source and destination ip addresses in network byte order in hex. rt is defined as struct rtable* and dev is the transmitting device..that is eth0 in this case.

Does anyone have any clue about why rt is turning out to be null?
 
Old 04-10-2005, 02:20 PM   #2
live_dont_exist
Member
 
Registered: Aug 2004
Location: India
Distribution: Redhat 9.0,FC3,FC5,FC10
Posts: 257

Rep: Reputation: 30
Hi
Just guessing here...but you have initialized all your pointers..right and there are no "null" fields in the call itself?.For the last parameter check if you are using the right interface ; coz that parameter does look like an interface.Print out individual fields and isolate the problem and see what field is printing out as null.
gud luck
Arvind
 
Old 04-10-2005, 04:18 PM   #3
sidra
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116

Original Poster
Rep: Reputation: 15
Yea, i did initialize the fields as such:

__u32 src, dest; and then equated them to the hex values in net byte order

struct rtable* rt = NULL; and also tried not equating it to NULL...either way it doesn't make a difference.

rt has a lot many fields....i'll try the printing out approach. Thanks.
 
Old 04-17-2005, 10:48 AM   #4
sidra
Member
 
Registered: Oct 2004
Location: USA
Distribution: Fedora Core 3, Red Hat 9, CentOS 4.2, Mandriva, Ret Hat Enterprise Linux 4.0
Posts: 116

Original Poster
Rep: Reputation: 15
Didn't work. rt is coming out to be NULL persistently. It might be a network byte order issue, i dunno. Does this seem right:

I tried printing out rt->rt_src and rt->rt_dest but they send the kernel in panic!

__u32 src = 0xc0a80204; // for 192.168.2.4 i.e. the source address
__u32 dest = 0xc0a80203; // for 192.168.2.3 i.e. the destination address

I think this is in network byte order, am i wrong. So then isn't it correct if i pass it as this in:

ip_route_output( &rt, dest, src, 0, dev->ifindex);

Any one please tell me....i really need to get this done. Thanks in advance.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Packet Filter to redirect a packet to a user level process akawale Linux - Networking 3 09-01-2006 12:06 PM
Packet Transmission in the Kernel sidra Linux - Networking 1 04-09-2005 07:39 AM
packet sending function in kernel sunnyriver Linux - Networking 0 03-22-2004 08:46 PM
packet handling at the kernel level valib4u *BSD 4 09-14-2003 03:16 AM
kernel packet forwarding doodah Linux - Networking 4 08-17-2001 08:14 PM

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

All times are GMT -5. The time now is 08:30 AM.

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