Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfrm: add XFRMA_REPLAY_VAL attribute to SA messages

After this commit, the attribute XFRMA_REPLAY_VAL is added when no ESN replay
value is defined. Thus sequence number values are always notified to userspace.

Signed-off-by: dingzhi <zhi.ding@6wind.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

authored by

dingzhi and committed by
Steffen Klassert
f293a5e3 5c1e9f2c

+8 -4
+8 -4
net/xfrm/xfrm_user.c
··· 824 824 ret = xfrm_mark_put(skb, &x->mark); 825 825 if (ret) 826 826 goto out; 827 - if (x->replay_esn) { 827 + if (x->replay_esn) 828 828 ret = nla_put(skb, XFRMA_REPLAY_ESN_VAL, 829 829 xfrm_replay_state_esn_len(x->replay_esn), 830 830 x->replay_esn); 831 - if (ret) 832 - goto out; 833 - } 831 + else 832 + ret = nla_put(skb, XFRMA_REPLAY_VAL, sizeof(x->replay), 833 + &x->replay); 834 + if (ret) 835 + goto out; 834 836 if (x->security) 835 837 ret = copy_sec_ctx(x->security, skb); 836 838 out: ··· 2571 2569 l += nla_total_size(sizeof(x->tfcpad)); 2572 2570 if (x->replay_esn) 2573 2571 l += nla_total_size(xfrm_replay_state_esn_len(x->replay_esn)); 2572 + else 2573 + l += nla_total_size(sizeof(struct xfrm_replay_state)); 2574 2574 if (x->security) 2575 2575 l += nla_total_size(sizeof(struct xfrm_user_sec_ctx) + 2576 2576 x->security->ctx_len);