aboutsummaryrefslogtreecommitdiffstats
path: root/net/appletalk
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-09-19 00:06:59 -0400
committerLen Brown <len.brown@intel.com>2009-09-19 00:06:59 -0400
commit71fd68e7d234f6b7d8407c8f486764d24f8411f4 (patch)
tree6dc2a4c356b4f454fc85d0c7cb019986f6f4993b /net/appletalk
parent8ff0e082f0833d32c7523a6cd72b6cf6a2142ce8 (diff)
parent78f28b7c555359c67c2a0d23f7436e915329421e (diff)
Merge branch 'linus' into release
Diffstat (limited to 'net/appletalk')
-rw-r--r--net/appletalk/aarp.c16
-rw-r--r--net/appletalk/ddp.c70
2 files changed, 48 insertions, 38 deletions
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 89f99d3beb6..9d4adfd2275 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -599,7 +599,7 @@ int aarp_send_ddp(struct net_device *dev, struct sk_buff *skb,
599 599
600 /* Non ELAP we cannot do. */ 600 /* Non ELAP we cannot do. */
601 if (dev->type != ARPHRD_ETHER) 601 if (dev->type != ARPHRD_ETHER)
602 return -1; 602 goto free_it;
603 603
604 skb->dev = dev; 604 skb->dev = dev;
605 skb->protocol = htons(ETH_P_ATALK); 605 skb->protocol = htons(ETH_P_ATALK);
@@ -634,7 +634,7 @@ int aarp_send_ddp(struct net_device *dev, struct sk_buff *skb,
634 if (!a) { 634 if (!a) {
635 /* Whoops slipped... good job it's an unreliable protocol 8) */ 635 /* Whoops slipped... good job it's an unreliable protocol 8) */
636 write_unlock_bh(&aarp_lock); 636 write_unlock_bh(&aarp_lock);
637 return -1; 637 goto free_it;
638 } 638 }
639 639
640 /* Set up the queue */ 640 /* Set up the queue */
@@ -663,15 +663,21 @@ out_unlock:
663 write_unlock_bh(&aarp_lock); 663 write_unlock_bh(&aarp_lock);
664 664
665 /* Tell the ddp layer we have taken over for this frame. */ 665 /* Tell the ddp layer we have taken over for this frame. */
666 return 0; 666 goto sent;
667 667
668sendit: 668sendit:
669 if (skb->sk) 669 if (skb->sk)
670 skb->priority = skb->sk->sk_priority; 670 skb->priority = skb->sk->sk_priority;
671 dev_queue_xmit(skb); 671 if (dev_queue_xmit(skb))
672 goto drop;
672sent: 673sent:
673 return 1; 674 return NET_XMIT_SUCCESS;
675free_it:
676 kfree_skb(skb);
677drop:
678 return NET_XMIT_DROP;
674} 679}
680EXPORT_SYMBOL(aarp_send_ddp);
675 681
676/* 682/*
677 * An entry in the aarp unresolved queue has become resolved. Send 683 * An entry in the aarp unresolved queue has become resolved. Send
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 875eda5dbad..b1a4290996b 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1270,8 +1270,10 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
1270 struct net_device_stats *stats; 1270 struct net_device_stats *stats;
1271 1271
1272 /* This needs to be able to handle ipddp"N" devices */ 1272 /* This needs to be able to handle ipddp"N" devices */
1273 if (!dev) 1273 if (!dev) {
1274 return -ENODEV; 1274 kfree_skb(skb);
1275 return NET_RX_DROP;
1276 }
1275 1277
1276 skb->protocol = htons(ETH_P_IP); 1278 skb->protocol = htons(ETH_P_IP);
1277 skb_pull(skb, 13); 1279 skb_pull(skb, 13);
@@ -1281,8 +1283,7 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
1281 stats = netdev_priv(dev); 1283 stats = netdev_priv(dev);
1282 stats->rx_packets++; 1284 stats->rx_packets++;
1283 stats->rx_bytes += skb->len + 13; 1285 stats->rx_bytes += skb->len + 13;
1284 netif_rx(skb); /* Send the SKB up to a higher place. */ 1286 return netif_rx(skb); /* Send the SKB up to a higher place. */
1285 return 0;
1286} 1287}
1287#else 1288#else
1288/* make it easy for gcc to optimize this test out, i.e. kill the code */ 1289/* make it easy for gcc to optimize this test out, i.e. kill the code */
@@ -1290,9 +1291,8 @@ static int handle_ip_over_ddp(struct sk_buff *skb)
1290#define handle_ip_over_ddp(skb) 0 1291#define handle_ip_over_ddp(skb) 0
1291#endif 1292#endif
1292 1293
1293static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev, 1294static int atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1294 struct ddpehdr *ddp, __u16 len_hops, 1295 struct ddpehdr *ddp, __u16 len_hops, int origlen)
1295 int origlen)
1296{ 1296{
1297 struct atalk_route *rt; 1297 struct atalk_route *rt;
1298 struct atalk_addr ta; 1298 struct atalk_addr ta;
@@ -1359,8 +1359,6 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1359 /* 22 bytes - 12 ether, 2 len, 3 802.2 5 snap */ 1359 /* 22 bytes - 12 ether, 2 len, 3 802.2 5 snap */
1360 struct sk_buff *nskb = skb_realloc_headroom(skb, 32); 1360 struct sk_buff *nskb = skb_realloc_headroom(skb, 32);
1361 kfree_skb(skb); 1361 kfree_skb(skb);
1362 if (!nskb)
1363 goto out;
1364 skb = nskb; 1362 skb = nskb;
1365 } else 1363 } else
1366 skb = skb_unshare(skb, GFP_ATOMIC); 1364 skb = skb_unshare(skb, GFP_ATOMIC);
@@ -1369,12 +1367,16 @@ static void atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1369 * If the buffer didn't vanish into the lack of space bitbucket we can 1367 * If the buffer didn't vanish into the lack of space bitbucket we can
1370 * send it. 1368 * send it.
1371 */ 1369 */
1372 if (skb && aarp_send_ddp(rt->dev, skb, &ta, NULL) == -1) 1370 if (skb == NULL)
1373 goto free_it; 1371 goto drop;
1374out: 1372
1375 return; 1373 if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP)
1374 return NET_RX_DROP;
1375 return NET_RX_SUCCESS;
1376free_it: 1376free_it:
1377 kfree_skb(skb); 1377 kfree_skb(skb);
1378drop:
1379 return NET_RX_DROP;
1378} 1380}
1379 1381
1380/** 1382/**
@@ -1400,7 +1402,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1400 __u16 len_hops; 1402 __u16 len_hops;
1401 1403
1402 if (!net_eq(dev_net(dev), &init_net)) 1404 if (!net_eq(dev_net(dev), &init_net))
1403 goto freeit; 1405 goto drop;
1404 1406
1405 /* Don't mangle buffer if shared */ 1407 /* Don't mangle buffer if shared */
1406 if (!(skb = skb_share_check(skb, GFP_ATOMIC))) 1408 if (!(skb = skb_share_check(skb, GFP_ATOMIC)))
@@ -1408,7 +1410,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1408 1410
1409 /* Size check and make sure header is contiguous */ 1411 /* Size check and make sure header is contiguous */
1410 if (!pskb_may_pull(skb, sizeof(*ddp))) 1412 if (!pskb_may_pull(skb, sizeof(*ddp)))
1411 goto freeit; 1413 goto drop;
1412 1414
1413 ddp = ddp_hdr(skb); 1415 ddp = ddp_hdr(skb);
1414 1416
@@ -1426,7 +1428,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1426 if (skb->len < sizeof(*ddp) || skb->len < (len_hops & 1023)) { 1428 if (skb->len < sizeof(*ddp) || skb->len < (len_hops & 1023)) {
1427 pr_debug("AppleTalk: dropping corrupted frame (deh_len=%u, " 1429 pr_debug("AppleTalk: dropping corrupted frame (deh_len=%u, "
1428 "skb->len=%u)\n", len_hops & 1023, skb->len); 1430 "skb->len=%u)\n", len_hops & 1023, skb->len);
1429 goto freeit; 1431 goto drop;
1430 } 1432 }
1431 1433
1432 /* 1434 /*
@@ -1436,7 +1438,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1436 if (ddp->deh_sum && 1438 if (ddp->deh_sum &&
1437 atalk_checksum(skb, len_hops & 1023) != ddp->deh_sum) 1439 atalk_checksum(skb, len_hops & 1023) != ddp->deh_sum)
1438 /* Not a valid AppleTalk frame - dustbin time */ 1440 /* Not a valid AppleTalk frame - dustbin time */
1439 goto freeit; 1441 goto drop;
1440 1442
1441 /* Check the packet is aimed at us */ 1443 /* Check the packet is aimed at us */
1442 if (!ddp->deh_dnet) /* Net 0 is 'this network' */ 1444 if (!ddp->deh_dnet) /* Net 0 is 'this network' */
@@ -1448,8 +1450,7 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1448 /* Not ours, so we route the packet via the correct 1450 /* Not ours, so we route the packet via the correct
1449 * AppleTalk iface 1451 * AppleTalk iface
1450 */ 1452 */
1451 atalk_route_packet(skb, dev, ddp, len_hops, origlen); 1453 return atalk_route_packet(skb, dev, ddp, len_hops, origlen);
1452 goto out;
1453 } 1454 }
1454 1455
1455 /* if IP over DDP is not selected this code will be optimized out */ 1456 /* if IP over DDP is not selected this code will be optimized out */
@@ -1465,18 +1466,21 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev,
1465 1466
1466 sock = atalk_search_socket(&tosat, atif); 1467 sock = atalk_search_socket(&tosat, atif);
1467 if (!sock) /* But not one of our sockets */ 1468 if (!sock) /* But not one of our sockets */
1468 goto freeit; 1469 goto drop;
1469 1470
1470 /* Queue packet (standard) */ 1471 /* Queue packet (standard) */
1471 skb->sk = sock; 1472 skb->sk = sock;
1472 1473
1473 if (sock_queue_rcv_skb(sock, skb) < 0) 1474 if (sock_queue_rcv_skb(sock, skb) < 0)
1474 goto freeit; 1475 goto drop;
1475out: 1476
1476 return 0; 1477 return NET_RX_SUCCESS;
1477freeit: 1478
1479drop:
1478 kfree_skb(skb); 1480 kfree_skb(skb);
1479 goto out; 1481out:
1482 return NET_RX_DROP;
1483
1480} 1484}
1481 1485
1482/* 1486/*
@@ -1652,10 +1656,10 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1652 if (skb2) { 1656 if (skb2) {
1653 loopback = 1; 1657 loopback = 1;
1654 SOCK_DEBUG(sk, "SK %p: send out(copy).\n", sk); 1658 SOCK_DEBUG(sk, "SK %p: send out(copy).\n", sk);
1655 if (aarp_send_ddp(dev, skb2, 1659 /*
1656 &usat->sat_addr, NULL) == -1) 1660 * If it fails it is queued/sent above in the aarp queue
1657 kfree_skb(skb2); 1661 */
1658 /* else queued/sent above in the aarp queue */ 1662 aarp_send_ddp(dev, skb2, &usat->sat_addr, NULL);
1659 } 1663 }
1660 } 1664 }
1661 1665
@@ -1685,9 +1689,10 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1685 usat = &gsat; 1689 usat = &gsat;
1686 } 1690 }
1687 1691
1688 if (aarp_send_ddp(dev, skb, &usat->sat_addr, NULL) == -1) 1692 /*
1689 kfree_skb(skb); 1693 * If it fails it is queued/sent above in the aarp queue
1690 /* else queued/sent above in the aarp queue */ 1694 */
1695 aarp_send_ddp(dev, skb, &usat->sat_addr, NULL);
1691 } 1696 }
1692 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len); 1697 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len);
1693 1698
@@ -1865,7 +1870,6 @@ static struct packet_type ppptalk_packet_type __read_mostly = {
1865static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B }; 1870static unsigned char ddp_snap_id[] = { 0x08, 0x00, 0x07, 0x80, 0x9B };
1866 1871
1867/* Export symbols for use by drivers when AppleTalk is a module */ 1872/* Export symbols for use by drivers when AppleTalk is a module */
1868EXPORT_SYMBOL(aarp_send_ddp);
1869EXPORT_SYMBOL(atrtr_get_dev); 1873EXPORT_SYMBOL(atrtr_get_dev);
1870EXPORT_SYMBOL(atalk_find_dev_addr); 1874EXPORT_SYMBOL(atalk_find_dev_addr);
1871 1875