diff options
Diffstat (limited to 'net/ipx/af_ipx.c')
-rw-r--r-- | net/ipx/af_ipx.c | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index bef3f61569f7..76c661566dfd 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -83,13 +83,13 @@ DEFINE_SPINLOCK(ipx_interfaces_lock); | |||
83 | struct ipx_interface *ipx_primary_net; | 83 | struct ipx_interface *ipx_primary_net; |
84 | struct ipx_interface *ipx_internal_net; | 84 | struct ipx_interface *ipx_internal_net; |
85 | 85 | ||
86 | extern int ipxrtr_add_route(__u32 network, struct ipx_interface *intrfc, | 86 | extern int ipxrtr_add_route(__be32 network, struct ipx_interface *intrfc, |
87 | unsigned char *node); | 87 | unsigned char *node); |
88 | extern void ipxrtr_del_routes(struct ipx_interface *intrfc); | 88 | extern void ipxrtr_del_routes(struct ipx_interface *intrfc); |
89 | extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, | 89 | extern int ipxrtr_route_packet(struct sock *sk, struct sockaddr_ipx *usipx, |
90 | struct iovec *iov, int len, int noblock); | 90 | struct iovec *iov, int len, int noblock); |
91 | extern int ipxrtr_route_skb(struct sk_buff *skb); | 91 | extern int ipxrtr_route_skb(struct sk_buff *skb); |
92 | extern struct ipx_route *ipxrtr_lookup(__u32 net); | 92 | extern struct ipx_route *ipxrtr_lookup(__be32 net); |
93 | extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg); | 93 | extern int ipxrtr_ioctl(unsigned int cmd, void __user *arg); |
94 | 94 | ||
95 | #undef IPX_REFCNT_DEBUG | 95 | #undef IPX_REFCNT_DEBUG |
@@ -177,7 +177,7 @@ static void ipxitf_clear_primary_net(void) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | static struct ipx_interface *__ipxitf_find_using_phys(struct net_device *dev, | 179 | static struct ipx_interface *__ipxitf_find_using_phys(struct net_device *dev, |
180 | unsigned short datalink) | 180 | __be16 datalink) |
181 | { | 181 | { |
182 | struct ipx_interface *i; | 182 | struct ipx_interface *i; |
183 | 183 | ||
@@ -190,7 +190,7 @@ out: | |||
190 | } | 190 | } |
191 | 191 | ||
192 | static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev, | 192 | static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev, |
193 | unsigned short datalink) | 193 | __be16 datalink) |
194 | { | 194 | { |
195 | struct ipx_interface *i; | 195 | struct ipx_interface *i; |
196 | 196 | ||
@@ -202,7 +202,7 @@ static struct ipx_interface *ipxitf_find_using_phys(struct net_device *dev, | |||
202 | return i; | 202 | return i; |
203 | } | 203 | } |
204 | 204 | ||
205 | struct ipx_interface *ipxitf_find_using_net(__u32 net) | 205 | struct ipx_interface *ipxitf_find_using_net(__be32 net) |
206 | { | 206 | { |
207 | struct ipx_interface *i; | 207 | struct ipx_interface *i; |
208 | 208 | ||
@@ -237,7 +237,7 @@ static void ipxitf_insert_socket(struct ipx_interface *intrfc, struct sock *sk) | |||
237 | 237 | ||
238 | /* caller must hold intrfc->if_sklist_lock */ | 238 | /* caller must hold intrfc->if_sklist_lock */ |
239 | static struct sock *__ipxitf_find_socket(struct ipx_interface *intrfc, | 239 | static struct sock *__ipxitf_find_socket(struct ipx_interface *intrfc, |
240 | unsigned short port) | 240 | __be16 port) |
241 | { | 241 | { |
242 | struct sock *s; | 242 | struct sock *s; |
243 | struct hlist_node *node; | 243 | struct hlist_node *node; |
@@ -252,7 +252,7 @@ found: | |||
252 | 252 | ||
253 | /* caller must hold a reference to intrfc */ | 253 | /* caller must hold a reference to intrfc */ |
254 | static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc, | 254 | static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc, |
255 | unsigned short port) | 255 | __be16 port) |
256 | { | 256 | { |
257 | struct sock *s; | 257 | struct sock *s; |
258 | 258 | ||
@@ -268,7 +268,7 @@ static struct sock *ipxitf_find_socket(struct ipx_interface *intrfc, | |||
268 | #ifdef CONFIG_IPX_INTERN | 268 | #ifdef CONFIG_IPX_INTERN |
269 | static struct sock *ipxitf_find_internal_socket(struct ipx_interface *intrfc, | 269 | static struct sock *ipxitf_find_internal_socket(struct ipx_interface *intrfc, |
270 | unsigned char *ipx_node, | 270 | unsigned char *ipx_node, |
271 | unsigned short port) | 271 | __be16 port) |
272 | { | 272 | { |
273 | struct sock *s; | 273 | struct sock *s; |
274 | struct hlist_node *node; | 274 | struct hlist_node *node; |
@@ -600,10 +600,10 @@ int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, char *node) | |||
600 | 600 | ||
601 | /* see if we need to include the netnum in the route list */ | 601 | /* see if we need to include the netnum in the route list */ |
602 | if (IPX_SKB_CB(skb)->last_hop.index >= 0) { | 602 | if (IPX_SKB_CB(skb)->last_hop.index >= 0) { |
603 | u32 *last_hop = (u32 *)(((u8 *) skb->data) + | 603 | __be32 *last_hop = (__be32 *)(((u8 *) skb->data) + |
604 | sizeof(struct ipxhdr) + | 604 | sizeof(struct ipxhdr) + |
605 | IPX_SKB_CB(skb)->last_hop.index * | 605 | IPX_SKB_CB(skb)->last_hop.index * |
606 | sizeof(u32)); | 606 | sizeof(__be32)); |
607 | *last_hop = IPX_SKB_CB(skb)->last_hop.netnum; | 607 | *last_hop = IPX_SKB_CB(skb)->last_hop.netnum; |
608 | IPX_SKB_CB(skb)->last_hop.index = -1; | 608 | IPX_SKB_CB(skb)->last_hop.index = -1; |
609 | } | 609 | } |
@@ -772,7 +772,7 @@ static void ipxitf_discover_netnum(struct ipx_interface *intrfc, | |||
772 | } else { | 772 | } else { |
773 | printk(KERN_WARNING "IPX: Network number collision " | 773 | printk(KERN_WARNING "IPX: Network number collision " |
774 | "%lx\n %s %s and %s %s\n", | 774 | "%lx\n %s %s and %s %s\n", |
775 | (unsigned long) htonl(cb->ipx_source_net), | 775 | (unsigned long) ntohl(cb->ipx_source_net), |
776 | ipx_device_name(i), | 776 | ipx_device_name(i), |
777 | ipx_frame_name(i->if_dlink_type), | 777 | ipx_frame_name(i->if_dlink_type), |
778 | ipx_device_name(intrfc), | 778 | ipx_device_name(intrfc), |
@@ -812,7 +812,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) | |||
812 | int i, rc = -EINVAL; | 812 | int i, rc = -EINVAL; |
813 | struct ipx_interface *ifcs; | 813 | struct ipx_interface *ifcs; |
814 | char *c; | 814 | char *c; |
815 | u32 *l; | 815 | __be32 *l; |
816 | 816 | ||
817 | /* Illegal packet - too many hops or too short */ | 817 | /* Illegal packet - too many hops or too short */ |
818 | /* We decide to throw it away: no broadcasting, no local processing. | 818 | /* We decide to throw it away: no broadcasting, no local processing. |
@@ -833,7 +833,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) | |||
833 | goto out; | 833 | goto out; |
834 | 834 | ||
835 | c = ((u8 *) ipx) + sizeof(struct ipxhdr); | 835 | c = ((u8 *) ipx) + sizeof(struct ipxhdr); |
836 | l = (u32 *) c; | 836 | l = (__be32 *) c; |
837 | 837 | ||
838 | /* Don't broadcast packet if already seen this net */ | 838 | /* Don't broadcast packet if already seen this net */ |
839 | for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) | 839 | for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) |
@@ -855,7 +855,7 @@ static int ipxitf_pprop(struct ipx_interface *intrfc, struct sk_buff *skb) | |||
855 | /* That aren't in the list */ | 855 | /* That aren't in the list */ |
856 | if (ifcs == intrfc) | 856 | if (ifcs == intrfc) |
857 | continue; | 857 | continue; |
858 | l = (__u32 *) c; | 858 | l = (__be32 *) c; |
859 | /* don't consider the last entry in the packet list, | 859 | /* don't consider the last entry in the packet list, |
860 | * it is our netnum, and it is not there yet */ | 860 | * it is our netnum, and it is not there yet */ |
861 | for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) | 861 | for (i = 0; i < IPX_SKB_CB(skb)->ipx_tctrl; i++) |
@@ -885,8 +885,8 @@ static void ipxitf_insert(struct ipx_interface *intrfc) | |||
885 | ipx_primary_net = intrfc; | 885 | ipx_primary_net = intrfc; |
886 | } | 886 | } |
887 | 887 | ||
888 | static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __u32 netnum, | 888 | static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __be32 netnum, |
889 | unsigned short dlink_type, | 889 | __be16 dlink_type, |
890 | struct datalink_proto *dlink, | 890 | struct datalink_proto *dlink, |
891 | unsigned char internal, | 891 | unsigned char internal, |
892 | int ipx_offset) | 892 | int ipx_offset) |
@@ -960,7 +960,7 @@ static __be16 ipx_map_frame_type(unsigned char type) | |||
960 | static int ipxitf_create(struct ipx_interface_definition *idef) | 960 | static int ipxitf_create(struct ipx_interface_definition *idef) |
961 | { | 961 | { |
962 | struct net_device *dev; | 962 | struct net_device *dev; |
963 | unsigned short dlink_type = 0; | 963 | __be16 dlink_type = 0; |
964 | struct datalink_proto *datalink = NULL; | 964 | struct datalink_proto *datalink = NULL; |
965 | struct ipx_interface *intrfc; | 965 | struct ipx_interface *intrfc; |
966 | int rc; | 966 | int rc; |
@@ -1073,7 +1073,7 @@ out: | |||
1073 | static int ipxitf_delete(struct ipx_interface_definition *idef) | 1073 | static int ipxitf_delete(struct ipx_interface_definition *idef) |
1074 | { | 1074 | { |
1075 | struct net_device *dev = NULL; | 1075 | struct net_device *dev = NULL; |
1076 | unsigned short dlink_type = 0; | 1076 | __be16 dlink_type = 0; |
1077 | struct ipx_interface *intrfc; | 1077 | struct ipx_interface *intrfc; |
1078 | int rc = 0; | 1078 | int rc = 0; |
1079 | 1079 | ||
@@ -1110,7 +1110,7 @@ out: | |||
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, | 1112 | static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, |
1113 | unsigned short dlink_type) | 1113 | __be16 dlink_type) |
1114 | { | 1114 | { |
1115 | struct ipx_interface *intrfc = NULL; | 1115 | struct ipx_interface *intrfc = NULL; |
1116 | struct datalink_proto *datalink; | 1116 | struct datalink_proto *datalink; |
@@ -1122,7 +1122,7 @@ static struct ipx_interface *ipxitf_auto_create(struct net_device *dev, | |||
1122 | if (dev->addr_len > IPX_NODE_LEN) | 1122 | if (dev->addr_len > IPX_NODE_LEN) |
1123 | goto out; | 1123 | goto out; |
1124 | 1124 | ||
1125 | switch (htons(dlink_type)) { | 1125 | switch (ntohs(dlink_type)) { |
1126 | case ETH_P_IPX: datalink = pEII_datalink; break; | 1126 | case ETH_P_IPX: datalink = pEII_datalink; break; |
1127 | case ETH_P_802_2: datalink = p8022_datalink; break; | 1127 | case ETH_P_802_2: datalink = p8022_datalink; break; |
1128 | case ETH_P_SNAP: datalink = pSNAP_datalink; break; | 1128 | case ETH_P_SNAP: datalink = pSNAP_datalink; break; |
@@ -1234,27 +1234,27 @@ static int ipxitf_ioctl(unsigned int cmd, void __user *arg) | |||
1234 | /* Note: We assume ipx_tctrl==0 and htons(length)==ipx_pktsize */ | 1234 | /* Note: We assume ipx_tctrl==0 and htons(length)==ipx_pktsize */ |
1235 | /* This functions should *not* mess with packet contents */ | 1235 | /* This functions should *not* mess with packet contents */ |
1236 | 1236 | ||
1237 | __u16 ipx_cksum(struct ipxhdr *packet, int length) | 1237 | __be16 ipx_cksum(struct ipxhdr *packet, int length) |
1238 | { | 1238 | { |
1239 | /* | 1239 | /* |
1240 | * NOTE: sum is a net byte order quantity, which optimizes the | 1240 | * NOTE: sum is a net byte order quantity, which optimizes the |
1241 | * loop. This only works on big and little endian machines. (I | 1241 | * loop. This only works on big and little endian machines. (I |
1242 | * don't know of a machine that isn't.) | 1242 | * don't know of a machine that isn't.) |
1243 | */ | 1243 | */ |
1244 | /* start at ipx_dest - We skip the checksum field and start with | 1244 | /* handle the first 3 words separately; checksum should be skipped |
1245 | * ipx_type before the loop, not considering ipx_tctrl in the calc */ | 1245 | * and ipx_tctrl masked out */ |
1246 | __u16 *p = (__u16 *)&packet->ipx_dest; | 1246 | __u16 *p = (__u16 *)packet; |
1247 | __u32 i = (length >> 1) - 1; /* Number of complete words */ | 1247 | __u32 sum = p[1] + (p[2] & (__force u16)htons(0x00ff)); |
1248 | __u32 sum = packet->ipx_type << sizeof(packet->ipx_tctrl); | 1248 | __u32 i = (length >> 1) - 3; /* Number of remaining complete words */ |
1249 | 1249 | ||
1250 | /* Loop through all complete words except the checksum field, | 1250 | /* Loop through them */ |
1251 | * ipx_type (accounted above) and ipx_tctrl (not used in the cksum) */ | 1251 | p += 3; |
1252 | while (--i) | 1252 | while (i--) |
1253 | sum += *p++; | 1253 | sum += *p++; |
1254 | 1254 | ||
1255 | /* Add on the last part word if it exists */ | 1255 | /* Add on the last part word if it exists */ |
1256 | if (packet->ipx_pktsize & htons(1)) | 1256 | if (packet->ipx_pktsize & htons(1)) |
1257 | sum += ntohs(0xff00) & *p; | 1257 | sum += (__force u16)htons(0xff00) & *p; |
1258 | 1258 | ||
1259 | /* Do final fixup */ | 1259 | /* Do final fixup */ |
1260 | sum = (sum & 0xffff) + (sum >> 16); | 1260 | sum = (sum & 0xffff) + (sum >> 16); |
@@ -1263,10 +1263,17 @@ __u16 ipx_cksum(struct ipxhdr *packet, int length) | |||
1263 | if (sum >= 0x10000) | 1263 | if (sum >= 0x10000) |
1264 | sum++; | 1264 | sum++; |
1265 | 1265 | ||
1266 | return ~sum; | 1266 | /* |
1267 | * Leave 0 alone; we don't want 0xffff here. Note that we can't get | ||
1268 | * here with 0x10000, so this check is the same as ((__u16)sum) | ||
1269 | */ | ||
1270 | if (sum) | ||
1271 | sum = ~sum; | ||
1272 | |||
1273 | return (__force __be16)sum; | ||
1267 | } | 1274 | } |
1268 | 1275 | ||
1269 | const char *ipx_frame_name(unsigned short frame) | 1276 | const char *ipx_frame_name(__be16 frame) |
1270 | { | 1277 | { |
1271 | char* rc = "None"; | 1278 | char* rc = "None"; |
1272 | 1279 | ||
@@ -1401,7 +1408,7 @@ out: | |||
1401 | 1408 | ||
1402 | /* caller must hold a reference to intrfc */ | 1409 | /* caller must hold a reference to intrfc */ |
1403 | 1410 | ||
1404 | static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc) | 1411 | static __be16 ipx_first_free_socketnum(struct ipx_interface *intrfc) |
1405 | { | 1412 | { |
1406 | unsigned short socketNum = intrfc->if_sknum; | 1413 | unsigned short socketNum = intrfc->if_sknum; |
1407 | 1414 | ||
@@ -1410,7 +1417,7 @@ static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc) | |||
1410 | if (socketNum < IPX_MIN_EPHEMERAL_SOCKET) | 1417 | if (socketNum < IPX_MIN_EPHEMERAL_SOCKET) |
1411 | socketNum = IPX_MIN_EPHEMERAL_SOCKET; | 1418 | socketNum = IPX_MIN_EPHEMERAL_SOCKET; |
1412 | 1419 | ||
1413 | while (__ipxitf_find_socket(intrfc, ntohs(socketNum))) | 1420 | while (__ipxitf_find_socket(intrfc, htons(socketNum))) |
1414 | if (socketNum > IPX_MAX_EPHEMERAL_SOCKET) | 1421 | if (socketNum > IPX_MAX_EPHEMERAL_SOCKET) |
1415 | socketNum = IPX_MIN_EPHEMERAL_SOCKET; | 1422 | socketNum = IPX_MIN_EPHEMERAL_SOCKET; |
1416 | else | 1423 | else |
@@ -1419,7 +1426,7 @@ static unsigned short ipx_first_free_socketnum(struct ipx_interface *intrfc) | |||
1419 | spin_unlock_bh(&intrfc->if_sklist_lock); | 1426 | spin_unlock_bh(&intrfc->if_sklist_lock); |
1420 | intrfc->if_sknum = socketNum; | 1427 | intrfc->if_sknum = socketNum; |
1421 | 1428 | ||
1422 | return ntohs(socketNum); | 1429 | return htons(socketNum); |
1423 | } | 1430 | } |
1424 | 1431 | ||
1425 | static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | 1432 | static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
@@ -1473,7 +1480,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
1473 | ipxs->port)) { | 1480 | ipxs->port)) { |
1474 | SOCK_DEBUG(sk, | 1481 | SOCK_DEBUG(sk, |
1475 | "IPX: bind failed because port %X in use.\n", | 1482 | "IPX: bind failed because port %X in use.\n", |
1476 | ntohs((int)addr->sipx_port)); | 1483 | ntohs(addr->sipx_port)); |
1477 | goto out_put; | 1484 | goto out_put; |
1478 | } | 1485 | } |
1479 | } else { | 1486 | } else { |
@@ -1488,7 +1495,7 @@ static int ipx_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
1488 | if (ipxitf_find_socket(intrfc, addr->sipx_port)) { | 1495 | if (ipxitf_find_socket(intrfc, addr->sipx_port)) { |
1489 | SOCK_DEBUG(sk, | 1496 | SOCK_DEBUG(sk, |
1490 | "IPX: bind failed because port %X in use.\n", | 1497 | "IPX: bind failed because port %X in use.\n", |
1491 | ntohs((int)addr->sipx_port)); | 1498 | ntohs(addr->sipx_port)); |
1492 | goto out_put; | 1499 | goto out_put; |
1493 | } | 1500 | } |
1494 | } | 1501 | } |
@@ -1665,7 +1672,7 @@ static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty | |||
1665 | intrfc = ipxitf_find_using_phys(dev, pt->type); | 1672 | intrfc = ipxitf_find_using_phys(dev, pt->type); |
1666 | if (!intrfc) { | 1673 | if (!intrfc) { |
1667 | if (ipxcfg_auto_create_interfaces && | 1674 | if (ipxcfg_auto_create_interfaces && |
1668 | ntohl(IPX_SKB_CB(skb)->ipx_dest_net)) { | 1675 | IPX_SKB_CB(skb)->ipx_dest_net) { |
1669 | intrfc = ipxitf_auto_create(dev, pt->type); | 1676 | intrfc = ipxitf_auto_create(dev, pt->type); |
1670 | if (intrfc) | 1677 | if (intrfc) |
1671 | ipxitf_hold(intrfc); | 1678 | ipxitf_hold(intrfc); |