Skip to content

Commit 0e12c5a

Browse files
committed
ping: fix address binding wrt vrf
jira LE-2157 Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5 commit-author Nicolas Dichtel <[email protected]> commit e1a7ac6 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/e1a7ac6f.failed When ping_group_range is updated, 'ping' uses the DGRAM ICMP socket, instead of an IP raw socket. In this case, 'ping' is unable to bind its socket to a local address owned by a vrflite. Before the patch: $ sysctl -w net.ipv4.ping_group_range='0 2147483647' $ ip link add blue type vrf table 10 $ ip link add foo type dummy $ ip link set foo master blue $ ip link set foo up $ ip addr add 192.168.1.1/24 dev foo $ ip addr add 2001::1/64 dev foo $ ip vrf exec blue ping -c1 -I 192.168.1.1 192.168.1.2 ping: bind: Cannot assign requested address $ ip vrf exec blue ping6 -c1 -I 2001::1 2001::2 ping6: bind icmp socket: Cannot assign requested address CC: [email protected] Fixes: 1b69c6d ("net: Introduce L3 Master device abstraction") Signed-off-by: Nicolas Dichtel <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit e1a7ac6) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # net/ipv4/ping.c
1 parent 2b0984c commit 0e12c5a

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
ping: fix address binding wrt vrf
2+
3+
jira LE-2157
4+
Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5
5+
commit-author Nicolas Dichtel <[email protected]>
6+
commit e1a7ac6f3ba6e157adcd0ca94d92a401f1943f56
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-503.14.1.el9_5/e1a7ac6f.failed
10+
11+
When ping_group_range is updated, 'ping' uses the DGRAM ICMP socket,
12+
instead of an IP raw socket. In this case, 'ping' is unable to bind its
13+
socket to a local address owned by a vrflite.
14+
15+
Before the patch:
16+
$ sysctl -w net.ipv4.ping_group_range='0 2147483647'
17+
$ ip link add blue type vrf table 10
18+
$ ip link add foo type dummy
19+
$ ip link set foo master blue
20+
$ ip link set foo up
21+
$ ip addr add 192.168.1.1/24 dev foo
22+
$ ip addr add 2001::1/64 dev foo
23+
$ ip vrf exec blue ping -c1 -I 192.168.1.1 192.168.1.2
24+
ping: bind: Cannot assign requested address
25+
$ ip vrf exec blue ping6 -c1 -I 2001::1 2001::2
26+
ping6: bind icmp socket: Cannot assign requested address
27+
28+
29+
Fixes: 1b69c6d0ae90 ("net: Introduce L3 Master device abstraction")
30+
Signed-off-by: Nicolas Dichtel <[email protected]>
31+
Reviewed-by: David Ahern <[email protected]>
32+
Signed-off-by: Jakub Kicinski <[email protected]>
33+
(cherry picked from commit e1a7ac6f3ba6e157adcd0ca94d92a401f1943f56)
34+
Signed-off-by: Jonathan Maple <[email protected]>
35+
36+
# Conflicts:
37+
# net/ipv4/ping.c
38+
diff --cc net/ipv4/ping.c
39+
index 1c5aba05d82c,aa9a11b20d18..000000000000
40+
--- a/net/ipv4/ping.c
41+
+++ b/net/ipv4/ping.c
42+
@@@ -334,15 -319,12 +335,20 @@@ static int ping_check_bind_addr(struct
43+
pr_debug("ping_check_bind_addr(sk=%p,addr=%pI4,port=%d)\n",
44+
sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port));
45+
46+
++<<<<<<< HEAD
47+
+ if (addr->sin_addr.s_addr == htonl(INADDR_ANY))
48+
+ chk_addr_ret = RTN_LOCAL;
49+
+ else
50+
+ chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
51+
++=======
52+
+ tb_id = l3mdev_fib_table_by_index(net, sk->sk_bound_dev_if) ? : tb_id;
53+
+ chk_addr_ret = inet_addr_type_table(net, addr->sin_addr.s_addr, tb_id);
54+
++>>>>>>> e1a7ac6f3ba6 (ping: fix address binding wrt vrf)
55+
56+
- if (!inet_addr_valid_or_nonlocal(net, inet_sk(sk),
57+
- addr->sin_addr.s_addr,
58+
- chk_addr_ret))
59+
+ if ((!inet_can_nonlocal_bind(net, isk) &&
60+
+ chk_addr_ret != RTN_LOCAL) ||
61+
+ chk_addr_ret == RTN_MULTICAST ||
62+
+ chk_addr_ret == RTN_BROADCAST)
63+
return -EADDRNOTAVAIL;
64+
65+
#if IS_ENABLED(CONFIG_IPV6)
66+
* Unmerged path net/ipv4/ping.c

0 commit comments

Comments
 (0)