Willem de Bruijn wrote:
quoted hunk ↗ jump to hunk
From: Willem de Bruijn <willemb@google.com>
Do not modify socket fields if it can be avoided.
The current code predates the introduction of ip cookies in commit
aa6615814533 ("ipv4: processing ancillary IP_TOS or IP_TTL"). Now that
cookies exist and support tos, update that field directly.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
Tested with ping -Q 32 127.0.0.1 and tcpdump
The existing logic works because inet->tos is read if ipc.tos (and
with that cork->tos) is left unitialized:
iph->tos = (cork->tos != -1) ? cork->tos : READ_ONCE(inet->tos);
---
net/ipv4/icmp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 094084b61bff..9c5e052a7802 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -429,7 +429,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
icmp_param->data.icmph.checksum = 0;
ipcm_init(&ipc);
- inet->tos = ip_hdr(skb)->tos;
+ ipc.tos = ip_hdr(skb)->tos;
ipc.sockc.mark = mark;
daddr = ipc.addr = ip_hdr(skb)->saddr;
saddr = fib_compute_spec_dst(skb);
local variable inet is no longer used, needs to be removed.
Will fix in v2.