aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2008-03-05 21:30:47 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-05 21:30:47 -0500
commitee6b967301b4aa5d4a4b61e2f682f086266db9fb (patch)
tree197c2430f87733dc80d00d1971f1be2a0e562358 /net/ipv4/route.c
parenta05c44f6d5fb6cd29da04f96bf5ffaa05f545ac5 (diff)
[IPV4]: Add 'rtable' field in struct sk_buff to alias 'dst' and avoid casts
(Anonymous) unions can help us to avoid ugly casts. A common cast it the (struct rtable *)skb->dst one. Defining an union like : union { struct dst_entry *dst; struct rtable *rtable; }; permits to use skb->rtable in place. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 8c3e165f0034..1051326c36b2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1289,7 +1289,7 @@ reject_redirect:
1289 1289
1290static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) 1290static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1291{ 1291{
1292 struct rtable *rt = (struct rtable*)dst; 1292 struct rtable *rt = (struct rtable *)dst;
1293 struct dst_entry *ret = dst; 1293 struct dst_entry *ret = dst;
1294 1294
1295 if (rt) { 1295 if (rt) {
@@ -1330,7 +1330,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1330 1330
1331void ip_rt_send_redirect(struct sk_buff *skb) 1331void ip_rt_send_redirect(struct sk_buff *skb)
1332{ 1332{
1333 struct rtable *rt = (struct rtable*)skb->dst; 1333 struct rtable *rt = skb->rtable;
1334 struct in_device *in_dev = in_dev_get(rt->u.dst.dev); 1334 struct in_device *in_dev = in_dev_get(rt->u.dst.dev);
1335 1335
1336 if (!in_dev) 1336 if (!in_dev)
@@ -1379,7 +1379,7 @@ out:
1379 1379
1380static int ip_error(struct sk_buff *skb) 1380static int ip_error(struct sk_buff *skb)
1381{ 1381{
1382 struct rtable *rt = (struct rtable*)skb->dst; 1382 struct rtable *rt = skb->rtable;
1383 unsigned long now; 1383 unsigned long now;
1384 int code; 1384 int code;
1385 1385
@@ -1548,7 +1548,7 @@ static void ipv4_link_failure(struct sk_buff *skb)
1548 1548
1549 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 1549 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
1550 1550
1551 rt = (struct rtable *) skb->dst; 1551 rt = skb->rtable;
1552 if (rt) 1552 if (rt)
1553 dst_set_expires(&rt->u.dst, 0); 1553 dst_set_expires(&rt->u.dst, 0);
1554} 1554}
@@ -1708,7 +1708,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1708 1708
1709 in_dev_put(in_dev); 1709 in_dev_put(in_dev);
1710 hash = rt_hash(daddr, saddr, dev->ifindex); 1710 hash = rt_hash(daddr, saddr, dev->ifindex);
1711 return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); 1711 return rt_intern_hash(hash, rth, &skb->rtable);
1712 1712
1713e_nobufs: 1713e_nobufs:
1714 in_dev_put(in_dev); 1714 in_dev_put(in_dev);
@@ -1869,7 +1869,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
1869 1869
1870 /* put it into the cache */ 1870 /* put it into the cache */
1871 hash = rt_hash(daddr, saddr, fl->iif); 1871 hash = rt_hash(daddr, saddr, fl->iif);
1872 return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 1872 return rt_intern_hash(hash, rth, &skb->rtable);
1873} 1873}
1874 1874
1875/* 1875/*
@@ -2025,7 +2025,7 @@ local_input:
2025 } 2025 }
2026 rth->rt_type = res.type; 2026 rth->rt_type = res.type;
2027 hash = rt_hash(daddr, saddr, fl.iif); 2027 hash = rt_hash(daddr, saddr, fl.iif);
2028 err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); 2028 err = rt_intern_hash(hash, rth, &skb->rtable);
2029 goto done; 2029 goto done;
2030 2030
2031no_route: 2031no_route:
@@ -2091,7 +2091,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2091 dst_use(&rth->u.dst, jiffies); 2091 dst_use(&rth->u.dst, jiffies);
2092 RT_CACHE_STAT_INC(in_hit); 2092 RT_CACHE_STAT_INC(in_hit);
2093 rcu_read_unlock(); 2093 rcu_read_unlock();
2094 skb->dst = (struct dst_entry*)rth; 2094 skb->rtable = rth;
2095 return 0; 2095 return 0;
2096 } 2096 }
2097 RT_CACHE_STAT_INC(in_hlist_search); 2097 RT_CACHE_STAT_INC(in_hlist_search);
@@ -2598,7 +2598,7 @@ int ip_route_output_key(struct net *net, struct rtable **rp, struct flowi *flp)
2598static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event, 2598static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2599 int nowait, unsigned int flags) 2599 int nowait, unsigned int flags)
2600{ 2600{
2601 struct rtable *rt = (struct rtable*)skb->dst; 2601 struct rtable *rt = skb->rtable;
2602 struct rtmsg *r; 2602 struct rtmsg *r;
2603 struct nlmsghdr *nlh; 2603 struct nlmsghdr *nlh;
2604 long expires; 2604 long expires;
@@ -2742,7 +2742,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2742 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev); 2742 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
2743 local_bh_enable(); 2743 local_bh_enable();
2744 2744
2745 rt = (struct rtable*) skb->dst; 2745 rt = skb->rtable;
2746 if (err == 0 && rt->u.dst.error) 2746 if (err == 0 && rt->u.dst.error)
2747 err = -rt->u.dst.error; 2747 err = -rt->u.dst.error;
2748 } else { 2748 } else {
@@ -2762,7 +2762,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2762 if (err) 2762 if (err)
2763 goto errout_free; 2763 goto errout_free;
2764 2764
2765 skb->dst = &rt->u.dst; 2765 skb->rtable = rt;
2766 if (rtm->rtm_flags & RTM_F_NOTIFY) 2766 if (rtm->rtm_flags & RTM_F_NOTIFY)
2767 rt->rt_flags |= RTCF_NOTIFY; 2767 rt->rt_flags |= RTCF_NOTIFY;
2768 2768