diff options
Diffstat (limited to 'Documentation/networking')
-rw-r--r-- | Documentation/networking/00-INDEX | 4 | ||||
-rw-r--r-- | Documentation/networking/bonding.txt | 204 | ||||
-rw-r--r-- | Documentation/networking/can.txt | 629 | ||||
-rw-r--r-- | Documentation/networking/dccp.txt | 39 | ||||
-rw-r--r-- | Documentation/networking/ip-sysctl.txt | 27 | ||||
-rw-r--r-- | Documentation/networking/shaper.txt | 48 | ||||
-rw-r--r-- | Documentation/networking/udplite.txt | 2 | ||||
-rw-r--r-- | Documentation/networking/xfrm_proc.txt | 70 |
8 files changed, 904 insertions, 119 deletions
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX index 563e442f2d42..02e56d447a8f 100644 --- a/Documentation/networking/00-INDEX +++ b/Documentation/networking/00-INDEX | |||
@@ -24,6 +24,8 @@ baycom.txt | |||
24 | - info on the driver for Baycom style amateur radio modems | 24 | - info on the driver for Baycom style amateur radio modems |
25 | bridge.txt | 25 | bridge.txt |
26 | - where to get user space programs for ethernet bridging with Linux. | 26 | - where to get user space programs for ethernet bridging with Linux. |
27 | can.txt | ||
28 | - documentation on CAN protocol family. | ||
27 | cops.txt | 29 | cops.txt |
28 | - info on the COPS LocalTalk Linux driver | 30 | - info on the COPS LocalTalk Linux driver |
29 | cs89x0.txt | 31 | cs89x0.txt |
@@ -82,8 +84,6 @@ policy-routing.txt | |||
82 | - IP policy-based routing | 84 | - IP policy-based routing |
83 | ray_cs.txt | 85 | ray_cs.txt |
84 | - Raylink Wireless LAN card driver info. | 86 | - Raylink Wireless LAN card driver info. |
85 | shaper.txt | ||
86 | - info on the module that can shape/limit transmitted traffic. | ||
87 | sk98lin.txt | 87 | sk98lin.txt |
88 | - Marvell Yukon Chipset / SysKonnect SK-98xx compliant Gigabit | 88 | - Marvell Yukon Chipset / SysKonnect SK-98xx compliant Gigabit |
89 | Ethernet Adapter family driver info | 89 | Ethernet Adapter family driver info |
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt index 6cc30e0d5795..a0cda062bc33 100644 --- a/Documentation/networking/bonding.txt +++ b/Documentation/networking/bonding.txt | |||
@@ -1,7 +1,7 @@ | |||
1 | 1 | ||
2 | Linux Ethernet Bonding Driver HOWTO | 2 | Linux Ethernet Bonding Driver HOWTO |
3 | 3 | ||
4 | Latest update: 24 April 2006 | 4 | Latest update: 12 November 2007 |
5 | 5 | ||
6 | Initial release : Thomas Davis <tadavis at lbl.gov> | 6 | Initial release : Thomas Davis <tadavis at lbl.gov> |
7 | Corrections, HA extensions : 2000/10/03-15 : | 7 | Corrections, HA extensions : 2000/10/03-15 : |
@@ -166,12 +166,17 @@ to use ifenslave. | |||
166 | 2. Bonding Driver Options | 166 | 2. Bonding Driver Options |
167 | ========================= | 167 | ========================= |
168 | 168 | ||
169 | Options for the bonding driver are supplied as parameters to | 169 | Options for the bonding driver are supplied as parameters to the |
170 | the bonding module at load time. They may be given as command line | 170 | bonding module at load time, or are specified via sysfs. |
171 | arguments to the insmod or modprobe command, but are usually specified | 171 | |
172 | in either the /etc/modules.conf or /etc/modprobe.conf configuration | 172 | Module options may be given as command line arguments to the |
173 | file, or in a distro-specific configuration file (some of which are | 173 | insmod or modprobe command, but are usually specified in either the |
174 | detailed in the next section). | 174 | /etc/modules.conf or /etc/modprobe.conf configuration file, or in a |
175 | distro-specific configuration file (some of which are detailed in the next | ||
176 | section). | ||
177 | |||
178 | Details on bonding support for sysfs is provided in the | ||
179 | "Configuring Bonding Manually via Sysfs" section, below. | ||
175 | 180 | ||
176 | The available bonding driver parameters are listed below. If a | 181 | The available bonding driver parameters are listed below. If a |
177 | parameter is not specified the default value is used. When initially | 182 | parameter is not specified the default value is used. When initially |
@@ -812,11 +817,13 @@ the system /etc/modules.conf or /etc/modprobe.conf configuration file. | |||
812 | 3.2 Configuration with Initscripts Support | 817 | 3.2 Configuration with Initscripts Support |
813 | ------------------------------------------ | 818 | ------------------------------------------ |
814 | 819 | ||
815 | This section applies to distros using a version of initscripts | 820 | This section applies to distros using a recent version of |
816 | with bonding support, for example, Red Hat Linux 9 or Red Hat | 821 | initscripts with bonding support, for example, Red Hat Enterprise Linux |
817 | Enterprise Linux version 3 or 4. On these systems, the network | 822 | version 3 or later, Fedora, etc. On these systems, the network |
818 | initialization scripts have some knowledge of bonding, and can be | 823 | initialization scripts have knowledge of bonding, and can be configured to |
819 | configured to control bonding devices. | 824 | control bonding devices. Note that older versions of the initscripts |
825 | package have lower levels of support for bonding; this will be noted where | ||
826 | applicable. | ||
820 | 827 | ||
821 | These distros will not automatically load the network adapter | 828 | These distros will not automatically load the network adapter |
822 | driver unless the ethX device is configured with an IP address. | 829 | driver unless the ethX device is configured with an IP address. |
@@ -864,11 +871,31 @@ USERCTL=no | |||
864 | Be sure to change the networking specific lines (IPADDR, | 871 | Be sure to change the networking specific lines (IPADDR, |
865 | NETMASK, NETWORK and BROADCAST) to match your network configuration. | 872 | NETMASK, NETWORK and BROADCAST) to match your network configuration. |
866 | 873 | ||
867 | Finally, it is necessary to edit /etc/modules.conf (or | 874 | For later versions of initscripts, such as that found with Fedora |
868 | /etc/modprobe.conf, depending upon your distro) to load the bonding | 875 | 7 and Red Hat Enterprise Linux version 5 (or later), it is possible, and, |
869 | module with your desired options when the bond0 interface is brought | 876 | indeed, preferable, to specify the bonding options in the ifcfg-bond0 |
870 | up. The following lines in /etc/modules.conf (or modprobe.conf) will | 877 | file, e.g. a line of the format: |
871 | load the bonding module, and select its options: | 878 | |
879 | BONDING_OPTS="mode=active-backup arp_interval=60 arp_ip_target=+192.168.1.254" | ||
880 | |||
881 | will configure the bond with the specified options. The options | ||
882 | specified in BONDING_OPTS are identical to the bonding module parameters | ||
883 | except for the arp_ip_target field. Each target should be included as a | ||
884 | separate option and should be preceded by a '+' to indicate it should be | ||
885 | added to the list of queried targets, e.g., | ||
886 | |||
887 | arp_ip_target=+192.168.1.1 arp_ip_target=+192.168.1.2 | ||
888 | |||
889 | is the proper syntax to specify multiple targets. When specifying | ||
890 | options via BONDING_OPTS, it is not necessary to edit /etc/modules.conf or | ||
891 | /etc/modprobe.conf. | ||
892 | |||
893 | For older versions of initscripts that do not support | ||
894 | BONDING_OPTS, it is necessary to edit /etc/modules.conf (or | ||
895 | /etc/modprobe.conf, depending upon your distro) to load the bonding module | ||
896 | with your desired options when the bond0 interface is brought up. The | ||
897 | following lines in /etc/modules.conf (or modprobe.conf) will load the | ||
898 | bonding module, and select its options: | ||
872 | 899 | ||
873 | alias bond0 bonding | 900 | alias bond0 bonding |
874 | options bond0 mode=balance-alb miimon=100 | 901 | options bond0 mode=balance-alb miimon=100 |
@@ -883,9 +910,10 @@ up and running. | |||
883 | 3.2.1 Using DHCP with Initscripts | 910 | 3.2.1 Using DHCP with Initscripts |
884 | --------------------------------- | 911 | --------------------------------- |
885 | 912 | ||
886 | Recent versions of initscripts (the version supplied with | 913 | Recent versions of initscripts (the versions supplied with Fedora |
887 | Fedora Core 3 and Red Hat Enterprise Linux 4 is reported to work) do | 914 | Core 3 and Red Hat Enterprise Linux 4, or later versions, are reported to |
888 | have support for assigning IP information to bonding devices via DHCP. | 915 | work) have support for assigning IP information to bonding devices via |
916 | DHCP. | ||
889 | 917 | ||
890 | To configure bonding for DHCP, configure it as described | 918 | To configure bonding for DHCP, configure it as described |
891 | above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp" | 919 | above, except replace the line "BOOTPROTO=none" with "BOOTPROTO=dhcp" |
@@ -895,18 +923,14 @@ is case sensitive. | |||
895 | 3.2.2 Configuring Multiple Bonds with Initscripts | 923 | 3.2.2 Configuring Multiple Bonds with Initscripts |
896 | ------------------------------------------------- | 924 | ------------------------------------------------- |
897 | 925 | ||
898 | At this writing, the initscripts package does not directly | 926 | Initscripts packages that are included with Fedora 7 and Red Hat |
899 | support loading the bonding driver multiple times, so the process for | 927 | Enterprise Linux 5 support multiple bonding interfaces by simply |
900 | doing so is the same as described in the "Configuring Multiple Bonds | 928 | specifying the appropriate BONDING_OPTS= in ifcfg-bondX where X is the |
901 | Manually" section, below. | 929 | number of the bond. This support requires sysfs support in the kernel, |
902 | 930 | and a bonding driver of version 3.0.0 or later. Other configurations may | |
903 | NOTE: It has been observed that some Red Hat supplied kernels | 931 | not support this method for specifying multiple bonding interfaces; for |
904 | are apparently unable to rename modules at load time (the "-o bond1" | 932 | those instances, see the "Configuring Multiple Bonds Manually" section, |
905 | part). Attempts to pass that option to modprobe will produce an | 933 | below. |
906 | "Operation not permitted" error. This has been reported on some | ||
907 | Fedora Core kernels, and has been seen on RHEL 4 as well. On kernels | ||
908 | exhibiting this problem, it will be impossible to configure multiple | ||
909 | bonds with differing parameters. | ||
910 | 934 | ||
911 | 3.3 Configuring Bonding Manually with Ifenslave | 935 | 3.3 Configuring Bonding Manually with Ifenslave |
912 | ----------------------------------------------- | 936 | ----------------------------------------------- |
@@ -977,15 +1001,58 @@ initialization scripts lack support for configuring multiple bonds. | |||
977 | options, you may wish to use the "max_bonds" module parameter, | 1001 | options, you may wish to use the "max_bonds" module parameter, |
978 | documented above. | 1002 | documented above. |
979 | 1003 | ||
980 | To create multiple bonding devices with differing options, it | 1004 | To create multiple bonding devices with differing options, it is |
981 | is necessary to use bonding parameters exported by sysfs, documented | 1005 | preferrable to use bonding parameters exported by sysfs, documented in the |
982 | in the section below. | 1006 | section below. |
1007 | |||
1008 | For versions of bonding without sysfs support, the only means to | ||
1009 | provide multiple instances of bonding with differing options is to load | ||
1010 | the bonding driver multiple times. Note that current versions of the | ||
1011 | sysconfig network initialization scripts handle this automatically; if | ||
1012 | your distro uses these scripts, no special action is needed. See the | ||
1013 | section Configuring Bonding Devices, above, if you're not sure about your | ||
1014 | network initialization scripts. | ||
1015 | |||
1016 | To load multiple instances of the module, it is necessary to | ||
1017 | specify a different name for each instance (the module loading system | ||
1018 | requires that every loaded module, even multiple instances of the same | ||
1019 | module, have a unique name). This is accomplished by supplying multiple | ||
1020 | sets of bonding options in /etc/modprobe.conf, for example: | ||
1021 | |||
1022 | alias bond0 bonding | ||
1023 | options bond0 -o bond0 mode=balance-rr miimon=100 | ||
1024 | |||
1025 | alias bond1 bonding | ||
1026 | options bond1 -o bond1 mode=balance-alb miimon=50 | ||
1027 | |||
1028 | will load the bonding module two times. The first instance is | ||
1029 | named "bond0" and creates the bond0 device in balance-rr mode with an | ||
1030 | miimon of 100. The second instance is named "bond1" and creates the | ||
1031 | bond1 device in balance-alb mode with an miimon of 50. | ||
1032 | |||
1033 | In some circumstances (typically with older distributions), | ||
1034 | the above does not work, and the second bonding instance never sees | ||
1035 | its options. In that case, the second options line can be substituted | ||
1036 | as follows: | ||
1037 | |||
1038 | install bond1 /sbin/modprobe --ignore-install bonding -o bond1 \ | ||
1039 | mode=balance-alb miimon=50 | ||
983 | 1040 | ||
1041 | This may be repeated any number of times, specifying a new and | ||
1042 | unique name in place of bond1 for each subsequent instance. | ||
1043 | |||
1044 | It has been observed that some Red Hat supplied kernels are unable | ||
1045 | to rename modules at load time (the "-o bond1" part). Attempts to pass | ||
1046 | that option to modprobe will produce an "Operation not permitted" error. | ||
1047 | This has been reported on some Fedora Core kernels, and has been seen on | ||
1048 | RHEL 4 as well. On kernels exhibiting this problem, it will be impossible | ||
1049 | to configure multiple bonds with differing parameters (as they are older | ||
1050 | kernels, and also lack sysfs support). | ||
984 | 1051 | ||
985 | 3.4 Configuring Bonding Manually via Sysfs | 1052 | 3.4 Configuring Bonding Manually via Sysfs |
986 | ------------------------------------------ | 1053 | ------------------------------------------ |
987 | 1054 | ||
988 | Starting with version 3.0, Channel Bonding may be configured | 1055 | Starting with version 3.0.0, Channel Bonding may be configured |
989 | via the sysfs interface. This interface allows dynamic configuration | 1056 | via the sysfs interface. This interface allows dynamic configuration |
990 | of all bonds in the system without unloading the module. It also | 1057 | of all bonds in the system without unloading the module. It also |
991 | allows for adding and removing bonds at runtime. Ifenslave is no | 1058 | allows for adding and removing bonds at runtime. Ifenslave is no |
@@ -1030,9 +1097,6 @@ To enslave interface eth0 to bond bond0: | |||
1030 | To free slave eth0 from bond bond0: | 1097 | To free slave eth0 from bond bond0: |
1031 | # echo -eth0 > /sys/class/net/bond0/bonding/slaves | 1098 | # echo -eth0 > /sys/class/net/bond0/bonding/slaves |
1032 | 1099 | ||
1033 | NOTE: The bond must be up before slaves can be added. All | ||
1034 | slaves are freed when the interface is brought down. | ||
1035 | |||
1036 | When an interface is enslaved to a bond, symlinks between the | 1100 | When an interface is enslaved to a bond, symlinks between the |
1037 | two are created in the sysfs filesystem. In this case, you would get | 1101 | two are created in the sysfs filesystem. In this case, you would get |
1038 | /sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and | 1102 | /sys/class/net/bond0/slave_eth0 pointing to /sys/class/net/eth0, and |
@@ -1622,6 +1686,15 @@ one for each switch in the network). This will insure that, | |||
1622 | regardless of which switch is active, the ARP monitor has a suitable | 1686 | regardless of which switch is active, the ARP monitor has a suitable |
1623 | target to query. | 1687 | target to query. |
1624 | 1688 | ||
1689 | Note, also, that of late many switches now support a functionality | ||
1690 | generally referred to as "trunk failover." This is a feature of the | ||
1691 | switch that causes the link state of a particular switch port to be set | ||
1692 | down (or up) when the state of another switch port goes down (or up). | ||
1693 | It's purpose is to propogate link failures from logically "exterior" ports | ||
1694 | to the logically "interior" ports that bonding is able to monitor via | ||
1695 | miimon. Availability and configuration for trunk failover varies by | ||
1696 | switch, but this can be a viable alternative to the ARP monitor when using | ||
1697 | suitable switches. | ||
1625 | 1698 | ||
1626 | 12. Configuring Bonding for Maximum Throughput | 1699 | 12. Configuring Bonding for Maximum Throughput |
1627 | ============================================== | 1700 | ============================================== |
@@ -1709,7 +1782,7 @@ balance-rr: This mode is the only mode that will permit a single | |||
1709 | interfaces. It is therefore the only mode that will allow a | 1782 | interfaces. It is therefore the only mode that will allow a |
1710 | single TCP/IP stream to utilize more than one interface's | 1783 | single TCP/IP stream to utilize more than one interface's |
1711 | worth of throughput. This comes at a cost, however: the | 1784 | worth of throughput. This comes at a cost, however: the |
1712 | striping often results in peer systems receiving packets out | 1785 | striping generally results in peer systems receiving packets out |
1713 | of order, causing TCP/IP's congestion control system to kick | 1786 | of order, causing TCP/IP's congestion control system to kick |
1714 | in, often by retransmitting segments. | 1787 | in, often by retransmitting segments. |
1715 | 1788 | ||
@@ -1721,22 +1794,20 @@ balance-rr: This mode is the only mode that will permit a single | |||
1721 | interface's worth of throughput, even after adjusting | 1794 | interface's worth of throughput, even after adjusting |
1722 | tcp_reordering. | 1795 | tcp_reordering. |
1723 | 1796 | ||
1724 | Note that this out of order delivery occurs when both the | 1797 | Note that the fraction of packets that will be delivered out of |
1725 | sending and receiving systems are utilizing a multiple | 1798 | order is highly variable, and is unlikely to be zero. The level |
1726 | interface bond. Consider a configuration in which a | 1799 | of reordering depends upon a variety of factors, including the |
1727 | balance-rr bond feeds into a single higher capacity network | 1800 | networking interfaces, the switch, and the topology of the |
1728 | channel (e.g., multiple 100Mb/sec ethernets feeding a single | 1801 | configuration. Speaking in general terms, higher speed network |
1729 | gigabit ethernet via an etherchannel capable switch). In this | 1802 | cards produce more reordering (due to factors such as packet |
1730 | configuration, traffic sent from the multiple 100Mb devices to | 1803 | coalescing), and a "many to many" topology will reorder at a |
1731 | a destination connected to the gigabit device will not see | 1804 | higher rate than a "many slow to one fast" configuration. |
1732 | packets out of order. However, traffic sent from the gigabit | 1805 | |
1733 | device to the multiple 100Mb devices may or may not see | 1806 | Many switches do not support any modes that stripe traffic |
1734 | traffic out of order, depending upon the balance policy of the | 1807 | (instead choosing a port based upon IP or MAC level addresses); |
1735 | switch. Many switches do not support any modes that stripe | 1808 | for those devices, traffic for a particular connection flowing |
1736 | traffic (instead choosing a port based upon IP or MAC level | 1809 | through the switch to a balance-rr bond will not utilize greater |
1737 | addresses); for those devices, traffic flowing from the | 1810 | than one interface's worth of bandwidth. |
1738 | gigabit device to the many 100Mb devices will only utilize one | ||
1739 | interface. | ||
1740 | 1811 | ||
1741 | If you are utilizing protocols other than TCP/IP, UDP for | 1812 | If you are utilizing protocols other than TCP/IP, UDP for |
1742 | example, and your application can tolerate out of order | 1813 | example, and your application can tolerate out of order |
@@ -1936,6 +2007,10 @@ Failover may be delayed via the downdelay bonding module option. | |||
1936 | 13.2 Duplicated Incoming Packets | 2007 | 13.2 Duplicated Incoming Packets |
1937 | -------------------------------- | 2008 | -------------------------------- |
1938 | 2009 | ||
2010 | NOTE: Starting with version 3.0.2, the bonding driver has logic to | ||
2011 | suppress duplicate packets, which should largely eliminate this problem. | ||
2012 | The following description is kept for reference. | ||
2013 | |||
1939 | It is not uncommon to observe a short burst of duplicated | 2014 | It is not uncommon to observe a short burst of duplicated |
1940 | traffic when the bonding device is first used, or after it has been | 2015 | traffic when the bonding device is first used, or after it has been |
1941 | idle for some period of time. This is most easily observed by issuing | 2016 | idle for some period of time. This is most easily observed by issuing |
@@ -2096,6 +2171,9 @@ The new driver was designed to be SMP safe from the start. | |||
2096 | EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes, | 2171 | EtherExpress PRO/100 and a 3com 3c905b, for example). For most modes, |
2097 | devices need not be of the same speed. | 2172 | devices need not be of the same speed. |
2098 | 2173 | ||
2174 | Starting with version 3.2.1, bonding also supports Infiniband | ||
2175 | slaves in active-backup mode. | ||
2176 | |||
2099 | 3. How many bonding devices can I have? | 2177 | 3. How many bonding devices can I have? |
2100 | 2178 | ||
2101 | There is no limit. | 2179 | There is no limit. |
@@ -2154,11 +2232,15 @@ switches currently available support 802.3ad. | |||
2154 | 2232 | ||
2155 | 8. Where does a bonding device get its MAC address from? | 2233 | 8. Where does a bonding device get its MAC address from? |
2156 | 2234 | ||
2157 | If not explicitly configured (with ifconfig or ip link), the | 2235 | When using slave devices that have fixed MAC addresses, or when |
2158 | MAC address of the bonding device is taken from its first slave | 2236 | the fail_over_mac option is enabled, the bonding device's MAC address is |
2159 | device. This MAC address is then passed to all following slaves and | 2237 | the MAC address of the active slave. |
2160 | remains persistent (even if the first slave is removed) until the | 2238 | |
2161 | bonding device is brought down or reconfigured. | 2239 | For other configurations, if not explicitly configured (with |
2240 | ifconfig or ip link), the MAC address of the bonding device is taken from | ||
2241 | its first slave device. This MAC address is then passed to all following | ||
2242 | slaves and remains persistent (even if the first slave is removed) until | ||
2243 | the bonding device is brought down or reconfigured. | ||
2162 | 2244 | ||
2163 | If you wish to change the MAC address, you can set it with | 2245 | If you wish to change the MAC address, you can set it with |
2164 | ifconfig or ip link: | 2246 | ifconfig or ip link: |
diff --git a/Documentation/networking/can.txt b/Documentation/networking/can.txt new file mode 100644 index 000000000000..f1b2de170929 --- /dev/null +++ b/Documentation/networking/can.txt | |||
@@ -0,0 +1,629 @@ | |||
1 | ============================================================================ | ||
2 | |||
3 | can.txt | ||
4 | |||
5 | Readme file for the Controller Area Network Protocol Family (aka Socket CAN) | ||
6 | |||
7 | This file contains | ||
8 | |||
9 | 1 Overview / What is Socket CAN | ||
10 | |||
11 | 2 Motivation / Why using the socket API | ||
12 | |||
13 | 3 Socket CAN concept | ||
14 | 3.1 receive lists | ||
15 | 3.2 local loopback of sent frames | ||
16 | 3.3 network security issues (capabilities) | ||
17 | 3.4 network problem notifications | ||
18 | |||
19 | 4 How to use Socket CAN | ||
20 | 4.1 RAW protocol sockets with can_filters (SOCK_RAW) | ||
21 | 4.1.1 RAW socket option CAN_RAW_FILTER | ||
22 | 4.1.2 RAW socket option CAN_RAW_ERR_FILTER | ||
23 | 4.1.3 RAW socket option CAN_RAW_LOOPBACK | ||
24 | 4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS | ||
25 | 4.2 Broadcast Manager protocol sockets (SOCK_DGRAM) | ||
26 | 4.3 connected transport protocols (SOCK_SEQPACKET) | ||
27 | 4.4 unconnected transport protocols (SOCK_DGRAM) | ||
28 | |||
29 | 5 Socket CAN core module | ||
30 | 5.1 can.ko module params | ||
31 | 5.2 procfs content | ||
32 | 5.3 writing own CAN protocol modules | ||
33 | |||
34 | 6 CAN network drivers | ||
35 | 6.1 general settings | ||
36 | 6.2 local loopback of sent frames | ||
37 | 6.3 CAN controller hardware filters | ||
38 | 6.4 currently supported CAN hardware | ||
39 | 6.5 todo | ||
40 | |||
41 | 7 Credits | ||
42 | |||
43 | ============================================================================ | ||
44 | |||
45 | 1. Overview / What is Socket CAN | ||
46 | -------------------------------- | ||
47 | |||
48 | The socketcan package is an implementation of CAN protocols | ||
49 | (Controller Area Network) for Linux. CAN is a networking technology | ||
50 | which has widespread use in automation, embedded devices, and | ||
51 | automotive fields. While there have been other CAN implementations | ||
52 | for Linux based on character devices, Socket CAN uses the Berkeley | ||
53 | socket API, the Linux network stack and implements the CAN device | ||
54 | drivers as network interfaces. The CAN socket API has been designed | ||
55 | as similar as possible to the TCP/IP protocols to allow programmers, | ||
56 | familiar with network programming, to easily learn how to use CAN | ||
57 | sockets. | ||
58 | |||
59 | 2. Motivation / Why using the socket API | ||
60 | ---------------------------------------- | ||
61 | |||
62 | There have been CAN implementations for Linux before Socket CAN so the | ||
63 | question arises, why we have started another project. Most existing | ||
64 | implementations come as a device driver for some CAN hardware, they | ||
65 | are based on character devices and provide comparatively little | ||
66 | functionality. Usually, there is only a hardware-specific device | ||
67 | driver which provides a character device interface to send and | ||
68 | receive raw CAN frames, directly to/from the controller hardware. | ||
69 | Queueing of frames and higher-level transport protocols like ISO-TP | ||
70 | have to be implemented in user space applications. Also, most | ||
71 | character-device implementations support only one single process to | ||
72 | open the device at a time, similar to a serial interface. Exchanging | ||
73 | the CAN controller requires employment of another device driver and | ||
74 | often the need for adaption of large parts of the application to the | ||
75 | new driver's API. | ||
76 | |||
77 | Socket CAN was designed to overcome all of these limitations. A new | ||
78 | protocol family has been implemented which provides a socket interface | ||
79 | to user space applications and which builds upon the Linux network | ||
80 | layer, so to use all of the provided queueing functionality. A device | ||
81 | driver for CAN controller hardware registers itself with the Linux | ||
82 | network layer as a network device, so that CAN frames from the | ||
83 | controller can be passed up to the network layer and on to the CAN | ||
84 | protocol family module and also vice-versa. Also, the protocol family | ||
85 | module provides an API for transport protocol modules to register, so | ||
86 | that any number of transport protocols can be loaded or unloaded | ||
87 | dynamically. In fact, the can core module alone does not provide any | ||
88 | protocol and cannot be used without loading at least one additional | ||
89 | protocol module. Multiple sockets can be opened at the same time, | ||
90 | on different or the same protocol module and they can listen/send | ||
91 | frames on different or the same CAN IDs. Several sockets listening on | ||
92 | the same interface for frames with the same CAN ID are all passed the | ||
93 | same received matching CAN frames. An application wishing to | ||
94 | communicate using a specific transport protocol, e.g. ISO-TP, just | ||
95 | selects that protocol when opening the socket, and then can read and | ||
96 | write application data byte streams, without having to deal with | ||
97 | CAN-IDs, frames, etc. | ||
98 | |||
99 | Similar functionality visible from user-space could be provided by a | ||
100 | character device, too, but this would lead to a technically inelegant | ||
101 | solution for a couple of reasons: | ||
102 | |||
103 | * Intricate usage. Instead of passing a protocol argument to | ||
104 | socket(2) and using bind(2) to select a CAN interface and CAN ID, an | ||
105 | application would have to do all these operations using ioctl(2)s. | ||
106 | |||
107 | * Code duplication. A character device cannot make use of the Linux | ||
108 | network queueing code, so all that code would have to be duplicated | ||
109 | for CAN networking. | ||
110 | |||
111 | * Abstraction. In most existing character-device implementations, the | ||
112 | hardware-specific device driver for a CAN controller directly | ||
113 | provides the character device for the application to work with. | ||
114 | This is at least very unusual in Unix systems for both, char and | ||
115 | block devices. For example you don't have a character device for a | ||
116 | certain UART of a serial interface, a certain sound chip in your | ||
117 | computer, a SCSI or IDE controller providing access to your hard | ||
118 | disk or tape streamer device. Instead, you have abstraction layers | ||
119 | which provide a unified character or block device interface to the | ||
120 | application on the one hand, and a interface for hardware-specific | ||
121 | device drivers on the other hand. These abstractions are provided | ||
122 | by subsystems like the tty layer, the audio subsystem or the SCSI | ||
123 | and IDE subsystems for the devices mentioned above. | ||
124 | |||
125 | The easiest way to implement a CAN device driver is as a character | ||
126 | device without such a (complete) abstraction layer, as is done by most | ||
127 | existing drivers. The right way, however, would be to add such a | ||
128 | layer with all the functionality like registering for certain CAN | ||
129 | IDs, supporting several open file descriptors and (de)multiplexing | ||
130 | CAN frames between them, (sophisticated) queueing of CAN frames, and | ||
131 | providing an API for device drivers to register with. However, then | ||
132 | it would be no more difficult, or may be even easier, to use the | ||
133 | networking framework provided by the Linux kernel, and this is what | ||
134 | Socket CAN does. | ||
135 | |||
136 | The use of the networking framework of the Linux kernel is just the | ||
137 | natural and most appropriate way to implement CAN for Linux. | ||
138 | |||
139 | 3. Socket CAN concept | ||
140 | --------------------- | ||
141 | |||
142 | As described in chapter 2 it is the main goal of Socket CAN to | ||
143 | provide a socket interface to user space applications which builds | ||
144 | upon the Linux network layer. In contrast to the commonly known | ||
145 | TCP/IP and ethernet networking, the CAN bus is a broadcast-only(!) | ||
146 | medium that has no MAC-layer addressing like ethernet. The CAN-identifier | ||
147 | (can_id) is used for arbitration on the CAN-bus. Therefore the CAN-IDs | ||
148 | have to be chosen uniquely on the bus. When designing a CAN-ECU | ||
149 | network the CAN-IDs are mapped to be sent by a specific ECU. | ||
150 | For this reason a CAN-ID can be treated best as a kind of source address. | ||
151 | |||
152 | 3.1 receive lists | ||
153 | |||
154 | The network transparent access of multiple applications leads to the | ||
155 | problem that different applications may be interested in the same | ||
156 | CAN-IDs from the same CAN network interface. The Socket CAN core | ||
157 | module - which implements the protocol family CAN - provides several | ||
158 | high efficient receive lists for this reason. If e.g. a user space | ||
159 | application opens a CAN RAW socket, the raw protocol module itself | ||
160 | requests the (range of) CAN-IDs from the Socket CAN core that are | ||
161 | requested by the user. The subscription and unsubscription of | ||
162 | CAN-IDs can be done for specific CAN interfaces or for all(!) known | ||
163 | CAN interfaces with the can_rx_(un)register() functions provided to | ||
164 | CAN protocol modules by the SocketCAN core (see chapter 5). | ||
165 | To optimize the CPU usage at runtime the receive lists are split up | ||
166 | into several specific lists per device that match the requested | ||
167 | filter complexity for a given use-case. | ||
168 | |||
169 | 3.2 local loopback of sent frames | ||
170 | |||
171 | As known from other networking concepts the data exchanging | ||
172 | applications may run on the same or different nodes without any | ||
173 | change (except for the according addressing information): | ||
174 | |||
175 | ___ ___ ___ _______ ___ | ||
176 | | _ | | _ | | _ | | _ _ | | _ | | ||
177 | ||A|| ||B|| ||C|| ||A| |B|| ||C|| | ||
178 | |___| |___| |___| |_______| |___| | ||
179 | | | | | | | ||
180 | -----------------(1)- CAN bus -(2)--------------- | ||
181 | |||
182 | To ensure that application A receives the same information in the | ||
183 | example (2) as it would receive in example (1) there is need for | ||
184 | some kind of local loopback of the sent CAN frames on the appropriate | ||
185 | node. | ||
186 | |||
187 | The Linux network devices (by default) just can handle the | ||
188 | transmission and reception of media dependent frames. Due to the | ||
189 | arbritration on the CAN bus the transmission of a low prio CAN-ID | ||
190 | may be delayed by the reception of a high prio CAN frame. To | ||
191 | reflect the correct* traffic on the node the loopback of the sent | ||
192 | data has to be performed right after a successful transmission. If | ||
193 | the CAN network interface is not capable of performing the loopback for | ||
194 | some reason the SocketCAN core can do this task as a fallback solution. | ||
195 | See chapter 6.2 for details (recommended). | ||
196 | |||
197 | The loopback functionality is enabled by default to reflect standard | ||
198 | networking behaviour for CAN applications. Due to some requests from | ||
199 | the RT-SocketCAN group the loopback optionally may be disabled for each | ||
200 | separate socket. See sockopts from the CAN RAW sockets in chapter 4.1. | ||
201 | |||
202 | * = you really like to have this when you're running analyser tools | ||
203 | like 'candump' or 'cansniffer' on the (same) node. | ||
204 | |||
205 | 3.3 network security issues (capabilities) | ||
206 | |||
207 | The Controller Area Network is a local field bus transmitting only | ||
208 | broadcast messages without any routing and security concepts. | ||
209 | In the majority of cases the user application has to deal with | ||
210 | raw CAN frames. Therefore it might be reasonable NOT to restrict | ||
211 | the CAN access only to the user root, as known from other networks. | ||
212 | Since the currently implemented CAN_RAW and CAN_BCM sockets can only | ||
213 | send and receive frames to/from CAN interfaces it does not affect | ||
214 | security of others networks to allow all users to access the CAN. | ||
215 | To enable non-root users to access CAN_RAW and CAN_BCM protocol | ||
216 | sockets the Kconfig options CAN_RAW_USER and/or CAN_BCM_USER may be | ||
217 | selected at kernel compile time. | ||
218 | |||
219 | 3.4 network problem notifications | ||
220 | |||
221 | The use of the CAN bus may lead to several problems on the physical | ||
222 | and media access control layer. Detecting and logging of these lower | ||
223 | layer problems is a vital requirement for CAN users to identify | ||
224 | hardware issues on the physical transceiver layer as well as | ||
225 | arbitration problems and error frames caused by the different | ||
226 | ECUs. The occurrence of detected errors are important for diagnosis | ||
227 | and have to be logged together with the exact timestamp. For this | ||
228 | reason the CAN interface driver can generate so called Error Frames | ||
229 | that can optionally be passed to the user application in the same | ||
230 | way as other CAN frames. Whenever an error on the physical layer | ||
231 | or the MAC layer is detected (e.g. by the CAN controller) the driver | ||
232 | creates an appropriate error frame. Error frames can be requested by | ||
233 | the user application using the common CAN filter mechanisms. Inside | ||
234 | this filter definition the (interested) type of errors may be | ||
235 | selected. The reception of error frames is disabled by default. | ||
236 | |||
237 | 4. How to use Socket CAN | ||
238 | ------------------------ | ||
239 | |||
240 | Like TCP/IP, you first need to open a socket for communicating over a | ||
241 | CAN network. Since Socket CAN implements a new protocol family, you | ||
242 | need to pass PF_CAN as the first argument to the socket(2) system | ||
243 | call. Currently, there are two CAN protocols to choose from, the raw | ||
244 | socket protocol and the broadcast manager (BCM). So to open a socket, | ||
245 | you would write | ||
246 | |||
247 | s = socket(PF_CAN, SOCK_RAW, CAN_RAW); | ||
248 | |||
249 | and | ||
250 | |||
251 | s = socket(PF_CAN, SOCK_DGRAM, CAN_BCM); | ||
252 | |||
253 | respectively. After the successful creation of the socket, you would | ||
254 | normally use the bind(2) system call to bind the socket to a CAN | ||
255 | interface (which is different from TCP/IP due to different addressing | ||
256 | - see chapter 3). After binding (CAN_RAW) or connecting (CAN_BCM) | ||
257 | the socket, you can read(2) and write(2) from/to the socket or use | ||
258 | send(2), sendto(2), sendmsg(2) and the recv* counterpart operations | ||
259 | on the socket as usual. There are also CAN specific socket options | ||
260 | described below. | ||
261 | |||
262 | The basic CAN frame structure and the sockaddr structure are defined | ||
263 | in include/linux/can.h: | ||
264 | |||
265 | struct can_frame { | ||
266 | canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ | ||
267 | __u8 can_dlc; /* data length code: 0 .. 8 */ | ||
268 | __u8 data[8] __attribute__((aligned(8))); | ||
269 | }; | ||
270 | |||
271 | The alignment of the (linear) payload data[] to a 64bit boundary | ||
272 | allows the user to define own structs and unions to easily access the | ||
273 | CAN payload. There is no given byteorder on the CAN bus by | ||
274 | default. A read(2) system call on a CAN_RAW socket transfers a | ||
275 | struct can_frame to the user space. | ||
276 | |||
277 | The sockaddr_can structure has an interface index like the | ||
278 | PF_PACKET socket, that also binds to a specific interface: | ||
279 | |||
280 | struct sockaddr_can { | ||
281 | sa_family_t can_family; | ||
282 | int can_ifindex; | ||
283 | union { | ||
284 | struct { canid_t rx_id, tx_id; } tp16; | ||
285 | struct { canid_t rx_id, tx_id; } tp20; | ||
286 | struct { canid_t rx_id, tx_id; } mcnet; | ||
287 | struct { canid_t rx_id, tx_id; } isotp; | ||
288 | } can_addr; | ||
289 | }; | ||
290 | |||
291 | To determine the interface index an appropriate ioctl() has to | ||
292 | be used (example for CAN_RAW sockets without error checking): | ||
293 | |||
294 | int s; | ||
295 | struct sockaddr_can addr; | ||
296 | struct ifreq ifr; | ||
297 | |||
298 | s = socket(PF_CAN, SOCK_RAW, CAN_RAW); | ||
299 | |||
300 | strcpy(ifr.ifr_name, "can0" ); | ||
301 | ioctl(s, SIOCGIFINDEX, &ifr); | ||
302 | |||
303 | addr.can_family = AF_CAN; | ||
304 | addr.can_ifindex = ifr.ifr_ifindex; | ||
305 | |||
306 | bind(s, (struct sockaddr *)&addr, sizeof(addr)); | ||
307 | |||
308 | (..) | ||
309 | |||
310 | To bind a socket to all(!) CAN interfaces the interface index must | ||
311 | be 0 (zero). In this case the socket receives CAN frames from every | ||
312 | enabled CAN interface. To determine the originating CAN interface | ||
313 | the system call recvfrom(2) may be used instead of read(2). To send | ||
314 | on a socket that is bound to 'any' interface sendto(2) is needed to | ||
315 | specify the outgoing interface. | ||
316 | |||
317 | Reading CAN frames from a bound CAN_RAW socket (see above) consists | ||
318 | of reading a struct can_frame: | ||
319 | |||
320 | struct can_frame frame; | ||
321 | |||
322 | nbytes = read(s, &frame, sizeof(struct can_frame)); | ||
323 | |||
324 | if (nbytes < 0) { | ||
325 | perror("can raw socket read"); | ||
326 | return 1; | ||
327 | } | ||
328 | |||
329 | /* paraniod check ... */ | ||
330 | if (nbytes < sizeof(struct can_frame)) { | ||
331 | fprintf(stderr, "read: incomplete CAN frame\n"); | ||
332 | return 1; | ||
333 | } | ||
334 | |||
335 | /* do something with the received CAN frame */ | ||
336 | |||
337 | Writing CAN frames can be done similarly, with the write(2) system call: | ||
338 | |||
339 | nbytes = write(s, &frame, sizeof(struct can_frame)); | ||
340 | |||
341 | When the CAN interface is bound to 'any' existing CAN interface | ||
342 | (addr.can_ifindex = 0) it is recommended to use recvfrom(2) if the | ||
343 | information about the originating CAN interface is needed: | ||
344 | |||
345 | struct sockaddr_can addr; | ||
346 | struct ifreq ifr; | ||
347 | socklen_t len = sizeof(addr); | ||
348 | struct can_frame frame; | ||
349 | |||
350 | nbytes = recvfrom(s, &frame, sizeof(struct can_frame), | ||
351 | 0, (struct sockaddr*)&addr, &len); | ||
352 | |||
353 | /* get interface name of the received CAN frame */ | ||
354 | ifr.ifr_ifindex = addr.can_ifindex; | ||
355 | ioctl(s, SIOCGIFNAME, &ifr); | ||
356 | printf("Received a CAN frame from interface %s", ifr.ifr_name); | ||
357 | |||
358 | To write CAN frames on sockets bound to 'any' CAN interface the | ||
359 | outgoing interface has to be defined certainly. | ||
360 | |||
361 | strcpy(ifr.ifr_name, "can0"); | ||
362 | ioctl(s, SIOCGIFINDEX, &ifr); | ||
363 | addr.can_ifindex = ifr.ifr_ifindex; | ||
364 | addr.can_family = AF_CAN; | ||
365 | |||
366 | nbytes = sendto(s, &frame, sizeof(struct can_frame), | ||
367 | 0, (struct sockaddr*)&addr, sizeof(addr)); | ||
368 | |||
369 | 4.1 RAW protocol sockets with can_filters (SOCK_RAW) | ||
370 | |||
371 | Using CAN_RAW sockets is extensively comparable to the commonly | ||
372 | known access to CAN character devices. To meet the new possibilities | ||
373 | provided by the multi user SocketCAN approach, some reasonable | ||
374 | defaults are set at RAW socket binding time: | ||
375 | |||
376 | - The filters are set to exactly one filter receiving everything | ||
377 | - The socket only receives valid data frames (=> no error frames) | ||
378 | - The loopback of sent CAN frames is enabled (see chapter 3.2) | ||
379 | - The socket does not receive its own sent frames (in loopback mode) | ||
380 | |||
381 | These default settings may be changed before or after binding the socket. | ||
382 | To use the referenced definitions of the socket options for CAN_RAW | ||
383 | sockets, include <linux/can/raw.h>. | ||
384 | |||
385 | 4.1.1 RAW socket option CAN_RAW_FILTER | ||
386 | |||
387 | The reception of CAN frames using CAN_RAW sockets can be controlled | ||
388 | by defining 0 .. n filters with the CAN_RAW_FILTER socket option. | ||
389 | |||
390 | The CAN filter structure is defined in include/linux/can.h: | ||
391 | |||
392 | struct can_filter { | ||
393 | canid_t can_id; | ||
394 | canid_t can_mask; | ||
395 | }; | ||
396 | |||
397 | A filter matches, when | ||
398 | |||
399 | <received_can_id> & mask == can_id & mask | ||
400 | |||
401 | which is analogous to known CAN controllers hardware filter semantics. | ||
402 | The filter can be inverted in this semantic, when the CAN_INV_FILTER | ||
403 | bit is set in can_id element of the can_filter structure. In | ||
404 | contrast to CAN controller hardware filters the user may set 0 .. n | ||
405 | receive filters for each open socket separately: | ||
406 | |||
407 | struct can_filter rfilter[2]; | ||
408 | |||
409 | rfilter[0].can_id = 0x123; | ||
410 | rfilter[0].can_mask = CAN_SFF_MASK; | ||
411 | rfilter[1].can_id = 0x200; | ||
412 | rfilter[1].can_mask = 0x700; | ||
413 | |||
414 | setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter, sizeof(rfilter)); | ||
415 | |||
416 | To disable the reception of CAN frames on the selected CAN_RAW socket: | ||
417 | |||
418 | setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0); | ||
419 | |||
420 | To set the filters to zero filters is quite obsolete as not read | ||
421 | data causes the raw socket to discard the received CAN frames. But | ||
422 | having this 'send only' use-case we may remove the receive list in the | ||
423 | Kernel to save a little (really a very little!) CPU usage. | ||
424 | |||
425 | 4.1.2 RAW socket option CAN_RAW_ERR_FILTER | ||
426 | |||
427 | As described in chapter 3.4 the CAN interface driver can generate so | ||
428 | called Error Frames that can optionally be passed to the user | ||
429 | application in the same way as other CAN frames. The possible | ||
430 | errors are divided into different error classes that may be filtered | ||
431 | using the appropriate error mask. To register for every possible | ||
432 | error condition CAN_ERR_MASK can be used as value for the error mask. | ||
433 | The values for the error mask are defined in linux/can/error.h . | ||
434 | |||
435 | can_err_mask_t err_mask = ( CAN_ERR_TX_TIMEOUT | CAN_ERR_BUSOFF ); | ||
436 | |||
437 | setsockopt(s, SOL_CAN_RAW, CAN_RAW_ERR_FILTER, | ||
438 | &err_mask, sizeof(err_mask)); | ||
439 | |||
440 | 4.1.3 RAW socket option CAN_RAW_LOOPBACK | ||
441 | |||
442 | To meet multi user needs the local loopback is enabled by default | ||
443 | (see chapter 3.2 for details). But in some embedded use-cases | ||
444 | (e.g. when only one application uses the CAN bus) this loopback | ||
445 | functionality can be disabled (separately for each socket): | ||
446 | |||
447 | int loopback = 0; /* 0 = disabled, 1 = enabled (default) */ | ||
448 | |||
449 | setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK, &loopback, sizeof(loopback)); | ||
450 | |||
451 | 4.1.4 RAW socket option CAN_RAW_RECV_OWN_MSGS | ||
452 | |||
453 | When the local loopback is enabled, all the sent CAN frames are | ||
454 | looped back to the open CAN sockets that registered for the CAN | ||
455 | frames' CAN-ID on this given interface to meet the multi user | ||
456 | needs. The reception of the CAN frames on the same socket that was | ||
457 | sending the CAN frame is assumed to be unwanted and therefore | ||
458 | disabled by default. This default behaviour may be changed on | ||
459 | demand: | ||
460 | |||
461 | int recv_own_msgs = 1; /* 0 = disabled (default), 1 = enabled */ | ||
462 | |||
463 | setsockopt(s, SOL_CAN_RAW, CAN_RAW_RECV_OWN_MSGS, | ||
464 | &recv_own_msgs, sizeof(recv_own_msgs)); | ||
465 | |||
466 | 4.2 Broadcast Manager protocol sockets (SOCK_DGRAM) | ||
467 | 4.3 connected transport protocols (SOCK_SEQPACKET) | ||
468 | 4.4 unconnected transport protocols (SOCK_DGRAM) | ||
469 | |||
470 | |||
471 | 5. Socket CAN core module | ||
472 | ------------------------- | ||
473 | |||
474 | The Socket CAN core module implements the protocol family | ||
475 | PF_CAN. CAN protocol modules are loaded by the core module at | ||
476 | runtime. The core module provides an interface for CAN protocol | ||
477 | modules to subscribe needed CAN IDs (see chapter 3.1). | ||
478 | |||
479 | 5.1 can.ko module params | ||
480 | |||
481 | - stats_timer: To calculate the Socket CAN core statistics | ||
482 | (e.g. current/maximum frames per second) this 1 second timer is | ||
483 | invoked at can.ko module start time by default. This timer can be | ||
484 | disabled by using stattimer=0 on the module comandline. | ||
485 | |||
486 | - debug: (removed since SocketCAN SVN r546) | ||
487 | |||
488 | 5.2 procfs content | ||
489 | |||
490 | As described in chapter 3.1 the Socket CAN core uses several filter | ||
491 | lists to deliver received CAN frames to CAN protocol modules. These | ||
492 | receive lists, their filters and the count of filter matches can be | ||
493 | checked in the appropriate receive list. All entries contain the | ||
494 | device and a protocol module identifier: | ||
495 | |||
496 | foo@bar:~$ cat /proc/net/can/rcvlist_all | ||
497 | |||
498 | receive list 'rx_all': | ||
499 | (vcan3: no entry) | ||
500 | (vcan2: no entry) | ||
501 | (vcan1: no entry) | ||
502 | device can_id can_mask function userdata matches ident | ||
503 | vcan0 000 00000000 f88e6370 f6c6f400 0 raw | ||
504 | (any: no entry) | ||
505 | |||
506 | In this example an application requests any CAN traffic from vcan0. | ||
507 | |||
508 | rcvlist_all - list for unfiltered entries (no filter operations) | ||
509 | rcvlist_eff - list for single extended frame (EFF) entries | ||
510 | rcvlist_err - list for error frames masks | ||
511 | rcvlist_fil - list for mask/value filters | ||
512 | rcvlist_inv - list for mask/value filters (inverse semantic) | ||
513 | rcvlist_sff - list for single standard frame (SFF) entries | ||
514 | |||
515 | Additional procfs files in /proc/net/can | ||
516 | |||
517 | stats - Socket CAN core statistics (rx/tx frames, match ratios, ...) | ||
518 | reset_stats - manual statistic reset | ||
519 | version - prints the Socket CAN core version and the ABI version | ||
520 | |||
521 | 5.3 writing own CAN protocol modules | ||
522 | |||
523 | To implement a new protocol in the protocol family PF_CAN a new | ||
524 | protocol has to be defined in include/linux/can.h . | ||
525 | The prototypes and definitions to use the Socket CAN core can be | ||
526 | accessed by including include/linux/can/core.h . | ||
527 | In addition to functions that register the CAN protocol and the | ||
528 | CAN device notifier chain there are functions to subscribe CAN | ||
529 | frames received by CAN interfaces and to send CAN frames: | ||
530 | |||
531 | can_rx_register - subscribe CAN frames from a specific interface | ||
532 | can_rx_unregister - unsubscribe CAN frames from a specific interface | ||
533 | can_send - transmit a CAN frame (optional with local loopback) | ||
534 | |||
535 | For details see the kerneldoc documentation in net/can/af_can.c or | ||
536 | the source code of net/can/raw.c or net/can/bcm.c . | ||
537 | |||
538 | 6. CAN network drivers | ||
539 | ---------------------- | ||
540 | |||
541 | Writing a CAN network device driver is much easier than writing a | ||
542 | CAN character device driver. Similar to other known network device | ||
543 | drivers you mainly have to deal with: | ||
544 | |||
545 | - TX: Put the CAN frame from the socket buffer to the CAN controller. | ||
546 | - RX: Put the CAN frame from the CAN controller to the socket buffer. | ||
547 | |||
548 | See e.g. at Documentation/networking/netdevices.txt . The differences | ||
549 | for writing CAN network device driver are described below: | ||
550 | |||
551 | 6.1 general settings | ||
552 | |||
553 | dev->type = ARPHRD_CAN; /* the netdevice hardware type */ | ||
554 | dev->flags = IFF_NOARP; /* CAN has no arp */ | ||
555 | |||
556 | dev->mtu = sizeof(struct can_frame); | ||
557 | |||
558 | The struct can_frame is the payload of each socket buffer in the | ||
559 | protocol family PF_CAN. | ||
560 | |||
561 | 6.2 local loopback of sent frames | ||
562 | |||
563 | As described in chapter 3.2 the CAN network device driver should | ||
564 | support a local loopback functionality similar to the local echo | ||
565 | e.g. of tty devices. In this case the driver flag IFF_ECHO has to be | ||
566 | set to prevent the PF_CAN core from locally echoing sent frames | ||
567 | (aka loopback) as fallback solution: | ||
568 | |||
569 | dev->flags = (IFF_NOARP | IFF_ECHO); | ||
570 | |||
571 | 6.3 CAN controller hardware filters | ||
572 | |||
573 | To reduce the interrupt load on deep embedded systems some CAN | ||
574 | controllers support the filtering of CAN IDs or ranges of CAN IDs. | ||
575 | These hardware filter capabilities vary from controller to | ||
576 | controller and have to be identified as not feasible in a multi-user | ||
577 | networking approach. The use of the very controller specific | ||
578 | hardware filters could make sense in a very dedicated use-case, as a | ||
579 | filter on driver level would affect all users in the multi-user | ||
580 | system. The high efficient filter sets inside the PF_CAN core allow | ||
581 | to set different multiple filters for each socket separately. | ||
582 | Therefore the use of hardware filters goes to the category 'handmade | ||
583 | tuning on deep embedded systems'. The author is running a MPC603e | ||
584 | @133MHz with four SJA1000 CAN controllers from 2002 under heavy bus | ||
585 | load without any problems ... | ||
586 | |||
587 | 6.4 currently supported CAN hardware (September 2007) | ||
588 | |||
589 | On the project website http://developer.berlios.de/projects/socketcan | ||
590 | there are different drivers available: | ||
591 | |||
592 | vcan: Virtual CAN interface driver (if no real hardware is available) | ||
593 | sja1000: Philips SJA1000 CAN controller (recommended) | ||
594 | i82527: Intel i82527 CAN controller | ||
595 | mscan: Motorola/Freescale CAN controller (e.g. inside SOC MPC5200) | ||
596 | ccan: CCAN controller core (e.g. inside SOC h7202) | ||
597 | slcan: For a bunch of CAN adaptors that are attached via a | ||
598 | serial line ASCII protocol (for serial / USB adaptors) | ||
599 | |||
600 | Additionally the different CAN adaptors (ISA/PCI/PCMCIA/USB/Parport) | ||
601 | from PEAK Systemtechnik support the CAN netdevice driver model | ||
602 | since Linux driver v6.0: http://www.peak-system.com/linux/index.htm | ||
603 | |||
604 | Please check the Mailing Lists on the berlios OSS project website. | ||
605 | |||
606 | 6.5 todo (September 2007) | ||
607 | |||
608 | The configuration interface for CAN network drivers is still an open | ||
609 | issue that has not been finalized in the socketcan project. Also the | ||
610 | idea of having a library module (candev.ko) that holds functions | ||
611 | that are needed by all CAN netdevices is not ready to ship. | ||
612 | Your contribution is welcome. | ||
613 | |||
614 | 7. Credits | ||
615 | ---------- | ||
616 | |||
617 | Oliver Hartkopp (PF_CAN core, filters, drivers, bcm) | ||
618 | Urs Thuermann (PF_CAN core, kernel integration, socket interfaces, raw, vcan) | ||
619 | Jan Kizka (RT-SocketCAN core, Socket-API reconciliation) | ||
620 | Wolfgang Grandegger (RT-SocketCAN core & drivers, Raw Socket-API reviews) | ||
621 | Robert Schwebel (design reviews, PTXdist integration) | ||
622 | Marc Kleine-Budde (design reviews, Kernel 2.6 cleanups, drivers) | ||
623 | Benedikt Spranger (reviews) | ||
624 | Thomas Gleixner (LKML reviews, coding style, posting hints) | ||
625 | Andrey Volkov (kernel subtree structure, ioctls, mscan driver) | ||
626 | Matthias Brukner (first SJA1000 CAN netdevice implementation Q2/2003) | ||
627 | Klaus Hitschler (PEAK driver integration) | ||
628 | Uwe Koppe (CAN netdevices with PF_PACKET approach) | ||
629 | Michael Schulze (driver layer loopback requirement, RT CAN drivers review) | ||
diff --git a/Documentation/networking/dccp.txt b/Documentation/networking/dccp.txt index afb66f9a8aff..39131a3c78f8 100644 --- a/Documentation/networking/dccp.txt +++ b/Documentation/networking/dccp.txt | |||
@@ -14,24 +14,35 @@ Introduction | |||
14 | ============ | 14 | ============ |
15 | 15 | ||
16 | Datagram Congestion Control Protocol (DCCP) is an unreliable, connection | 16 | Datagram Congestion Control Protocol (DCCP) is an unreliable, connection |
17 | based protocol designed to solve issues present in UDP and TCP particularly | 17 | oriented protocol designed to solve issues present in UDP and TCP, particularly |
18 | for real time and multimedia traffic. | 18 | for real-time and multimedia (streaming) traffic. |
19 | It divides into a base protocol (RFC 4340) and plugable congestion control | ||
20 | modules called CCIDs. Like plugable TCP congestion control, at least one CCID | ||
21 | needs to be enabled in order for the protocol to function properly. In the Linux | ||
22 | implementation, this is the TCP-like CCID2 (RFC 4341). Additional CCIDs, such as | ||
23 | the TCP-friendly CCID3 (RFC 4342), are optional. | ||
24 | For a brief introduction to CCIDs and suggestions for choosing a CCID to match | ||
25 | given applications, see section 10 of RFC 4340. | ||
19 | 26 | ||
20 | It has a base protocol and pluggable congestion control IDs (CCIDs). | 27 | It has a base protocol and pluggable congestion control IDs (CCIDs). |
21 | 28 | ||
22 | It is at proposed standard RFC status and the homepage for DCCP as a protocol | 29 | DCCP is a Proposed Standard (RFC 2026), and the homepage for DCCP as a protocol |
23 | is at: | 30 | is at http://www.ietf.org/html.charters/dccp-charter.html |
24 | http://www.read.cs.ucla.edu/dccp/ | ||
25 | 31 | ||
26 | Missing features | 32 | Missing features |
27 | ================ | 33 | ================ |
28 | 34 | ||
29 | The DCCP implementation does not currently have all the features that are in | 35 | The Linux DCCP implementation does not currently support all the features that are |
30 | the RFC. | 36 | specified in RFCs 4340...42. |
31 | 37 | ||
32 | The known bugs are at: | 38 | The known bugs are at: |
33 | http://linux-net.osdl.org/index.php/TODO#DCCP | 39 | http://linux-net.osdl.org/index.php/TODO#DCCP |
34 | 40 | ||
41 | For more up-to-date versions of the DCCP implementation, please consider using | ||
42 | the experimental DCCP test tree; instructions for checking this out are on: | ||
43 | http://linux-net.osdl.org/index.php/DCCP_Testing#Experimental_DCCP_source_tree | ||
44 | |||
45 | |||
35 | Socket options | 46 | Socket options |
36 | ============== | 47 | ============== |
37 | 48 | ||
@@ -46,6 +57,12 @@ can be set before calling bind(). | |||
46 | DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet | 57 | DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet |
47 | size (application payload size) in bytes, see RFC 4340, section 14. | 58 | size (application payload size) in bytes, see RFC 4340, section 14. |
48 | 59 | ||
60 | DCCP_SOCKOPT_SERVER_TIMEWAIT enables the server (listening socket) to hold | ||
61 | timewait state when closing the connection (RFC 4340, 8.3). The usual case is | ||
62 | that the closing server sends a CloseReq, whereupon the client holds timewait | ||
63 | state. When this boolean socket option is on, the server sends a Close instead | ||
64 | and will enter TIMEWAIT. This option must be set after accept() returns. | ||
65 | |||
49 | DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the | 66 | DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the |
50 | partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums | 67 | partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums |
51 | always cover the entire packet and that only fully covered application data is | 68 | always cover the entire packet and that only fully covered application data is |
@@ -72,6 +89,8 @@ DCCP_SOCKOPT_CCID_TX_INFO | |||
72 | Returns a `struct tfrc_tx_info' in optval; the buffer for optval and | 89 | Returns a `struct tfrc_tx_info' in optval; the buffer for optval and |
73 | optlen must be set to at least sizeof(struct tfrc_tx_info). | 90 | optlen must be set to at least sizeof(struct tfrc_tx_info). |
74 | 91 | ||
92 | On unidirectional connections it is useful to close the unused half-connection | ||
93 | via shutdown (SHUT_WR or SHUT_RD): this will reduce per-packet processing costs. | ||
75 | 94 | ||
76 | Sysctl variables | 95 | Sysctl variables |
77 | ================ | 96 | ================ |
@@ -123,6 +142,12 @@ sync_ratelimit = 125 ms | |||
123 | sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit | 142 | sequence-invalid packets on the same socket (RFC 4340, 7.5.4). The unit |
124 | of this parameter is milliseconds; a value of 0 disables rate-limiting. | 143 | of this parameter is milliseconds; a value of 0 disables rate-limiting. |
125 | 144 | ||
145 | IOCTLS | ||
146 | ====== | ||
147 | FIONREAD | ||
148 | Works as in udp(7): returns in the `int' argument pointer the size of | ||
149 | the next pending datagram in bytes, or 0 when no datagram is pending. | ||
150 | |||
126 | Notes | 151 | Notes |
127 | ===== | 152 | ===== |
128 | 153 | ||
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 6f7872ba1def..17a6e46fbd43 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt | |||
@@ -446,6 +446,33 @@ tcp_dma_copybreak - INTEGER | |||
446 | and CONFIG_NET_DMA is enabled. | 446 | and CONFIG_NET_DMA is enabled. |
447 | Default: 4096 | 447 | Default: 4096 |
448 | 448 | ||
449 | UDP variables: | ||
450 | |||
451 | udp_mem - vector of 3 INTEGERs: min, pressure, max | ||
452 | Number of pages allowed for queueing by all UDP sockets. | ||
453 | |||
454 | min: Below this number of pages UDP is not bothered about its | ||
455 | memory appetite. When amount of memory allocated by UDP exceeds | ||
456 | this number, UDP starts to moderate memory usage. | ||
457 | |||
458 | pressure: This value was introduced to follow format of tcp_mem. | ||
459 | |||
460 | max: Number of pages allowed for queueing by all UDP sockets. | ||
461 | |||
462 | Default is calculated at boot time from amount of available memory. | ||
463 | |||
464 | udp_rmem_min - INTEGER | ||
465 | Minimal size of receive buffer used by UDP sockets in moderation. | ||
466 | Each UDP socket is able to use the size for receiving data, even if | ||
467 | total pages of UDP sockets exceed udp_mem pressure. The unit is byte. | ||
468 | Default: 4096 | ||
469 | |||
470 | udp_wmem_min - INTEGER | ||
471 | Minimal size of send buffer used by UDP sockets in moderation. | ||
472 | Each UDP socket is able to use the size for sending data, even if | ||
473 | total pages of UDP sockets exceed udp_mem pressure. The unit is byte. | ||
474 | Default: 4096 | ||
475 | |||
449 | CIPSOv4 Variables: | 476 | CIPSOv4 Variables: |
450 | 477 | ||
451 | cipso_cache_enable - BOOLEAN | 478 | cipso_cache_enable - BOOLEAN |
diff --git a/Documentation/networking/shaper.txt b/Documentation/networking/shaper.txt deleted file mode 100644 index 6c4ebb66a906..000000000000 --- a/Documentation/networking/shaper.txt +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | Traffic Shaper For Linux | ||
2 | |||
3 | This is the current BETA release of the traffic shaper for Linux. It works | ||
4 | within the following limits: | ||
5 | |||
6 | o Minimum shaping speed is currently about 9600 baud (it can only | ||
7 | shape down to 1 byte per clock tick) | ||
8 | |||
9 | o Maximum is about 256K, it will go above this but get a bit blocky. | ||
10 | |||
11 | o If you ifconfig the master device that a shaper is attached to down | ||
12 | then your machine will follow. | ||
13 | |||
14 | o The shaper must be a module. | ||
15 | |||
16 | |||
17 | Setup: | ||
18 | |||
19 | A shaper device is configured using the shapeconfig program. | ||
20 | Typically you will do something like this | ||
21 | |||
22 | shapecfg attach shaper0 eth1 | ||
23 | shapecfg speed shaper0 64000 | ||
24 | ifconfig shaper0 myhost netmask 255.255.255.240 broadcast 1.2.3.4.255 up | ||
25 | route add -net some.network netmask a.b.c.d dev shaper0 | ||
26 | |||
27 | The shaper should have the same IP address as the device it is attached to | ||
28 | for normal use. | ||
29 | |||
30 | Gotchas: | ||
31 | |||
32 | The shaper shapes transmitted traffic. It's rather impossible to | ||
33 | shape received traffic except at the end (or a router) transmitting it. | ||
34 | |||
35 | Gated/routed/rwhod/mrouted all see the shaper as an additional device | ||
36 | and will treat it as such unless patched. Note that for mrouted you can run | ||
37 | mrouted tunnels via a traffic shaper to control bandwidth usage. | ||
38 | |||
39 | The shaper is device/route based. This makes it very easy to use | ||
40 | with any setup BUT less flexible. You may need to use iproute2 to set up | ||
41 | multiple route tables to get the flexibility. | ||
42 | |||
43 | There is no "borrowing" or "sharing" scheme. This is a simple | ||
44 | traffic limiter. We implement Van Jacobson and Sally Floyd's CBQ | ||
45 | architecture into Linux 2.2. This is the preferred solution. Shaper is | ||
46 | for simple or back compatible setups. | ||
47 | |||
48 | Alan | ||
diff --git a/Documentation/networking/udplite.txt b/Documentation/networking/udplite.txt index b6409cab075c..3870f280280b 100644 --- a/Documentation/networking/udplite.txt +++ b/Documentation/networking/udplite.txt | |||
@@ -236,7 +236,7 @@ | |||
236 | 236 | ||
237 | This displays UDP-Lite statistics variables, whose meaning is as follows. | 237 | This displays UDP-Lite statistics variables, whose meaning is as follows. |
238 | 238 | ||
239 | InDatagrams: Total number of received datagrams. | 239 | InDatagrams: The total number of datagrams delivered to users. |
240 | 240 | ||
241 | NoPorts: Number of packets received to an unknown port. | 241 | NoPorts: Number of packets received to an unknown port. |
242 | These cases are counted separately (not as InErrors). | 242 | These cases are counted separately (not as InErrors). |
diff --git a/Documentation/networking/xfrm_proc.txt b/Documentation/networking/xfrm_proc.txt new file mode 100644 index 000000000000..53c1a58b02f1 --- /dev/null +++ b/Documentation/networking/xfrm_proc.txt | |||
@@ -0,0 +1,70 @@ | |||
1 | XFRM proc - /proc/net/xfrm_* files | ||
2 | ================================== | ||
3 | Masahide NAKAMURA <nakam@linux-ipv6.org> | ||
4 | |||
5 | |||
6 | Transformation Statistics | ||
7 | ------------------------- | ||
8 | xfrm_proc is a statistics shown factor dropped by transformation | ||
9 | for developer. | ||
10 | It is a counter designed from current transformation source code | ||
11 | and defined like linux private MIB. | ||
12 | |||
13 | Inbound statistics | ||
14 | ~~~~~~~~~~~~~~~~~~ | ||
15 | XfrmInError: | ||
16 | All errors which is not matched others | ||
17 | XfrmInBufferError: | ||
18 | No buffer is left | ||
19 | XfrmInHdrError: | ||
20 | Header error | ||
21 | XfrmInNoStates: | ||
22 | No state is found | ||
23 | i.e. Either inbound SPI, address, or IPsec protocol at SA is wrong | ||
24 | XfrmInStateProtoError: | ||
25 | Transformation protocol specific error | ||
26 | e.g. SA key is wrong | ||
27 | XfrmInStateModeError: | ||
28 | Transformation mode specific error | ||
29 | XfrmInSeqOutOfWindow: | ||
30 | Sequence out of window | ||
31 | XfrmInStateExpired: | ||
32 | State is expired | ||
33 | XfrmInStateMismatch: | ||
34 | State has mismatch option | ||
35 | e.g. UDP encapsulation type is mismatch | ||
36 | XfrmInStateInvalid: | ||
37 | State is invalid | ||
38 | XfrmInTmplMismatch: | ||
39 | No matching template for states | ||
40 | e.g. Inbound SAs are correct but SP rule is wrong | ||
41 | XfrmInNoPols: | ||
42 | No policy is found for states | ||
43 | e.g. Inbound SAs are correct but no SP is found | ||
44 | XfrmInPolBlock: | ||
45 | Policy discards | ||
46 | XfrmInPolError: | ||
47 | Policy error | ||
48 | |||
49 | Outbound errors | ||
50 | ~~~~~~~~~~~~~~~ | ||
51 | XfrmOutError: | ||
52 | All errors which is not matched others | ||
53 | XfrmOutBundleGenError: | ||
54 | Bundle generation error | ||
55 | XfrmOutBundleCheckError: | ||
56 | Bundle check error | ||
57 | XfrmOutNoStates: | ||
58 | No state is found | ||
59 | XfrmOutStateProtoError: | ||
60 | Transformation protocol specific error | ||
61 | XfrmOutStateModeError: | ||
62 | Transformation mode specific error | ||
63 | XfrmOutStateExpired: | ||
64 | State is expired | ||
65 | XfrmOutPolBlock: | ||
66 | Policy discards | ||
67 | XfrmOutPolDead: | ||
68 | Policy is dead | ||
69 | XfrmOutPolError: | ||
70 | Policy error | ||