aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_route.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/decnet/dn_route.c')
-rw-r--r--net/decnet/dn_route.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 3407f190afe8..e172cf98d7fc 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -133,9 +133,9 @@ static struct dst_ops dn_dst_ops = {
133 .entries = ATOMIC_INIT(0), 133 .entries = ATOMIC_INIT(0),
134}; 134};
135 135
136static __inline__ unsigned dn_hash(unsigned short src, unsigned short dst) 136static __inline__ unsigned dn_hash(__le16 src, __le16 dst)
137{ 137{
138 unsigned short tmp = src ^ dst; 138 __u16 tmp = (__u16 __force)(src ^ dst);
139 tmp ^= (tmp >> 3); 139 tmp ^= (tmp >> 3);
140 tmp ^= (tmp >> 5); 140 tmp ^= (tmp >> 5);
141 tmp ^= (tmp >> 10); 141 tmp ^= (tmp >> 10);
@@ -149,8 +149,7 @@ static inline void dnrt_free(struct dn_route *rt)
149 149
150static inline void dnrt_drop(struct dn_route *rt) 150static inline void dnrt_drop(struct dn_route *rt)
151{ 151{
152 if (rt) 152 dst_release(&rt->u.dst);
153 dst_release(&rt->u.dst);
154 call_rcu_bh(&rt->u.dst.rcu_head, dst_rcu_free); 153 call_rcu_bh(&rt->u.dst.rcu_head, dst_rcu_free);
155} 154}
156 155
@@ -379,9 +378,9 @@ static int dn_return_short(struct sk_buff *skb)
379{ 378{
380 struct dn_skb_cb *cb; 379 struct dn_skb_cb *cb;
381 unsigned char *ptr; 380 unsigned char *ptr;
382 dn_address *src; 381 __le16 *src;
383 dn_address *dst; 382 __le16 *dst;
384 dn_address tmp; 383 __le16 tmp;
385 384
386 /* Add back headers */ 385 /* Add back headers */
387 skb_push(skb, skb->data - skb->nh.raw); 386 skb_push(skb, skb->data - skb->nh.raw);
@@ -394,9 +393,9 @@ static int dn_return_short(struct sk_buff *skb)
394 ptr = skb->data + 2; 393 ptr = skb->data + 2;
395 *ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS; 394 *ptr++ = (cb->rt_flags & ~DN_RT_F_RQR) | DN_RT_F_RTS;
396 395
397 dst = (dn_address *)ptr; 396 dst = (__le16 *)ptr;
398 ptr += 2; 397 ptr += 2;
399 src = (dn_address *)ptr; 398 src = (__le16 *)ptr;
400 ptr += 2; 399 ptr += 2;
401 *ptr = 0; /* Zero hop count */ 400 *ptr = 0; /* Zero hop count */
402 401
@@ -475,7 +474,8 @@ static int dn_route_rx_packet(struct sk_buff *skb)
475 struct dn_skb_cb *cb = DN_SKB_CB(skb); 474 struct dn_skb_cb *cb = DN_SKB_CB(skb);
476 printk(KERN_DEBUG 475 printk(KERN_DEBUG
477 "DECnet: dn_route_rx_packet: rt_flags=0x%02x dev=%s len=%d src=0x%04hx dst=0x%04hx err=%d type=%d\n", 476 "DECnet: dn_route_rx_packet: rt_flags=0x%02x dev=%s len=%d src=0x%04hx dst=0x%04hx err=%d type=%d\n",
478 (int)cb->rt_flags, devname, skb->len, cb->src, cb->dst, 477 (int)cb->rt_flags, devname, skb->len,
478 dn_ntohs(cb->src), dn_ntohs(cb->dst),
479 err, skb->pkt_type); 479 err, skb->pkt_type);
480 } 480 }
481 481
@@ -505,7 +505,7 @@ static int dn_route_rx_long(struct sk_buff *skb)
505 505
506 /* Destination info */ 506 /* Destination info */
507 ptr += 2; 507 ptr += 2;
508 cb->dst = dn_htons(dn_eth2dn(ptr)); 508 cb->dst = dn_eth2dn(ptr);
509 if (memcmp(ptr, dn_hiord_addr, 4) != 0) 509 if (memcmp(ptr, dn_hiord_addr, 4) != 0)
510 goto drop_it; 510 goto drop_it;
511 ptr += 6; 511 ptr += 6;
@@ -513,7 +513,7 @@ static int dn_route_rx_long(struct sk_buff *skb)
513 513
514 /* Source info */ 514 /* Source info */
515 ptr += 2; 515 ptr += 2;
516 cb->src = dn_htons(dn_eth2dn(ptr)); 516 cb->src = dn_eth2dn(ptr);
517 if (memcmp(ptr, dn_hiord_addr, 4) != 0) 517 if (memcmp(ptr, dn_hiord_addr, 4) != 0)
518 goto drop_it; 518 goto drop_it;
519 ptr += 6; 519 ptr += 6;
@@ -541,9 +541,9 @@ static int dn_route_rx_short(struct sk_buff *skb)
541 skb_pull(skb, 5); 541 skb_pull(skb, 5);
542 skb->h.raw = skb->data; 542 skb->h.raw = skb->data;
543 543
544 cb->dst = *(dn_address *)ptr; 544 cb->dst = *(__le16 *)ptr;
545 ptr += 2; 545 ptr += 2;
546 cb->src = *(dn_address *)ptr; 546 cb->src = *(__le16 *)ptr;
547 ptr += 2; 547 ptr += 2;
548 cb->hops = *ptr & 0x3f; 548 cb->hops = *ptr & 0x3f;
549 549
@@ -575,7 +575,7 @@ int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type
575{ 575{
576 struct dn_skb_cb *cb; 576 struct dn_skb_cb *cb;
577 unsigned char flags = 0; 577 unsigned char flags = 0;
578 __u16 len = dn_ntohs(*(__u16 *)skb->data); 578 __u16 len = dn_ntohs(*(__le16 *)skb->data);
579 struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr; 579 struct dn_dev *dn = (struct dn_dev *)dev->dn_ptr;
580 unsigned char padlen = 0; 580 unsigned char padlen = 0;
581 581
@@ -782,7 +782,7 @@ static int dn_rt_bug(struct sk_buff *skb)
782 struct dn_skb_cb *cb = DN_SKB_CB(skb); 782 struct dn_skb_cb *cb = DN_SKB_CB(skb);
783 783
784 printk(KERN_DEBUG "dn_rt_bug: skb from:%04x to:%04x\n", 784 printk(KERN_DEBUG "dn_rt_bug: skb from:%04x to:%04x\n",
785 cb->src, cb->dst); 785 dn_ntohs(cb->src), dn_ntohs(cb->dst));
786 } 786 }
787 787
788 kfree_skb(skb); 788 kfree_skb(skb);
@@ -823,7 +823,7 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
823 return 0; 823 return 0;
824} 824}
825 825
826static inline int dn_match_addr(__u16 addr1, __u16 addr2) 826static inline int dn_match_addr(__le16 addr1, __le16 addr2)
827{ 827{
828 __u16 tmp = dn_ntohs(addr1) ^ dn_ntohs(addr2); 828 __u16 tmp = dn_ntohs(addr1) ^ dn_ntohs(addr2);
829 int match = 16; 829 int match = 16;
@@ -834,9 +834,9 @@ static inline int dn_match_addr(__u16 addr1, __u16 addr2)
834 return match; 834 return match;
835} 835}
836 836
837static __u16 dnet_select_source(const struct net_device *dev, __u16 daddr, int scope) 837static __le16 dnet_select_source(const struct net_device *dev, __le16 daddr, int scope)
838{ 838{
839 __u16 saddr = 0; 839 __le16 saddr = 0;
840 struct dn_dev *dn_db = dev->dn_ptr; 840 struct dn_dev *dn_db = dev->dn_ptr;
841 struct dn_ifaddr *ifa; 841 struct dn_ifaddr *ifa;
842 int best_match = 0; 842 int best_match = 0;
@@ -861,14 +861,14 @@ static __u16 dnet_select_source(const struct net_device *dev, __u16 daddr, int s
861 return saddr; 861 return saddr;
862} 862}
863 863
864static inline __u16 __dn_fib_res_prefsrc(struct dn_fib_res *res) 864static inline __le16 __dn_fib_res_prefsrc(struct dn_fib_res *res)
865{ 865{
866 return dnet_select_source(DN_FIB_RES_DEV(*res), DN_FIB_RES_GW(*res), res->scope); 866 return dnet_select_source(DN_FIB_RES_DEV(*res), DN_FIB_RES_GW(*res), res->scope);
867} 867}
868 868
869static inline __u16 dn_fib_rules_map_destination(__u16 daddr, struct dn_fib_res *res) 869static inline __le16 dn_fib_rules_map_destination(__le16 daddr, struct dn_fib_res *res)
870{ 870{
871 __u16 mask = dnet_make_mask(res->prefixlen); 871 __le16 mask = dnet_make_mask(res->prefixlen);
872 return (daddr&~mask)|res->fi->fib_nh->nh_gw; 872 return (daddr&~mask)|res->fi->fib_nh->nh_gw;
873} 873}
874 874
@@ -892,12 +892,13 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
892 struct dn_fib_res res = { .fi = NULL, .type = RTN_UNICAST }; 892 struct dn_fib_res res = { .fi = NULL, .type = RTN_UNICAST };
893 int err; 893 int err;
894 int free_res = 0; 894 int free_res = 0;
895 __u16 gateway = 0; 895 __le16 gateway = 0;
896 896
897 if (decnet_debug_level & 16) 897 if (decnet_debug_level & 16)
898 printk(KERN_DEBUG 898 printk(KERN_DEBUG
899 "dn_route_output_slow: dst=%04x src=%04x mark=%d" 899 "dn_route_output_slow: dst=%04x src=%04x mark=%d"
900 " iif=%d oif=%d\n", oldflp->fld_dst, oldflp->fld_src, 900 " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
901 dn_ntohs(oldflp->fld_src),
901 oldflp->fld_fwmark, loopback_dev.ifindex, oldflp->oif); 902 oldflp->fld_fwmark, loopback_dev.ifindex, oldflp->oif);
902 903
903 /* If we have an output interface, verify its a DECnet device */ 904 /* If we have an output interface, verify its a DECnet device */
@@ -961,8 +962,9 @@ source_ok:
961 if (decnet_debug_level & 16) 962 if (decnet_debug_level & 16)
962 printk(KERN_DEBUG 963 printk(KERN_DEBUG
963 "dn_route_output_slow: initial checks complete." 964 "dn_route_output_slow: initial checks complete."
964 " dst=%o4x src=%04x oif=%d try_hard=%d\n", fl.fld_dst, 965 " dst=%o4x src=%04x oif=%d try_hard=%d\n",
965 fl.fld_src, fl.oif, try_hard); 966 dn_ntohs(fl.fld_dst), dn_ntohs(fl.fld_src),
967 fl.oif, try_hard);
966 968
967 /* 969 /*
968 * N.B. If the kernel is compiled without router support then 970 * N.B. If the kernel is compiled without router support then
@@ -1218,8 +1220,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
1218 struct neighbour *neigh = NULL; 1220 struct neighbour *neigh = NULL;
1219 unsigned hash; 1221 unsigned hash;
1220 int flags = 0; 1222 int flags = 0;
1221 __u16 gateway = 0; 1223 __le16 gateway = 0;
1222 __u16 local_src = 0; 1224 __le16 local_src = 0;
1223 struct flowi fl = { .nl_u = { .dn_u = 1225 struct flowi fl = { .nl_u = { .dn_u =
1224 { .daddr = cb->dst, 1226 { .daddr = cb->dst,
1225 .saddr = cb->src, 1227 .saddr = cb->src,
@@ -1266,7 +1268,7 @@ static int dn_route_input_slow(struct sk_buff *skb)
1266 res.type = RTN_LOCAL; 1268 res.type = RTN_LOCAL;
1267 flags |= RTCF_DIRECTSRC; 1269 flags |= RTCF_DIRECTSRC;
1268 } else { 1270 } else {
1269 __u16 src_map = fl.fld_src; 1271 __le16 src_map = fl.fld_src;
1270 free_res = 1; 1272 free_res = 1;
1271 1273
1272 out_dev = DN_FIB_RES_DEV(res); 1274 out_dev = DN_FIB_RES_DEV(res);