Browse Source

TT#145450 cache last used PT to avoid repeated bsearch

Change-Id: I4d7d11f40a9c4225418b8f9835a8f2f5047dcdd2
pull/1388/head
Richard Fuchs 4 years ago
parent
commit
e443614d16
1 changed files with 13 additions and 4 deletions
  1. +13
    -4
      kernel-module/xt_RTPENGINE.c

+ 13
- 4
kernel-module/xt_RTPENGINE.c View File

@ -299,6 +299,7 @@ struct rtpengine_target {
atomic_t refcnt;
uint32_t table;
struct rtpengine_target_info target;
unsigned int last_pt; // index into payload_types[]
struct rtpengine_stats_a stats;
struct rtpengine_rtp_stats_a rtp_stats[RTPE_NUM_PAYLOAD_TYPES];
@ -4184,11 +4185,18 @@ static int rtp_payload_match(const void *a, const void *b) {
}
#endif
static inline int rtp_payload_type(const struct rtp_header *hdr, const struct rtpengine_target_info *tg) {
static inline int rtp_payload_type(const struct rtp_header *hdr, const struct rtpengine_target_info *tg,
int *last_pt)
{
struct rtpengine_payload_type pt;
const struct rtpengine_payload_type *match;
pt.pt_num = hdr->m_pt & 0x7f;
if (*last_pt < tg->num_payload_types) {
match = &tg->payload_types[*last_pt];
if (rtp_payload_match(match, &pt) == 0)
goto found;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0)
match = bsearch(&pt, tg->payload_types, tg->num_payload_types, sizeof(pt), rtp_payload_match);
#else
@ -4197,11 +4205,12 @@ static inline int rtp_payload_type(const struct rtp_header *hdr, const struct rt
goto found;
}
match = NULL;
found:
#endif
if (!match)
return -1;
return match - tg->payload_types;
found:
*last_pt = match - tg->payload_types;
return *last_pt;
}
static struct sk_buff *intercept_skb_copy(struct sk_buff *oskb, const struct re_address *src) {
@ -4441,7 +4450,7 @@ src_check_ok:
goto not_rtp;
}
rtp_pt_idx = rtp_payload_type(rtp.header, &g->target);
rtp_pt_idx = rtp_payload_type(rtp.header, &g->target, &g->last_pt);
// Pass to userspace if SSRC has changed.
errstr = "SSRC mismatch";


Loading…
Cancel
Save