Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9 from sforshee/master
Fix build with Linux 5.3
  • Loading branch information
maru-sama committed Oct 31, 2019
2 parents 858db1e + 57394bc commit acb3f80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
11 changes: 11 additions & 0 deletions netfilter_helpers.h
Expand Up @@ -14,6 +14,8 @@
/* Only include these functions for kernel code. */
#ifdef __KERNEL__

#include <net/netfilter/nf_conntrack_expect.h>

#include <linux/ctype.h>
#define iseol(c) ( (c) == '\r' || (c) == '\n' )

Expand Down Expand Up @@ -128,6 +130,15 @@ nf_nextline(char* p, uint len, uint* poff, uint* plineoff, uint* plinelen)
}
#endif /* NF_NEED_NEXTLINE */

static inline int rtsp_nf_ct_expect_related(struct nf_conntrack_expect *expect)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
return nf_ct_expect_related(expect, 0);
#else
return nf_ct_expect_related(expect);
#endif
}

#endif /* __KERNEL__ */

#endif /* _NETFILTER_HELPERS_H */
5 changes: 2 additions & 3 deletions nf_conntrack_rtsp.c
Expand Up @@ -41,7 +41,6 @@
#include <net/tcp.h>

#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_expect.h>
#include <net/netfilter/nf_conntrack_helper.h>
#include "nf_conntrack_rtsp.h"

Expand Down Expand Up @@ -396,8 +395,8 @@ help_out(struct sk_buff *skb, unsigned char *rb_ptr, unsigned int datalen,
&expinfo, rtp_exp, rtcp_exp);
#endif
else {
if (nf_ct_expect_related(rtp_exp) == 0) {
if (rtcp_exp && nf_ct_expect_related(rtcp_exp) != 0) {
if (rtsp_nf_ct_expect_related(rtp_exp) == 0) {
if (rtcp_exp && rtsp_nf_ct_expect_related(rtcp_exp) != 0) {
nf_ct_unexpect_related(rtp_exp);
pr_info("nf_conntrack_expect_related failed for rtcp\n");
ret = NF_DROP;
Expand Down
11 changes: 5 additions & 6 deletions nf_nat_rtsp.c
Expand Up @@ -46,7 +46,6 @@
#endif
#include <net/netfilter/nf_nat_helper.h>
#include "nf_conntrack_rtsp.h"
#include <net/netfilter/nf_conntrack_expect.h>

#include <linux/inet.h>
#include <linux/ctype.h>
Expand Down Expand Up @@ -202,7 +201,7 @@ rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
case pb_single:
for (loport = prtspexp->loport; loport != 0; loport++) { /* XXX: improper wrap? */
rtp_t->dst.u.udp.port = htons(loport);
if (nf_ct_expect_related(rtp_exp) == 0) {
if (rtsp_nf_ct_expect_related(rtp_exp) == 0) {
pr_debug("using port %hu\n", loport);
break;
}
Expand All @@ -215,12 +214,12 @@ rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
case pb_range:
for (loport = prtspexp->loport; loport != 0; loport += 2) { /* XXX: improper wrap? */
rtp_t->dst.u.udp.port = htons(loport);
if (nf_ct_expect_related(rtp_exp) != 0) {
if (rtsp_nf_ct_expect_related(rtp_exp) != 0) {
continue;
}
hiport = loport + 1;
rtcp_exp->tuple.dst.u.udp.port = htons(hiport);
if (nf_ct_expect_related(rtcp_exp) != 0) {
if (rtsp_nf_ct_expect_related(rtcp_exp) != 0) {
nf_ct_unexpect_related(rtp_exp);
continue;
}
Expand All @@ -243,14 +242,14 @@ rtsp_mangle_tran(enum ip_conntrack_info ctinfo,
case pb_discon:
for (loport = prtspexp->loport; loport != 0; loport++) { /* XXX: improper wrap? */
rtp_t->dst.u.udp.port = htons(loport);
if (nf_ct_expect_related(rtp_exp) == 0) {
if (rtsp_nf_ct_expect_related(rtp_exp) == 0) {
pr_debug("using port %hu (1 of 2)\n", loport);
break;
}
}
for (hiport = prtspexp->hiport; hiport != 0; hiport++) { /* XXX: improper wrap? */
rtp_t->dst.u.udp.port = htons(hiport);
if (nf_ct_expect_related(rtp_exp) == 0) {
if (rtsp_nf_ct_expect_related(rtp_exp) == 0) {
pr_debug("using port %hu (2 of 2)\n", hiport);
break;
}
Expand Down

0 comments on commit acb3f80

Please sign in to comment.