ip_conntrack_amanda, passing amanda udp port as parameter
Subsystems (2)
Hello Folks,
We are using netfilter and ip_conntrack_amanda. However for historical reasons, amanda is using a different port than 10080. As the port is hard coded in ip_conntrack_amanda, I wrote a patch in order to be able to select the port through a parameter.
As I think this may be helpfull to others I send you this patch here. Feel free to do wathever you like with it.
Signature · 2 lines
Jean-Philippe Rey Professeur informatique - École Centrale Paris [email protected] 92295 Châtenay-Malabry Cedex - France
net/ipv4/netfilter/ip_conntrack_amanda.c +10 -4
@@ -8,11 +8,11 @@* 2 of the License, or (at your option) any later version. * * Module load syntax: -* insmod ip_conntrack_amanda.o [master_timeout=n] +* insmod ip_conntrack_amanda.o [master_timeout=n][master_port=m] * * Where master_timeout is the timeout (in seconds) of the master -* connection (port 10080). This defaults to 5 minutes but if -* your clients take longer than 5 minutes to do their work +* connection (port m, default to 10080). This defaults to 5 minutes +* but if your clients take longer than 5 minutes to do their work * before getting back to the Amanda server, you can increase * this value. *
@@ -29,12 +29,15 @@#include <linux/netfilter_ipv4/ip_conntrack_amanda.h> static unsigned int master_timeout =300 ; +static unsigned int master_port =10080 ;MODULE_AUTHOR ("Brian J. Murrell <[email protected]>" );MODULE_DESCRIPTION ("Amanda connection tracking module" );MODULE_LICENSE ("GPL" );MODULE_PARM (master_timeout,"i" ); +MODULE_PARM (master_port,"i" );MODULE_PARM_DESC (master_timeout,"timeout for the master connection" ); +MODULE_PARM_DESC (master_port,"udp port for the master connection" );static struct {char *match;int len; } conns[] = { {"DATA " ,5 },
@@ -126,7 +129,7 @@static int __init init (void ) { - amanda_helper.tuple.src.u.udp.port =htons (10080 ); + amanda_helper.tuple.src.u.udp.port =htons (master_port); amanda_helper.tuple.dst.protonum =IPPROTO_UDP ; amanda_helper.mask.src.u.udp.port =0xFFFF ; amanda_helper.mask.dst.protonum =0xFFFF ;
@@ -137,6 +140,9 @@ amanda_helper.help = help; amanda_helper.name ="amanda" ; +printk (KERN_INFO "ip_conntrack_amanda: port=%d, timeout=%ds\n" , + master_port, master_timeout); +return ip_conntrack_helper_register (&amanda_helper); }
net/ipv4/netfilter/ip_nat_amanda.c +7 -2
@@ -8,7 +8,7 @@* 2 of the License, or (at your option) any later version. * * Module load syntax: -* insmod ip_nat_amanda.o +* insmod ip_nat_amanda.o [master_port=m] */ #include <linux/kernel.h>
@@ -26,10 +26,13 @@#include <linux/netfilter_ipv4/ip_conntrack_helper.h> #include <linux/netfilter_ipv4/ip_conntrack_amanda.h> +static unsigned int master_port =10080 ;MODULE_AUTHOR ("Brian J. Murrell <[email protected]>" );MODULE_DESCRIPTION ("Amanda NAT helper" );MODULE_LICENSE ("GPL" ); +MODULE_PARM (master_port,"i" ); +MODULE_PARM_DESC (master_port,"udp port for the master connection" ); static unsigned int amanda_nat_expected(struct sk_buff **pskb,
@@ -132,7 +135,7 @@struct ip_nat_helper *hlpr = &ip_nat_amanda_helper; hlpr->tuple.dst.protonum =IPPROTO_UDP ; - hlpr->tuple.src.u.udp.port =htons (10080 ); + hlpr->tuple.src.u.udp.port =htons (master_port); hlpr->mask.src.u.udp.port =0xFFFF ; hlpr->mask.dst.protonum =0xFFFF ; hlpr->help = help;
@@ -141,6 +144,8 @@ hlpr->expect = amanda_nat_expected; hlpr->name ="amanda" ; +printk (KERN_INFO ,"ip_nat_amanda: port=%d\n" , master_port); +return ip_nat_helper_register (hlpr); }