From: Manu Garg <manu.garg@med.ge.com>
To: linux lover <linux_lover2004@yahoo.com>
Cc: linuxnet <linux-net@vger.kernel.org>, netdev <netdev@oss.sgi.com>,
netfilter <netfilter-devel@lists.netfilter.org>
Subject: Re: how ip header added in ip_bulid_xmit function?
Date: Tue, 18 May 2004 19:53:16 +0530 [thread overview]
Message-ID: <40AA1C54.2090201@med.ge.com> (raw)
In-Reply-To: <20040518063106.85290.qmail@web90102.mail.scd.yahoo.com>
linux lover wrote:
>hello ,
> In ip_output.c file there is ip_build_xmit function
>call. when packet comes from tcp layer to IP layer
>this function is called. In that i found that
> skb = sock_alloc_send_skb(sk, length+hh_len+15
>,flags&MSG_DONTWAIT, &err);
>staement allocates skb for packet. after that i found
>that no iphdr adding statement in ip_build_xmit. i
>want to know where is iphdr push to skb? cause skb
>works using first alloc_skb to allocate memory then
>skb_reserve to reserve headroom then put data in skb
>by skb_put or skb_push for pushing headers in skb. so
>there i found
> skb->nh.iph = iph = (struct iphdr *)skb_put(skb,
>length);
>statement is this does that iphdr adding?
>
>regards,
>linuxlover
>
>
>
>
>__________________________________
>Do you Yahoo!?
>SBC Yahoo! - Internet access at a great low price.
>http://promo.yahoo.com/sbc/
>-
>To unsubscribe from this list: send the line "unsubscribe linux-net" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
A packet comes from TCP layer to IP layer through function call
tp->af_specific->queue_xmit() (in tcp_output.c:tcp_transmit_skb() ). For
IP this function is nothing but ip_queue_xmit() defined in
ip_output.c.
If you'll check this function, it clearly allocates ip header and put
information in it.
----------------------------------------------------
iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ?
opt->optlen : 0));
*((__u16 *)iph) = htons((4 << 12) | (5 << 8) |
(sk->protinfo.af_inet.tos & 0xff));
iph->tot_len = htons(skb->len);
if (ip_dont_fragment(sk, &rt->u.dst))
iph->frag_off = htons(IP_DF);
else
iph->frag_off = 0;
iph->ttl = sk->protinfo.af_inet.ttl;
iph->protocol = sk->protocol;
iph->saddr = rt->rt_src;
iph->daddr = rt->rt_dst;
skb->nh.iph = iph;
---------------------------------------------------
I hope this answers your question.
regards,
Manu Garg
http://manugarg.freezope.org/notes
next prev parent reply other threads:[~2004-05-18 14:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-18 6:31 how ip header added in ip_bulid_xmit function? linux lover
2004-05-18 14:23 ` Manu Garg [this message]
2004-05-19 6:20 ` linux lover
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
2004-05-24 18:58 ` Tommy Reynolds
2004-05-24 20:22 ` Richard B. Johnson
2004-05-24 20:29 ` Chris Wright
-- strict thread matches above, loose matches on Subject: below --
2004-05-19 6:27 how ip header added in ip_bulid_xmit function? Galy Lee
2004-05-19 10:36 ` linux lover
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=40AA1C54.2090201@med.ge.com \
--to=manu.garg@med.ge.com \
--cc=linux-net@vger.kernel.org \
--cc=linux_lover2004@yahoo.com \
--cc=netdev@oss.sgi.com \
--cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.