netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ipv4 ID calculation
@ 2017-09-19  0:43 Harsha Chenji
  2017-09-20 21:15 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Harsha Chenji @ 2017-09-19  0:43 UTC (permalink / raw)
  To: netdev

Hi all,

Where is the ID field of the IPv4 header created when the DF flag is
set? I am looking at ip_build_and_send_pkt. The code seems to have
changed in 4.4-rc1:

if (ip_dont_fragment(sk, &rt->dst)) {
    iph->frag_off = htons(IP_DF);
    iph->id = 0;
} else {
    iph->frag_off = 0;
    __ip_select_ident(net, iph, 1);
}

old code (executed irrespective of DF or not):

    ip_select_ident(sock_net(sk), skb, sk);

The code in Stevens is basically iph->id = htons(ip_ident++) and now
it seems to be calculated based on a hash + lookup table.

So where is the id of 0 overwritten when DF is set? Didn't find any
info in the docs.

P.S. - is this the right mailing list for these kind of questions?

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ipv4 ID calculation
  2017-09-19  0:43 ipv4 ID calculation Harsha Chenji
@ 2017-09-20 21:15 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2017-09-20 21:15 UTC (permalink / raw)
  To: Harsha Chenji; +Cc: netdev

On Mon, 18 Sep 2017 20:43:05 -0400
Harsha Chenji <cjkernel@gmail.com> wrote:

> Hi all,
> 
> Where is the ID field of the IPv4 header created when the DF flag is
> set? I am looking at ip_build_and_send_pkt. The code seems to have
> changed in 4.4-rc1:
> 
> if (ip_dont_fragment(sk, &rt->dst)) {
>     iph->frag_off = htons(IP_DF);
>     iph->id = 0;
> } else {
>     iph->frag_off = 0;
>     __ip_select_ident(net, iph, 1);
> }
> 
> old code (executed irrespective of DF or not):
> 
>     ip_select_ident(sock_net(sk), skb, sk);
> 
> The code in Stevens is basically iph->id = htons(ip_ident++) and now
> it seems to be calculated based on a hash + lookup table.
> 
> So where is the id of 0 overwritten when DF is set? Didn't find any
> info in the docs.

IP id doesn't matter if Dont Fragment bit is set. The IP id is used
by receiver (and firewalls) to coalesce fragments by the ID. If DF
is set no system in the path is supposed to fragment. The idea is
to reduce the number of possible cases of fragment collisions.



> P.S. - is this the right mailing list for these kind of questions?

Sort of, the list is more about technical discussions and patches.

You could find more info by using git blame to find the commit that
introduced the change, then read the log for that.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-20 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-19  0:43 ipv4 ID calculation Harsha Chenji
2017-09-20 21:15 ` Stephen Hemminger

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).