Skip to content

Commit 5be083c

Browse files
David Aherndavem330
authored andcommitted
net: ipv6: Remove redundant RTA_OIF in multipath routes
Dinesh reported that RTA_MULTIPATH nexthops are 8-bytes larger with IPv6 than IPv4. The recent refactoring for multipath support in netlink messages does discriminate between non-multipath which needs the OIF and multipath which adds a rtnexthop struct for each hop making the RTA_OIF attribute redundant. Resolve by adding a flag to the info function to skip the oif for multipath. Fixes: beb1afa ("net: ipv6: Add support to dump multipath routes via RTA_MULTIPATH attribute") Reported-by: Dinesh Dutt <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 713c43b commit 5be083c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/ipv6/route.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,6 @@ static size_t rt6_nlmsg_size(struct rt6_info *rt)
32993299
nexthop_len = nla_total_size(0) /* RTA_MULTIPATH */
33003300
+ NLA_ALIGN(sizeof(struct rtnexthop))
33013301
+ nla_total_size(16) /* RTA_GATEWAY */
3302-
+ nla_total_size(4) /* RTA_OIF */
33033302
+ lwtunnel_get_encap_size(rt->dst.lwtstate);
33043303

33053304
nexthop_len *= rt->rt6i_nsiblings;
@@ -3323,7 +3322,7 @@ static size_t rt6_nlmsg_size(struct rt6_info *rt)
33233322
}
33243323

33253324
static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt,
3326-
unsigned int *flags)
3325+
unsigned int *flags, bool skip_oif)
33273326
{
33283327
if (!netif_running(rt->dst.dev) || !netif_carrier_ok(rt->dst.dev)) {
33293328
*flags |= RTNH_F_LINKDOWN;
@@ -3336,7 +3335,8 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt,
33363335
goto nla_put_failure;
33373336
}
33383337

3339-
if (rt->dst.dev &&
3338+
/* not needed for multipath encoding b/c it has a rtnexthop struct */
3339+
if (!skip_oif && rt->dst.dev &&
33403340
nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
33413341
goto nla_put_failure;
33423342

@@ -3350,6 +3350,7 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt,
33503350
return -EMSGSIZE;
33513351
}
33523352

3353+
/* add multipath next hop */
33533354
static int rt6_add_nexthop(struct sk_buff *skb, struct rt6_info *rt)
33543355
{
33553356
struct rtnexthop *rtnh;
@@ -3362,7 +3363,7 @@ static int rt6_add_nexthop(struct sk_buff *skb, struct rt6_info *rt)
33623363
rtnh->rtnh_hops = 0;
33633364
rtnh->rtnh_ifindex = rt->dst.dev ? rt->dst.dev->ifindex : 0;
33643365

3365-
if (rt6_nexthop_info(skb, rt, &flags) < 0)
3366+
if (rt6_nexthop_info(skb, rt, &flags, true) < 0)
33663367
goto nla_put_failure;
33673368

33683369
rtnh->rtnh_flags = flags;
@@ -3515,7 +3516,7 @@ static int rt6_fill_node(struct net *net,
35153516

35163517
nla_nest_end(skb, mp);
35173518
} else {
3518-
if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags) < 0)
3519+
if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags, false) < 0)
35193520
goto nla_put_failure;
35203521
}
35213522

0 commit comments

Comments
 (0)