net: forbid underlaying devices to change its type
authorJiri Pirko <jpirko@redhat.com>
Wed, 10 Mar 2010 10:30:19 +0000 (10:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Mar 2010 03:00:02 +0000 (20:00 -0700)
It's not desired for underlaying devices to change type. At the time,
there is for example possible to have bond with changed type from
Ethernet to Infiniband as a port of a bridge. This patch fixes this.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvlan.c
net/8021q/vlan.c
net/bridge/br_notify.c

index 40faa368b07a89f175f6e48b0ef750f2d3bf8d57..445e73c343ba7c8e096e6b9de4c59f5b6ddc6373 100644 (file)
@@ -748,6 +748,9 @@ static int macvlan_device_event(struct notifier_block *unused,
                list_for_each_entry_safe(vlan, next, &port->vlans, list)
                        vlan->dev->rtnl_link_ops->dellink(vlan->dev, NULL);
                break;
+       case NETDEV_PRE_TYPE_CHANGE:
+               /* Forbid underlaying device to change its type. */
+               return NOTIFY_BAD;
        }
        return NOTIFY_DONE;
 }
index 453512266ea1dd783dbc68f5e6b511dd64ec5ac5..c39a5f41169c19493bbca77f95a382719caafda3 100644 (file)
@@ -530,6 +530,10 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
                }
                unregister_netdevice_many(&list);
                break;
+
+       case NETDEV_PRE_TYPE_CHANGE:
+               /* Forbid underlaying device to change its type. */
+               return NOTIFY_BAD;
        }
 
 out:
index 763a3ec292e599081ad04394fde8d1e9914a2ea3..1413b72acc7fd8851fa163423582665f4f097fb0 100644 (file)
@@ -82,6 +82,10 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
        case NETDEV_UNREGISTER:
                br_del_if(br, dev);
                break;
+
+       case NETDEV_PRE_TYPE_CHANGE:
+               /* Forbid underlaying device to change its type. */
+               return NOTIFY_BAD;
        }
 
        /* Events that may cause spanning tree to refresh */