From 21cf2253ebcf070bc307e0b56d696a2519c75cb4 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 16 Dec 2007 13:44:00 -0800 Subject: [IPV4] net/core: Use ipv4_is_ Signed-off-by: Joe Perches Signed-off-by: David S. Miller --- net/core/pktgen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'net/core/pktgen.c') diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 285ec3ed9b3..ede1feacddf 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2358,9 +2358,11 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) t = random32() % (imx - imn) + imn; s = htonl(t); - while (LOOPBACK(s) || MULTICAST(s) - || BADCLASS(s) || ZERONET(s) - || LOCAL_MCAST(s)) { + while (ipv4_is_loopback(s) || + ipv4_is_multicast(s) || + ipv4_is_badclass(s) || + ipv4_is_zeronet(s) || + ipv4_is_local_multicast(s)) { t = random32() % (imx - imn) + imn; s = htonl(t); } -- cgit v1.2.3-70-g09d2 From 56e252c7484c3ebc058f3c22d4a75386b079c49c Mon Sep 17 00:00:00 2001 From: Ilpo Järvinen Date: Sat, 12 Jan 2008 03:23:58 -0800 Subject: [PKTGEN]: Kill dead static inlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ilpo Järvinen Signed-off-by: David S. Miller --- net/core/pktgen.c | 94 ------------------------------------------------------- 1 file changed, 94 deletions(-) (limited to 'net/core/pktgen.c') diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ede1feacddf..ebfb1268ac3 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -397,62 +397,6 @@ struct pktgen_thread { #define REMOVE 1 #define FIND 0 -/* This code works around the fact that do_div cannot handle two 64-bit - numbers, and regular 64-bit division doesn't work on x86 kernels. - --Ben -*/ - -#define PG_DIV 0 - -/* This was emailed to LMKL by: Chris Caputo - * Function copied/adapted/optimized from: - * - * nemesis.sourceforge.net/browse/lib/static/intmath/ix86/intmath.c.html - * - * Copyright 1994, University of Cambridge Computer Laboratory - * All Rights Reserved. - * - */ -static inline s64 divremdi3(s64 x, s64 y, int type) -{ - u64 a = (x < 0) ? -x : x; - u64 b = (y < 0) ? -y : y; - u64 res = 0, d = 1; - - if (b > 0) { - while (b < a) { - b <<= 1; - d <<= 1; - } - } - - do { - if (a >= b) { - a -= b; - res += d; - } - b >>= 1; - d >>= 1; - } - while (d); - - if (PG_DIV == type) { - return (((x ^ y) & (1ll << 63)) == 0) ? res : -(s64) res; - } else { - return ((x & (1ll << 63)) == 0) ? a : -(s64) a; - } -} - -/* End of hacks to deal with 64-bit math on x86 */ - -/** Convert to milliseconds */ -static inline __u64 tv_to_ms(const struct timeval *tv) -{ - __u64 ms = tv->tv_usec / 1000; - ms += (__u64) tv->tv_sec * (__u64) 1000; - return ms; -} - /** Convert to micro-seconds */ static inline __u64 tv_to_us(const struct timeval *tv) { @@ -461,39 +405,6 @@ static inline __u64 tv_to_us(const struct timeval *tv) return us; } -static inline __u64 pg_div(__u64 n, __u32 base) -{ - __u64 tmp = n; - do_div(tmp, base); - /* printk("pktgen: pg_div, n: %llu base: %d rv: %llu\n", - n, base, tmp); */ - return tmp; -} - -static inline __u64 pg_div64(__u64 n, __u64 base) -{ - __u64 tmp = n; -/* - * How do we know if the architecture we are running on - * supports division with 64 bit base? - * - */ -#if defined(__sparc_v9__) || defined(__powerpc64__) || defined(__alpha__) || defined(__x86_64__) || defined(__ia64__) - - do_div(tmp, base); -#else - tmp = divremdi3(n, base, PG_DIV); -#endif - return tmp; -} - -static inline __u64 getCurMs(void) -{ - struct timeval tv; - do_gettimeofday(&tv); - return tv_to_ms(&tv); -} - static inline __u64 getCurUs(void) { struct timeval tv; @@ -501,11 +412,6 @@ static inline __u64 getCurUs(void) return tv_to_us(&tv); } -static inline __u64 tv_diff(const struct timeval *a, const struct timeval *b) -{ - return tv_to_us(a) - tv_to_us(b); -} - /* old include end */ static char version[] __initdata = VERSION; -- cgit v1.2.3-70-g09d2 From 6db105db95197c0fe93f8b3fb338eb6cf17440b7 Mon Sep 17 00:00:00 2001 From: Ilpo Järvinen Date: Sat, 12 Jan 2008 03:25:00 -0800 Subject: [PKTGEN]: uninline getCurUs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit net/core/pktgen.c: pktgen_stop_device | -50 pktgen_run | -105 pktgen_if_show | -37 pktgen_thread_worker | -702 4 functions changed, 894 bytes removed, diff: -894 net/core/pktgen.c: getCurUs | +36 1 function changed, 36 bytes added, diff: +36 net/core/pktgen.o: 5 functions changed, 36 bytes added, 894 bytes removed, diff: -858 Signed-off-by: Ilpo Järvinen Signed-off-by: David S. Miller --- net/core/pktgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/core/pktgen.c') diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ebfb1268ac3..d18fdb10236 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -405,7 +405,7 @@ static inline __u64 tv_to_us(const struct timeval *tv) return us; } -static inline __u64 getCurUs(void) +static __u64 getCurUs(void) { struct timeval tv; do_gettimeofday(&tv); -- cgit v1.2.3-70-g09d2 From 1e637c74b0f84eaca02b914c0b8c6f67276e9697 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 21 Jan 2008 03:18:08 -0800 Subject: [IPV4]: Enable use of 240/4 address space. This short patch modifies the IPv4 networking to enable use of the 240.0.0.0/4 (aka "class-E") address space as propsed in the internet draft draft-fuller-240space-00.txt. Signed-off-by: Jan Engelhardt Acked-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- include/linux/in.h | 5 +++-- include/net/addrconf.h | 2 +- net/core/pktgen.c | 2 +- net/ipv4/fib_frontend.c | 2 +- net/ipv4/route.c | 12 ++++++------ 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'net/core/pktgen.c') diff --git a/include/linux/in.h b/include/linux/in.h index 27d8a5ae9f7..70c6df88269 100644 --- a/include/linux/in.h +++ b/include/linux/in.h @@ -262,9 +262,10 @@ static inline bool ipv4_is_local_multicast(__be32 addr) return (addr & htonl(0xffffff00)) == htonl(0xe0000000); } -static inline bool ipv4_is_badclass(__be32 addr) +static inline bool ipv4_is_lbcast(__be32 addr) { - return (addr & htonl(0xf0000000)) == htonl(0xf0000000); + /* limited broadcast */ + return addr == INADDR_BROADCAST; } static inline bool ipv4_is_zeronet(__be32 addr) diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 8b1509bfc69..496503c0384 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -262,7 +262,7 @@ static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr) ipv4_is_private_172(addr) || ipv4_is_test_192(addr) || ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) || ipv4_is_test_198(addr) || ipv4_is_multicast(addr) || - ipv4_is_badclass(addr)) ? 0x00 : 0x02; + ipv4_is_lbcast(addr)) ? 0x00 : 0x02; eui[1] = 0; eui[2] = 0x5E; eui[3] = 0xFE; diff --git a/net/core/pktgen.c b/net/core/pktgen.c index d18fdb10236..eebccdbdbac 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2266,7 +2266,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) while (ipv4_is_loopback(s) || ipv4_is_multicast(s) || - ipv4_is_badclass(s) || + ipv4_is_lbcast(s) || ipv4_is_zeronet(s) || ipv4_is_local_multicast(s)) { t = random32() % (imx - imn) + imn; diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 62bd791c204..8987046d97f 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -176,7 +176,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net, unsigned ret = RTN_BROADCAST; struct fib_table *local_table; - if (ipv4_is_zeronet(addr) || ipv4_is_badclass(addr)) + if (ipv4_is_zeronet(addr) || ipv4_is_lbcast(addr)) return RTN_BROADCAST; if (ipv4_is_multicast(addr)) return RTN_MULTICAST; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index fc0145385e8..f80c761ea0b 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1154,7 +1154,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, return; if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev) - || ipv4_is_multicast(new_gw) || ipv4_is_badclass(new_gw) + || ipv4_is_multicast(new_gw) || ipv4_is_lbcast(new_gw) || ipv4_is_zeronet(new_gw)) goto reject_redirect; @@ -1634,7 +1634,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, if (in_dev == NULL) return -EINVAL; - if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) || + if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) || ipv4_is_loopback(saddr) || skb->protocol != htons(ETH_P_IP)) goto e_inval; @@ -1891,7 +1891,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, by fib_lookup. */ - if (ipv4_is_multicast(saddr) || ipv4_is_badclass(saddr) || + if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) || ipv4_is_loopback(saddr)) goto martian_source; @@ -1904,7 +1904,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, if (ipv4_is_zeronet(saddr)) goto martian_source; - if (ipv4_is_badclass(daddr) || ipv4_is_zeronet(daddr) || + if (ipv4_is_lbcast(daddr) || ipv4_is_zeronet(daddr) || ipv4_is_loopback(daddr)) goto martian_destination; @@ -2125,7 +2125,7 @@ static inline int __mkroute_output(struct rtable **result, res->type = RTN_BROADCAST; else if (ipv4_is_multicast(fl->fl4_dst)) res->type = RTN_MULTICAST; - else if (ipv4_is_badclass(fl->fl4_dst) || ipv4_is_zeronet(fl->fl4_dst)) + else if (ipv4_is_lbcast(fl->fl4_dst) || ipv4_is_zeronet(fl->fl4_dst)) return -EINVAL; if (dev_out->flags & IFF_LOOPBACK) @@ -2276,7 +2276,7 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp) if (oldflp->fl4_src) { err = -EINVAL; if (ipv4_is_multicast(oldflp->fl4_src) || - ipv4_is_badclass(oldflp->fl4_src) || + ipv4_is_lbcast(oldflp->fl4_src) || ipv4_is_zeronet(oldflp->fl4_src)) goto out; -- cgit v1.2.3-70-g09d2