Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Perches and committed by
David S. Miller
4a9e4b09 4e985ada

+258 -258
+73 -73
net/appletalk/aarp.c
··· 779 779 } 780 780 781 781 switch (function) { 782 - case AARP_REPLY: 783 - if (!unresolved_count) /* Speed up */ 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 - 791 - /* We can fill one in - this is good. */ 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); 782 + case AARP_REPLY: 783 + if (!unresolved_count) /* Speed up */ 797 784 break; 798 785 799 - case AARP_REQUEST: 800 - case AARP_PROBE: 786 + /* Find the entry. */ 787 + a = __aarp_find_entry(unresolved[hash], dev, &sa); 788 + if (!a || dev != a->dev) 789 + break; 790 + 791 + /* We can fill one in - this is good. */ 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 + } 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); 801 836 802 837 /* 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. 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. 812 842 */ 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; 843 + if (a) { 844 + a->expires_at = jiffies - 1; 845 + mod_timer(&aarp_timer, jiffies + 846 + sysctl_aarp_tick_time); 825 847 } 848 + } 826 849 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 - } 849 - 850 - if (sa.s_node != ma->s_node) 851 - break; 852 - 853 - if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) 854 - break; 855 - 856 - sa.s_node = ea->pa_src_node; 857 - sa.s_net = ea->pa_src_net; 858 - 859 - /* aarp_my_address has found the address to use for us. 860 - */ 861 - aarp_send_reply(dev, ma, &sa, ea->hw_src); 850 + if (sa.s_node != ma->s_node) 862 851 break; 852 + 853 + if (sa.s_net && ma->s_net && sa.s_net != ma->s_net) 854 + break; 855 + 856 + sa.s_node = ea->pa_src_node; 857 + sa.s_net = ea->pa_src_net; 858 + 859 + /* aarp_my_address has found the address to use for us. 860 + */ 861 + aarp_send_reply(dev, ma, &sa, ea->hw_src); 862 + break; 863 863 } 864 864 865 865 unlock:
+185 -185
net/appletalk/ddp.c
··· 684 684 atif = atalk_find_dev(dev); 685 685 686 686 switch (cmd) { 687 - case SIOCSIFADDR: 688 - if (!capable(CAP_NET_ADMIN)) 689 - return -EPERM; 690 - if (sa->sat_family != AF_APPLETALK) 691 - return -EINVAL; 692 - if (dev->type != ARPHRD_ETHER && 693 - dev->type != ARPHRD_LOOPBACK && 694 - dev->type != ARPHRD_LOCALTLK && 695 - dev->type != ARPHRD_PPP) 696 - return -EPROTONOSUPPORT; 687 + case SIOCSIFADDR: 688 + if (!capable(CAP_NET_ADMIN)) 689 + return -EPERM; 690 + if (sa->sat_family != AF_APPLETALK) 691 + return -EINVAL; 692 + if (dev->type != ARPHRD_ETHER && 693 + dev->type != ARPHRD_LOOPBACK && 694 + dev->type != ARPHRD_LOCALTLK && 695 + dev->type != ARPHRD_PPP) 696 + return -EPROTONOSUPPORT; 697 697 698 - nr = (struct atalk_netrange *)&sa->sat_zero[0]; 699 - add_route = 1; 698 + nr = (struct atalk_netrange *)&sa->sat_zero[0]; 699 + add_route = 1; 700 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 - } 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 714 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; 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 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 - 787 - case SIOCGIFADDR: 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 734 if (!atif) 789 - return -EADDRNOTAVAIL; 735 + return -ENOMEM; 736 + } 737 + atif->nets = *nr; 790 738 791 - sa->sat_family = AF_APPLETALK; 792 - sa->sat_addr = atif->address; 793 - break; 739 + /* 740 + * Check if the chosen address is used. If so we 741 + * error and atalkd will try another. 742 + */ 794 743 795 - case SIOCGIFBRDADDR: 796 - if (!atif) 797 - return -EADDRNOTAVAIL; 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 + } 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 767 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) 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"); 809 775 return -EINVAL; 810 - atalk_dev_down(dev); 811 - break; 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; 812 786 813 - case SIOCSARP: 814 - if (!capable(CAP_NET_ADMIN)) 815 - return -EPERM; 816 - if (sa->sat_family != AF_APPLETALK) 817 - return -EINVAL; 818 - /* 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; 787 + case SIOCGIFADDR: 788 + if (!atif) 789 + return -EADDRNOTAVAIL; 824 790 825 - /* 826 - * atif points to the current interface on this network; 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; 791 + sa->sat_family = AF_APPLETALK; 792 + sa->sat_addr = atif->address; 793 + break; 834 794 835 - nr = (struct atalk_netrange *)&(atif->nets); 836 - /* 837 - * Phase 1 is fine on Localtalk but we don't do 838 - * Ethertalk phase 1. Anyone wanting to add it go ahead. 839 - */ 840 - if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 841 - return -EPROTONOSUPPORT; 795 + case SIOCGIFBRDADDR: 796 + if (!atif) 797 + return -EADDRNOTAVAIL; 842 798 843 - if (sa->sat_addr.s_node == ATADDR_BCAST || 844 - sa->sat_addr.s_node == 254) 845 - return -EINVAL; 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; 846 803 847 - /* 848 - * Check if the chosen address is used. If so we 849 - * error and ATCP will try another. 850 - */ 851 - if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) 852 - return -EADDRINUSE; 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; 853 812 854 - /* 855 - * We now have an address on the local network, and 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; 813 + case SIOCSARP: 814 + if (!capable(CAP_NET_ADMIN)) 815 + return -EPERM; 816 + if (sa->sat_family != AF_APPLETALK) 817 + return -EINVAL; 818 + /* 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; 861 824 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; 825 + /* 826 + * atif points to the current interface on this network; 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; 869 834 870 - /* give to aarp module to remove proxy entry */ 871 - aarp_proxy_remove(atif->dev, &(sa->sat_addr)); 872 - return 0; 835 + nr = (struct atalk_netrange *)&(atif->nets); 836 + /* 837 + * Phase 1 is fine on Localtalk but we don't do 838 + * Ethertalk phase 1. Anyone wanting to add it go ahead. 839 + */ 840 + if (dev->type == ARPHRD_ETHER && nr->nr_phase != 2) 841 + return -EPROTONOSUPPORT; 842 + 843 + if (sa->sat_addr.s_node == ATADDR_BCAST || 844 + sa->sat_addr.s_node == 254) 845 + return -EINVAL; 846 + 847 + /* 848 + * Check if the chosen address is used. If so we 849 + * error and ATCP will try another. 850 + */ 851 + if (atif_proxy_probe_device(atif, &(sa->sat_addr)) < 0) 852 + return -EADDRINUSE; 853 + 854 + /* 855 + * We now have an address on the local network, and 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 875 return copy_to_user(arg, &atreq, sizeof(atreq)) ? -EFAULT : 0; ··· 884 884 return -EFAULT; 885 885 886 886 switch (cmd) { 887 - case SIOCDELRT: 888 - if (rt.rt_dst.sa_family != AF_APPLETALK) 889 - return -EINVAL; 890 - return atrtr_delete(&((struct sockaddr_at *) 891 - &rt.rt_dst)->sat_addr); 887 + case SIOCDELRT: 888 + if (rt.rt_dst.sa_family != AF_APPLETALK) 889 + return -EINVAL; 890 + return atrtr_delete(&((struct sockaddr_at *) 891 + &rt.rt_dst)->sat_addr); 892 892 893 - case SIOCADDRT: { 894 - struct net_device *dev = NULL; 895 - if (rt.rt_dev) { 896 - char name[IFNAMSIZ]; 897 - if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) 898 - return -EFAULT; 899 - name[IFNAMSIZ-1] = '\0'; 900 - dev = __dev_get_by_name(&init_net, name); 901 - if (!dev) 902 - return -ENODEV; 903 - } 904 - return atrtr_create(&rt, dev); 893 + case SIOCADDRT: { 894 + struct net_device *dev = NULL; 895 + if (rt.rt_dev) { 896 + char name[IFNAMSIZ]; 897 + if (copy_from_user(name, rt.rt_dev, IFNAMSIZ-1)) 898 + return -EFAULT; 899 + name[IFNAMSIZ-1] = '\0'; 900 + dev = __dev_get_by_name(&init_net, name); 901 + if (!dev) 902 + return -ENODEV; 905 903 } 904 + return atrtr_create(&rt, dev); 905 + } 906 906 } 907 907 return -EINVAL; 908 908 }