network: xfrm: refuse zero interface ID
Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically, https://github.com/torvalds/linux/commit/8dce43919566f06e865f7e8949f5c10d8c2493f5) the kernel refuses to create an xfrm interface with zero ID.
This commit is contained in:
@@ -14,6 +14,7 @@ static int xfrm_fill_message_create(NetDev *netdev, Link *link, sd_netlink_messa
|
||||
|
||||
x = XFRM(netdev);
|
||||
|
||||
assert(x);
|
||||
assert(link || x->independent);
|
||||
|
||||
r = sd_netlink_message_append_u32(message, IFLA_XFRM_LINK, link ? link->ifindex : LOOPBACK_IFINDEX);
|
||||
@@ -27,10 +28,28 @@ static int xfrm_fill_message_create(NetDev *netdev, Link *link, sd_netlink_messa
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xfrm_verify(NetDev *netdev, const char *filename) {
|
||||
Xfrm *x;
|
||||
|
||||
assert(netdev);
|
||||
assert(filename);
|
||||
|
||||
x = XFRM(netdev);
|
||||
|
||||
assert(x);
|
||||
|
||||
if (x->if_id == 0)
|
||||
return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
|
||||
"%s: Xfrm interface ID cannot be zero.", filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const NetDevVTable xfrm_vtable = {
|
||||
.object_size = sizeof(Xfrm),
|
||||
.sections = NETDEV_COMMON_SECTIONS "Xfrm\0",
|
||||
.fill_message_create = xfrm_fill_message_create,
|
||||
.config_verify = xfrm_verify,
|
||||
.create_type = NETDEV_CREATE_STACKED,
|
||||
.iftype = ARPHRD_NONE,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user