xfrmi_build_state() parses RTA_ENCAP with nla_parse_nested(), which
requires NLA_F_NESTED, but lwtunnel_fill_encap() dumps RTA_ENCAP
without it. As a result, "ip route restore" cannot restore the routes
saved by "ip route save":
# ip -6 route add 2001:db8:3::/64 dev ipsec0 encap xfrm if_id 1
# ip -6 route save 2001:db8:3::/64 > route.bin
# ip -6 route del 2001:db8:3::/64
# ip -6 route restore < route.bin
Error: NLA_F_NESTED is missing.
Use lwtunnel_nla_parse().
Fixes: 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces
in collect_md mode")
Assisted-by: LLM
Signed-off-by: Yuya Kusakabe <[email protected]>
---
net/xfrm/xfrm_interface_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_interface_core.c b/net/xfrm/xfrm_interface_core.c
index 688306bf62c5..2fcfbfac315a 100644
--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -80,7 +80,8 @@ static int xfrmi_build_state(struct net *net, struct nlattr
*nla,
struct xfrm_md_info *info;
int ret;
- ret = nla_parse_nested(tb, LWT_XFRM_MAX, nla, xfrm_lwt_policy, extack);
+ ret = lwtunnel_nla_parse(tb, LWT_XFRM_MAX, nla, xfrm_lwt_policy,
+ extack);
if (ret < 0)
return ret;
--
2.50.1