xtables-addons: update rtsp extension
authorDENG Qingfang <dengqf6@mail2.sysu.edu.cn>
Sun, 1 Mar 2020 12:48:31 +0000 (20:48 +0800)
committerDENG Qingfang <dengqf6@mail2.sysu.edu.cn>
Sun, 1 Mar 2020 12:48:31 +0000 (20:48 +0800)
57394bc Fix build with Linux 5.3
b95d68c Use uint for module parameter type for setup_timeout, remove -ve check

Signed-off-by: DENG Qingfang <dengqf6@mail2.sysu.edu.cn>
net/xtables-addons/patches/100-add-rtsp-conntrack.patch

index 3cb37007180eefd04e426d73aaeb718cfc11160a..9eddf780d49af53a3bb314e5932652ce72d15af8 100644 (file)
@@ -7,7 +7,7 @@
 +obj-m += nf_conntrack_rtsp.o
 --- /dev/null
 +++ b/extensions/rtsp/netfilter_helpers.h
-@@ -0,0 +1,133 @@
+@@ -0,0 +1,144 @@
 +/*
 + * Helpers for netfiler modules.  This file provides implementations for basic
 + * functions such as strncasecmp(), etc.
@@ -24,6 +24,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' )
 +
 +}
 +#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 */
 +#endif /* _NETFILTER_MIME_H */
 --- /dev/null
 +++ b/extensions/rtsp/nf_conntrack_rtsp.c
-@@ -0,0 +1,761 @@
+@@ -0,0 +1,756 @@
 +/*
 + * RTSP extension for IP connection tracking
 + * (C) 2003 by Tom Marshall <tmarshall at real.com>
 +#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 <net/netfilter/nf_conntrack_zones.h>
 +#include "nf_conntrack_rtsp.h"
 +MODULE_PARM_DESC(ports, "port numbers of RTSP servers");
 +module_param(max_outstanding, int, 0400);
 +MODULE_PARM_DESC(max_outstanding, "max number of outstanding SETUP requests per RTSP session");
-+module_param(setup_timeout, int, 0400);
++module_param(setup_timeout, uint, 0400);
 +MODULE_PARM_DESC(setup_timeout, "timeout on for unestablished data channels");
 +
 +static char *rtsp_buffer;
 +                                        &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;
 +              printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
 +              return -EBUSY;
 +      }
-+      if (setup_timeout < 0) {
-+              printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
-+              return -EBUSY;
-+      }
 +
 +      rtsp_exp_policy.max_expected = max_outstanding;
 +      rtsp_exp_policy.timeout = setup_timeout;
 +#endif /* _IP_CONNTRACK_RTSP_H */
 --- /dev/null
 +++ b/extensions/rtsp/nf_nat_rtsp.c
-@@ -0,0 +1,636 @@
+@@ -0,0 +1,635 @@
 +/*
 + * RTSP extension for TCP NAT alteration
 + * (C) 2003 by Tom Marshall <tmarshall at real.com>
 +#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>
 +      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;
 +                      }
 +      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;
 +                      }
 +      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;
 +                      }