Skip to content

Commit e848591

Browse files
wdebruijkuba-moo
authored andcommitted
icmp: reflect tos through ip cookie rather than updating inet_sk
Do not modify socket fields if it can be avoided. The current code predates the introduction of ip cookies in commit aa66158 ("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 <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9329b58 commit e848591

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/ipv4/icmp.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
405405
struct ipcm_cookie ipc;
406406
struct flowi4 fl4;
407407
struct sock *sk;
408-
struct inet_sock *inet;
409408
__be32 daddr, saddr;
410409
u32 mark = IP4_REPLY_MARK(net, skb->mark);
411410
int type = icmp_param->data.icmph.type;
@@ -424,12 +423,11 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
424423
sk = icmp_xmit_lock(net);
425424
if (!sk)
426425
goto out_bh_enable;
427-
inet = inet_sk(sk);
428426

429427
icmp_param->data.icmph.checksum = 0;
430428

431429
ipcm_init(&ipc);
432-
inet->tos = ip_hdr(skb)->tos;
430+
ipc.tos = ip_hdr(skb)->tos;
433431
ipc.sockc.mark = mark;
434432
daddr = ipc.addr = ip_hdr(skb)->saddr;
435433
saddr = fib_compute_spec_dst(skb);
@@ -737,8 +735,8 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
737735
icmp_param.data.icmph.checksum = 0;
738736
icmp_param.skb = skb_in;
739737
icmp_param.offset = skb_network_offset(skb_in);
740-
inet_sk(sk)->tos = tos;
741738
ipcm_init(&ipc);
739+
ipc.tos = tos;
742740
ipc.addr = iph->saddr;
743741
ipc.opt = &icmp_param.replyopts.opt;
744742
ipc.sockc.mark = mark;

0 commit comments

Comments
 (0)