Skip to content

Commit 5eff069

Browse files
qsndavem330
authored andcommitted
ipv4: fill fl4_icmp_{type,code} in ping_v4_sendmsg
IPv4 ping sockets don't set fl4.fl4_icmp_{type,code}, which leads to incomplete IPsec ACQUIRE messages being sent to userspace. Currently, both raw sockets and IPv6 ping sockets set those fields. Expected output of "ip xfrm monitor": acquire proto esp sel src 10.0.2.15/32 dst 8.8.8.8/32 proto icmp type 8 code 0 dev ens4 policy src 10.0.2.15/32 dst 8.8.8.8/32 <snip> Currently with ping sockets: acquire proto esp sel src 10.0.2.15/32 dst 8.8.8.8/32 proto icmp type 0 code 0 dev ens4 policy src 10.0.2.15/32 dst 8.8.8.8/32 <snip> The Libreswan test suite found this problem after Fedora changed the value for the sysctl net.ipv4.ping_group_range. Fixes: c319b4d ("net: ipv4: add IPPROTO_ICMP socket kind") Reported-by: Paul Wouters <[email protected]> Tested-by: Paul Wouters <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7cdaa4c commit 5eff069

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/ping.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
786786
inet_sk_flowi_flags(sk), faddr, saddr, 0, 0,
787787
sk->sk_uid);
788788

789+
fl4.fl4_icmp_type = user_icmph.type;
790+
fl4.fl4_icmp_code = user_icmph.code;
791+
789792
security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
790793
rt = ip_route_output_flow(net, &fl4, sk);
791794
if (IS_ERR(rt)) {

0 commit comments

Comments
 (0)