aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-06-02 01:14:27 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-03 05:51:02 -0400
commit511c3f92ad5b6d9f8f6464be1b4f85f0422be91a (patch)
tree3e368d9a78f87eb9dd7ff9e57f4aab3f4a96e3b1
parentdfbf97f3ac980b69dfbc41c83a208211a38443e8 (diff)
net: skb->rtable accessor
Define skb_rtable(const struct sk_buff *skb) accessor to get rtable from skb Delete skb->rtable field Setting rtable is not allowed, just set dst instead as rtable is an alias. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/appletalk/ipddp.c2
-rw-r--r--include/linux/skbuff.h6
-rw-r--r--include/net/route.h2
-rw-r--r--net/bridge/br_netfilter.c25
-rw-r--r--net/dccp/ipv4.c6
-rw-r--r--net/ipv4/arp.c4
-rw-r--r--net/ipv4/icmp.c10
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/ip_forward.c2
-rw-r--r--net/ipv4/ip_gre.c4
-rw-r--r--net/ipv4/ip_input.c2
-rw-r--r--net/ipv4/ip_options.c16
-rw-r--r--net/ipv4/ip_output.c10
-rw-r--r--net/ipv4/ip_sockglue.c2
-rw-r--r--net/ipv4/ipip.c2
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c2
-rw-r--r--net/ipv4/netfilter/nf_nat_helper.c4
-rw-r--r--net/ipv4/route.c37
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/netfilter/nf_conntrack_netbios_ns.c2
-rw-r--r--net/sched/em_meta.c4
-rw-r--r--net/sctp/protocol.c8
23 files changed, 89 insertions, 73 deletions
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index 9832b757f109..78cea5e80b1d 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -115,7 +115,7 @@ static struct net_device * __init ipddp_init(void)
115 */ 115 */
116static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev) 116static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
117{ 117{
118 __be32 paddr = ((struct rtable*)skb->dst)->rt_gateway; 118 __be32 paddr = skb_rtable(skb)->rt_gateway;
119 struct ddpehdr *ddp; 119 struct ddpehdr *ddp;
120 struct ipddp_route *rt; 120 struct ipddp_route *rt;
121 struct atalk_addr *our_addr; 121 struct atalk_addr *our_addr;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d4d7c666ca63..a3ae3c525833 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -324,7 +324,6 @@ struct sk_buff {
324 324
325 union { 325 union {
326 struct dst_entry *dst; 326 struct dst_entry *dst;
327 struct rtable *rtable;
328 unsigned long _skb_dst; 327 unsigned long _skb_dst;
329 }; 328 };
330#ifdef CONFIG_XFRM 329#ifdef CONFIG_XFRM
@@ -427,6 +426,11 @@ extern void skb_dma_unmap(struct device *dev, struct sk_buff *skb,
427 enum dma_data_direction dir); 426 enum dma_data_direction dir);
428#endif 427#endif
429 428
429static inline struct rtable *skb_rtable(const struct sk_buff *skb)
430{
431 return (struct rtable *)skb->_skb_dst;
432}
433
430extern void kfree_skb(struct sk_buff *skb); 434extern void kfree_skb(struct sk_buff *skb);
431extern void consume_skb(struct sk_buff *skb); 435extern void consume_skb(struct sk_buff *skb);
432extern void __kfree_skb(struct sk_buff *skb); 436extern void __kfree_skb(struct sk_buff *skb);
diff --git a/include/net/route.h b/include/net/route.h
index 4e8cae0e5841..40f6346ef496 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -210,7 +210,7 @@ static inline struct inet_peer *rt_get_peer(struct rtable *rt)
210 210
211static inline int inet_iif(const struct sk_buff *skb) 211static inline int inet_iif(const struct sk_buff *skb)
212{ 212{
213 return skb->rtable->rt_iif; 213 return skb_rtable(skb)->rt_iif;
214} 214}
215 215
216#endif /* _ROUTE_H */ 216#endif /* _ROUTE_H */
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index e4a418fcb35b..e0ceb66a9ec5 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -228,6 +228,7 @@ int nf_bridge_copy_header(struct sk_buff *skb)
228static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb) 228static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
229{ 229{
230 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 230 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
231 struct rtable *rt;
231 232
232 if (nf_bridge->mask & BRNF_PKT_TYPE) { 233 if (nf_bridge->mask & BRNF_PKT_TYPE) {
233 skb->pkt_type = PACKET_OTHERHOST; 234 skb->pkt_type = PACKET_OTHERHOST;
@@ -235,12 +236,13 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
235 } 236 }
236 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; 237 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
237 238
238 skb->rtable = bridge_parent_rtable(nf_bridge->physindev); 239 rt = bridge_parent_rtable(nf_bridge->physindev);
239 if (!skb->rtable) { 240 if (!rt) {
240 kfree_skb(skb); 241 kfree_skb(skb);
241 return 0; 242 return 0;
242 } 243 }
243 dst_hold(&skb->rtable->u.dst); 244 dst_hold(&rt->u.dst);
245 skb->dst = &rt->u.dst;
244 246
245 skb->dev = nf_bridge->physindev; 247 skb->dev = nf_bridge->physindev;
246 nf_bridge_push_encap_header(skb); 248 nf_bridge_push_encap_header(skb);
@@ -338,6 +340,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
338 struct net_device *dev = skb->dev; 340 struct net_device *dev = skb->dev;
339 struct iphdr *iph = ip_hdr(skb); 341 struct iphdr *iph = ip_hdr(skb);
340 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 342 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
343 struct rtable *rt;
341 int err; 344 int err;
342 345
343 if (nf_bridge->mask & BRNF_PKT_TYPE) { 346 if (nf_bridge->mask & BRNF_PKT_TYPE) {
@@ -347,7 +350,6 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
347 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; 350 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
348 if (dnat_took_place(skb)) { 351 if (dnat_took_place(skb)) {
349 if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) { 352 if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
350 struct rtable *rt;
351 struct flowi fl = { 353 struct flowi fl = {
352 .nl_u = { 354 .nl_u = {
353 .ip4_u = { 355 .ip4_u = {
@@ -404,12 +406,13 @@ bridged_dnat:
404 skb->pkt_type = PACKET_HOST; 406 skb->pkt_type = PACKET_HOST;
405 } 407 }
406 } else { 408 } else {
407 skb->rtable = bridge_parent_rtable(nf_bridge->physindev); 409 rt = bridge_parent_rtable(nf_bridge->physindev);
408 if (!skb->rtable) { 410 if (!rt) {
409 kfree_skb(skb); 411 kfree_skb(skb);
410 return 0; 412 return 0;
411 } 413 }
412 dst_hold(&skb->rtable->u.dst); 414 dst_hold(&rt->u.dst);
415 skb->dst = &rt->u.dst;
413 } 416 }
414 417
415 skb->dev = nf_bridge->physindev; 418 skb->dev = nf_bridge->physindev;
@@ -628,9 +631,11 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,
628 const struct net_device *out, 631 const struct net_device *out,
629 int (*okfn)(struct sk_buff *)) 632 int (*okfn)(struct sk_buff *))
630{ 633{
631 if (skb->rtable && skb->rtable == bridge_parent_rtable(in)) { 634 struct rtable *rt = skb_rtable(skb);
632 dst_release(&skb->rtable->u.dst); 635
633 skb->rtable = NULL; 636 if (rt && rt == bridge_parent_rtable(in)) {
637 dst_release(&rt->u.dst);
638 skb->dst = NULL;
634 } 639 }
635 640
636 return NF_ACCEPT; 641 return NF_ACCEPT;
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d1dd95289b89..2cf48ba0dbb1 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -452,7 +452,7 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
452 struct sk_buff *skb) 452 struct sk_buff *skb)
453{ 453{
454 struct rtable *rt; 454 struct rtable *rt;
455 struct flowi fl = { .oif = skb->rtable->rt_iif, 455 struct flowi fl = { .oif = skb_rtable(skb)->rt_iif,
456 .nl_u = { .ip4_u = 456 .nl_u = { .ip4_u =
457 { .daddr = ip_hdr(skb)->saddr, 457 { .daddr = ip_hdr(skb)->saddr,
458 .saddr = ip_hdr(skb)->daddr, 458 .saddr = ip_hdr(skb)->daddr,
@@ -514,7 +514,7 @@ static void dccp_v4_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
514 if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET) 514 if (dccp_hdr(rxskb)->dccph_type == DCCP_PKT_RESET)
515 return; 515 return;
516 516
517 if (rxskb->rtable->rt_type != RTN_LOCAL) 517 if (skb_rtable(rxskb)->rt_type != RTN_LOCAL)
518 return; 518 return;
519 519
520 dst = dccp_v4_route_skb(net, ctl_sk, rxskb); 520 dst = dccp_v4_route_skb(net, ctl_sk, rxskb);
@@ -567,7 +567,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
567 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); 567 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
568 568
569 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */ 569 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
570 if (skb->rtable->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) 570 if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
571 return 0; /* discard, don't send a reset here */ 571 return 0; /* discard, don't send a reset here */
572 572
573 if (dccp_bad_service_code(sk, service)) { 573 if (dccp_bad_service_code(sk, service)) {
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index f11931c18381..816494f271a7 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -474,7 +474,7 @@ int arp_find(unsigned char *haddr, struct sk_buff *skb)
474 return 1; 474 return 1;
475 } 475 }
476 476
477 paddr = skb->rtable->rt_gateway; 477 paddr = skb_rtable(skb)->rt_gateway;
478 478
479 if (arp_set_predefined(inet_addr_type(dev_net(dev), paddr), haddr, paddr, dev)) 479 if (arp_set_predefined(inet_addr_type(dev_net(dev), paddr), haddr, paddr, dev))
480 return 0; 480 return 0;
@@ -817,7 +817,7 @@ static int arp_process(struct sk_buff *skb)
817 if (arp->ar_op == htons(ARPOP_REQUEST) && 817 if (arp->ar_op == htons(ARPOP_REQUEST) &&
818 ip_route_input(skb, tip, sip, 0, dev) == 0) { 818 ip_route_input(skb, tip, sip, 0, dev) == 0) {
819 819
820 rt = skb->rtable; 820 rt = skb_rtable(skb);
821 addr_type = rt->rt_type; 821 addr_type = rt->rt_type;
822 822
823 if (addr_type == RTN_LOCAL) { 823 if (addr_type == RTN_LOCAL) {
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 3f50807237e0..94f75efae938 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -356,7 +356,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
356static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) 356static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
357{ 357{
358 struct ipcm_cookie ipc; 358 struct ipcm_cookie ipc;
359 struct rtable *rt = skb->rtable; 359 struct rtable *rt = skb_rtable(skb);
360 struct net *net = dev_net(rt->u.dst.dev); 360 struct net *net = dev_net(rt->u.dst.dev);
361 struct sock *sk; 361 struct sock *sk;
362 struct inet_sock *inet; 362 struct inet_sock *inet;
@@ -416,7 +416,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
416 struct iphdr *iph; 416 struct iphdr *iph;
417 int room; 417 int room;
418 struct icmp_bxm icmp_param; 418 struct icmp_bxm icmp_param;
419 struct rtable *rt = skb_in->rtable; 419 struct rtable *rt = skb_rtable(skb_in);
420 struct ipcm_cookie ipc; 420 struct ipcm_cookie ipc;
421 __be32 saddr; 421 __be32 saddr;
422 u8 tos; 422 u8 tos;
@@ -596,7 +596,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
596 RT_TOS(tos), rt2->u.dst.dev); 596 RT_TOS(tos), rt2->u.dst.dev);
597 597
598 dst_release(&rt2->u.dst); 598 dst_release(&rt2->u.dst);
599 rt2 = skb_in->rtable; 599 rt2 = skb_rtable(skb_in);
600 skb_in->dst = odst; 600 skb_in->dst = odst;
601 } 601 }
602 602
@@ -926,7 +926,7 @@ static void icmp_address(struct sk_buff *skb)
926 926
927static void icmp_address_reply(struct sk_buff *skb) 927static void icmp_address_reply(struct sk_buff *skb)
928{ 928{
929 struct rtable *rt = skb->rtable; 929 struct rtable *rt = skb_rtable(skb);
930 struct net_device *dev = skb->dev; 930 struct net_device *dev = skb->dev;
931 struct in_device *in_dev; 931 struct in_device *in_dev;
932 struct in_ifaddr *ifa; 932 struct in_ifaddr *ifa;
@@ -970,7 +970,7 @@ static void icmp_discard(struct sk_buff *skb)
970int icmp_rcv(struct sk_buff *skb) 970int icmp_rcv(struct sk_buff *skb)
971{ 971{
972 struct icmphdr *icmph; 972 struct icmphdr *icmph;
973 struct rtable *rt = skb->rtable; 973 struct rtable *rt = skb_rtable(skb);
974 struct net *net = dev_net(rt->u.dst.dev); 974 struct net *net = dev_net(rt->u.dst.dev);
975 975
976 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { 976 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index e6058a503796..afabd2758b67 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -948,7 +948,7 @@ int igmp_rcv(struct sk_buff *skb)
948 case IGMPV2_HOST_MEMBERSHIP_REPORT: 948 case IGMPV2_HOST_MEMBERSHIP_REPORT:
949 case IGMPV3_HOST_MEMBERSHIP_REPORT: 949 case IGMPV3_HOST_MEMBERSHIP_REPORT:
950 /* Is it our report looped back? */ 950 /* Is it our report looped back? */
951 if (skb->rtable->fl.iif == 0) 951 if (skb_rtable(skb)->fl.iif == 0)
952 break; 952 break;
953 /* don't rely on MC router hearing unicast reports */ 953 /* don't rely on MC router hearing unicast reports */
954 if (skb->pkt_type == PACKET_MULTICAST || 954 if (skb->pkt_type == PACKET_MULTICAST ||
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index df3fe50bbf0d..0761cd9bbd10 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -81,7 +81,7 @@ int ip_forward(struct sk_buff *skb)
81 if (!xfrm4_route_forward(skb)) 81 if (!xfrm4_route_forward(skb))
82 goto drop; 82 goto drop;
83 83
84 rt = skb->rtable; 84 rt = skb_rtable(skb);
85 85
86 if (opt->is_strictroute && rt->rt_dst != rt->rt_gateway) 86 if (opt->is_strictroute && rt->rt_dst != rt->rt_gateway)
87 goto sr_failed; 87 goto sr_failed;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 77436e2732eb..85ddad45a918 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -602,7 +602,7 @@ static int ipgre_rcv(struct sk_buff *skb)
602#ifdef CONFIG_NET_IPGRE_BROADCAST 602#ifdef CONFIG_NET_IPGRE_BROADCAST
603 if (ipv4_is_multicast(iph->daddr)) { 603 if (ipv4_is_multicast(iph->daddr)) {
604 /* Looped back packet, drop it! */ 604 /* Looped back packet, drop it! */
605 if (skb->rtable->fl.iif == 0) 605 if (skb_rtable(skb)->fl.iif == 0)
606 goto drop; 606 goto drop;
607 stats->multicast++; 607 stats->multicast++;
608 skb->pkt_type = PACKET_BROADCAST; 608 skb->pkt_type = PACKET_BROADCAST;
@@ -704,7 +704,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
704 } 704 }
705 705
706 if (skb->protocol == htons(ETH_P_IP)) { 706 if (skb->protocol == htons(ETH_P_IP)) {
707 rt = skb->rtable; 707 rt = skb_rtable(skb);
708 if ((dst = rt->rt_gateway) == 0) 708 if ((dst = rt->rt_gateway) == 0)
709 goto tx_error_icmp; 709 goto tx_error_icmp;
710 } 710 }
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 40f6206b2aa9..cea784b0aa47 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -357,7 +357,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
357 if (iph->ihl > 5 && ip_rcv_options(skb)) 357 if (iph->ihl > 5 && ip_rcv_options(skb))
358 goto drop; 358 goto drop;
359 359
360 rt = skb->rtable; 360 rt = skb_rtable(skb);
361 if (rt->rt_type == RTN_MULTICAST) { 361 if (rt->rt_type == RTN_MULTICAST) {
362 IP_UPD_PO_STATS_BH(dev_net(rt->u.dst.dev), IPSTATS_MIB_INMCAST, 362 IP_UPD_PO_STATS_BH(dev_net(rt->u.dst.dev), IPSTATS_MIB_INMCAST,
363 skb->len); 363 skb->len);
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 2c88da6e7862..7e1074ffdbd1 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -102,7 +102,7 @@ int ip_options_echo(struct ip_options * dopt, struct sk_buff * skb)
102 sptr = skb_network_header(skb); 102 sptr = skb_network_header(skb);
103 dptr = dopt->__data; 103 dptr = dopt->__data;
104 104
105 daddr = skb->rtable->rt_spec_dst; 105 daddr = skb_rtable(skb)->rt_spec_dst;
106 106
107 if (sopt->rr) { 107 if (sopt->rr) {
108 optlen = sptr[sopt->rr+1]; 108 optlen = sptr[sopt->rr+1];
@@ -257,7 +257,7 @@ int ip_options_compile(struct net *net,
257 struct rtable *rt = NULL; 257 struct rtable *rt = NULL;
258 258
259 if (skb != NULL) { 259 if (skb != NULL) {
260 rt = skb->rtable; 260 rt = skb_rtable(skb);
261 optptr = (unsigned char *)&(ip_hdr(skb)[1]); 261 optptr = (unsigned char *)&(ip_hdr(skb)[1]);
262 } else 262 } else
263 optptr = opt->__data; 263 optptr = opt->__data;
@@ -550,7 +550,7 @@ void ip_forward_options(struct sk_buff *skb)
550{ 550{
551 struct ip_options * opt = &(IPCB(skb)->opt); 551 struct ip_options * opt = &(IPCB(skb)->opt);
552 unsigned char * optptr; 552 unsigned char * optptr;
553 struct rtable *rt = skb->rtable; 553 struct rtable *rt = skb_rtable(skb);
554 unsigned char *raw = skb_network_header(skb); 554 unsigned char *raw = skb_network_header(skb);
555 555
556 if (opt->rr_needaddr) { 556 if (opt->rr_needaddr) {
@@ -598,7 +598,7 @@ int ip_options_rcv_srr(struct sk_buff *skb)
598 __be32 nexthop; 598 __be32 nexthop;
599 struct iphdr *iph = ip_hdr(skb); 599 struct iphdr *iph = ip_hdr(skb);
600 unsigned char *optptr = skb_network_header(skb) + opt->srr; 600 unsigned char *optptr = skb_network_header(skb) + opt->srr;
601 struct rtable *rt = skb->rtable; 601 struct rtable *rt = skb_rtable(skb);
602 struct rtable *rt2; 602 struct rtable *rt2;
603 int err; 603 int err;
604 604
@@ -623,13 +623,13 @@ int ip_options_rcv_srr(struct sk_buff *skb)
623 } 623 }
624 memcpy(&nexthop, &optptr[srrptr-1], 4); 624 memcpy(&nexthop, &optptr[srrptr-1], 4);
625 625
626 rt = skb->rtable; 626 rt = skb_rtable(skb);
627 skb->rtable = NULL; 627 skb->dst = NULL;
628 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev); 628 err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev);
629 rt2 = skb->rtable; 629 rt2 = skb_rtable(skb);
630 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) { 630 if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) {
631 ip_rt_put(rt2); 631 ip_rt_put(rt2);
632 skb->rtable = rt; 632 skb->dst = &rt->u.dst;
633 return -EINVAL; 633 return -EINVAL;
634 } 634 }
635 ip_rt_put(rt); 635 ip_rt_put(rt);
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index ea19c37ccc0c..8d845ebfccaa 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -140,7 +140,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
140 __be32 saddr, __be32 daddr, struct ip_options *opt) 140 __be32 saddr, __be32 daddr, struct ip_options *opt)
141{ 141{
142 struct inet_sock *inet = inet_sk(sk); 142 struct inet_sock *inet = inet_sk(sk);
143 struct rtable *rt = skb->rtable; 143 struct rtable *rt = skb_rtable(skb);
144 struct iphdr *iph; 144 struct iphdr *iph;
145 145
146 /* Build the IP header. */ 146 /* Build the IP header. */
@@ -238,7 +238,7 @@ static int ip_finish_output(struct sk_buff *skb)
238int ip_mc_output(struct sk_buff *skb) 238int ip_mc_output(struct sk_buff *skb)
239{ 239{
240 struct sock *sk = skb->sk; 240 struct sock *sk = skb->sk;
241 struct rtable *rt = skb->rtable; 241 struct rtable *rt = skb_rtable(skb);
242 struct net_device *dev = rt->u.dst.dev; 242 struct net_device *dev = rt->u.dst.dev;
243 243
244 /* 244 /*
@@ -319,7 +319,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok)
319 /* Skip all of this if the packet is already routed, 319 /* Skip all of this if the packet is already routed,
320 * f.e. by something like SCTP. 320 * f.e. by something like SCTP.
321 */ 321 */
322 rt = skb->rtable; 322 rt = skb_rtable(skb);
323 if (rt != NULL) 323 if (rt != NULL)
324 goto packet_routed; 324 goto packet_routed;
325 325
@@ -440,7 +440,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
440 unsigned int mtu, hlen, left, len, ll_rs, pad; 440 unsigned int mtu, hlen, left, len, ll_rs, pad;
441 int offset; 441 int offset;
442 __be16 not_last_frag; 442 __be16 not_last_frag;
443 struct rtable *rt = skb->rtable; 443 struct rtable *rt = skb_rtable(skb);
444 int err = 0; 444 int err = 0;
445 445
446 dev = rt->u.dst.dev; 446 dev = rt->u.dst.dev;
@@ -1362,7 +1362,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
1362 } replyopts; 1362 } replyopts;
1363 struct ipcm_cookie ipc; 1363 struct ipcm_cookie ipc;
1364 __be32 daddr; 1364 __be32 daddr;
1365 struct rtable *rt = skb->rtable; 1365 struct rtable *rt = skb_rtable(skb);
1366 1366
1367 if (ip_options_echo(&replyopts.opt, skb)) 1367 if (ip_options_echo(&replyopts.opt, skb))
1368 return; 1368 return;
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index cb49936856e0..fc7993e9061f 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -57,7 +57,7 @@
57static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb) 57static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
58{ 58{
59 struct in_pktinfo info; 59 struct in_pktinfo info;
60 struct rtable *rt = skb->rtable; 60 struct rtable *rt = skb_rtable(skb);
61 61
62 info.ipi_addr.s_addr = ip_hdr(skb)->daddr; 62 info.ipi_addr.s_addr = ip_hdr(skb)->daddr;
63 if (rt) { 63 if (rt) {
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index bb2f1b17fbf1..0c6e7bf18a43 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -416,7 +416,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
416 416
417 if (!dst) { 417 if (!dst) {
418 /* NBMA tunnel */ 418 /* NBMA tunnel */
419 if ((rt = skb->rtable) == NULL) { 419 if ((rt = skb_rtable(skb)) == NULL) {
420 stats->tx_fifo_errors++; 420 stats->tx_fifo_errors++;
421 goto tx_error; 421 goto tx_error;
422 } 422 }
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 13e9dd3012b3..69dd058283eb 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1354,7 +1354,7 @@ static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local
1354 if (net->ipv4.vif_table[vif].dev != skb->dev) { 1354 if (net->ipv4.vif_table[vif].dev != skb->dev) {
1355 int true_vifi; 1355 int true_vifi;
1356 1356
1357 if (skb->rtable->fl.iif == 0) { 1357 if (skb_rtable(skb)->fl.iif == 0) {
1358 /* It is our own packet, looped back. 1358 /* It is our own packet, looped back.
1359 Very complicated situation... 1359 Very complicated situation...
1360 1360
@@ -1430,7 +1430,7 @@ int ip_mr_input(struct sk_buff *skb)
1430{ 1430{
1431 struct mfc_cache *cache; 1431 struct mfc_cache *cache;
1432 struct net *net = dev_net(skb->dev); 1432 struct net *net = dev_net(skb->dev);
1433 int local = skb->rtable->rt_flags&RTCF_LOCAL; 1433 int local = skb_rtable(skb)->rt_flags & RTCF_LOCAL;
1434 1434
1435 /* Packet is looped back after forward, it should not be 1435 /* Packet is looped back after forward, it should not be
1436 forwarded second time, but still can be delivered locally. 1436 forwarded second time, but still can be delivered locally.
@@ -1646,7 +1646,7 @@ int ipmr_get_route(struct net *net,
1646{ 1646{
1647 int err; 1647 int err;
1648 struct mfc_cache *cache; 1648 struct mfc_cache *cache;
1649 struct rtable *rt = skb->rtable; 1649 struct rtable *rt = skb_rtable(skb);
1650 1650
1651 read_lock(&mrt_lock); 1651 read_lock(&mrt_lock);
1652 cache = ipmr_cache_find(net, rt->rt_src, rt->rt_dst); 1652 cache = ipmr_cache_find(net, rt->rt_src, rt->rt_dst);
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index f389f60cb105..c0992c75bdac 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -72,7 +72,7 @@ masquerade_tg(struct sk_buff *skb, const struct xt_target_param *par)
72 return NF_ACCEPT; 72 return NF_ACCEPT;
73 73
74 mr = par->targinfo; 74 mr = par->targinfo;
75 rt = skb->rtable; 75 rt = skb_rtable(skb);
76 newsrc = inet_select_addr(par->out, rt->rt_gateway, RT_SCOPE_UNIVERSE); 76 newsrc = inet_select_addr(par->out, rt->rt_gateway, RT_SCOPE_UNIVERSE);
77 if (!newsrc) { 77 if (!newsrc) {
78 printk("MASQUERADE: %s ate my IP address\n", par->out->name); 78 printk("MASQUERADE: %s ate my IP address\n", par->out->name);
diff --git a/net/ipv4/netfilter/nf_nat_helper.c b/net/ipv4/netfilter/nf_nat_helper.c
index cf7a42bf9820..155c008626c8 100644
--- a/net/ipv4/netfilter/nf_nat_helper.c
+++ b/net/ipv4/netfilter/nf_nat_helper.c
@@ -140,7 +140,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb,
140 const char *rep_buffer, 140 const char *rep_buffer,
141 unsigned int rep_len) 141 unsigned int rep_len)
142{ 142{
143 struct rtable *rt = skb->rtable; 143 struct rtable *rt = skb_rtable(skb);
144 struct iphdr *iph; 144 struct iphdr *iph;
145 struct tcphdr *tcph; 145 struct tcphdr *tcph;
146 int oldlen, datalen; 146 int oldlen, datalen;
@@ -218,7 +218,7 @@ nf_nat_mangle_udp_packet(struct sk_buff *skb,
218 const char *rep_buffer, 218 const char *rep_buffer,
219 unsigned int rep_len) 219 unsigned int rep_len)
220{ 220{
221 struct rtable *rt = skb->rtable; 221 struct rtable *rt = skb_rtable(skb);
222 struct iphdr *iph; 222 struct iphdr *iph;
223 struct udphdr *udph; 223 struct udphdr *udph;
224 int datalen, oldlen; 224 int datalen, oldlen;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 28205e5bfa9b..f20060ac2f09 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1064,7 +1064,8 @@ work_done:
1064out: return 0; 1064out: return 0;
1065} 1065}
1066 1066
1067static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp) 1067static int rt_intern_hash(unsigned hash, struct rtable *rt,
1068 struct rtable **rp, struct sk_buff *skb)
1068{ 1069{
1069 struct rtable *rth, **rthp; 1070 struct rtable *rth, **rthp;
1070 unsigned long now; 1071 unsigned long now;
@@ -1114,7 +1115,10 @@ restart:
1114 spin_unlock_bh(rt_hash_lock_addr(hash)); 1115 spin_unlock_bh(rt_hash_lock_addr(hash));
1115 1116
1116 rt_drop(rt); 1117 rt_drop(rt);
1117 *rp = rth; 1118 if (rp)
1119 *rp = rth;
1120 else
1121 skb->dst = &rth->u.dst;
1118 return 0; 1122 return 0;
1119 } 1123 }
1120 1124
@@ -1210,7 +1214,10 @@ restart:
1210 rcu_assign_pointer(rt_hash_table[hash].chain, rt); 1214 rcu_assign_pointer(rt_hash_table[hash].chain, rt);
1211 1215
1212 spin_unlock_bh(rt_hash_lock_addr(hash)); 1216 spin_unlock_bh(rt_hash_lock_addr(hash));
1213 *rp = rt; 1217 if (rp)
1218 *rp = rt;
1219 else
1220 skb->dst = &rt->u.dst;
1214 return 0; 1221 return 0;
1215} 1222}
1216 1223
@@ -1407,7 +1414,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1407 &netevent); 1414 &netevent);
1408 1415
1409 rt_del(hash, rth); 1416 rt_del(hash, rth);
1410 if (!rt_intern_hash(hash, rt, &rt)) 1417 if (!rt_intern_hash(hash, rt, &rt, NULL))
1411 ip_rt_put(rt); 1418 ip_rt_put(rt);
1412 goto do_next; 1419 goto do_next;
1413 } 1420 }
@@ -1473,7 +1480,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1473 1480
1474void ip_rt_send_redirect(struct sk_buff *skb) 1481void ip_rt_send_redirect(struct sk_buff *skb)
1475{ 1482{
1476 struct rtable *rt = skb->rtable; 1483 struct rtable *rt = skb_rtable(skb);
1477 struct in_device *in_dev = in_dev_get(rt->u.dst.dev); 1484 struct in_device *in_dev = in_dev_get(rt->u.dst.dev);
1478 1485
1479 if (!in_dev) 1486 if (!in_dev)
@@ -1521,7 +1528,7 @@ out:
1521 1528
1522static int ip_error(struct sk_buff *skb) 1529static int ip_error(struct sk_buff *skb)
1523{ 1530{
1524 struct rtable *rt = skb->rtable; 1531 struct rtable *rt = skb_rtable(skb);
1525 unsigned long now; 1532 unsigned long now;
1526 int code; 1533 int code;
1527 1534
@@ -1698,7 +1705,7 @@ static void ipv4_link_failure(struct sk_buff *skb)
1698 1705
1699 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0); 1706 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
1700 1707
1701 rt = skb->rtable; 1708 rt = skb_rtable(skb);
1702 if (rt) 1709 if (rt)
1703 dst_set_expires(&rt->u.dst, 0); 1710 dst_set_expires(&rt->u.dst, 0);
1704} 1711}
@@ -1858,7 +1865,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1858 1865
1859 in_dev_put(in_dev); 1866 in_dev_put(in_dev);
1860 hash = rt_hash(daddr, saddr, dev->ifindex, rt_genid(dev_net(dev))); 1867 hash = rt_hash(daddr, saddr, dev->ifindex, rt_genid(dev_net(dev)));
1861 return rt_intern_hash(hash, rth, &skb->rtable); 1868 return rt_intern_hash(hash, rth, NULL, skb);
1862 1869
1863e_nobufs: 1870e_nobufs:
1864 in_dev_put(in_dev); 1871 in_dev_put(in_dev);
@@ -2019,7 +2026,7 @@ static int ip_mkroute_input(struct sk_buff *skb,
2019 /* put it into the cache */ 2026 /* put it into the cache */
2020 hash = rt_hash(daddr, saddr, fl->iif, 2027 hash = rt_hash(daddr, saddr, fl->iif,
2021 rt_genid(dev_net(rth->u.dst.dev))); 2028 rt_genid(dev_net(rth->u.dst.dev)));
2022 return rt_intern_hash(hash, rth, &skb->rtable); 2029 return rt_intern_hash(hash, rth, NULL, skb);
2023} 2030}
2024 2031
2025/* 2032/*
@@ -2175,7 +2182,7 @@ local_input:
2175 } 2182 }
2176 rth->rt_type = res.type; 2183 rth->rt_type = res.type;
2177 hash = rt_hash(daddr, saddr, fl.iif, rt_genid(net)); 2184 hash = rt_hash(daddr, saddr, fl.iif, rt_genid(net));
2178 err = rt_intern_hash(hash, rth, &skb->rtable); 2185 err = rt_intern_hash(hash, rth, NULL, skb);
2179 goto done; 2186 goto done;
2180 2187
2181no_route: 2188no_route:
@@ -2244,7 +2251,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2244 dst_use(&rth->u.dst, jiffies); 2251 dst_use(&rth->u.dst, jiffies);
2245 RT_CACHE_STAT_INC(in_hit); 2252 RT_CACHE_STAT_INC(in_hit);
2246 rcu_read_unlock(); 2253 rcu_read_unlock();
2247 skb->rtable = rth; 2254 skb->dst = &rth->u.dst;
2248 return 0; 2255 return 0;
2249 } 2256 }
2250 RT_CACHE_STAT_INC(in_hlist_search); 2257 RT_CACHE_STAT_INC(in_hlist_search);
@@ -2420,7 +2427,7 @@ static int ip_mkroute_output(struct rtable **rp,
2420 if (err == 0) { 2427 if (err == 0) {
2421 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif, 2428 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
2422 rt_genid(dev_net(dev_out))); 2429 rt_genid(dev_net(dev_out)));
2423 err = rt_intern_hash(hash, rth, rp); 2430 err = rt_intern_hash(hash, rth, rp, NULL);
2424 } 2431 }
2425 2432
2426 return err; 2433 return err;
@@ -2763,7 +2770,7 @@ static int rt_fill_info(struct net *net,
2763 struct sk_buff *skb, u32 pid, u32 seq, int event, 2770 struct sk_buff *skb, u32 pid, u32 seq, int event,
2764 int nowait, unsigned int flags) 2771 int nowait, unsigned int flags)
2765{ 2772{
2766 struct rtable *rt = skb->rtable; 2773 struct rtable *rt = skb_rtable(skb);
2767 struct rtmsg *r; 2774 struct rtmsg *r;
2768 struct nlmsghdr *nlh; 2775 struct nlmsghdr *nlh;
2769 long expires; 2776 long expires;
@@ -2907,7 +2914,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2907 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev); 2914 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
2908 local_bh_enable(); 2915 local_bh_enable();
2909 2916
2910 rt = skb->rtable; 2917 rt = skb_rtable(skb);
2911 if (err == 0 && rt->u.dst.error) 2918 if (err == 0 && rt->u.dst.error)
2912 err = -rt->u.dst.error; 2919 err = -rt->u.dst.error;
2913 } else { 2920 } else {
@@ -2927,7 +2934,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2927 if (err) 2934 if (err)
2928 goto errout_free; 2935 goto errout_free;
2929 2936
2930 skb->rtable = rt; 2937 skb->dst = &rt->u.dst;
2931 if (rtm->rtm_flags & RTM_F_NOTIFY) 2938 if (rtm->rtm_flags & RTM_F_NOTIFY)
2932 rt->rt_flags |= RTCF_NOTIFY; 2939 rt->rt_flags |= RTCF_NOTIFY;
2933 2940
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index fc79e3416288..319c88526449 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -546,7 +546,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
546 if (th->rst) 546 if (th->rst)
547 return; 547 return;
548 548
549 if (skb->rtable->rt_type != RTN_LOCAL) 549 if (skb_rtable(skb)->rt_type != RTN_LOCAL)
550 return; 550 return;
551 551
552 /* Swap the send and the receive. */ 552 /* Swap the send and the receive. */
@@ -1185,7 +1185,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
1185#endif 1185#endif
1186 1186
1187 /* Never answer to SYNs send to broadcast or multicast */ 1187 /* Never answer to SYNs send to broadcast or multicast */
1188 if (skb->rtable->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) 1188 if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
1189 goto drop; 1189 goto drop;
1190 1190
1191 /* TW buckets are converted to open requests without 1191 /* TW buckets are converted to open requests without
diff --git a/net/netfilter/nf_conntrack_netbios_ns.c b/net/netfilter/nf_conntrack_netbios_ns.c
index 8a3875e36ec2..497b2224536f 100644
--- a/net/netfilter/nf_conntrack_netbios_ns.c
+++ b/net/netfilter/nf_conntrack_netbios_ns.c
@@ -48,7 +48,7 @@ static int help(struct sk_buff *skb, unsigned int protoff,
48{ 48{
49 struct nf_conntrack_expect *exp; 49 struct nf_conntrack_expect *exp;
50 struct iphdr *iph = ip_hdr(skb); 50 struct iphdr *iph = ip_hdr(skb);
51 struct rtable *rt = skb->rtable; 51 struct rtable *rt = skb_rtable(skb);
52 struct in_device *in_dev; 52 struct in_device *in_dev;
53 __be32 mask = 0; 53 __be32 mask = 0;
54 54
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index fad596bf32d7..b6b588bed4e1 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -258,10 +258,10 @@ META_COLLECTOR(int_rtclassid)
258 258
259META_COLLECTOR(int_rtiif) 259META_COLLECTOR(int_rtiif)
260{ 260{
261 if (unlikely(skb->rtable == NULL)) 261 if (unlikely(skb_rtable(skb) == NULL))
262 *err = -1; 262 *err = -1;
263 else 263 else
264 dst->value = skb->rtable->fl.iif; 264 dst->value = skb_rtable(skb)->fl.iif;
265} 265}
266 266
267/************************************************************************** 267/**************************************************************************
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 8eb3e61cb701..cb2c50dbd421 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -393,7 +393,7 @@ static int sctp_v4_addr_valid(union sctp_addr *addr,
393 return 0; 393 return 0;
394 394
395 /* Is this a broadcast address? */ 395 /* Is this a broadcast address? */
396 if (skb && skb->rtable->rt_flags & RTCF_BROADCAST) 396 if (skb && skb_rtable(skb)->rt_flags & RTCF_BROADCAST)
397 return 0; 397 return 0;
398 398
399 return 1; 399 return 1;
@@ -572,7 +572,7 @@ static void sctp_v4_get_saddr(struct sctp_sock *sk,
572/* What interface did this skb arrive on? */ 572/* What interface did this skb arrive on? */
573static int sctp_v4_skb_iif(const struct sk_buff *skb) 573static int sctp_v4_skb_iif(const struct sk_buff *skb)
574{ 574{
575 return skb->rtable->rt_iif; 575 return skb_rtable(skb)->rt_iif;
576} 576}
577 577
578/* Was this packet marked by Explicit Congestion Notification? */ 578/* Was this packet marked by Explicit Congestion Notification? */
@@ -848,8 +848,8 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
848 848
849 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n", 849 SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI4, dst:%pI4\n",
850 __func__, skb, skb->len, 850 __func__, skb, skb->len,
851 &skb->rtable->rt_src, 851 &skb_rtable(skb)->rt_src,
852 &skb->rtable->rt_dst); 852 &skb_rtable(skb)->rt_dst);
853 853
854 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? 854 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ?
855 IP_PMTUDISC_DO : IP_PMTUDISC_DONT; 855 IP_PMTUDISC_DO : IP_PMTUDISC_DONT;