Only set IFLA_XFRM_IF_ID if not 0

A value of 0 for IFLA_XFRM_IF_ID is not valid and will be rejected by
the kernel by returning EINVAL, see [1]. Thus, only set the
IFLA_XFRM_IF_ID attribute in case Xfrmi.Ifid != 0.

[1] 8efd0d9c31/net/xfrm/xfrm_interface.c (L645-L648)
This commit is contained in:
Tobias Klauser 2022-02-19 15:21:19 +01:00 committed by Alessandro Boch
parent 59bb5b4d56
commit f7fd7af437

View File

@ -3229,8 +3229,9 @@ func parseVfInfo(data []syscall.NetlinkRouteAttr, id int) VfInfo {
func addXfrmiAttrs(xfrmi *Xfrmi, linkInfo *nl.RtAttr) {
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
data.AddRtAttr(nl.IFLA_XFRM_LINK, nl.Uint32Attr(uint32(xfrmi.ParentIndex)))
data.AddRtAttr(nl.IFLA_XFRM_IF_ID, nl.Uint32Attr(xfrmi.Ifid))
if xfrmi.Ifid != 0 {
data.AddRtAttr(nl.IFLA_XFRM_IF_ID, nl.Uint32Attr(xfrmi.Ifid))
}
}
func parseXfrmiData(link Link, data []syscall.NetlinkRouteAttr) {