Skip to contentSkip to conversation

net: ipv4: Cache pmtu for all packet paths if multipath enabled

PATCH Superseded Vladimir Vdovin 5 participants 14 messages Oct 29, 2024 – Nov 6, 2024

Subsystems (4)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipv4: Cache pmtu for all packet paths if multipath enabled

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

---
 net/ipv4/route.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/ipv4/route.c +13 -0
index 723ac9181558..8eac6e361388 100644
@@ -1027,10 +1027,23 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
 		struct fib_nh_common *nhc;
 
 		fib_select_path(net, &res, fl4, NULL);
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+		if (fib_info_num_path(res.fi) > 1) {
+			int nhsel;
+
+			for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) {
+				nhc = fib_info_nhc(res.fi, nhsel);
+				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
+					jiffies + net->ipv4.ip_rt_mtu_expires);
+			}
+			goto rcu_unlock;
+		}
+#endif /* CONFIG_IP_ROUTE_MULTIPATH */
 		nhc = FIB_RES_NHC(res);
 		update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
 				      jiffies + net->ipv4.ip_rt_mtu_expires);
 	}
+rcu_unlock:
 	rcu_read_unlock();
 }
 

base-commit: 66600fac7a984dea4ae095411f644770b2561ede

Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 52 lines · Vladimir Vdovin

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

Quoted 8 lines

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

well known problem, and years ago I meant to send a similar patch.

Can you add a test case under selftests; you will see many pmtu, redirect and multipath tests.

Quoted 25 lines

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

---
 net/ipv4/route.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
net/ipv4/route.c +7 -0
index 723ac9181558..8eac6e361388 100644
@@ -1027,10 +1027,23 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
 		struct fib_nh_common *nhc;
 
 		fib_select_path(net, &res, fl4, NULL);
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+		if (fib_info_num_path(res.fi) > 1) {
+			int nhsel;
+
+			for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) {
+				nhc = fib_info_nhc(res.fi, nhsel);
+				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,

net/ipv4/route.c static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) · line 1046

Quoted 10 lines
net/ipv4/route.c +6 -0
+					jiffies + net->ipv4.ip_rt_mtu_expires);
+			}
+			goto rcu_unlock;
+		}
+#endif /* CONFIG_IP_ROUTE_MULTIPATH */
 		nhc = FIB_RES_NHC(res);
 		update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
 				      jiffies + net->ipv4.ip_rt_mtu_expires);
 	}
+rcu_unlock:

compiler error when CONFIG_IP_ROUTE_MULTIPATH is not set.

Quoted 5 lines
net/ipv4/route.c +0 -0
 	rcu_read_unlock();
 }
 

base-commit: 66600fac7a984dea4ae095411f644770b2561ede

#2 lore raw
Quoted 57 lines · David Ahern
Quoted 56 lines · Vladimir Vdovin

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

Quoted 6 lines
Quoted 4 lines

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

well known problem, and years ago I meant to send a similar patch.

Doesn't IPv6 suffer from a similar problem?

Quoted 10 lines

Can you add a test case under selftests; you will see many pmtu, redirect and multipath tests.

Quoted 6 lines

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

Thanks for the detailed commit message

#3 lore raw
Quoted 58 lines · Ido Schimmel
Quoted 57 lines · David Ahern
Quoted 56 lines · Vladimir Vdovin

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

well known problem, and years ago I meant to send a similar patch.

Doesn't IPv6 suffer from a similar problem?

I am not very familiar with ipv6,
but I tried to reproduce same problem with my tests with same topology.

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30003 dport 443
fc00:1001::2:2 via fc00:2::2 dev veth_A-R2 src fc00:1000::1:1 metric 1024 expires 495sec mtu 1500 pref medium

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30013 dport 443
fc00:1001::2:2 via fc00:1::2 dev veth_A-R1 src fc00:1000::1:1 metric 1024 expires 484sec mtu 1500 pref medium

It seems that there are no problems with ipv6. We have nhce entries for both paths.

