aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2011-07-11 18:44:24 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-13 04:12:28 -0400
commit3769cffb1c48f64640ffab7ce3bffe867342c0f0 (patch)
tree8f6fcf2d822bf3a170a534e8540faa34fe9258ef /net/ipv4/route.c
parente5b1de1f5ebe0200e988e195fefb6c7396de6e20 (diff)
ipv4: Inline neigh binding.
Get rid of all of the useless and costly indirection by doing the neigh hash table lookup directly inside of the neighbour binding. Rename from arp_bind_neighbour to rt_bind_neighbour. Use new helpers {__,}ipv4_neigh_lookup() In rt_bind_neighbour() get rid of useless tests which are never true in the context this function is called, namely dev is never NULL and the dst->neighbour is always NULL. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a8ccd9bca09c..c6388e825ed3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -108,6 +108,7 @@
108#ifdef CONFIG_SYSCTL 108#ifdef CONFIG_SYSCTL
109#include <linux/sysctl.h> 109#include <linux/sysctl.h>
110#endif 110#endif
111#include <net/atmclip.h>
111 112
112#define RT_FL_TOS(oldflp4) \ 113#define RT_FL_TOS(oldflp4) \
113 ((u32)(oldflp4->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK))) 114 ((u32)(oldflp4->flowi4_tos & (IPTOS_RT_MASK | RTO_ONLINK)))
@@ -1006,6 +1007,29 @@ static int slow_chain_length(const struct rtable *head)
1006 return length >> FRACT_BITS; 1007 return length >> FRACT_BITS;
1007} 1008}
1008 1009
1010static int rt_bind_neighbour(struct rtable *rt)
1011{
1012 static const __be32 inaddr_any = 0;
1013 struct net_device *dev = rt->dst.dev;
1014 struct neigh_table *tbl = &arp_tbl;
1015 const __be32 *nexthop;
1016 struct neighbour *n;
1017
1018#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
1019 if (dev->type == ARPHRD_ATM)
1020 tbl = clip_tbl_hook;
1021#endif
1022 nexthop = &rt->rt_gateway;
1023 if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
1024 nexthop = &inaddr_any;
1025 n = ipv4_neigh_lookup(tbl, dev, nexthop);
1026 if (IS_ERR(n))
1027 return PTR_ERR(n);
1028 rt->dst.neighbour = n;
1029
1030 return 0;
1031}
1032
1009static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt, 1033static struct rtable *rt_intern_hash(unsigned hash, struct rtable *rt,
1010 struct sk_buff *skb, int ifindex) 1034 struct sk_buff *skb, int ifindex)
1011{ 1035{
@@ -1042,7 +1066,7 @@ restart:
1042 1066
1043 rt->dst.flags |= DST_NOCACHE; 1067 rt->dst.flags |= DST_NOCACHE;
1044 if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { 1068 if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) {
1045 int err = arp_bind_neighbour(&rt->dst); 1069 int err = rt_bind_neighbour(rt);
1046 if (err) { 1070 if (err) {
1047 if (net_ratelimit()) 1071 if (net_ratelimit())
1048 printk(KERN_WARNING 1072 printk(KERN_WARNING
@@ -1138,7 +1162,7 @@ restart:
1138 route or unicast forwarding path. 1162 route or unicast forwarding path.
1139 */ 1163 */
1140 if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) { 1164 if (rt->rt_type == RTN_UNICAST || rt_is_output_route(rt)) {
1141 int err = arp_bind_neighbour(&rt->dst); 1165 int err = rt_bind_neighbour(rt);
1142 if (err) { 1166 if (err) {
1143 spin_unlock_bh(rt_hash_lock_addr(hash)); 1167 spin_unlock_bh(rt_hash_lock_addr(hash));
1144 1168
@@ -1599,7 +1623,7 @@ static int check_peer_redir(struct dst_entry *dst, struct inet_peer *peer)
1599 rt->dst.neighbour = NULL; 1623 rt->dst.neighbour = NULL;
1600 1624
1601 rt->rt_gateway = peer->redirect_learned.a4; 1625 rt->rt_gateway = peer->redirect_learned.a4;
1602 if (arp_bind_neighbour(&rt->dst) || 1626 if (rt_bind_neighbour(rt) ||
1603 !(rt->dst.neighbour->nud_state & NUD_VALID)) { 1627 !(rt->dst.neighbour->nud_state & NUD_VALID)) {
1604 if (rt->dst.neighbour) 1628 if (rt->dst.neighbour)
1605 neigh_event_send(rt->dst.neighbour, NULL); 1629 neigh_event_send(rt->dst.neighbour, NULL);