diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2009-09-20 06:35:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-05 03:21:56 -0400 |
commit | 16c6cf8bb471392fd09b48b7c27e7d83a446b4bc (patch) | |
tree | 6b7c83c37314b54508f6a37613c33610e388d85b /net/ipv4/fib_frontend.c | |
parent | 977750076d98c7ff6cbda51858bb5a5894a9d9ab (diff) |
ipv4: fib table algorithm performance improvement
The FIB algorithim for IPV4 is set at compile time, but kernel goes through
the overhead of function call indirection at runtime. Save some
cycles by turning the indirect calls to direct calls to either
hash or trie code.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_frontend.c')
-rw-r--r-- | net/ipv4/fib_frontend.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index e2f950592566..f73dbed0f0d7 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -125,7 +125,7 @@ void fib_select_default(struct net *net, | |||
125 | #endif | 125 | #endif |
126 | tb = fib_get_table(net, table); | 126 | tb = fib_get_table(net, table); |
127 | if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) | 127 | if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) |
128 | tb->tb_select_default(tb, flp, res); | 128 | fib_table_select_default(tb, flp, res); |
129 | } | 129 | } |
130 | 130 | ||
131 | static void fib_flush(struct net *net) | 131 | static void fib_flush(struct net *net) |
@@ -139,7 +139,7 @@ static void fib_flush(struct net *net) | |||
139 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { | 139 | for (h = 0; h < FIB_TABLE_HASHSZ; h++) { |
140 | head = &net->ipv4.fib_table_hash[h]; | 140 | head = &net->ipv4.fib_table_hash[h]; |
141 | hlist_for_each_entry(tb, node, head, tb_hlist) | 141 | hlist_for_each_entry(tb, node, head, tb_hlist) |
142 | flushed += tb->tb_flush(tb); | 142 | flushed += fib_table_flush(tb); |
143 | } | 143 | } |
144 | 144 | ||
145 | if (flushed) | 145 | if (flushed) |
@@ -162,7 +162,7 @@ struct net_device * ip_dev_find(struct net *net, __be32 addr) | |||
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | local_table = fib_get_table(net, RT_TABLE_LOCAL); | 164 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
165 | if (!local_table || local_table->tb_lookup(local_table, &fl, &res)) | 165 | if (!local_table || fib_table_lookup(local_table, &fl, &res)) |
166 | return NULL; | 166 | return NULL; |
167 | if (res.type != RTN_LOCAL) | 167 | if (res.type != RTN_LOCAL) |
168 | goto out; | 168 | goto out; |
@@ -200,7 +200,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net, | |||
200 | local_table = fib_get_table(net, RT_TABLE_LOCAL); | 200 | local_table = fib_get_table(net, RT_TABLE_LOCAL); |
201 | if (local_table) { | 201 | if (local_table) { |
202 | ret = RTN_UNICAST; | 202 | ret = RTN_UNICAST; |
203 | if (!local_table->tb_lookup(local_table, &fl, &res)) { | 203 | if (!fib_table_lookup(local_table, &fl, &res)) { |
204 | if (!dev || dev == res.fi->fib_dev) | 204 | if (!dev || dev == res.fi->fib_dev) |
205 | ret = res.type; | 205 | ret = res.type; |
206 | fib_res_put(&res); | 206 | fib_res_put(&res); |
@@ -473,13 +473,13 @@ int ip_rt_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
473 | if (cmd == SIOCDELRT) { | 473 | if (cmd == SIOCDELRT) { |
474 | tb = fib_get_table(net, cfg.fc_table); | 474 | tb = fib_get_table(net, cfg.fc_table); |
475 | if (tb) | 475 | if (tb) |
476 | err = tb->tb_delete(tb, &cfg); | 476 | err = fib_table_delete(tb, &cfg); |
477 | else | 477 | else |
478 | err = -ESRCH; | 478 | err = -ESRCH; |
479 | } else { | 479 | } else { |
480 | tb = fib_new_table(net, cfg.fc_table); | 480 | tb = fib_new_table(net, cfg.fc_table); |
481 | if (tb) | 481 | if (tb) |
482 | err = tb->tb_insert(tb, &cfg); | 482 | err = fib_table_insert(tb, &cfg); |
483 | else | 483 | else |
484 | err = -ENOBUFS; | 484 | err = -ENOBUFS; |
485 | } | 485 | } |
@@ -594,7 +594,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *ar | |||
594 | goto errout; | 594 | goto errout; |
595 | } | 595 | } |
596 | 596 | ||
597 | err = tb->tb_delete(tb, &cfg); | 597 | err = fib_table_delete(tb, &cfg); |
598 | errout: | 598 | errout: |
599 | return err; | 599 | return err; |
600 | } | 600 | } |
@@ -616,7 +616,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *ar | |||
616 | goto errout; | 616 | goto errout; |
617 | } | 617 | } |
618 | 618 | ||
619 | err = tb->tb_insert(tb, &cfg); | 619 | err = fib_table_insert(tb, &cfg); |
620 | errout: | 620 | errout: |
621 | return err; | 621 | return err; |
622 | } | 622 | } |
@@ -647,7 +647,7 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) | |||
647 | if (dumped) | 647 | if (dumped) |
648 | memset(&cb->args[2], 0, sizeof(cb->args) - | 648 | memset(&cb->args[2], 0, sizeof(cb->args) - |
649 | 2 * sizeof(cb->args[0])); | 649 | 2 * sizeof(cb->args[0])); |
650 | if (tb->tb_dump(tb, skb, cb) < 0) | 650 | if (fib_table_dump(tb, skb, cb) < 0) |
651 | goto out; | 651 | goto out; |
652 | dumped = 1; | 652 | dumped = 1; |
653 | next: | 653 | next: |
@@ -701,9 +701,9 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad | |||
701 | cfg.fc_scope = RT_SCOPE_HOST; | 701 | cfg.fc_scope = RT_SCOPE_HOST; |
702 | 702 | ||
703 | if (cmd == RTM_NEWROUTE) | 703 | if (cmd == RTM_NEWROUTE) |
704 | tb->tb_insert(tb, &cfg); | 704 | fib_table_insert(tb, &cfg); |
705 | else | 705 | else |
706 | tb->tb_delete(tb, &cfg); | 706 | fib_table_delete(tb, &cfg); |
707 | } | 707 | } |
708 | 708 | ||
709 | void fib_add_ifaddr(struct in_ifaddr *ifa) | 709 | void fib_add_ifaddr(struct in_ifaddr *ifa) |
@@ -832,7 +832,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb ) | |||
832 | local_bh_disable(); | 832 | local_bh_disable(); |
833 | 833 | ||
834 | frn->tb_id = tb->tb_id; | 834 | frn->tb_id = tb->tb_id; |
835 | frn->err = tb->tb_lookup(tb, &fl, &res); | 835 | frn->err = fib_table_lookup(tb, &fl, &res); |
836 | 836 | ||
837 | if (!frn->err) { | 837 | if (!frn->err) { |
838 | frn->prefixlen = res.prefixlen; | 838 | frn->prefixlen = res.prefixlen; |
@@ -1009,7 +1009,7 @@ static void __net_exit ip_fib_net_exit(struct net *net) | |||
1009 | head = &net->ipv4.fib_table_hash[i]; | 1009 | head = &net->ipv4.fib_table_hash[i]; |
1010 | hlist_for_each_entry_safe(tb, node, tmp, head, tb_hlist) { | 1010 | hlist_for_each_entry_safe(tb, node, tmp, head, tb_hlist) { |
1011 | hlist_del(node); | 1011 | hlist_del(node); |
1012 | tb->tb_flush(tb); | 1012 | fib_table_flush(tb); |
1013 | kfree(tb); | 1013 | kfree(tb); |
1014 | } | 1014 | } |
1015 | } | 1015 | } |