Quoted 13 lines
Quoted 11 lines

Can you add a test case under selftests; you will see many pmtu, redirect and multipath tests.

Quoted 6 lines

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

Thanks for the detailed commit message

maintainer
#4 lore raw
Quoted 2 lines · Vladimir Vdovin
Quoted 2 lines

Doesn't IPv6 suffer from a similar problem?

I believe the answer is yes, but do not have time to find a reproducer right now.

Quoted 11 lines

I am not very familiar with ipv6,
but I tried to reproduce same problem with my tests with same topology.

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30003 dport 443
fc00:1001::2:2 via fc00:2::2 dev veth_A-R2 src fc00:1000::1:1 metric 1024 expires 495sec mtu 1500 pref medium

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30013 dport 443
fc00:1001::2:2 via fc00:1::2 dev veth_A-R1 src fc00:1000::1:1 metric 1024 expires 484sec mtu 1500 pref medium

It seems that there are no problems with ipv6. We have nhce entries for both paths.

Does rt6_cache_allowed_for_pmtu return true or false for this test?

#5 lore raw
Quoted 14 lines · David Ahern
Quoted 2 lines · Vladimir Vdovin
Quoted 2 lines

Doesn't IPv6 suffer from a similar problem?

I believe the answer is yes, but do not have time to find a reproducer right now.

Quoted 7 lines

I am not very familiar with ipv6,
but I tried to reproduce same problem with my tests with same topology.

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30003 dport 443
fc00:1001::2:2 via fc00:2::2 dev veth_A-R2 src fc00:1000::1:1 metric 1024 expires 495sec mtu 1500 pref medium

Quoted 6 lines
Quoted 4 lines

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30013 dport 443
fc00:1001::2:2 via fc00:1::2 dev veth_A-R1 src fc00:1000::1:1 metric 1024 expires 484sec mtu 1500 pref medium

It seems that there are no problems with ipv6. We have nhce entries for both paths.

Does rt6_cache_allowed_for_pmtu return true or false for this test?

It returns true.

maintainer
#6 lore raw
Quoted 9 lines · Vladimir Vdovin
Quoted 8 lines · David Ahern
Quoted 2 lines · Vladimir Vdovin
Quoted 2 lines

Doesn't IPv6 suffer from a similar problem?

I believe the answer is yes, but do not have time to find a reproducer right now.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

I am not very familiar with ipv6,
but I tried to reproduce same problem with my tests with same topology.

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30003 dport 443
fc00:1001::2:2 via fc00:2::2 dev veth_A-R2 src fc00:1000::1:1 metric 1024 expires 495sec mtu 1500 pref medium

ip netns exec ns_a-AHtoRb ip -6 r g fc00:1001::2:2 sport 30013 dport 443
fc00:1001::2:2 via fc00:1::2 dev veth_A-R1 src fc00:1000::1:1 metric 1024 expires 484sec mtu 1500 pref medium

you should dump the cache to see the full exception list.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

It seems that there are no problems with ipv6. We have nhce entries for both paths.

Does rt6_cache_allowed_for_pmtu return true or false for this test?

It returns true.

Looking at the code, it is creating a single exception - not one per path. I am fine with deferring the ipv6 patch until someone with time and interest can work on it.

#7 lore raw

PATCH v3 1/1 net: ipv4: Cache pmtu for all packet paths if multipath enabled

In reply to David Ahern

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

V3:
- added selftest
- fixed compile error

V2:
- fix fib_info_num_path parameter pass

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

---
 net/ipv4/route.c                    | 13 ++++++
 tools/testing/selftests/net/pmtu.sh | 71 ++++++++++++++++++++++++++++-
 2 files changed, 83 insertions(+), 1 deletion(-)
