All of lore.kernel.org
 help / color / mirror / Atom feed
* ipt_time fixes (resend, sorry)
@ 2005-01-14 14:04 Krzysztof Oledzki
  2005-01-14 14:37 ` Bill Rugolsky Jr.
       [not found] ` <200502030010.47260.fabrice.marie@fma-rms.com>
  0 siblings, 2 replies; 24+ messages in thread
From: Krzysztof Oledzki @ 2005-01-14 14:04 UTC (permalink / raw)
  To: Fabrice MARIE; +Cc: Netfilter Development Mailinglist

[-- Attachment #1: Type: TEXT/PLAIN, Size: 4850 bytes --]

Hello,

My two patches fixes two problem I have just found. I tried to 
migrate from 2.4.x to the 2.6.11-rc1 kernel. Patches are against 
patch-o-matic-ng-20050105 but can be cleanly applied to the latest 
patch-o-matic-ng (20050113).

1. Fix compilation, without this patch I got:

net/ipv4/netfilter/ipt_time.c:128: warning: initialization makes integer from pointer without a cast
net/ipv4/netfilter/ipt_time.c:128: error: initializer element is not computable at load time
net/ipv4/netfilter/ipt_time.c:128: error: (near initialization for `time_match.revision')
net/ipv4/netfilter/ipt_time.c:128: warning: initialization from incompatible pointer type
net/ipv4/netfilter/ipt_time.c:128: warning: initialization from incompatible pointer type
make[3]: *** [net/ipv4/netfilter/ipt_time.o] Error 1
make[2]: *** [net/ipv4/netfilter] Error 2
make[1]: *** [net/ipv4] Error 2
make: *** [net] Error 2

Anyway, should we use "match"/"checkentry" or "&match"/"&checkentry"?
I noticed different netfilter modules use different syntax.

diff -Nur patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c
--- patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c	2004-05-05 12:11:24.000000000 +0200
+++ patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 12:15:09.000000000 +0100
@@ -48,8 +48,6 @@
         const struct net_device *out,
         const void *matchinfo,
         int offset,
-      const void *hdr,
-      u_int16_t datalen,
         int *hotdrop)
   {
   	const struct ipt_time_info *info = matchinfo;   /* match info for rule */
@@ -124,8 +122,12 @@
   	return 1;
   }

-static struct ipt_match time_match
-= { { NULL, NULL }, "time", &match, &checkentry, NULL, THIS_MODULE };
+static struct ipt_match time_match = {
+	.name		= "time",
+	.match		= match,
+	.checkentry	= checkentry,
+	.me		= THIS_MODULE,
+};

   static int __init init(void)
   {


2. Fix time match when skb->stamp.tv_sec is 0. I don't know why but on 
2.6.11-rc1 (and probably others 2.6.x kernels) skb->stamp.tv_sec seems to 
be allways 0, even on PRE_ROUTING and LOCAL_IN. So I fixed it by allways 
use kernel time byt only if skb->stamp.tv_sec is 0 (like in ULOG). With 
such modification we no longer needs kerneltime in the "struct ipt_time_info"
but I'm afraid we should keep it for binary compability, shouldn't we?

BTW, why we cannot use ipt_time on POSTROUTING?

diff -Nur patch-o-matic-ng-20050105-orig/time/linux/include/linux/netfilter_ipv4/ipt_time.h patch-o-matic-ng-20050105/time/linux/include/linux/netfilter_ipv4/ipt_time.h
--- patch-o-matic-ng-20050105-orig/time/linux/include/linux/netfilter_ipv4/ipt_time.h	2004-05-05 12:11:24.000000000 +0200
+++ patch-o-matic-ng-20050105/time/linux/include/linux/netfilter_ipv4/ipt_time.h	2005-01-14 13:48:46.000000000 +0100
@@ -6,7 +6,10 @@
   	u_int8_t  days_match;   /* 1 bit per day. -SMTWTFS                      */
   	u_int16_t time_start;   /* 0 < time_start < 23*60+59 = 1439             */
   	u_int16_t time_stop;    /* 0:0 < time_stat < 23:59                      */
+
+				/* FIXME: Keep this one for userspace iptables binary compability: */
   	u_int8_t  kerneltime;   /* ignore skb time (and use kerneltime) or not. */
+
   	time_t    date_start;
   	time_t    date_stop;
   };
diff -Nur patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c
--- patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 12:15:09.000000000 +0100
+++ patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 13:46:47.000000000 +0100
@@ -57,13 +57,11 @@
   	struct timeval kerneltimeval;
   	time_t packet_local_time;

-	/* if kerneltime=1, we don't read the skb->timestamp but kernel time instead */
-	if (info->kerneltime)
-	{
+	/* We might not have a timestamp, get one */
+	if (skb->stamp.tv_sec == 0) {
   		do_gettimeofday(&kerneltimeval);
   		packet_local_time = kerneltimeval.tv_sec;
-	}
-	else
+	} else
   		packet_local_time = skb->stamp.tv_sec;

   	/* First we make sure we are in the date start-stop boundaries */
@@ -102,11 +100,6 @@
   		printk("ipt_time: error, only valid for PRE_ROUTING, LOCAL_IN, FORWARD and OUTPUT)\n");
   		return 0;
   	}
-	/* we use the kerneltime if we are in forward or output */
-	info->kerneltime = 1;
-	if (hook_mask & ~((1 << NF_IP_FORWARD) | (1 << NF_IP_LOCAL_OUT))) 
-		/* we use the skb time */
-		info->kerneltime = 0;

   	/* Check the size */
   	if (matchsize != IPT_ALIGN(sizeof(struct ipt_time_info)))


Both patches are atatched. Tested on 2.6.11-rc1.

Best regards,


  			Krzysztof Olędzki

[-- Attachment #2: Type: TEXT/PLAIN, Size: 961 bytes --]

diff -Nur patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c
--- patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c	2004-05-05 12:11:24.000000000 +0200
+++ patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 12:15:09.000000000 +0100
@@ -48,8 +48,6 @@
       const struct net_device *out,
       const void *matchinfo,
       int offset,
-      const void *hdr,
-      u_int16_t datalen,
       int *hotdrop)
 {
 	const struct ipt_time_info *info = matchinfo;   /* match info for rule */
@@ -124,8 +122,12 @@
 	return 1;
 }
 
-static struct ipt_match time_match
-= { { NULL, NULL }, "time", &match, &checkentry, NULL, THIS_MODULE };
+static struct ipt_match time_match = {
+	.name		= "time",
+	.match		= match,
+	.checkentry	= checkentry,
+	.me		= THIS_MODULE,
+};
 
 static int __init init(void)
 {

[-- Attachment #3: Type: TEXT/PLAIN, Size: 2183 bytes --]

diff -Nur patch-o-matic-ng-20050105-orig/time/linux/include/linux/netfilter_ipv4/ipt_time.h patch-o-matic-ng-20050105/time/linux/include/linux/netfilter_ipv4/ipt_time.h
--- patch-o-matic-ng-20050105-orig/time/linux/include/linux/netfilter_ipv4/ipt_time.h	2004-05-05 12:11:24.000000000 +0200
+++ patch-o-matic-ng-20050105/time/linux/include/linux/netfilter_ipv4/ipt_time.h	2005-01-14 13:48:46.000000000 +0100
@@ -6,7 +6,10 @@
 	u_int8_t  days_match;   /* 1 bit per day. -SMTWTFS                      */
 	u_int16_t time_start;   /* 0 < time_start < 23*60+59 = 1439             */
 	u_int16_t time_stop;    /* 0:0 < time_stat < 23:59                      */
+
+				/* FIXME: Keep this one for userspace iptables binary compability: */
 	u_int8_t  kerneltime;   /* ignore skb time (and use kerneltime) or not. */
+
 	time_t    date_start;
 	time_t    date_stop;
 };
diff -Nur patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c
--- patch-o-matic-ng-20050105-orig/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 12:15:09.000000000 +0100
+++ patch-o-matic-ng-20050105/time/linux/net/ipv4/netfilter/ipt_time.c	2005-01-14 13:46:47.000000000 +0100
@@ -57,13 +57,11 @@
 	struct timeval kerneltimeval;
 	time_t packet_local_time;
 
-	/* if kerneltime=1, we don't read the skb->timestamp but kernel time instead */
-	if (info->kerneltime)
-	{
+	/* We might not have a timestamp, get one */
+	if (skb->stamp.tv_sec == 0) {
 		do_gettimeofday(&kerneltimeval);
 		packet_local_time = kerneltimeval.tv_sec;
-	}
-	else
+	} else
 		packet_local_time = skb->stamp.tv_sec;
 
 	/* First we make sure we are in the date start-stop boundaries */
@@ -102,11 +100,6 @@
 		printk("ipt_time: error, only valid for PRE_ROUTING, LOCAL_IN, FORWARD and OUTPUT)\n");
 		return 0;
 	}
-	/* we use the kerneltime if we are in forward or output */
-	info->kerneltime = 1;
-	if (hook_mask & ~((1 << NF_IP_FORWARD) | (1 << NF_IP_LOCAL_OUT))) 
-		/* we use the skb time */
-		info->kerneltime = 0;
 
 	/* Check the size */
 	if (matchsize != IPT_ALIGN(sizeof(struct ipt_time_info)))

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2005-04-12 18:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-14 14:04 ipt_time fixes (resend, sorry) Krzysztof Oledzki
2005-01-14 14:37 ` Bill Rugolsky Jr.
2005-01-14 14:48   ` Krzysztof Oledzki
2005-01-14 15:32     ` Samuel Jean
2005-01-14 15:24       ` Krzysztof Oledzki
2005-01-14 16:27         ` Brad Fisher
2005-01-14 16:35           ` Brad Fisher
2005-01-20 13:40             ` Krzysztof Oledzki
2005-01-20 16:35               ` Brad Fisher
2005-01-20 17:18                 ` Krzysztof Oledzki
2005-01-20 18:33                   ` Samuel Jean
2005-01-20 18:45                     ` Brad Fisher
2005-01-20 22:54                     ` Krzysztof Oledzki
2005-01-21  0:23                       ` Samuel Jean
2005-02-01 12:06         ` Harald Welte
2005-02-01 16:52           ` Krzysztof Oledzki
2005-02-15  0:57             ` Harald Welte
2005-04-05  8:18           ` Krzysztof Oledzki
2005-04-10 20:26             ` Harald Welte
2005-04-12 18:45               ` Krzysztof Oledzki
2005-01-14 22:47       ` Samuel Jean
     [not found] ` <200502030010.47260.fabrice.marie@fma-rms.com>
     [not found]   ` <Pine.LNX.4.62.0502150219100.17929@bizon.gios.gov.pl>
2005-02-15 15:23     ` Fabrice MARIE
2005-02-15 15:58       ` Krzysztof Oledzki
2005-02-16 15:24         ` Fabrice MARIE

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.