|
| 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