net/ipv4/route.c +13 -0
index 723ac9181558..41162b5cc4cb 100644
@@ -1027,6 +1027,19 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
 		struct fib_nh_common *nhc;
 
 		fib_select_path(net, &res, fl4, NULL);
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+		if (fib_info_num_path(res.fi) > 1) {
+			int nhsel;
+
+			for (nhsel = 0; nhsel < fib_info_num_path(res.fi); nhsel++) {
+				nhc = fib_info_nhc(res.fi, nhsel);
+				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
+							  jiffies + net->ipv4.ip_rt_mtu_expires);
+			}
+			rcu_read_unlock();
+			return;
+		}
+#endif /* CONFIG_IP_ROUTE_MULTIPATH */
 		nhc = FIB_RES_NHC(res);
 		update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
 				      jiffies + net->ipv4.ip_rt_mtu_expires);
tools/testing/selftests/net/pmtu.sh +70 -1

83 lines not on this page · raw message

base-commit: 66600fac7a984dea4ae095411f644770b2561ede

Signature · 1 line
2.43.5
#8 lore raw

PATCH v4 1/1 net: ipv4: Cache pmtu for all packet paths if multipath enabled

In reply to David Ahern

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

V4:
- fix selftest, do route lookup before checking cached exceptions

V3:
- added selftest
- fixed compile error

V2:
- fix fib_info_num_path parameter pass

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

---
 net/ipv4/route.c                    | 13 +++++
 tools/testing/selftests/net/pmtu.sh | 79 ++++++++++++++++++++++++++++-
 2 files changed, 91 insertions(+), 1 deletion(-)
net/ipv4/route.c +13 -0
index 723ac9181558..41162b5cc4cb 100644
@@ -1027,6 +1027,19 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
 		struct fib_nh_common *nhc;
 
 		fib_select_path(net, &res, fl4, NULL);
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+		if (fib_info_num_path(res.fi) > 1) {
+			int nhsel;
+
+			for (nhsel = 0; nhsel < fib_info_num_path(res.fi); nhsel++) {
+				nhc = fib_info_nhc(res.fi, nhsel);
+				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
+							  jiffies + net->ipv4.ip_rt_mtu_expires);
+			}
+			rcu_read_unlock();
+			return;
+		}
+#endif /* CONFIG_IP_ROUTE_MULTIPATH */
 		nhc = FIB_RES_NHC(res);
 		update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
 				      jiffies + net->ipv4.ip_rt_mtu_expires);
tools/testing/selftests/net/pmtu.sh +78 -1

91 lines not on this page · raw message

base-commit: 66600fac7a984dea4ae095411f644770b2561ede

Signature · 1 line
2.43.5
#9 lore raw

PATCH v5 1/1 net: ipv4: Cache pmtu for all packet paths if multipath enabled

In reply to David Ahern

Check number of paths by fib_info_num_path(), and update_or_create_fnhe() for every path. Problem is that pmtu is cached only for the oif that has received icmp message "need to frag", other oifs will still try to use "default" iface mtu.

V5:
- make self test cleaner

V4:
- fix selftest, do route lookup before checking cached exceptions

V3:
- added selftest
- fixed compile error

V2:
- fix fib_info_num_path parameter pass

An example topology showing the problem:

                    |  host1
                +---------+
                |  dummy0 | 10.179.20.18/32  mtu9000
                +---------+
        +-----------+----------------+
    +---------+                     +---------+
    | ens17f0 |  10.179.2.141/31    | ens17f1 |  10.179.2.13/31
    +---------+                     +---------+
        |    (all here have mtu 9000)    |
    +------+                         +------+
    | ro1  |  10.179.2.140/31        | ro2  |  10.179.2.12/31
    +------+                         +------+
        |                                |
---------+------------+-------------------+------
                        |
                    +-----+
                    | ro3 | 10.10.10.10  mtu1500
                    +-----+
                        |
    ========================================
                some networks
    ========================================
                        |
                    +-----+
                    | eth0| 10.10.30.30  mtu9000
                    +-----+
                        |  host2

host1 have enabled multipath and
sysctl net.ipv4.fib_multipath_hash_policy = 1:

