Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f293a5e3 authored by dingzhi's avatar dingzhi Committed by Steffen Klassert
Browse files

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: default avatardingzhi <zhi.ding@6wind.com>
Signed-off-by: default avatarAdrien Mazarguil <adrien.mazarguil@6wind.com>
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 5c1e9f2c
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -824,13 +824,15 @@ static int copy_to_user_state_extra(struct xfrm_state *x,
	ret = xfrm_mark_put(skb, &x->mark);
	ret = xfrm_mark_put(skb, &x->mark);
	if (ret)
	if (ret)
		goto out;
		goto out;
	if (x->replay_esn) {
	if (x->replay_esn)
		ret = nla_put(skb, XFRMA_REPLAY_ESN_VAL,
		ret = nla_put(skb, XFRMA_REPLAY_ESN_VAL,
			      xfrm_replay_state_esn_len(x->replay_esn),
			      xfrm_replay_state_esn_len(x->replay_esn),
			      x->replay_esn);
			      x->replay_esn);
	else
		ret = nla_put(skb, XFRMA_REPLAY_VAL, sizeof(x->replay),
			      &x->replay);
	if (ret)
	if (ret)
		goto out;
		goto out;
	}
	if (x->security)
	if (x->security)
		ret = copy_sec_ctx(x->security, skb);
		ret = copy_sec_ctx(x->security, skb);
out:
out:
@@ -2569,6 +2571,8 @@ static inline size_t xfrm_sa_len(struct xfrm_state *x)
		l += nla_total_size(sizeof(x->tfcpad));
		l += nla_total_size(sizeof(x->tfcpad));
	if (x->replay_esn)
	if (x->replay_esn)
		l += nla_total_size(xfrm_replay_state_esn_len(x->replay_esn));
		l += nla_total_size(xfrm_replay_state_esn_len(x->replay_esn));
	else
		l += nla_total_size(sizeof(struct xfrm_replay_state));
	if (x->security)
	if (x->security)
		l += nla_total_size(sizeof(struct xfrm_user_sec_ctx) +
		l += nla_total_size(sizeof(struct xfrm_user_sec_ctx) +
				    x->security->ctx_len);
				    x->security->ctx_len);