From 78857d275e71d5ee4905d6994d1cbb744c3f9f1c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 7 Jul 2011 07:52:43 -0700 Subject: kbench_mod: Use flowi4 and pointer returns throughout. Signed-off-by: David S. Miller --- kbench_mod.c | 62 +++++++++++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/kbench_mod.c b/kbench_mod.c index 35dc0dc..fc3765c 100644 --- a/kbench_mod.c +++ b/kbench_mod.c @@ -40,7 +40,6 @@ static inline unsigned long long get_tick(void) #error Unsupported architecture, please implement get_tick() #endif -#define IP_ROUTE_RETURNS_PTR #undef IP_ROUTE_HAVE_PREALLOC #undef IP_ROUTE_CYCLE_SAMPLES #undef IP_FIB_LOOKUP_EXPORTED @@ -93,48 +92,35 @@ module_param_named(tos, flow_tos, int, 0); static int warmup_count = DEFAULT_WARMUP_COUNT; module_param_named(count, warmup_count, int, 0); -static void flow_init(struct flowi *fl) +static void flow_init(struct flowi4 *fl4) { - memset(fl, 0, sizeof(*fl)); - fl->oif = flow_oif; - fl->iif = flow_iif; - fl->mark = flow_mark; - fl->fl4_dst = flow_dst_ip_addr; - fl->fl4_src = flow_src_ip_addr; - fl->fl4_tos = flow_tos; + memset(fl4, 0, sizeof(*fl4)); + fl4->flowi4_oif = flow_oif; + fl4->flowi4_iif = flow_iif; + fl4->flowi4_mark = flow_mark; + fl4->flowi4_tos = flow_tos; + fl4->daddr = flow_dst_ip_addr; + fl4->saddr = flow_src_ip_addr; } -#ifdef IP_ROUTE_RETURNS_PTR -static struct rtable *route_output(struct net *net, struct flowi *fl) +static struct rtable *route_output(struct net *net, struct flowi4 *fl4) { - return ip_route_output_key(net, fl); + return ip_route_output_key(net, fl4); } -#else -static struct rtable *route_output(struct net *net, struct flowi *fl) -{ - struct rtable *rt; - int err; - - err = ip_route_output_key(net, &rt, fl); - if (err) - return ERR_PTR(err); - return rt; -} -#endif static void do_full_output_lookup_bench(void) { unsigned long long t1, t2, tdiff; struct rtable *rt; - struct flowi fl; + struct flowi4 fl4; int i; rt = NULL; for (i = 0; i < warmup_count; i++) { - flow_init(&fl); + flow_init(&fl4); - rt = route_output(&init_net, &fl); + rt = route_output(&init_net, &fl4); if (IS_ERR(rt)) break; ip_rt_put(rt); @@ -154,10 +140,10 @@ static void do_full_output_lookup_bench(void) ip_route_output_cycles_7 = 0; #endif - flow_init(&fl); + flow_init(&fl4); t1 = get_tick(); - rt = route_output(&init_net, &fl); + rt = route_output(&init_net, &fl4); t2 = get_tick(); if (!IS_ERR(rt)) ip_rt_put(rt); @@ -248,15 +234,15 @@ static void do_full_lookup_prealloc_bench(void) { unsigned long long t1, t2, tdiff; struct rtable *rt, rt_stack; - struct flowi fl; + struct flowi4 fl4; int err, i; err = 0; for (i = 0; i < warmup_count; i++) { - flow_init(&fl); + flow_init(&fl4); - rt = ip_route_output_flow_prealloc(&init_net, &fl, NULL, &rt_stack.dst); + rt = ip_route_output_flow_prealloc(&init_net, &fl4, NULL, &rt_stack.dst); if (IS_ERR(rt)) { err = PTR_ERR(rt); break; @@ -278,10 +264,10 @@ static void do_full_lookup_prealloc_bench(void) ip_route_output_cycles_7 = 0; #endif - flow_init(&fl); + flow_init(&fl4); t1 = get_tick(); - rt = ip_route_output_flow_prealloc(&init_net, &fl, NULL, &rt_stack.dst); + rt = ip_route_output_flow_prealloc(&init_net, &fl4, NULL, &rt_stack.dst); t2 = get_tick(); if (!IS_ERR(rt)) ip_rt_put(rt); @@ -306,10 +292,10 @@ static void do_fib_lookup_bench(void) { unsigned long long t1, t2, tdiff; struct fib_result res; - struct flowi fl; + struct flowi4 fl4; int err, i; - flow_init(&fl); + flow_init(&fl4); for (i = 0; i < warmup_count; i++) { struct fib_table *table; @@ -319,7 +305,7 @@ static void do_fib_lookup_bench(void) pr_info("fib_lookup: No main table.\n"); return; } - err = fib_table_lookup(table, &fl, &res, FIB_LOOKUP_NOREF); + err = fib_table_lookup(table, &fl4, &res, FIB_LOOKUP_NOREF); if (err) { pr_info("fib_lookup: err=%d\n", err); return; @@ -335,7 +321,7 @@ static void do_fib_lookup_bench(void) pr_info("fib_lookup: No main table.\n"); return; } - err = fib_table_lookup(table, &fl, &res, FIB_LOOKUP_NOREF); + err = fib_table_lookup(table, &fl4, &res, FIB_LOOKUP_NOREF); t2 = get_tick(); } tdiff = t2 - t1; -- cgit 1.2.3-korg