configuration.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. .. SPDX-License-Identifier: GPL-2.0
  2. =======================================
  3. DSA switch configuration from userspace
  4. =======================================
  5. The DSA switch configuration is not integrated into the main userspace
  6. network configuration suites by now and has to be performed manualy.
  7. .. _dsa-config-showcases:
  8. Configuration showcases
  9. -----------------------
  10. To configure a DSA switch a couple of commands need to be executed. In this
  11. documentation some common configuration scenarios are handled as showcases:
  12. *single port*
  13. Every switch port acts as a different configurable Ethernet port
  14. *bridge*
  15. Every switch port is part of one configurable Ethernet bridge
  16. *gateway*
  17. Every switch port except one upstream port is part of a configurable
  18. Ethernet bridge.
  19. The upstream port acts as different configurable Ethernet port.
  20. All configurations are performed with tools from iproute2, which is available
  21. at https://www.kernel.org/pub/linux/utils/net/iproute2/
  22. Through DSA every port of a switch is handled like a normal linux Ethernet
  23. interface. The CPU port is the switch port connected to an Ethernet MAC chip.
  24. The corresponding linux Ethernet interface is called the master interface.
  25. All other corresponding linux interfaces are called slave interfaces.
  26. The slave interfaces depend on the master interface. They can only brought up,
  27. when the master interface is up.
  28. In this documentation the following Ethernet interfaces are used:
  29. *eth0*
  30. the master interface
  31. *lan1*
  32. a slave interface
  33. *lan2*
  34. another slave interface
  35. *lan3*
  36. a third slave interface
  37. *wan*
  38. A slave interface dedicated for upstream traffic
  39. Further Ethernet interfaces can be configured similar.
  40. The configured IPs and networks are:
  41. *single port*
  42. * lan1: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
  43. * lan2: 192.0.2.5/30 (192.0.2.4 - 192.0.2.7)
  44. * lan3: 192.0.2.9/30 (192.0.2.8 - 192.0.2.11)
  45. *bridge*
  46. * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
  47. *gateway*
  48. * br0: 192.0.2.129/25 (192.0.2.128 - 192.0.2.255)
  49. * wan: 192.0.2.1/30 (192.0.2.0 - 192.0.2.3)
  50. .. _dsa-tagged-configuration:
  51. Configuration with tagging support
  52. ----------------------------------
  53. The tagging based configuration is desired and supported by the majority of
  54. DSA switches. These switches are capable to tag incoming and outgoing traffic
  55. without using a VLAN based configuration.
  56. single port
  57. ~~~~~~~~~~~
  58. .. code-block:: sh
  59. # configure each interface
  60. ip addr add 192.0.2.1/30 dev lan1
  61. ip addr add 192.0.2.5/30 dev lan2
  62. ip addr add 192.0.2.9/30 dev lan3
  63. # The master interface needs to be brought up before the slave ports.
  64. ip link set eth0 up
  65. # bring up the slave interfaces
  66. ip link set lan1 up
  67. ip link set lan2 up
  68. ip link set lan3 up
  69. bridge
  70. ~~~~~~
  71. .. code-block:: sh
  72. # The master interface needs to be brought up before the slave ports.
  73. ip link set eth0 up
  74. # bring up the slave interfaces
  75. ip link set lan1 up
  76. ip link set lan2 up
  77. ip link set lan3 up
  78. # create bridge
  79. ip link add name br0 type bridge
  80. # add ports to bridge
  81. ip link set dev lan1 master br0
  82. ip link set dev lan2 master br0
  83. ip link set dev lan3 master br0
  84. # configure the bridge
  85. ip addr add 192.0.2.129/25 dev br0
  86. # bring up the bridge
  87. ip link set dev br0 up
  88. gateway
  89. ~~~~~~~
  90. .. code-block:: sh
  91. # The master interface needs to be brought up before the slave ports.
  92. ip link set eth0 up
  93. # bring up the slave interfaces
  94. ip link set wan up
  95. ip link set lan1 up
  96. ip link set lan2 up
  97. # configure the upstream port
  98. ip addr add 192.0.2.1/30 dev wan
  99. # create bridge
  100. ip link add name br0 type bridge
  101. # add ports to bridge
  102. ip link set dev lan1 master br0
  103. ip link set dev lan2 master br0
  104. # configure the bridge
  105. ip addr add 192.0.2.129/25 dev br0
  106. # bring up the bridge
  107. ip link set dev br0 up
  108. .. _dsa-vlan-configuration:
  109. Configuration without tagging support
  110. -------------------------------------
  111. A minority of switches are not capable to use a taging protocol
  112. (DSA_TAG_PROTO_NONE). These switches can be configured by a VLAN based
  113. configuration.
  114. single port
  115. ~~~~~~~~~~~
  116. The configuration can only be set up via VLAN tagging and bridge setup.
  117. .. code-block:: sh
  118. # tag traffic on CPU port
  119. ip link add link eth0 name eth0.1 type vlan id 1
  120. ip link add link eth0 name eth0.2 type vlan id 2
  121. ip link add link eth0 name eth0.3 type vlan id 3
  122. # The master interface needs to be brought up before the slave ports.
  123. ip link set eth0 up
  124. ip link set eth0.1 up
  125. ip link set eth0.2 up
  126. ip link set eth0.3 up
  127. # bring up the slave interfaces
  128. ip link set lan1 up
  129. ip link set lan2 up
  130. ip link set lan3 up
  131. # create bridge
  132. ip link add name br0 type bridge
  133. # activate VLAN filtering
  134. ip link set dev br0 type bridge vlan_filtering 1
  135. # add ports to bridges
  136. ip link set dev lan1 master br0
  137. ip link set dev lan2 master br0
  138. ip link set dev lan3 master br0
  139. # tag traffic on ports
  140. bridge vlan add dev lan1 vid 1 pvid untagged
  141. bridge vlan add dev lan2 vid 2 pvid untagged
  142. bridge vlan add dev lan3 vid 3 pvid untagged
  143. # configure the VLANs
  144. ip addr add 192.0.2.1/30 dev eth0.1
  145. ip addr add 192.0.2.5/30 dev eth0.2
  146. ip addr add 192.0.2.9/30 dev eth0.3
  147. # bring up the bridge devices
  148. ip link set br0 up
  149. bridge
  150. ~~~~~~
  151. .. code-block:: sh
  152. # tag traffic on CPU port
  153. ip link add link eth0 name eth0.1 type vlan id 1
  154. # The master interface needs to be brought up before the slave ports.
  155. ip link set eth0 up
  156. ip link set eth0.1 up
  157. # bring up the slave interfaces
  158. ip link set lan1 up
  159. ip link set lan2 up
  160. ip link set lan3 up
  161. # create bridge
  162. ip link add name br0 type bridge
  163. # activate VLAN filtering
  164. ip link set dev br0 type bridge vlan_filtering 1
  165. # add ports to bridge
  166. ip link set dev lan1 master br0
  167. ip link set dev lan2 master br0
  168. ip link set dev lan3 master br0
  169. ip link set eth0.1 master br0
  170. # tag traffic on ports
  171. bridge vlan add dev lan1 vid 1 pvid untagged
  172. bridge vlan add dev lan2 vid 1 pvid untagged
  173. bridge vlan add dev lan3 vid 1 pvid untagged
  174. # configure the bridge
  175. ip addr add 192.0.2.129/25 dev br0
  176. # bring up the bridge
  177. ip link set dev br0 up
  178. gateway
  179. ~~~~~~~
  180. .. code-block:: sh
  181. # tag traffic on CPU port
  182. ip link add link eth0 name eth0.1 type vlan id 1
  183. ip link add link eth0 name eth0.2 type vlan id 2
  184. # The master interface needs to be brought up before the slave ports.
  185. ip link set eth0 up
  186. ip link set eth0.1 up
  187. ip link set eth0.2 up
  188. # bring up the slave interfaces
  189. ip link set wan up
  190. ip link set lan1 up
  191. ip link set lan2 up
  192. # create bridge
  193. ip link add name br0 type bridge
  194. # activate VLAN filtering
  195. ip link set dev br0 type bridge vlan_filtering 1
  196. # add ports to bridges
  197. ip link set dev wan master br0
  198. ip link set eth0.1 master br0
  199. ip link set dev lan1 master br0
  200. ip link set dev lan2 master br0
  201. # tag traffic on ports
  202. bridge vlan add dev lan1 vid 1 pvid untagged
  203. bridge vlan add dev lan2 vid 1 pvid untagged
  204. bridge vlan add dev wan vid 2 pvid untagged
  205. # configure the VLANs
  206. ip addr add 192.0.2.1/30 dev eth0.2
  207. ip addr add 192.0.2.129/25 dev br0
  208. # bring up the bridge devices
  209. ip link set br0 up