Skip to content

Commit e6652a8

Browse files
ayalevinPaolo Abeni
authored and
Paolo Abeni
committed
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: 1365122 ("net: ping6: support setting basic SOL_IPV6 options via cmsg") Signed-off-by: Aya Levin <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 196a888 commit e6652a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/ipv6/ping.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
101101
ipc6.sockc.tsflags = sk->sk_tsflags;
102102
ipc6.sockc.mark = sk->sk_mark;
103103

104+
memset(&fl6, 0, sizeof(fl6));
105+
fl6.flowi6_oif = oif;
106+
104107
if (msg->msg_controllen) {
105108
struct ipv6_txoptions opt = {};
106109

@@ -112,17 +115,14 @@ static int ping_v6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
112115
return err;
113116

114117
/* Changes to txoptions and flow info are not implemented, yet.
115-
* Drop the options, fl6 is wiped below.
118+
* Drop the options.
116119
*/
117120
ipc6.opt = NULL;
118121
}
119122

120-
memset(&fl6, 0, sizeof(fl6));
121-
122123
fl6.flowi6_proto = IPPROTO_ICMPV6;
123124
fl6.saddr = np->saddr;
124125
fl6.daddr = *daddr;
125-
fl6.flowi6_oif = oif;
126126
fl6.flowi6_mark = ipc6.sockc.mark;
127127
fl6.flowi6_uid = sk->sk_uid;
128128
fl6.fl6_icmp_type = user_icmph.icmp6_type;

0 commit comments

Comments
 (0)