forked from Minki/linux
net: ipv4: Fix rtnexthop len when RTA_FLOW is present
Multipath RTA_FLOW is embedded in nexthop. Dump it in fib_add_nexthop()
to get the length of rtnexthop correct.
Fixes: b0f6019363
("ipv4: Refactor nexthop attributes in fib_dump_info")
Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
325fd36ae7
commit
597aa16c78
@ -597,5 +597,5 @@ int ip_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
|
|||||||
int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh,
|
int fib_nexthop_info(struct sk_buff *skb, const struct fib_nh_common *nh,
|
||||||
u8 rt_family, unsigned char *flags, bool skip_oif);
|
u8 rt_family, unsigned char *flags, bool skip_oif);
|
||||||
int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh,
|
int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nh,
|
||||||
int nh_weight, u8 rt_family);
|
int nh_weight, u8 rt_family, u32 nh_tclassid);
|
||||||
#endif /* _NET_FIB_H */
|
#endif /* _NET_FIB_H */
|
||||||
|
@ -325,7 +325,7 @@ int nexthop_mpath_fill_node(struct sk_buff *skb, struct nexthop *nh,
|
|||||||
struct fib_nh_common *nhc = &nhi->fib_nhc;
|
struct fib_nh_common *nhc = &nhi->fib_nhc;
|
||||||
int weight = nhg->nh_entries[i].weight;
|
int weight = nhg->nh_entries[i].weight;
|
||||||
|
|
||||||
if (fib_add_nexthop(skb, nhc, weight, rt_family) < 0)
|
if (fib_add_nexthop(skb, nhc, weight, rt_family, 0) < 0)
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1661,7 +1661,7 @@ EXPORT_SYMBOL_GPL(fib_nexthop_info);
|
|||||||
|
|
||||||
#if IS_ENABLED(CONFIG_IP_ROUTE_MULTIPATH) || IS_ENABLED(CONFIG_IPV6)
|
#if IS_ENABLED(CONFIG_IP_ROUTE_MULTIPATH) || IS_ENABLED(CONFIG_IPV6)
|
||||||
int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc,
|
int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc,
|
||||||
int nh_weight, u8 rt_family)
|
int nh_weight, u8 rt_family, u32 nh_tclassid)
|
||||||
{
|
{
|
||||||
const struct net_device *dev = nhc->nhc_dev;
|
const struct net_device *dev = nhc->nhc_dev;
|
||||||
struct rtnexthop *rtnh;
|
struct rtnexthop *rtnh;
|
||||||
@ -1679,6 +1679,9 @@ int fib_add_nexthop(struct sk_buff *skb, const struct fib_nh_common *nhc,
|
|||||||
|
|
||||||
rtnh->rtnh_flags = flags;
|
rtnh->rtnh_flags = flags;
|
||||||
|
|
||||||
|
if (nh_tclassid && nla_put_u32(skb, RTA_FLOW, nh_tclassid))
|
||||||
|
goto nla_put_failure;
|
||||||
|
|
||||||
/* length of rtnetlink header + attributes */
|
/* length of rtnetlink header + attributes */
|
||||||
rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *)rtnh;
|
rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *)rtnh;
|
||||||
|
|
||||||
@ -1706,14 +1709,13 @@ static int fib_add_multipath(struct sk_buff *skb, struct fib_info *fi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for_nexthops(fi) {
|
for_nexthops(fi) {
|
||||||
if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight,
|
u32 nh_tclassid = 0;
|
||||||
AF_INET) < 0)
|
|
||||||
goto nla_put_failure;
|
|
||||||
#ifdef CONFIG_IP_ROUTE_CLASSID
|
#ifdef CONFIG_IP_ROUTE_CLASSID
|
||||||
if (nh->nh_tclassid &&
|
nh_tclassid = nh->nh_tclassid;
|
||||||
nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
|
|
||||||
goto nla_put_failure;
|
|
||||||
#endif
|
#endif
|
||||||
|
if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight,
|
||||||
|
AF_INET, nh_tclassid) < 0)
|
||||||
|
goto nla_put_failure;
|
||||||
} endfor_nexthops(fi);
|
} endfor_nexthops(fi);
|
||||||
|
|
||||||
mp_end:
|
mp_end:
|
||||||
|
@ -5681,14 +5681,15 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
|
|||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
||||||
if (fib_add_nexthop(skb, &rt->fib6_nh->nh_common,
|
if (fib_add_nexthop(skb, &rt->fib6_nh->nh_common,
|
||||||
rt->fib6_nh->fib_nh_weight, AF_INET6) < 0)
|
rt->fib6_nh->fib_nh_weight, AF_INET6,
|
||||||
|
0) < 0)
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
||||||
list_for_each_entry_safe(sibling, next_sibling,
|
list_for_each_entry_safe(sibling, next_sibling,
|
||||||
&rt->fib6_siblings, fib6_siblings) {
|
&rt->fib6_siblings, fib6_siblings) {
|
||||||
if (fib_add_nexthop(skb, &sibling->fib6_nh->nh_common,
|
if (fib_add_nexthop(skb, &sibling->fib6_nh->nh_common,
|
||||||
sibling->fib6_nh->fib_nh_weight,
|
sibling->fib6_nh->fib_nh_weight,
|
||||||
AF_INET6) < 0)
|
AF_INET6, 0) < 0)
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user