]> git.proxmox.com Git - pve-kernel-2.6.32.git/blob - rhel63-vlan-bonding-failover-fix.patch
rhel6.3 bonding vlan fixes
[pve-kernel-2.6.32.git] / rhel63-vlan-bonding-failover-fix.patch
1 From b0c17fb0e76a50f6845083964f42842ad5cebb41 Mon Sep 17 00:00:00 2001
2 From: Neil Horman <nhorman@redhat.com>
3 Date: Fri, 20 Jul 2012 15:55:45 -0400
4 Subject: [RHEL 6.3.Z PATCH] vlan: filter device events on bonds
5
6 Since bond masters and slaves only have separate vlan groups now, the
7 vlan_device_event handler has to be taught to ignore network events from slave
8 devices when they're truly attached to the bond master. We do this by looking
9 up the network device of a given vide on both the slave and its master. if they
10 match, then we're processing an event for a physical device that we don't really
11 care about (since the masters events are realy what we're interested in.
12
13 This patch adds that comparison, and allows us to filter those slave events that
14 the vlan code should ignore.
15 ---
16 net/8021q/vlan.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 1 files changed, 64 insertions(+), 0 deletions(-)
18
19 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
20 index ad5e2ae..cc046a1 100644
21 --- a/net/8021q/vlan.c
22 +++ b/net/8021q/vlan.c
23 @@ -439,6 +439,56 @@ static void __vlan_device_event(struct net_device *dev, unsigned long event)
24 }
25 }
26
27 +/*
28 + * Since bonding slaves have their own vlan groups now, we need
29 + * to make sure that, when we process an event for a device, that its
30 + * actually relevant to a particular vid. If the bond actually owns the vid
31 + * and the slave just holds a copy of it, then we need to ignore the event,
32 + * because the vlan treats the bond, not the slave as its lower layer device
33 + */
34 +static int ignore_slave_event(struct net_device *dev, int i)
35 +{
36 + struct vlan_group *sgrp, *mgrp;
37 + struct net_device *svdev, *mvdev;
38 +
39 + /* process if this isn't a slave */
40 + if (!dev->master)
41 + return 0;
42 +
43 + /* This is just a check for bonding */
44 + if (!(dev->master->priv_flags & IFF_BONDING))
45 + return 0;
46 +
47 + sgrp = __vlan_find_group(dev);
48 + mgrp = __vlan_find_group(dev->master);
49 +
50 + /* process if either the slave or master doesn't have a vlan group */
51 + if (!sgrp || !mgrp)
52 + return 0;
53 +
54 + svdev = vlan_group_get_device(sgrp, i);
55 + mvdev = vlan_group_get_device(mgrp, i);
56 +
57 + /* process If a vlan isn't found on either the slave or master */
58 + if (!svdev || !mvdev)
59 + return 0;
60 +
61 + /*
62 + * If, and only if, we have the same vlan device attached to both
63 + * the slave and the master device, then we know for certain that
64 + * this event is comming from a slave, and that the vlan is actually
65 + * attached to the master. In this case, vlan_device_event should
66 + * ignore the event process and not transfer the operstae, because
67 + * the bonds operstate won't actually change, it will just fail over
68 + * to another slave
69 + */
70 + if (svdev == mvdev)
71 + return 1;
72 +
73 + return 0;
74 +
75 +}
76 +
77 static int vlan_device_event(struct notifier_block *unused, unsigned long event,
78 void *ptr)
79 {
80 @@ -470,6 +520,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
81 case NETDEV_CHANGE:
82 /* Propagate real device state to vlan devices */
83 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
84 + if (ignore_slave_event(dev, i))
85 + continue;
86 vlandev = vlan_group_get_device(grp, i);
87 if (!vlandev)
88 continue;
89 @@ -481,6 +533,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
90 case NETDEV_CHANGEADDR:
91 /* Adjust unicast filters on underlying device */
92 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
93 + if (ignore_slave_event(dev, i))
94 + continue;
95 vlandev = vlan_group_get_device(grp, i);
96 if (!vlandev)
97 continue;
98 @@ -495,6 +549,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
99
100 case NETDEV_CHANGEMTU:
101 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
102 + if (ignore_slave_event(dev, i))
103 + continue;
104 vlandev = vlan_group_get_device(grp, i);
105 if (!vlandev)
106 continue;
107 @@ -509,6 +565,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
108 case NETDEV_FEAT_CHANGE:
109 /* Propagate device features to underlying device */
110 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
111 + if (ignore_slave_event(dev, i))
112 + continue;
113 vlandev = vlan_group_get_device(grp, i);
114 if (!vlandev)
115 continue;
116 @@ -521,6 +579,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
117 case NETDEV_DOWN:
118 /* Put all VLANs for this dev in the down state too. */
119 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
120 + if (ignore_slave_event(dev, i))
121 + continue;
122 vlandev = vlan_group_get_device(grp, i);
123 if (!vlandev)
124 continue;
125 @@ -537,6 +597,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
126 case NETDEV_UP:
127 /* Put all VLANs for this dev in the up state too. */
128 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
129 + if (ignore_slave_event(dev, i))
130 + continue;
131 vlandev = vlan_group_get_device(grp, i);
132 if (!vlandev)
133 continue;
134 @@ -553,6 +615,8 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
135 case NETDEV_UNREGISTER:
136 /* Delete all VLANs for this dev. */
137 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
138 + if (ignore_slave_event(dev, i))
139 + continue;
140 vlandev = vlan_group_get_device(grp, i);
141 if (!vlandev)
142 continue;
143 --
144 1.7.7.6