The existing code does not allow migration from UDP encapsulation to non-encapsulation (ESP). This is useful when migrating from behind a NAT to no NAT, or from IPv4 with NAT to IPv6 without NAT. With this fix, while migrating state, the existing encap will be copied only if the migrate call includes the encap attribute. Which fixes tag should I add? Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)") ? or Fixes: 4ab47d47af20 ("xfrm: extend MIGRATE with UDP encapsulation port") ? Signed-off-by: Antony Antony --- net/xfrm/xfrm_state.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 7f70ea7f4d46..1770b56c8587 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2008,14 +2008,8 @@ static struct xfrm_state *xfrm_state_clone_and_setup(struct xfrm_state *orig, } x->props.calgo = orig->props.calgo; - if (encap || orig->encap) { - if (encap) - x->encap = kmemdup(encap, sizeof(*x->encap), - GFP_KERNEL); - else - x->encap = kmemdup(orig->encap, sizeof(*x->encap), - GFP_KERNEL); - + if (encap) { + x->encap = kmemdup(encap, sizeof(*x->encap), GFP_KERNEL); if (!x->encap) goto error; } -- 2.39.5