aboutsummaryrefslogtreecommitdiffstats
path: root/net/appletalk
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-07-01 05:43:02 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-01 19:11:15 -0400
commit4a9e4b09326baa6db30ae35e3521bf5259b238f5 (patch)
tree4f7bf882d15ccc515de67c83e4fcae561e1ca80b /net/appletalk
parent4e985adaa504c1c1a05c8e013777ea0791a17b4d (diff)
appletalk: Reduce switch/case indent
Make the case labels the same indent as the switch. (git diff -w net/appletalk shows no difference) Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/appletalk')
-rw-r--r--net/appletalk/aarp.c138
-rw-r--r--net/appletalk/ddp.c380
2 files changed, 259 insertions, 259 deletions
diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c
index 50dce7981321..1acc69576df8 100644
--- a/net/appletalk/aarp.c
+++ b/net/appletalk/aarp.c
@@ -779,87 +779,87 @@ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev,
779 } 779 }
780 780
781 switch (function) { 781 switch (function) {
782 case AARP_REPLY: 782 case AARP_REPLY:
783 if (!unresolved_count) /* Speed up */ 783 if (!unresolved_count) /* Speed up */
784 break; 784 break;
785
786 /* Find the entry. */
787 a = __aarp_find_entry(unresolved[hash], dev, &sa);
788 if (!a || dev != a->dev)
789 break;
790 785
791 /* We can fill one in - this is good. */ 786 /* Find the entry. */
792 memcpy(a->hwaddr, ea->hw_src, ETH_ALEN); 787 a = __aarp_find_entry(unresolved[hash], dev, &sa);
793 __aarp_resolved(&unresolved[hash], a, hash); 788 if (!a || dev != a->dev)
794 if (!unresolved_count)
795 mod_timer(&aarp_timer,
796 jiffies + sysctl_aarp_expiry_time);
797 break; 789 break;
798 790
799 case AARP_REQUEST: 791 /* We can fill one in - this is good. */
800 case AARP_PROBE: 792 memcpy(a->hwaddr, ea->hw_src, ETH_ALEN);
793 __aarp_resolved(&unresolved[hash], a, hash);
794 if (!unresolved_count)
795 mod_timer(&aarp_timer,
796 jiffies + sysctl_aarp_expiry_time);
797 break;
798
799 case AARP_REQUEST:
800 case AARP_PROBE:
801
802 /*
803 * If it is my address set ma to my address and reply.
804 * We can treat probe and request the same. Probe
805 * simply means we shouldn't cache the querying host,
806 * as in a probe they are proposing an address not
807 * using one.
808 *
809 * Support for proxy-AARP added. We check if the
810 * address is one of our proxies before we toss the
811 * packet out.
812 */
813
814 sa.s_node = ea->pa_dst_node;
815 sa.s_net = ea->pa_dst_net;
816
817 /* See if we have a matching proxy. */
818 ma = __aarp_proxy_find(dev, &sa);
819 if (!ma)
820 ma = &ifa->address;
821 else { /* We need to make a copy of the entry. */
822 da.s_node = sa.s_node;
823 da.s_net = sa.s_net;
824 ma = &da;
825 }
801 826
827 if (function == AARP_PROBE) {
802 /* 828 /*
803 * If it is my address set ma to my address and reply. 829 * A probe implies someone trying to get an
804 * We can treat probe and request the same. Probe 830 * address. So as a precaution flush any
805 * simply means we shouldn't cache the querying host, 831 * entries we have for this address.
806 * as in a probe they are proposing an address not
807 * using one.
808 *
809 * Support for proxy-AARP added. We check if the
810 * address is one of our proxies before we toss the
811 * packet out.
812 */ 832 */
833 a = __aarp_find_entry(resolved[sa.s_node %
834 (AARP_HASH_SIZE - 1)],
835 skb->dev, &sa);
813 836
814 sa.s_node = ea->pa_dst_node; 837 /*
815 sa.s_net = ea->pa_dst_net; 838 * Make it expire next tick - that avoids us
816 839 * getting into a probe/flush/learn/probe/
817 /* See if we have a matching proxy. */ 840 * flush/learn cycle during probing of a slow
818 ma = __aarp_proxy_find(dev, &sa); 841 * to respond host addr.
819 if (!ma) 842 */
820 ma = &ifa->address; 843 if (a) {
821 else { /* We need to make a copy of the entry. */ 844 a->expires_at = jiffies - 1;
822 da.s_node = sa.s_node; 845 mod_timer(&aarp_timer, jiffies +
823 da.s_net = sa.s_net; 846 sysctl_aarp_tick_time);
824 ma = &da;
825 }
826
827 if (function == AARP_PROBE) {
828 /*
829 * A probe implies someone trying to get an
830 * address. So as a precaution flush any
831 * entries we have for this address.
832 */
833 a = __aarp_find_entry(resolved[sa.s_node %
834 (AARP_HASH_SIZE - 1)],
835 skb->dev, &sa);
836
837 /*
838 * Make it expire next tick - that avoids us
839 * getting into a probe/flush/learn/probe/
840 * flush/learn cycle during probing of a slow
841 * to respond host addr.
842 */
843 if (a) {
844 a->expires_at = jiffies - 1;
845 mod_timer(&aarp_timer, jiffies +
846 sysctl_aarp_tick_time);
847 }
848 } 847 }
848 }
849 849
850 if (sa.s_node != ma->s_node) 850 if (sa.s_node != ma->s_node)
851 break; 851 break;
852 852
853 if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) 853 if (sa.s_net && ma->s_net && sa.s_net != ma->s_net)
854 break; 854 break;
855 855
856 sa.s_node = ea->pa_src_node; 856 sa.s_node = ea->pa_src_node;
857 sa.s_net = ea->pa_src_net; 857 sa.s_net = ea->pa_src_net;
858 858
859 /* aarp_my_address has found the address to use for us. 859 /* aarp_my_address has found the address to use for us.
860 */ 860 */
861 aarp_send_reply(dev, ma, &sa, ea->hw_src); 861 aarp_send_reply(dev, ma, &sa, ea->hw_src);
862 break; 862 break;
863 } 863 }
864 864
865unlock: 865unlock:
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 956a5302002a..b1fe7c35e8d1 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -684,192 +684,192 @@ static int atif_ioctl(int cmd, void __user *arg)
684 atif = atalk_find_dev(dev); 684 atif = atalk_find_dev(dev);
685 685
686 switch (cmd) { 686 switch (cmd) {
687 case SIOCSIFADDR: 687 case SIOCSIFADDR:
688 if (!capable(CAP_NET_ADMIN)) 688 if (!capable(CAP_NET_ADMIN))
689 return -EPERM; 689 return -EPERM;
690 if (sa->sat_family != AF_APPLETALK) 690 if (sa->sat_family != AF_APPLETALK)
691 return -EINVAL; 691 return -EINVAL;
692 if (dev->type != ARPHRD_ETHER && 692 if (dev->type != ARPHRD_ETHER &&
693 dev->type != ARPHRD_LOOPBACK && 693 dev->type != ARPHRD_LOOPBACK &&
694 dev->type != ARPHRD_LOCALTLK && 694 dev->type != ARPHRD_LOCALTLK &&
695 dev->type != ARPHRD_PPP) 695 dev->type != ARPHRD_PPP)
696 return -EPROTONOSUPPORT; 696 return -EPROTONOSUPPORT;
697 697
698 nr = (struct atalk_netrange *)&sa->sat_zero[0]; 698 nr = (struct atalk_netrange *)&sa->sat_zero[0];
699 add_route = 1; 699 add_route = 1;
700
701 /*
702 * if this is a point-to-point iface, and we already
703 * have an iface for this AppleTalk address, then we
704 * should not add a route
705 */
706 if ((dev->flags & IFF_POINTOPOINT) &&
707 atalk_find_interface(sa->sat_addr.s_net,
708 sa->sat_addr.s_node)) {
709 printk(KERN_DEBUG "AppleTalk: point-to-point "
710 "interface added with "
711 "existing address\n");
712 add_route = 0;
713 }
714 700
715 /* 701 /*
716 * Phase 1 is fine on LocalTalk but we don't do 702 * if this is a point-to-point iface, and we already
717 * EtherTalk phase 1. Anyone wanting to add it go ahead. 703 * have an iface for this AppleTalk address, then we
718 */ 704 * should not add a route
719 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 705 */
720 return -EPROTONOSUPPORT; 706 if ((dev->flags & IFF_POINTOPOINT) &&
721 if (sa->sat_addr.s_node == ATADDR_BCAST || 707 atalk_find_interface(sa->sat_addr.s_net,
722 sa->sat_addr.s_node == 254) 708 sa->sat_addr.s_node)) {
723 return -EINVAL; 709 printk(KERN_DEBUG "AppleTalk: point-to-point "
724 if (atif) { 710 "interface added with "
725 /* Already setting address */ 711 "existing address\n");
726 if (atif->status & ATIF_PROBE) 712 add_route = 0;
727 return -EBUSY; 713 }
728
729 atif->address.s_net = sa->sat_addr.s_net;
730 atif->address.s_node = sa->sat_addr.s_node;
731 atrtr_device_down(dev); /* Flush old routes */
732 } else {
733 atif = atif_add_device(dev, &sa->sat_addr);
734 if (!atif)
735 return -ENOMEM;
736 }
737 atif->nets = *nr;
738
739 /*
740 * Check if the chosen address is used. If so we
741 * error and atalkd will try another.
742 */
743
744 if (!(dev->flags & IFF_LOOPBACK) &&
745 !(dev->flags & IFF_POINTOPOINT) &&
746 atif_probe_device(atif) < 0) {
747 atif_drop_device(dev);
748 return -EADDRINUSE;
749 }
750
751 /* Hey it worked - add the direct routes */
752 sa = (struct sockaddr_at *)&rtdef.rt_gateway;
753 sa->sat_family = AF_APPLETALK;
754 sa->sat_addr.s_net = atif->address.s_net;
755 sa->sat_addr.s_node = atif->address.s_node;
756 sa = (struct sockaddr_at *)&rtdef.rt_dst;
757 rtdef.rt_flags = RTF_UP;
758 sa->sat_family = AF_APPLETALK;
759 sa->sat_addr.s_node = ATADDR_ANYNODE;
760 if (dev->flags & IFF_LOOPBACK ||
761 dev->flags & IFF_POINTOPOINT)
762 rtdef.rt_flags |= RTF_HOST;
763
764 /* Routerless initial state */
765 if (nr->nr_firstnet == htons(0) &&
766 nr->nr_lastnet == htons(0xFFFE)) {
767 sa->sat_addr.s_net = atif->address.s_net;
768 atrtr_create(&rtdef, dev);
769 atrtr_set_default(dev);
770 } else {
771 limit = ntohs(nr->nr_lastnet);
772 if (limit - ntohs(nr->nr_firstnet) > 4096) {
773 printk(KERN_WARNING "Too many routes/"
774 "iface.\n");
775 return -EINVAL;
776 }
777 if (add_route)
778 for (ct = ntohs(nr->nr_firstnet);
779 ct <= limit; ct++) {
780 sa->sat_addr.s_net = htons(ct);
781 atrtr_create(&rtdef, dev);
782 }
783 }
784 dev_mc_add_global(dev, aarp_mcast);
785 return 0;
786 714
787 case SIOCGIFADDR: 715 /*
716 * Phase 1 is fine on LocalTalk but we don't do
717 * EtherTalk phase 1. Anyone wanting to add it go ahead.
718 */
719 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
720 return -EPROTONOSUPPORT;
721 if (sa->sat_addr.s_node == ATADDR_BCAST ||
722 sa->sat_addr.s_node == 254)
723 return -EINVAL;
724 if (atif) {
725 /* Already setting address */
726 if (atif->status & ATIF_PROBE)
727 return -EBUSY;
728
729 atif->address.s_net = sa->sat_addr.s_net;
730 atif->address.s_node = sa->sat_addr.s_node;
731 atrtr_device_down(dev); /* Flush old routes */
732 } else {
733 atif = atif_add_device(dev, &sa->sat_addr);
788 if (!atif) 734 if (!atif)
789 return -EADDRNOTAVAIL; 735 return -ENOMEM;
736 }
737 atif->nets = *nr;
790 738
791 sa->sat_family = AF_APPLETALK; 739 /*
792 sa->sat_addr = atif->address; 740 * Check if the chosen address is used. If so we
793 break; 741 * error and atalkd will try another.
742 */
794 743
795 case SIOCGIFBRDADDR: 744 if (!(dev->flags & IFF_LOOPBACK) &&
796 if (!atif) 745 !(dev->flags & IFF_POINTOPOINT) &&
797 return -EADDRNOTAVAIL; 746 atif_probe_device(atif) < 0) {
747 atif_drop_device(dev);
748 return -EADDRINUSE;
749 }
798 750
799 sa->sat_family = AF_APPLETALK; 751 /* Hey it worked - add the direct routes */
752 sa = (struct sockaddr_at *)&rtdef.rt_gateway;
753 sa->sat_family = AF_APPLETALK;
754 sa->sat_addr.s_net = atif->address.s_net;
755 sa->sat_addr.s_node = atif->address.s_node;
756 sa = (struct sockaddr_at *)&rtdef.rt_dst;
757 rtdef.rt_flags = RTF_UP;
758 sa->sat_family = AF_APPLETALK;
759 sa->sat_addr.s_node = ATADDR_ANYNODE;
760 if (dev->flags & IFF_LOOPBACK ||
761 dev->flags & IFF_POINTOPOINT)
762 rtdef.rt_flags |= RTF_HOST;
763
764 /* Routerless initial state */
765 if (nr->nr_firstnet == htons(0) &&
766 nr->nr_lastnet == htons(0xFFFE)) {
800 sa->sat_addr.s_net = atif->address.s_net; 767 sa->sat_addr.s_net = atif->address.s_net;
801 sa->sat_addr.s_node = ATADDR_BCAST; 768 atrtr_create(&rtdef, dev);
802 break; 769 atrtr_set_default(dev);
803 770 } else {
804 case SIOCATALKDIFADDR: 771 limit = ntohs(nr->nr_lastnet);
805 case SIOCDIFADDR: 772 if (limit - ntohs(nr->nr_firstnet) > 4096) {
806 if (!capable(CAP_NET_ADMIN)) 773 printk(KERN_WARNING "Too many routes/"
807 return -EPERM; 774 "iface.\n");
808 if (sa->sat_family != AF_APPLETALK)
809 return -EINVAL; 775 return -EINVAL;
810 atalk_dev_down(dev); 776 }
811 break; 777 if (add_route)
812 778 for (ct = ntohs(nr->nr_firstnet);
813 case SIOCSARP: 779 ct <= limit; ct++) {
814 if (!capable(CAP_NET_ADMIN)) 780 sa->sat_addr.s_net = htons(ct);
815 return -EPERM; 781 atrtr_create(&rtdef, dev);
816 if (sa->sat_family != AF_APPLETALK) 782 }
817 return -EINVAL; 783 }
818 /* 784 dev_mc_add_global(dev, aarp_mcast);
819 * for now, we only support proxy AARP on ELAP; 785 return 0;
820 * we should be able to do it for LocalTalk, too. 786
821 */ 787 case SIOCGIFADDR:
822 if (dev->type != ARPHRD_ETHER) 788 if (!atif)
823 return -EPROTONOSUPPORT; 789 return -EADDRNOTAVAIL;
824 790
825 /* 791 sa->sat_family = AF_APPLETALK;
826 * atif points to the current interface on this network; 792 sa->sat_addr = atif->address;
827 * we aren't concerned about its current status (at 793 break;
828 * least for now), but it has all the settings about 794
829 * the network we're going to probe. Consequently, it 795 case SIOCGIFBRDADDR:
830 * must exist. 796 if (!atif)
831 */ 797 return -EADDRNOTAVAIL;
832 if (!atif) 798
833 return -EADDRNOTAVAIL; 799 sa->sat_family = AF_APPLETALK;
800 sa->sat_addr.s_net = atif->address.s_net;
801 sa->sat_addr.s_node = ATADDR_BCAST;
802 break;
803
804 case SIOCATALKDIFADDR:
805 case SIOCDIFADDR:
806 if (!capable(CAP_NET_ADMIN))
807 return -EPERM;
808 if (sa->sat_family != AF_APPLETALK)
809 return -EINVAL;
810 atalk_dev_down(dev);
811 break;
834 812
835 nr = (struct atalk_netrange *)&(atif->nets); 813 case SIOCSARP:
836 /* 814 if (!capable(CAP_NET_ADMIN))
837 * Phase 1 is fine on Localtalk but we don't do 815 return -EPERM;
838 * Ethertalk phase 1. Anyone wanting to add it go ahead. 816 if (sa->sat_family != AF_APPLETALK)
839 */ 817 return -EINVAL;
840 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 818 /*
841 return -EPROTONOSUPPORT; 819 * for now, we only support proxy AARP on ELAP;
820 * we should be able to do it for LocalTalk, too.
821 */
822 if (dev->type != ARPHRD_ETHER)
823 return -EPROTONOSUPPORT;
842 824
843 if (sa->sat_addr.s_node == ATADDR_BCAST || 825 /*
844 sa->sat_addr.s_node == 254) 826 * atif points to the current interface on this network;
845 return -EINVAL; 827 * we aren't concerned about its current status (at
828 * least for now), but it has all the settings about
829 * the network we're going to probe. Consequently, it
830 * must exist.
831 */
832 if (!atif)
833 return -EADDRNOTAVAIL;
846 834
847 /* 835 nr = (struct atalk_netrange *)&(atif->nets);
848 * Check if the chosen address is used. If so we 836 /*
849 * error and ATCP will try another. 837 * Phase 1 is fine on Localtalk but we don't do
850 */ 838 * Ethertalk phase 1. Anyone wanting to add it go ahead.
851 if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) 839 */
852 return -EADDRINUSE; 840 if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2)
841 return -EPROTONOSUPPORT;
853 842
854 /* 843 if (sa->sat_addr.s_node == ATADDR_BCAST ||
855 * We now have an address on the local network, and 844 sa->sat_addr.s_node == 254)
856 * the AARP code will defend it for us until we take it 845 return -EINVAL;
857 * down. We don't set up any routes right now, because
858 * ATCP will install them manually via SIOCADDRT.
859 */
860 break;
861 846
862 case SIOCDARP: 847 /*
863 if (!capable(CAP_NET_ADMIN)) 848 * Check if the chosen address is used. If so we
864 return -EPERM; 849 * error and ATCP will try another.
865 if (sa->sat_family != AF_APPLETALK) 850 */
866 return -EINVAL; 851 if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0)
867 if (!atif) 852 return -EADDRINUSE;
868 return -EADDRNOTAVAIL;
869 853
870 /* give to aarp module to remove proxy entry */ 854 /*
871 aarp_proxy_remove(atif->dev, &(sa->sat_addr)); 855 * We now have an address on the local network, and
872 return 0; 856 * the AARP code will defend it for us until we take it
857 * down. We don't set up any routes right now, because
858 * ATCP will install them manually via SIOCADDRT.
859 */
860 break;
861
862 case SIOCDARP:
863 if (!capable(CAP_NET_ADMIN))
864 return -EPERM;
865 if (sa->sat_family != AF_APPLETALK)
866 return -EINVAL;
867 if (!atif)
868 return -EADDRNOTAVAIL;
869
870 /* give to aarp module to remove proxy entry */
871 aarp_proxy_remove(atif->dev, &(sa->sat_addr));
872 return 0;
873 } 873 }
874 874
875 return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0; 875 return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0;
@@ -884,25 +884,25 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
884 return -EFAULT; 884 return -EFAULT;
885 885
886 switch (cmd) { 886 switch (cmd) {
887 case SIOCDELRT: 887 case SIOCDELRT:
888 if (rt.rt_dst.sa_family != AF_APPLETALK) 888 if (rt.rt_dst.sa_family != AF_APPLETALK)
889 return -EINVAL; 889 return -EINVAL;
890 return atrtr_delete(&((struct sockaddr_at *) 890 return atrtr_delete(&((struct sockaddr_at *)
891 &rt.rt_dst)->sat_addr); 891 &rt.rt_dst)->sat_addr);
892 892
893 case SIOCADDRT: { 893 case SIOCADDRT: {
894 struct net_device *dev = NULL; 894 struct net_device *dev = NULL;
895 if (rt.rt_dev) { 895 if (rt.rt_dev) {
896 char name[IFNAMSIZ]; 896 char name[IFNAMSIZ];
897 if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) 897 if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1))
898 return -EFAULT; 898 return -EFAULT;
899 name[IFNAMSIZ-1] = '\0'; 899 name[IFNAMSIZ-1] = '\0';
900 dev = __dev_get_by_name(&init_net, name); 900 dev = __dev_get_by_name(&init_net, name);
901 if (!dev) 901 if (!dev)
902 return -ENODEV; 902 return -ENODEV;
903 }
904 return atrtr_create(&rt, dev);
905 } 903 }
904 return atrtr_create(&rt, dev);
905 }
906 } 906 }
907 return -EINVAL; 907 return -EINVAL;
908} 908}