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

docs: networking: convert ipvlan.txt to ReST

- add SPDX header;
- adjust titles and chapters, adding proper markups;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mauro Carvalho Chehab and committed by
David S. Miller
1dc2a785 19093313

+99 -55
+1
Documentation/networking/index.rst
··· 71 71 ipsec 72 72 ip-sysctl 73 73 ipv6 74 + ipvlan 74 75 75 76 .. only:: subproject and html 76 77
+98 -55
Documentation/networking/ipvlan.txt Documentation/networking/ipvlan.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 1 2 2 - IPVLAN Driver HOWTO 3 + =================== 4 + IPVLAN Driver HOWTO 5 + =================== 3 6 4 7 Initial Release: 5 8 Mahesh Bandewar <maheshb AT google.com> 6 9 7 10 1. Introduction: 8 - This is conceptually very similar to the macvlan driver with one major 11 + ================ 12 + This is conceptually very similar to the macvlan driver with one major 9 13 exception of using L3 for mux-ing /demux-ing among slaves. This property makes 10 14 the master device share the L2 with it's slave devices. I have developed this 11 15 driver in conjunction with network namespaces and not sure if there is use case ··· 17 13 18 14 19 15 2. Building and Installation: 20 - In order to build the driver, please select the config item CONFIG_IPVLAN. 16 + ============================= 17 + 18 + In order to build the driver, please select the config item CONFIG_IPVLAN. 21 19 The driver can be built into the kernel (CONFIG_IPVLAN=y) or as a module 22 20 (CONFIG_IPVLAN=m). 23 21 24 22 25 23 3. Configuration: 26 - There are no module parameters for this driver and it can be configured 24 + ================= 25 + 26 + There are no module parameters for this driver and it can be configured 27 27 using IProute2/ip utility. 28 + :: 28 29 29 30 ip link add link <master> name <slave> type ipvlan [ mode MODE ] [ FLAGS ] 30 31 where 31 - MODE: l3 (default) | l3s | l2 32 - FLAGS: bridge (default) | private | vepa 32 + MODE: l3 (default) | l3s | l2 33 + FLAGS: bridge (default) | private | vepa 33 34 34 - e.g. 35 + e.g. 36 + 35 37 (a) Following will create IPvlan link with eth0 as master in 36 - L3 bridge mode 37 - bash# ip link add link eth0 name ipvl0 type ipvlan 38 - (b) This command will create IPvlan link in L2 bridge mode. 39 - bash# ip link add link eth0 name ipvl0 type ipvlan mode l2 bridge 40 - (c) This command will create an IPvlan device in L2 private mode. 41 - bash# ip link add link eth0 name ipvlan type ipvlan mode l2 private 42 - (d) This command will create an IPvlan device in L2 vepa mode. 43 - bash# ip link add link eth0 name ipvlan type ipvlan mode l2 vepa 38 + L3 bridge mode:: 39 + 40 + bash# ip link add link eth0 name ipvl0 type ipvlan 41 + (b) This command will create IPvlan link in L2 bridge mode:: 42 + 43 + bash# ip link add link eth0 name ipvl0 type ipvlan mode l2 bridge 44 + 45 + (c) This command will create an IPvlan device in L2 private mode:: 46 + 47 + bash# ip link add link eth0 name ipvlan type ipvlan mode l2 private 48 + 49 + (d) This command will create an IPvlan device in L2 vepa mode:: 50 + 51 + bash# ip link add link eth0 name ipvlan type ipvlan mode l2 vepa 44 52 45 53 46 54 4. Operating modes: 47 - IPvlan has two modes of operation - L2 and L3. For a given master device, 55 + =================== 56 + 57 + IPvlan has two modes of operation - L2 and L3. For a given master device, 48 58 you can select one of these two modes and all slaves on that master will 49 59 operate in the same (selected) mode. The RX mode is almost identical except 50 60 that in L3 mode the slaves wont receive any multicast / broadcast traffic. ··· 66 48 default namespace. 67 49 68 50 4.1 L2 mode: 69 - In this mode TX processing happens on the stack instance attached to the 51 + ------------ 52 + 53 + In this mode TX processing happens on the stack instance attached to the 70 54 slave device and packets are switched and queued to the master device to send 71 55 out. In this mode the slaves will RX/TX multicast and broadcast (if applicable) 72 56 as well. 73 57 74 58 4.2 L3 mode: 75 - In this mode TX processing up to L3 happens on the stack instance attached 59 + ------------ 60 + 61 + In this mode TX processing up to L3 happens on the stack instance attached 76 62 to the slave device and packets are switched to the stack instance of the 77 63 master device for the L2 processing and routing from that instance will be 78 64 used before packets are queued on the outbound device. In this mode the slaves 79 65 will not receive nor can send multicast / broadcast traffic. 80 66 81 67 4.3 L3S mode: 82 - This is very similar to the L3 mode except that iptables (conn-tracking) 68 + ------------- 69 + 70 + This is very similar to the L3 mode except that iptables (conn-tracking) 83 71 works in this mode and hence it is L3-symmetric (L3s). This will have slightly less 84 72 performance but that shouldn't matter since you are choosing this mode over plain-L3 85 73 mode to make conn-tracking work. 86 74 87 75 5. Mode flags: 88 - At this time following mode flags are available 76 + ============== 77 + 78 + At this time following mode flags are available 89 79 90 80 5.1 bridge: 91 - This is the default option. To configure the IPvlan port in this mode, 81 + ----------- 82 + This is the default option. To configure the IPvlan port in this mode, 92 83 user can choose to either add this option on the command-line or don't specify 93 84 anything. This is the traditional mode where slaves can cross-talk among 94 85 themselves apart from talking through the master device. 95 86 96 87 5.2 private: 97 - If this option is added to the command-line, the port is set in private 88 + ------------ 89 + If this option is added to the command-line, the port is set in private 98 90 mode. i.e. port won't allow cross communication between slaves. 99 91 100 92 5.3 vepa: 101 - If this is added to the command-line, the port is set in VEPA mode. 93 + --------- 94 + If this is added to the command-line, the port is set in VEPA mode. 102 95 i.e. port will offload switching functionality to the external entity as 103 96 described in 802.1Qbg 104 97 Note: VEPA mode in IPvlan has limitations. IPvlan uses the mac-address of the ··· 118 89 router send the redirect message. 119 90 120 91 6. What to choose (macvlan vs. ipvlan)? 121 - These two devices are very similar in many regards and the specific use 92 + ======================================= 93 + 94 + These two devices are very similar in many regards and the specific use 122 95 case could very well define which device to choose. if one of the following 123 - situations defines your use case then you can choose to use ipvlan - 124 - (a) The Linux host that is connected to the external switch / router has 125 - policy configured that allows only one mac per port. 126 - (b) No of virtual devices created on a master exceed the mac capacity and 127 - puts the NIC in promiscuous mode and degraded performance is a concern. 128 - (c) If the slave device is to be put into the hostile / untrusted network 129 - namespace where L2 on the slave could be changed / misused. 96 + situations defines your use case then you can choose to use ipvlan: 97 + 98 + 99 + (a) The Linux host that is connected to the external switch / router has 100 + policy configured that allows only one mac per port. 101 + (b) No of virtual devices created on a master exceed the mac capacity and 102 + puts the NIC in promiscuous mode and degraded performance is a concern. 103 + (c) If the slave device is to be put into the hostile / untrusted network 104 + namespace where L2 on the slave could be changed / misused. 130 105 131 106 132 107 6. Example configuration: 108 + ========================= 109 + 110 + :: 133 111 134 112 +=============================================================+ 135 113 | Host: host1 | ··· 153 117 +==============================#==============================+ 154 118 155 119 156 - (a) Create two network namespaces - ns0, ns1 157 - ip netns add ns0 158 - ip netns add ns1 120 + (a) Create two network namespaces - ns0, ns1:: 159 121 160 - (b) Create two ipvlan slaves on eth0 (master device) 161 - ip link add link eth0 ipvl0 type ipvlan mode l2 162 - ip link add link eth0 ipvl1 type ipvlan mode l2 122 + ip netns add ns0 123 + ip netns add ns1 163 124 164 - (c) Assign slaves to the respective network namespaces 165 - ip link set dev ipvl0 netns ns0 166 - ip link set dev ipvl1 netns ns1 125 + (b) Create two ipvlan slaves on eth0 (master device):: 167 126 168 - (d) Now switch to the namespace (ns0 or ns1) to configure the slave devices 169 - - For ns0 170 - (1) ip netns exec ns0 bash 171 - (2) ip link set dev ipvl0 up 172 - (3) ip link set dev lo up 173 - (4) ip -4 addr add 127.0.0.1 dev lo 174 - (5) ip -4 addr add $IPADDR dev ipvl0 175 - (6) ip -4 route add default via $ROUTER dev ipvl0 176 - - For ns1 177 - (1) ip netns exec ns1 bash 178 - (2) ip link set dev ipvl1 up 179 - (3) ip link set dev lo up 180 - (4) ip -4 addr add 127.0.0.1 dev lo 181 - (5) ip -4 addr add $IPADDR dev ipvl1 182 - (6) ip -4 route add default via $ROUTER dev ipvl1 127 + ip link add link eth0 ipvl0 type ipvlan mode l2 128 + ip link add link eth0 ipvl1 type ipvlan mode l2 129 + 130 + (c) Assign slaves to the respective network namespaces:: 131 + 132 + ip link set dev ipvl0 netns ns0 133 + ip link set dev ipvl1 netns ns1 134 + 135 + (d) Now switch to the namespace (ns0 or ns1) to configure the slave devices 136 + 137 + - For ns0:: 138 + 139 + (1) ip netns exec ns0 bash 140 + (2) ip link set dev ipvl0 up 141 + (3) ip link set dev lo up 142 + (4) ip -4 addr add 127.0.0.1 dev lo 143 + (5) ip -4 addr add $IPADDR dev ipvl0 144 + (6) ip -4 route add default via $ROUTER dev ipvl0 145 + 146 + - For ns1:: 147 + 148 + (1) ip netns exec ns1 bash 149 + (2) ip link set dev ipvl1 up 150 + (3) ip link set dev lo up 151 + (4) ip -4 addr add 127.0.0.1 dev lo 152 + (5) ip -4 addr add $IPADDR dev ipvl1 153 + (6) ip -4 route add default via $ROUTER dev ipvl1