default proto static src 10.179.20.18

        nexthop via 10.179.2.12 dev ens17f1 weight 1
        nexthop via 10.179.2.140 dev ens17f0 weight 1

When host1 tries to do pmtud from 10.179.20.18/32 to host2, host1 receives at ens17f1 iface an icmp packet from ro3 that ro3 mtu=1500. And host1 caches it in nexthop exceptions cache.

Problem is that it is cached only for the iface that has received icmp, and there is no way that ro3 will send icmp msg to host1 via another path.

Host1 now have this routes to host2:

ip r g 10.10.30.30 sport 30000 dport 443
10.10.30.30 via 10.179.2.12 dev ens17f1 src 10.179.20.18 uid 0
cache expires 521sec mtu 1500

ip r g 10.10.30.30 sport 30033 dport 443
10.10.30.30 via 10.179.2.140 dev ens17f0 src 10.179.20.18 uid 0
cache

So when host1 tries again to reach host2 with mtu>1500,
if packet flow is lucky enough to be hashed with oif=ens17f1 its ok, if oif=ens17f0 it blackholes and still gets icmp msgs from ro3 to ens17f1, until lucky day when ro3 will send it through another flow to ens17f0.

---
 net/ipv4/route.c                    | 13 +++++
 tools/testing/selftests/net/pmtu.sh | 78 ++++++++++++++++++++++++++++-
 2 files changed, 90 insertions(+), 1 deletion(-)
net/ipv4/route.c +13 -0
index 723ac9181558..41162b5cc4cb 100644
@@ -1027,6 +1027,19 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
 		struct fib_nh_common *nhc;
 
 		fib_select_path(net, &res, fl4, NULL);
+#ifdef CONFIG_IP_ROUTE_MULTIPATH
+		if (fib_info_num_path(res.fi) > 1) {
+			int nhsel;
+
+			for (nhsel = 0; nhsel < fib_info_num_path(res.fi); nhsel++) {
+				nhc = fib_info_nhc(res.fi, nhsel);
+				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
+							  jiffies + net->ipv4.ip_rt_mtu_expires);
+			}
+			rcu_read_unlock();
+			return;
+		}
+#endif /* CONFIG_IP_ROUTE_MULTIPATH */
 		nhc = FIB_RES_NHC(res);
 		update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
 				      jiffies + net->ipv4.ip_rt_mtu_expires);
tools/testing/selftests/net/pmtu.sh +77 -1

90 lines not on this page · raw message

base-commit: 66600fac7a984dea4ae095411f644770b2561ede

Signature · 1 line
2.43.5
maintainer
#10 lore raw

tools/testing/selftests/net/pmtu.sh tests=" · line 270

Quoted 1 line · On Fri, 1 Nov 2024 10:48:57 +0000 Vladimir Vdovin wrote:
tools/testing/selftests/net/pmtu.sh +1 -0
+	pmtu_ipv4_mp_exceptions		ipv4: PMTU multipath nh exceptions		0"

This new test seems to fail in our CI:

# TEST: ipv4: PMTU multipath nh exceptions [FAIL]
# there are not enough cached exceptions

https://netdev-3.bots.linux.dev/vmksft-net/results/840861/3-pmtu-sh/stdout

Also some process notes:
- please don't post multiple versions of the patch a day:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
- please avoid posting new versions in-reply-to the old one

Signature · 1 line
pw-bot: cr
#11 lore raw
Quoted 9 lines · Jakub Kicinski

tools/testing/selftests/net/pmtu.sh tests=" · line 270

Quoted 1 line · On Fri, 1 Nov 2024 10:48:57 +0000 Vladimir Vdovin wrote:
tools/testing/selftests/net/pmtu.sh +1 -0
+	pmtu_ipv4_mp_exceptions		ipv4: PMTU multipath nh exceptions		0"

This new test seems to fail in our CI:

# TEST: ipv4: PMTU multipath nh exceptions [FAIL]
# there are not enough cached exceptions

https://netdev-3.bots.linux.dev/vmksft-net/results/840861/3-pmtu-sh/stdout

