Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ip: Handle delivery_time in ip defrag

A latter patch will postpone the delivery_time clearing until the stack
knows the skb is being delivered locally. That will allow other kernel
forwarding path (e.g. ip[6]_forward) to keep the delivery_time also.

An earlier attempt was to do skb_clear_delivery_time() in
ip_local_deliver() and ip6_input(). The discussion [0] requested
to move it one step later into ip_local_deliver_finish()
and ip6_input_finish() so that the delivery_time can be kept
for the ip_vs forwarding path also.

To do that, this patch also needs to take care of the (rcv) timestamp
usecase in ip_is_fragment(). It needs to expect delivery_time in
the skb->tstamp, so it needs to save the mono_delivery_time bit in
inet_frag_queue such that the delivery_time (if any) can be restored
in the final defragmented skb.

[Note that it will only happen when the locally generated skb is looping
from egress to ingress over a virtual interface (e.g. veth, loopback...),
skb->tstamp may have the delivery time before it is known that it will
be delivered locally and received by another sk.]

[0]: https://lore.kernel.org/netdev/ca728d81-80e8-3767-d5e-d44f6ad96e43@ssi.bg/

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Martin KaFai Lau and committed by
David S. Miller
8672406e d98d58a0

+4
+2
include/net/inet_frag.h
··· 70 70 * @stamp: timestamp of the last received fragment 71 71 * @len: total length of the original datagram 72 72 * @meat: length of received fragments so far 73 + * @mono_delivery_time: stamp has a mono delivery time (EDT) 73 74 * @flags: fragment queue flags 74 75 * @max_size: maximum received fragment size 75 76 * @fqdir: pointer to struct fqdir ··· 91 90 ktime_t stamp; 92 91 int len; 93 92 int meat; 93 + u8 mono_delivery_time; 94 94 __u8 flags; 95 95 u16 max_size; 96 96 struct fqdir *fqdir;
+1
net/ipv4/inet_fragment.c
··· 572 572 skb_mark_not_on_list(head); 573 573 head->prev = NULL; 574 574 head->tstamp = q->stamp; 575 + head->mono_delivery_time = q->mono_delivery_time; 575 576 } 576 577 EXPORT_SYMBOL(inet_frag_reasm_finish); 577 578
+1
net/ipv4/ip_fragment.c
··· 349 349 qp->iif = dev->ifindex; 350 350 351 351 qp->q.stamp = skb->tstamp; 352 + qp->q.mono_delivery_time = skb->mono_delivery_time; 352 353 qp->q.meat += skb->len; 353 354 qp->ecn |= ecn; 354 355 add_frag_mem_limit(qp->q.fqdir, skb->truesize);