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

Configure Feed

Select the types of activity you want to include in your feed.

net: ping6: Fix ping -6 with interface name

When passing interface parameter to ping -6:
$ ping -6 ::11:141:84:9 -I eth2
Results in:
PING ::11:141:84:10(::11:141:84:10) from ::11:141:84:9 eth2: 56 data bytes
ping: sendmsg: Invalid argument
ping: sendmsg: Invalid argument

Initialize the fl6's outgoing interface (OIF) before triggering
ip6_datagram_send_ctl. Don't wipe fl6 after ip6_datagram_send_ctl() as
changes in fl6 that may happen in the function are overwritten explicitly.
Update comment accordingly.

Fixes: 13651224c00b ("net: ping6: support setting basic SOL_IPV6 options via cmsg")
Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20220531084544.15126-1-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Aya Levin and committed by
Paolo Abeni
e6652a8e 196a888c

+4 -4
+4 -4
net/ipv6/ping.c
··· 101 101 ipc6.sockc.tsflags = sk->sk_tsflags; 102 102 ipc6.sockc.mark = sk->sk_mark; 103 103 104 + memset(&fl6, 0, sizeof(fl6)); 105 + fl6.flowi6_oif = oif; 106 + 104 107 if (msg->msg_controllen) { 105 108 struct ipv6_txoptions opt = {}; 106 109 ··· 115 112 return err; 116 113 117 114 /* Changes to txoptions and flow info are not implemented, yet. 118 - * Drop the options, fl6 is wiped below. 115 + * Drop the options. 119 116 */ 120 117 ipc6.opt = NULL; 121 118 } 122 119 123 - memset(&fl6, 0, sizeof(fl6)); 124 - 125 120 fl6.flowi6_proto = IPPROTO_ICMPV6; 126 121 fl6.saddr = np->saddr; 127 122 fl6.daddr = *daddr; 128 - fl6.flowi6_oif = oif; 129 123 fl6.flowi6_mark = ipc6.sockc.mark; 130 124 fl6.flowi6_uid = sk->sk_uid; 131 125 fl6.fl6_icmp_type = user_icmph.icmp6_type;