fib_semantics: Don't match route with mismatching tclassid
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 40 lines · Stefano Brivio
In
fib_nh_match(), if output interface or gateway are passed in the FIB configuration, we don't have to check next hops of multipath routes to conclude whether we have a match or not.However, we might still have routes with different realms matching the same output interface and gateway configuration, and this needs to cause the match to fail. Otherwise the first route inserted in the FIB will match, regardless of the realms:
# ip route add 1.1.1.1 dev eth0 table 1234 realms 1/2 # ip route append 1.1.1.1 dev eth0 table 1234 realms 3/4 # ip route list table 1234 1.1.1.1 dev eth0 scope link realms 1/2 1.1.1.1 dev eth0 scope link realms 3/4 # ip route del 1.1.1.1 dev ens3 table 1234 realms 3/4 # ip route list table 1234 1.1.1.1 dev ens3 scope link realms 3/4whereas route with realms 3/4 should have been deleted instead.
Explicitly check for
fc_flowpassed in the FIB configuration (this comes fromRTA_FLOWextracted byrtm_to_fib_config()) and fail matching if it differs fromnh_tclassid.The handling of
RTA_FLOWfor multipath routes later infib_nh_match()is still needed, as we can have multipleRTA_FLOWattributes that need to be matched against the tclassid of each next hop.Reported-by Jianlin Shi <[email protected]>Signed-off-by Stefano Brivio <[email protected]>--- net/ipv4/fib_semantics.c | 4 ++++ 1 file changed, 4 insertions(+)net/ipv4/fib_semantics.c +0
-0
net/ipv4/fib_semantics.c int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, · line 652
Quoted 7 lines
net/ipv4/fib_semantics.c +4
-0@@ -646,6 +646,10 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, fi->fib_nh, cfg, extack))return 1 ; } +#ifdef CONFIG_IP_ROUTE_CLASSID +if (cfg->fc_flow != fi->fib_nh->nh_tclassid) +return 1 ; +#endif
you should verify fc_flow is set. user is allowed to delete first matching route based on data that is given.
Quoted 4 lines
net/ipv4/fib_semantics.c +0
-0if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && (!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->nh_gw))return 0 ;
Hi David,
Quoted 9 lines · On Wed, 14 Feb 2018 10:46:05 -0700 David Ahern <[email protected]> wrote:
Review
Quoted 4 lines · Stefano Brivio
(quoted diff) +4
-0+#ifdef CONFIG_IP_ROUTE_CLASSID + if (cfg->fc_flow != fi->fib_nh->nh_tclassid) + return 1; +#endifyou should verify
fc_flowis set. user is allowed to delete first matching route based on data that is given.
Thanks for your comment.
My intended semantic was different, that is, I assumed that if fc_flow is not set (zero, here), the user shouldn't be able to just delete the first matching route. But I guess your interpretation makes more sense because it's consistent with the other checks. I'll send a v2.
Signature · 1 line
Stefano