"ip route save" stores a route dump and "ip route restore" sends it
back to the kernel unchanged. The kernel dumps RTA_ENCAP, and some of
the attributes nested in it, without NLA_F_NESTED, but rpl, ioam6,
xfrm and the geneve, vxlan and erspan options of the ip and ip6 encaps
require the flag when parsing them. Restoring such a route fails with
"NLA_F_NESTED is missing", and none of them has been restorable in any
release.
Setting the flag in the dumps would change the UAPI: userspace that
does not mask it off the attribute type, such as parse_rtattr() in
iproute2, would no longer find RTA_ENCAP, and dumps that have already
been saved would still fail. The series therefore only makes the
parsers accept what the kernel itself dumps. The dumps, and the
attributes accepted with the flag set, stay as they are.
Patch 1 adds lwtunnel_nla_parse() to the lwtunnel core, so that the
missing flag is documented once next to the build_state callback
instead of being worked around in each lwtunnel. It is
nla_parse_nested() without the flag check: the nested attributes are
still validated strictly, which nla_parse_nested_deprecated(), used by
the older lwtunnels, would not do. Patch 1 uses it in rpl and ioam6,
and patch 2 in xfrm.
Patch 3 does the same for the ip and ip6 encaps, whose geneve, vxlan
and erspan options are nested one level further down: the level shared
by all options is validated through lwtunnel_nla_validate(), the
counterpart of lwtunnel_nla_parse() for nla_validate(). Nothing but
the NLA_F_NESTED check is relaxed.
Patch 4 adds a selftest that saves and restores a route of each kind.
---
Yuya Kusakabe (4):
net: lwtunnel: accept RTA_ENCAP without NLA_F_NESTED
xfrm: lwtunnel: accept RTA_ENCAP without NLA_F_NESTED
net: ip_tunnel: accept tunnel options without NLA_F_NESTED
selftests: net: add lwtunnel route save and restore test
include/net/lwtunnel.h | 49 ++++++++++
net/ipv4/ip_tunnel_core.c | 24 +++--
net/ipv6/ioam6_iptunnel.c | 4 +-
net/ipv6/rpl_iptunnel.c | 4 +-
net/xfrm/xfrm_interface_core.c | 3 +-
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/lwt_save_restore.sh | 116 ++++++++++++++++++++++++
7 files changed, 186 insertions(+), 15 deletions(-)
---
base-commit: 17741334d00bf5ebd37f8c1c36bc9c146a351deb
change-id: 20260918-lwt-encap-noflag-ae795af30b52
Best regards,
--
Yuya Kusakabe <[email protected]>