]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfrm: add error messages to state migration
authorAntony Antony <antony.antony@secunet.com>
Tue, 26 May 2026 19:08:29 +0000 (21:08 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 4 Jun 2026 10:22:41 +0000 (12:22 +0200)
Add descriptive(extack) error messages for all error paths
in state migration. This improves diagnostics by
providing clear feedback when migration fails.

After xfrm_init_state() use NL_SET_ERR_MSG_WEAK() as fallback for
error paths not yet propagating extack e.g. mode_cbs->init_state()

No functional change.

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_state.c

index fcf6f0c6400dcfa66ec7949212f9da70806d79dd..1db48ecda80d5571d14c29d6aa5ede005b9d212b 100644 (file)
@@ -2130,11 +2130,15 @@ struct xfrm_state *xfrm_state_migrate_create(struct xfrm_state *x,
        struct xfrm_state *xc;
 
        xc = xfrm_state_clone_and_setup(x, encap, m);
-       if (!xc)
+       if (!xc) {
+               NL_SET_ERR_MSG(extack, "Failed to clone and setup state");
                return NULL;
+       }
 
-       if (xfrm_init_state(xc, extack) < 0)
+       if (xfrm_init_state(xc, extack) < 0) {
+               NL_SET_ERR_MSG_WEAK(extack, "Failed to initialize migrated state");
                goto error;
+       }
 
        /* configure the hardware if offload is requested */
        if (xuo && xfrm_dev_state_add(net, xc, xuo, extack))
@@ -2163,6 +2167,7 @@ int xfrm_state_migrate_install(const struct xfrm_state *x,
                xfrm_state_insert(xc);
        } else {
                if (xfrm_state_add(xc) < 0) {
+                       NL_SET_ERR_MSG(extack, "Failed to add migrated state");
                        if (xuo)
                                xfrm_dev_state_delete(xc);
                        xc->km.state = XFRM_STATE_DEAD;