Blame view

Documentation/networking/ipvlan.txt 4.61 KB
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
1
2
3
4
5
6
7
8
9
10
  
                              IPVLAN Driver HOWTO
  
  Initial Release:
  	Mahesh Bandewar <maheshb AT google.com>
  
  1. Introduction:
  	This is conceptually very similar to the macvlan driver with one major
  exception of using L3 for mux-ing /demux-ing among slaves. This property makes
  the master device share the L2 with it's slave devices. I have developed this
edb9a1b89   Eric Engestrom   Documentation: ne...
11
  driver in conjunction with network namespaces and not sure if there is use case
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
12
13
14
15
16
17
18
19
20
21
22
23
  outside of it.
  
  
  2. Building and Installation:
  	In order to build the driver, please select the config item CONFIG_IPVLAN.
  The driver can be built into the kernel (CONFIG_IPVLAN=y) or as a module
  (CONFIG_IPVLAN=m).
  
  
  3. Configuration:
  	There are no module parameters for this driver and it can be configured
  using IProute2/ip utility.
4fbae7d83   Mahesh Bandewar   ipvlan: Introduce...
24
  	ip link add link <master-dev> <slave-dev> type ipvlan mode { l2 | l3 | l3s }
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  
  	e.g. ip link add link ipvl0 eth0 type ipvlan mode l2
  
  
  4. Operating modes:
  	IPvlan has two modes of operation - L2 and L3. For a given master device,
  you can select one of these two modes and all slaves on that master will
  operate in the same (selected) mode. The RX mode is almost identical except
  that in L3 mode the slaves wont receive any multicast / broadcast traffic.
  L3 mode is more restrictive since routing is controlled from the other (mostly)
  default namespace.
  
  4.1 L2 mode:
  	In this mode TX processing happens on the stack instance attached to the
  slave device and packets are switched and queued to the master device to send
  out. In this mode the slaves will RX/TX multicast and broadcast (if applicable)
  as well.
  
  4.2 L3 mode:
edb9a1b89   Eric Engestrom   Documentation: ne...
44
  	In this mode TX processing up to L3 happens on the stack instance attached
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
45
46
47
48
  to the slave device and packets are switched to the stack instance of the
  master device for the L2 processing and routing from that instance will be
  used before packets are queued on the outbound device. In this mode the slaves
  will not receive nor can send multicast / broadcast traffic.
4fbae7d83   Mahesh Bandewar   ipvlan: Introduce...
49
50
51
52
53
  4.3 L3S mode:
  	This is very similar to the L3 mode except that iptables (conn-tracking)
  works in this mode and hence it is L3-symmetric (L3s). This will have slightly less
  performance but that shouldn't matter since you are choosing this mode over plain-L3
  mode to make conn-tracking work.
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
54
55
56
57
58
59
60
61
  
  5. What to choose (macvlan vs. ipvlan)?
  	These two devices are very similar in many regards and the specific use
  case could very well define which device to choose. if one of the following
  situations defines your use case then you can choose to use ipvlan -
  	(a) The Linux host that is connected to the external switch / router has
  policy configured that allows only one mac per port.
  	(b) No of virtual devices created on a master exceed the mac capacity and
edb9a1b89   Eric Engestrom   Documentation: ne...
62
  puts the NIC in promiscuous mode and degraded performance is a concern.
2ad7bf363   Mahesh Bandewar   ipvlan: Initial c...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  	(c) If the slave device is to be put into the hostile / untrusted network
  namespace where L2 on the slave could be changed / misused.
  
  
  6. Example configuration:
  
    +=============================================================+
    |  Host: host1                                                |
    |                                                             |
    |   +----------------------+      +----------------------+    |
    |   |   NS:ns0             |      |  NS:ns1              |    |
    |   |                      |      |                      |    |
    |   |                      |      |                      |    |
    |   |        ipvl0         |      |         ipvl1        |    |
    |   +----------#-----------+      +-----------#----------+    |
    |              #                              #               |
    |              ################################               |
    |                              # eth0                         |
    +==============================#==============================+
  
  
  	(a) Create two network namespaces - ns0, ns1
  		ip netns add ns0
  		ip netns add ns1
  
  	(b) Create two ipvlan slaves on eth0 (master device)
  		ip link add link eth0 ipvl0 type ipvlan mode l2
  		ip link add link eth0 ipvl1 type ipvlan mode l2
  
  	(c) Assign slaves to the respective network namespaces
  		ip link set dev ipvl0 netns ns0
  		ip link set dev ipvl1 netns ns1
  
  	(d) Now switch to the namespace (ns0 or ns1) to configure the slave devices
  		- For ns0
  			(1) ip netns exec ns0 bash
  			(2) ip link set dev ipvl0 up
  			(3) ip link set dev lo up
  			(4) ip -4 addr add 127.0.0.1 dev lo
  			(5) ip -4 addr add $IPADDR dev ipvl0
  			(6) ip -4 route add default via $ROUTER dev ipvl0
  		- For ns1
  			(1) ip netns exec ns1 bash
  			(2) ip link set dev ipvl1 up
  			(3) ip link set dev lo up
  			(4) ip -4 addr add 127.0.0.1 dev lo
  			(5) ip -4 addr add $IPADDR dev ipvl1
  			(6) ip -4 route add default via $ROUTER dev ipvl1