Skip to content

Commit

Permalink
MT#55283 fix kernel SRTCP indexing
Browse files Browse the repository at this point in the history
Only increase the SRTCP index when encrypted SRTCP is actually in use.

This would be apparent when a stream is switched from RTCP to SRTCP.

Change-Id: I3a31377b89c5124035152d504e7d99f8cf1d96a1
  • Loading branch information
rfuchs committed Apr 18, 2024
1 parent 7117727 commit c5f56c4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kernel-module/xt_RTPENGINE.c
Original file line number Diff line number Diff line change
Expand Up @@ -4788,7 +4788,7 @@ static inline int srtp_encrypt(struct re_crypto_context *c,
}
static inline int srtcp_encrypt(struct re_crypto_context *c,
struct rtpengine_srtp *s, struct rtp_parsed *r,
uint64_t pkt_idx)
uint64_t *pkt_idxp)
{
int ret;
uint32_t idx;
Expand All @@ -4797,13 +4797,14 @@ static inline int srtcp_encrypt(struct re_crypto_context *c,
return 0;
if (!c->cipher->encrypt_rtcp)
return 0;
ret = c->cipher->encrypt_rtcp(c, s, r, &pkt_idx);
ret = c->cipher->encrypt_rtcp(c, s, r, pkt_idxp);
if (ret)
return ret;

idx = htonl(0x80000000ULL | pkt_idx);
idx = htonl(0x80000000ULL | *pkt_idxp);
memcpy(r->payload + r->payload_len, &idx, sizeof(idx));
r->payload_len += sizeof(idx);
(*pkt_idxp)++;

return 0;
}
Expand Down Expand Up @@ -4987,7 +4988,7 @@ static void proxy_packet_output_rtcp(struct sk_buff *skb, struct rtpengine_outpu
pkt_idx = o->output.encrypt.last_rtcp_index[ssrc_idx]++;
spin_unlock_irqrestore(&o->encrypt_rtcp.lock, flags);
pllen = rtp->payload_len;
srtcp_encrypt(&o->encrypt_rtcp, &o->output.encrypt, rtp, pkt_idx);
srtcp_encrypt(&o->encrypt_rtcp, &o->output.encrypt, rtp, &o->output.encrypt.last_rtcp_index[ssrc_idx]);
srtcp_authenticate(&o->encrypt_rtcp, &o->output.encrypt, rtp, pkt_idx);
skb_put(skb, rtp->payload_len - pllen);
}
Expand Down

0 comments on commit c5f56c4

Please sign in to comment.