Skip to contentSkip to conversation

:Replace with time_before in net/ipv4/ipip.c

PATCH In review Shani Moideen 2 participants 2 messages Apr 25, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 :Replace with time_before in net/ipv4/ipip.c

Hi,

Replacing (jiffies - errtime < TIMEOUT) with time_before in net/ipv4/ipip.c

thanks.

----

net/ipv4/ipip.c +3 -2
index 3ec5ce0..d2bc835 100644
@@ -108,6 +108,7 @@
 #include <linux/init.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/if_ether.h>
+#include <linux/jiffies.h>
 
 #include <net/sock.h>
 #include <net/ip.h>
@@ -324,7 +325,7 @@ static int ipip_err(struct sk_buff *skb, u32 info)
 	if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
 		goto out;
 
-	if (jiffies - t->err_time < IPTUNNEL_ERR_TIMEO)
+	if (time_before(jiffies , t->err_time + IPTUNNEL_ERR_TIMEO))
 		t->err_count++;
 	else
 		t->err_count = 1;
@@ -590,7 +591,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	if (tunnel->err_count > 0) {
-		if (jiffies - tunnel->err_time < IPTUNNEL_ERR_TIMEO) {
+		if (time_before(jiffies , tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
 			tunnel->err_count--;
 			dst_link_failure(skb);
 		} else
Signature · 1 line
Shani 
maintainer
#1 lore raw

From: Shani Moideen <[email protected]>
Date: Wed, 25 Apr 2007 11:30:13 +0530

Quoted 5 lines

Replacing (jiffies - errtime < TIMEOUT) with time_before in net/ipv4/ipip.c

thanks.

The test you are replacing actually gives a larger window of acceptance than time_before() does.

It's been a long standing issue whether we should give up this semantic advantage for the sake of code cleanliness in the networking code.