Yes it failed in V4 patch, in this V5 its already ok:

# TEST: ipv4: PMTU multipath nh exceptions [ OK ]
ok 1 selftests: net: pmtu.sh

https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/2-pmtu-sh/stdout

But in V5, there is failed test, not sure that this patch causes fail:
https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/31-busy-poll-test-sh/stdout

Quoted 5 lines

Also some process notes:
- please don't post multiple versions of the patch a day:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
- please avoid posting new versions in-reply-to the old one

Thanks, will keep it in mind next time, sorry for my ignorance

maintainer
#12 lore raw

Hi,

Quoted 22 lines · Vladimir Vdovin
Quoted 9 lines · Jakub Kicinski

tools/testing/selftests/net/pmtu.sh tests=" · line 270

Quoted 1 line · On Fri, 1 Nov 2024 10:48:57 +0000 Vladimir Vdovin wrote:
tools/testing/selftests/net/pmtu.sh +1 -0
+	pmtu_ipv4_mp_exceptions		ipv4: PMTU multipath nh exceptions		0"

This new test seems to fail in our CI:

# TEST: ipv4: PMTU multipath nh exceptions [FAIL]
# there are not enough cached exceptions

https://netdev-3.bots.linux.dev/vmksft-net/results/840861/3-pmtu-sh/stdout

Yes it failed in V4 patch, in this V5 its already ok:

# TEST: ipv4: PMTU multipath nh exceptions [ OK ]
ok 1 selftests: net: pmtu.sh

https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/2-pmtu-sh/stdout

But in V5, there is failed test, not sure that this patch causes fail:
https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/31-busy-poll-test-sh/stdout

Quoted 1 line
Quoted 5 lines
Quoted 4 lines

Also some process notes:
- please don't post multiple versions of the patch a day:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
- please avoid posting new versions in-reply-to the old one

Thanks, will keep it in mind next time, sorry for my ignorance

Some additional notes:

- please do answer to Ido's question: what about ipv6?
- move the changelog after the SoB tag and a '---' separator, so that it will not be included into the git commit message
- post new revisions of the patch in a different thread

Thanks,

Paolo

#13 lore raw
Quoted 33 lines · Paolo Abeni

Hi,

Quoted 22 lines · Vladimir Vdovin
Quoted 9 lines · Jakub Kicinski

tools/testing/selftests/net/pmtu.sh tests=" · line 270

Quoted 1 line · On Fri, 1 Nov 2024 10:48:57 +0000 Vladimir Vdovin wrote:
tools/testing/selftests/net/pmtu.sh +1 -0
+	pmtu_ipv4_mp_exceptions		ipv4: PMTU multipath nh exceptions		0"

This new test seems to fail in our CI:

# TEST: ipv4: PMTU multipath nh exceptions [FAIL]
# there are not enough cached exceptions

https://netdev-3.bots.linux.dev/vmksft-net/results/840861/3-pmtu-sh/stdout

Yes it failed in V4 patch, in this V5 its already ok:

# TEST: ipv4: PMTU multipath nh exceptions [ OK ]
ok 1 selftests: net: pmtu.sh

https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/2-pmtu-sh/stdout

But in V5, there is failed test, not sure that this patch causes fail:
https://netdev-3.bots.linux.dev/vmksft-net-dbg/results/841042/31-busy-poll-test-sh/stdout

Quoted 1 line
Quoted 5 lines
Quoted 4 lines

Also some process notes:
- please don't post multiple versions of the patch a day:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
- please avoid posting new versions in-reply-to the old one

Thanks, will keep it in mind next time, sorry for my ignorance

Some additional notes:

Quoted 8 lines

- please do answer to Ido's question: what about ipv6?
- move the changelog after the SoB tag and a '---' separator, so that it will not be included into the git commit message
- post new revisions of the patch in a different thread

Thanks,

Paolo

Thanks for your comments,
I will resend patch with fixed commit message as new thread.