Skip to content

Commit 65a55aa

Browse files
Guillaume Naultkuba-moo
authored andcommitted
ipv4: Prepare inet_rtm_getroute() to .flowi4_tos conversion.
Store rtm->rtm_tos in a dscp_t variable, which can then be used for setting fl4.flowi4_tos and also be passed as parameter of ip_route_input_rcu(). The .flowi4_tos field is going to be converted to dscp_t to ensure ECN bits aren't erroneously taken into account during route lookups. Having a dscp_t variable available will simplify that conversion, as we'll just have to drop the inet_dscp_to_dsfield() call. Note that we can't just convert rtm->rtm_tos to dscp_t because this structure is exported to user space. Signed-off-by: Guillaume Nault <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/7bc1c7dc47ad1393569095d334521fae59af5bc7.1736944951.git.gnault@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2c77bcb commit 65a55aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/ipv4/route.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,6 +3270,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
32703270
struct flowi4 fl4 = {};
32713271
__be32 dst = 0;
32723272
__be32 src = 0;
3273+
dscp_t dscp;
32733274
kuid_t uid;
32743275
u32 iif;
32753276
int err;
@@ -3284,6 +3285,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
32843285
dst = nla_get_in_addr_default(tb[RTA_DST], 0);
32853286
iif = nla_get_u32_default(tb[RTA_IIF], 0);
32863287
mark = nla_get_u32_default(tb[RTA_MARK], 0);
3288+
dscp = inet_dsfield_to_dscp(rtm->rtm_tos);
32873289
if (tb[RTA_UID])
32883290
uid = make_kuid(current_user_ns(), nla_get_u32(tb[RTA_UID]));
32893291
else
@@ -3308,7 +3310,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
33083310

33093311
fl4.daddr = dst;
33103312
fl4.saddr = src;
3311-
fl4.flowi4_tos = rtm->rtm_tos & INET_DSCP_MASK;
3313+
fl4.flowi4_tos = inet_dscp_to_dsfield(dscp);
33123314
fl4.flowi4_oif = nla_get_u32_default(tb[RTA_OIF], 0);
33133315
fl4.flowi4_mark = mark;
33143316
fl4.flowi4_uid = uid;
@@ -3332,9 +3334,8 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
33323334
fl4.flowi4_iif = iif; /* for rt_fill_info */
33333335
skb->dev = dev;
33343336
skb->mark = mark;
3335-
err = ip_route_input_rcu(skb, dst, src,
3336-
inet_dsfield_to_dscp(rtm->rtm_tos),
3337-
dev, &res) ? -EINVAL : 0;
3337+
err = ip_route_input_rcu(skb, dst, src, dscp, dev,
3338+
&res) ? -EINVAL : 0;
33383339

33393340
rt = skb_rtable(skb);
33403341
if (err == 0 && rt->dst.error)

0 commit comments

Comments
 (0)