aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_options.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/ip_options.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/ip_options.c')
-rw-r--r--net/ipv4/ip_options.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index baaedd9689a0..df93a9c2efda 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -107,7 +107,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
107 sptr = skb_network_header(skb); 107 sptr = skb_network_header(skb);
108 dptr = dopt->__data; 108 dptr = dopt->__data;
109 109
110 daddr = ((struct rtable*)skb->dst)->rt_spec_dst; 110 daddr = skb->rtable->rt_spec_dst;
111 111
112 if (sopt->rr) { 112 if (sopt->rr) {
113 optlen = sptr[sopt->rr+1]; 113 optlen = sptr[sopt->rr+1];
@@ -258,7 +258,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
258 unsigned char * optptr; 258 unsigned char * optptr;
259 int optlen; 259 int optlen;
260 unsigned char * pp_ptr = NULL; 260 unsigned char * pp_ptr = NULL;
261 struct rtable *rt = skb ? (struct rtable*)skb->dst : NULL; 261 struct rtable *rt = skb ? skb->rtable : NULL;
262 262
263 if (!opt) { 263 if (!opt) {
264 opt = &(IPCB(skb)->opt); 264 opt = &(IPCB(skb)->opt);
@@ -558,7 +558,7 @@ void ip_forward_options(struct sk_buff *skb)
558{ 558{
559 struct ip_options * opt = &(IPCB(skb)->opt); 559 struct ip_options * opt = &(IPCB(skb)->opt);
560 unsigned char * optptr; 560 unsigned char * optptr;
561 struct rtable *rt = (struct rtable*)skb->dst; 561 struct rtable *rt = skb->rtable;
562 unsigned char *raw = skb_network_header(skb); 562 unsigned char *raw = skb_network_header(skb);
563 563
564 if (opt->rr_needaddr) { 564 if (opt->rr_needaddr) {
@@ -606,7 +606,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
606 __be32 nexthop; 606 __be32 nexthop;
607 struct iphdr *iph = ip_hdr(skb); 607 struct iphdr *iph = ip_hdr(skb);
608 unsigned char *optptr = skb_network_header(skb) + opt->srr; 608 unsigned char *optptr = skb_network_header(skb) + opt->srr;
609 struct rtable *rt = (struct rtable*)skb->dst; 609 struct rtable *rt = skb->rtable;
610 struct rtable *rt2; 610 struct rtable *rt2;
611 int err; 611 int err;
612 612
@@ -631,13 +631,13 @@ int ip_options_rcv_srr(struct sk_buff *skb)
631 } 631 }
632 memcpy(&nexthop, &optptr[srrptr-1], 4); 632 memcpy(&nexthop, &optptr[srrptr-1], 4);
633 633
634 rt = (struct rtable*)skb->dst; 634 rt = skb->rtable;
635 skb->dst = NULL; 635 skb->rtable = NULL;
636 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev); 636 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev);
637 rt2 = (struct rtable*)skb->dst; 637 rt2 = skb->rtable;
638 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) { 638 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
639 ip_rt_put(rt2); 639 ip_rt_put(rt2);
640 skb->dst = &rt->u.dst; 640 skb->rtable = rt;
641 return -EINVAL; 641 return -EINVAL;
642 } 642 }
643 ip_rt_put(rt); 643 ip_rt_put(rt);