Patch for ip_nat_rtsp.c
Subsystems (2)
Hi
I was trying to get the RTSP nat module to work by applying the patches in patch-o-matic but ip_nat_rtsp.c continued to give compiler errors. I patched as far as I could but got stuck in help_out where it uses seq field of struct ip_conntrack_expect, which I believe was removed in 2.6.11. I haven't been able to figure out the exact functionality and I see on other nat modules that they were simplified a lot after the 2.6.11 API change.
Maybe someone on the list can understand the functionality better, or can hint me on what should be changed. /Sverker
include/linux/netfilter_ipv4/ip_conntrack_rtsp.h +7 -0
@@ -47,6 +47,13 @@#endif }; +/* For NAT to hook in when we find a packet which describes what other +* connection we should expect. */ +extern unsigned int (*ip_nat_rtsp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct ip_ct_rtsp_expect *expinfo, +struct ip_conntrack_expect *exp); +#ifdef __KERNEL__#define RTSP_PORT 554
net/ipv4/netfilter/ip_nat_rtsp.c +18 -17
@@ -69,6 +69,7 @@static int num_ports =0 ;static u_int32_t extip =0 ;static int dstact =0 ; +static DEFINE_SPINLOCK (ip_rtsp_lock);MODULE_AUTHOR ("Tom Marshall <[email protected]>" );MODULE_DESCRIPTION ("RTSP network address translation module" );
@@ -163,8 +164,8 @@case pb_single:for (loport = prtspexp->loport; loport !=0 ; loport++)/* XXX: improper wrap? */ { - t.dst.u.udp.port =htons (loport); -if (ip_conntrack_change_expect (exp, &t) ==0 ) + exp->tuple.dst.u.udp.port =htons (loport); +if (ip_conntrack_expect_related (exp) ==0 ) {DEBUGP ("using port %hu\n" , loport);break ;
@@ -179,8 +180,8 @@case pb_range:for (loport = prtspexp->loport; loport !=0 ; loport +=2 )/* XXX: improper wrap? */ { - t.dst.u.udp.port =htons (loport); -if (ip_conntrack_change_expect (exp, &t) ==0 ) + exp->tuple.dst.u.udp.port =htons (loport); +if (ip_conntrack_expect_related (exp) ==0 ) { hiport = loport + ~exp->mask.dst.u.udp.port;DEBUGP ("using ports %hu-%hu\n" , loport, hiport);
@@ -196,8 +197,8 @@case pb_discon:for (loport = prtspexp->loport; loport !=0 ; loport++)/* XXX: improper wrap? */ { - t.dst.u.udp.port =htons (loport); -if (ip_conntrack_change_expect (exp, &t) ==0 ) + exp->tuple.dst.u.udp.port =htons (loport); +if (ip_conntrack_expect_related (exp) ==0 ) {DEBUGP ("using port %hu (1 of 2)\n" , loport);break ;
@@ -205,8 +206,8 @@ }for (hiport = prtspexp->hiport; hiport !=0 ; hiport++)/* XXX: improper wrap? */ { - t.dst.u.udp.port =htons (hiport); -if (ip_conntrack_change_expect (exp, &t) ==0 ) + exp->tuple.dst.u.udp.port =htons (hiport); +if (ip_conntrack_expect_related (exp) ==0 ) {DEBUGP ("using port %hu (2 of 2)\n" , hiport);break ;
@@ -365,7 +366,7 @@static unsigned int expected (struct sk_buff **pskb,uint hooknum,struct ip_conntrack * ct,struct ip_nat_info * info) { -struct ip_nat_multi_range mr; +struct ip_nat_range mr;u_int32_t newdstip, newsrcip, newip;struct ip_conntrack *master =master_ct (ct);
@@ -382,10 +383,9 @@DEBUGP ("newsrcip=%u.%u.%u.%u, newdstip=%u.%u.%u.%u, newip=%u.%u.%u.%u\n" ,NIPQUAD (newsrcip),NIPQUAD (newdstip),NIPQUAD (newip)); - mr.rangesize =1 ;/* We don't want to manip the per-protocol, just the IPs. */ - mr.range[0 ].flags =IP_NAT_RANGE_MAP_IPS ; - mr.range[0 ].min_ip = mr.range[0 ].max_ip = newip; + mr.flags =IP_NAT_RANGE_MAP_IPS ; + mr.min_ip = mr.max_ip = newip;return ip_nat_setup_info (ct, &mr, hooknum); }
@@ -428,7 +428,7 @@if (nf_strncasecmp (ptcp+lineoff,"Transport:" ,10 ) ==0 ) {uint oldtcplen = tcplen; -if (!rtsp_mangle_tran (ct, ctinfo, exp, prtspexp, pskb, lineoff, linelen)) +if (!rtsp_mangle_tran (ctinfo, exp, prtspexp, pskb, lineoff, linelen)) {break ; }
@@ -445,9 +445,9 @@ }static int -help (struct sk_buff **pskb +help (struct sk_buff **pskb,enum ip_conntrack_info ctinfo, - struct ip_ct_rtsp_expect *ct_rtsp_info; +struct ip_ct_rtsp_expect *ct_rtsp_info,struct ip_conntrack_expect * exp) {struct iphdr * iph = (struct iphdr *)(*pskb)->nh.iph;
@@ -456,17 +456,18 @@int dir =CTINFO2DIR (ctinfo);int rc =NF_ACCEPT ; +spin_lock_bh (&ip_rtsp_lock);switch (dir) {case IP_CT_DIR_ORIGINAL : - rc =help_out (pskb, ctinfo, ct_rtsp_info, exp, pskb); + rc =help_out (pskb, ctinfo, ct_rtsp_info, exp);break ;case IP_CT_DIR_REPLY :/* XXX: unmangle */ rc =NF_ACCEPT ;break ; } -UNLOCK_BH (&ip_rtsp_lock); +spin_unlock_bh (&ip_rtsp_lock);return rc; }