]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfrm: prevent configuration of interface index when offload is used
authorLeon Romanovsky <leonro@nvidia.com>
Tue, 13 May 2025 10:59:19 +0000 (13:59 +0300)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 15 May 2025 07:56:20 +0000 (09:56 +0200)
Both packet and crypto offloads perform decryption while packet is
arriving to the HW from the wire. It means that there is no possible
way to perform lookup on XFRM if_id as it can't be set to be "before' HW.

So instead of silently ignore this configuration, let's warn users about
misconfiguration.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_device.c

index 3be0139373f75b947e39207331ba2a91d26156d4..81fd486b5e5664b4e58b3ea80c966c0a379030ee 100644 (file)
@@ -251,6 +251,11 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
                return -EINVAL;
        }
 
+       if (xuo->flags & XFRM_OFFLOAD_INBOUND && x->if_id) {
+               NL_SET_ERR_MSG(extack, "XFRM if_id is not supported in RX path");
+               return -EINVAL;
+       }
+
        is_packet_offload = xuo->flags & XFRM_OFFLOAD_PACKET;
 
        /* We don't yet support TFC padding. */