[PATCH] cosmetic cleanup patch
Rusty Russell
rusty@linuxcare.com.au
Fri, 21 Jul 2000 04:51:09 +1000
Linus, please apply.
Changes non-standard IP_PARTS() to NIPQUAD(), and spells guarantee
correctly.
Thanks to Marc Boucher,
Rusty.
--- linux-2.4.0-test4-ipparts/include/linux/netfilter_ipv4/ip_conntrack_tuple.h 2000/07/17 17:02:35 1.1
+++ linux-2.4.0-test4-ipparts/include/linux/netfilter_ipv4/ip_conntrack_tuple.h 2000/07/17 17:03:53
@@ -61,21 +61,13 @@
} dst;
};
-#define IP_PARTS_NATIVE(n) \
-(unsigned int)((n)>>24)&0xFF, \
-(unsigned int)((n)>>16)&0xFF, \
-(unsigned int)((n)>>8)&0xFF, \
-(unsigned int)((n)&0xFF)
-
-#define IP_PARTS(n) IP_PARTS_NATIVE(ntohl(n))
-
#ifdef __KERNEL__
#define DUMP_TUPLE(tp) \
-DEBUGP("tuple %p: %u %u.%u.%u.%u:%u -> %u.%u.%u.%u:%u\n", \
+DEBUGP("tuple %p: %u %u.%u.%u.%u:%hu -> %u.%u.%u.%u:%hu\n", \
(tp), (tp)->dst.protonum, \
- IP_PARTS((tp)->src.ip), ntohs((tp)->src.u.all), \
- IP_PARTS((tp)->dst.ip), ntohs((tp)->dst.u.all))
+ NIPQUAD((tp)->src.ip), ntohs((tp)->src.u.all), \
+ NIPQUAD((tp)->dst.ip), ntohs((tp)->dst.u.all))
#define CTINFO2DIR(ctinfo) ((ctinfo) >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL)
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_conntrack_core.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_conntrack_core.c 2000/07/17 17:06:57
@@ -644,8 +644,8 @@
} else if (((*pskb)->nh.iph->daddr & htonl(0x000000FF))
== htonl(0x000000FF)) {
printk("Should bcast: %u.%u.%u.%u->%u.%u.%u.%u (sk=%p, ptype=%u)\n",
- IP_PARTS((*pskb)->nh.iph->saddr),
- IP_PARTS((*pskb)->nh.iph->daddr),
+ NIPQUAD((*pskb)->nh.iph->saddr),
+ NIPQUAD((*pskb)->nh.iph->daddr),
(*pskb)->sk, (*pskb)->pkt_type);
}
#endif
@@ -945,7 +945,7 @@
.tuple.dst.ip;
DEBUGP("SO_ORIGINAL_DST: %u.%u.%u.%u %u\n",
- IP_PARTS(sin.sin_addr.s_addr), ntohs(sin.sin_port));
+ NIPQUAD(sin.sin_addr.s_addr), ntohs(sin.sin_port));
ip_conntrack_put(h->ctrack);
if (copy_to_user(user, &sin, sizeof(sin)) != 0)
return -EFAULT;
@@ -953,8 +953,8 @@
return 0;
}
DEBUGP("SO_ORIGINAL_DST: Can't find %u.%u.%u.%u/%u-%u.%u.%u.%u/%u.\n",
- IP_PARTS(tuple.src.ip), ntohs(tuple.src.u.tcp.port),
- IP_PARTS(tuple.dst.ip), ntohs(tuple.dst.u.tcp.port));
+ NIPQUAD(tuple.src.ip), ntohs(tuple.src.u.tcp.port),
+ NIPQUAD(tuple.dst.ip), ntohs(tuple.dst.u.tcp.port));
return -ENOENT;
}
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_conntrack_ftp.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_conntrack_ftp.c 2000/07/17 17:08:25
@@ -21,14 +21,6 @@
#define DEBUGP(format, args...)
#endif
-#define IP_PARTS_NATIVE(n) \
-(unsigned int)((n)>>24)&0xFF, \
-(unsigned int)((n)>>16)&0xFF, \
-(unsigned int)((n)>>8)&0xFF, \
-(unsigned int)((n)&0xFF)
-
-#define IP_PARTS(n) IP_PARTS_NATIVE(ntohl(n))
-
static struct {
const char *pattern;
size_t plen;
@@ -111,7 +103,7 @@
struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo)
{
- /* tcplen not negative guarenteed by ip_conntrack_tcp.c */
+ /* tcplen not negative guaranteed by ip_conntrack_tcp.c */
struct tcphdr *tcph = (void *)iph + iph->ihl * 4;
const char *data = (const char *)tcph + tcph->doff * 4;
unsigned int tcplen = len - iph->ihl * 4;
@@ -142,8 +134,8 @@
if (tcp_v4_check(tcph, tcplen, iph->saddr, iph->daddr,
csum_partial((char *)tcph, tcplen, 0))) {
DEBUGP("ftp_help: bad csum: %p %u %u.%u.%u.%u %u.%u.%u.%u\n",
- tcph, tcplen, IP_PARTS(iph->saddr),
- IP_PARTS(iph->daddr));
+ tcph, tcplen, NIPQUAD(iph->saddr),
+ NIPQUAD(iph->daddr));
return NF_ACCEPT;
}
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_core.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_core.c 2000/07/17 17:06:36
@@ -206,7 +206,7 @@
/* FIXME: IPTOS_TOS(iph->tos) --RR */
if (ip_route_output(&rt, var_ip, 0, 0, 0) != 0) {
DEBUGP("do_extra_mangle: Can't get route to %u.%u.%u.%u\n",
- IP_PARTS(var_ip));
+ NIPQUAD(var_ip));
return 0;
}
@@ -312,7 +312,7 @@
&& *var_ipp != orig_dstip
&& !do_extra_mangle(*var_ipp, other_ipp)) {
DEBUGP("Range %u %u.%u.%u.%u rt failed!\n",
- i, IP_PARTS(*var_ipp));
+ i, NIPQUAD(*var_ipp));
/* Can't route? This whole range part is
* probably screwed, but keep trying
* anyway. */
@@ -511,8 +511,8 @@
? " PROTO_SPECIFIED" : "",
(mr->range[i].flags & IP_NAT_RANGE_FULL)
? " FULL" : "",
- IP_PARTS(mr->range[i].min_ip),
- IP_PARTS(mr->range[i].max_ip),
+ NIPQUAD(mr->range[i].min_ip),
+ NIPQUAD(mr->range[i].max_ip),
mr->range[i].min.all,
mr->range[i].max.all);
}
@@ -714,7 +714,7 @@
*pskb,
info->manips[i].maniptype == IP_NAT_MANIP_SRC
? "SRC" : "DST",
- IP_PARTS(info->manips[i].manip.ip),
+ NIPQUAD(info->manips[i].manip.ip),
htons(info->manips[i].manip.u.all));
manip_pkt((*pskb)->nh.iph->protocol,
(*pskb)->nh.iph,
@@ -780,7 +780,7 @@
DEBUGP("icmp_reply: inner %s -> %u.%u.%u.%u %u\n",
info->manips[i].maniptype == IP_NAT_MANIP_SRC
? "DST" : "SRC",
- IP_PARTS(info->manips[i].manip.ip),
+ NIPQUAD(info->manips[i].manip.ip),
ntohs(info->manips[i].manip.u.udp.port));
manip_pkt(inner->protocol, inner,
skb->len - ((void *)inner - (void *)iph),
@@ -795,7 +795,7 @@
DEBUGP("icmp_reply: outer %s -> %u.%u.%u.%u\n",
info->manips[i].maniptype == IP_NAT_MANIP_SRC
? "SRC" : "DST",
- IP_PARTS(info->manips[i].manip.ip));
+ NIPQUAD(info->manips[i].manip.ip));
manip_pkt(0, iph, skb->len,
&info->manips[i].manip,
info->manips[i].maniptype,
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_ftp.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_ftp.c 2000/07/17 17:06:16
@@ -54,13 +54,13 @@
newdstip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
newsrcip = master->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip;
DEBUGP("nat_expected: PORT cmd. %u.%u.%u.%u->%u.%u.%u.%u\n",
- IP_PARTS(newsrcip), IP_PARTS(newdstip));
+ NIPQUAD(newsrcip), NIPQUAD(newdstip));
} else {
/* PASV command: make the connection go to the server */
newdstip = master->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip;
newsrcip = master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip;
DEBUGP("nat_expected: PASV cmd. %u.%u.%u.%u->%u.%u.%u.%u\n",
- IP_PARTS(newsrcip), IP_PARTS(newdstip));
+ NIPQUAD(newsrcip), NIPQUAD(newdstip));
}
UNLOCK_BH(&ip_ftp_lock);
@@ -69,7 +69,7 @@
else
newip = newdstip;
- DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", IP_PARTS(newip));
+ DEBUGP("nat_expected: IP to %u.%u.%u.%u\n", NIPQUAD(newip));
mr.rangesize = 1;
/* We don't want to manip the per-protocol, just the IPs. */
@@ -102,7 +102,7 @@
MUST_BE_LOCKED(&ip_ftp_lock);
sprintf(buffer, "%u,%u,%u,%u,%u,%u",
- IP_PARTS(newip), port>>8, port&0xFF);
+ NIPQUAD(newip), port>>8, port&0xFF);
tcplen = (*pskb)->len - iph->ihl * 4;
newtcplen = tcplen - matchlen + strlen(buffer);
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_rule.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ip_nat_rule.c 2000/07/17 17:05:50
@@ -226,7 +226,7 @@
= { 1, { { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } } } };
DEBUGP("Allocating NULL binding for %p (%u.%u.%u.%u)\n", conntrack,
- IP_PARTS(ip));
+ NIPQUAD(ip));
return ip_nat_setup_info(conntrack, &mr, hooknum);
}
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ipt_limit.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ipt_limit.c 2000/07/17 17:05:42
@@ -15,14 +15,6 @@
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv4/ipt_limit.h>
-#define IP_PARTS_NATIVE(n) \
-(unsigned int)((n)>>24)&0xFF, \
-(unsigned int)((n)>>16)&0xFF, \
-(unsigned int)((n)>>8)&0xFF, \
-(unsigned int)((n)&0xFF)
-
-#define IP_PARTS(n) IP_PARTS_NATIVE(ntohl(n))
-
/* The algorithm used is the Simple Token Bucket Filter (TBF)
* see net/sched/sch_tbf.c in the linux source tree
*/
--- linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ipt_MASQUERADE.c 2000/07/17 17:05:20 1.1
+++ linux-2.4.0-test4-ipparts/net/ipv4/netfilter/ipt_MASQUERADE.c 2000/07/17 17:05:33
@@ -92,7 +92,7 @@
}
newsrc = rt->rt_src;
- DEBUGP("newsrc = %u.%u.%u.%u\n", IP_PARTS(newsrc));
+ DEBUGP("newsrc = %u.%u.%u.%u\n", NIPQUAD(newsrc));
ip_rt_put(rt);
WRITE_LOCK(&masq_lock);
--
Hacking time.