* [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2
@ 2010-03-09 14:17 Jiri Pirko
2010-03-09 14:18 ` [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change Jiri Pirko
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-09 14:17 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
Reworked version of patch/patchset. This time I use netdevice notifier as
Stephen suggested. Changed the name of the original ones (NETDEV_BONDING_*TYPE)
to be more general and reused them. Now the change is refused by brigde only.
I will follow up with vlan soon.
Jirka
^ permalink raw reply [flat|nested] 7+ messages in thread
* [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change
2010-03-09 14:17 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
@ 2010-03-09 14:18 ` Jiri Pirko
2010-03-09 22:00 ` Jiri Pirko
2010-03-09 14:19 ` [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type Jiri Pirko
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Jiri Pirko @ 2010-03-09 14:18 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
Since generally there could be more netdevices changing type other than bonding,
making this event type name "bonding-unrelated"
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/bonding/bond_main.c | 4 ++--
include/linux/notifier.h | 4 ++--
net/ipv4/devinet.c | 4 ++--
net/ipv6/addrconf.c | 16 ++++++++--------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 430c022..c1b39b7 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1480,14 +1480,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_dev->name,
bond_dev->type, slave_dev->type);
- netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE);
+ netdev_bonding_change(bond_dev, NETDEV_TYPE_CHNG_START);
if (slave_dev->type != ARPHRD_ETHER)
bond_setup_by_slave(bond_dev, slave_dev);
else
ether_setup(bond_dev);
- netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE);
+ netdev_bonding_change(bond_dev, NETDEV_TYPE_CHNG_DONE);
}
} else if (bond_dev->type != slave_dev->type) {
pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n",
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index fee6c2f..c8145c2 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -199,8 +199,8 @@ static inline int notifier_to_errno(int ret)
#define NETDEV_FEAT_CHANGE 0x000B
#define NETDEV_BONDING_FAILOVER 0x000C
#define NETDEV_PRE_UP 0x000D
-#define NETDEV_BONDING_OLDTYPE 0x000E
-#define NETDEV_BONDING_NEWTYPE 0x000F
+#define NETDEV_TYPE_CHNG_START 0x000E
+#define NETDEV_TYPE_CHNG_DONE 0x000F
#define NETDEV_POST_INIT 0x0010
#define NETDEV_UNREGISTER_BATCH 0x0011
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 51ca946..16bfc45 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1095,10 +1095,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
case NETDEV_DOWN:
ip_mc_down(in_dev);
break;
- case NETDEV_BONDING_OLDTYPE:
+ case NETDEV_TYPE_CHNG_START:
ip_mc_unmap(in_dev);
break;
- case NETDEV_BONDING_NEWTYPE:
+ case NETDEV_TYPE_CHNG_DONE:
ip_mc_remap(in_dev);
break;
case NETDEV_CHANGEMTU:
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 88fd8c5..b2409ac 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -137,8 +137,8 @@ static DEFINE_SPINLOCK(addrconf_verify_lock);
static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
-static void addrconf_bonding_change(struct net_device *dev,
- unsigned long event);
+static void addrconf_type_change(struct net_device *dev,
+ unsigned long event);
static int addrconf_ifdown(struct net_device *dev, int how);
static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags);
@@ -2582,9 +2582,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
return notifier_from_errno(err);
}
break;
- case NETDEV_BONDING_OLDTYPE:
- case NETDEV_BONDING_NEWTYPE:
- addrconf_bonding_change(dev, event);
+ case NETDEV_TYPE_CHNG_START:
+ case NETDEV_TYPE_CHNG_DONE:
+ addrconf_type_change(dev, event);
break;
}
@@ -2599,16 +2599,16 @@ static struct notifier_block ipv6_dev_notf = {
.priority = 0
};
-static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
+static void addrconf_type_change(struct net_device *dev, unsigned long event)
{
struct inet6_dev *idev;
ASSERT_RTNL();
idev = __in6_dev_get(dev);
- if (event == NETDEV_BONDING_NEWTYPE)
+ if (event == NETDEV_TYPE_CHNG_DONE)
ipv6_mc_remap(idev);
- else if (event == NETDEV_BONDING_OLDTYPE)
+ else if (event == NETDEV_TYPE_CHNG_START)
ipv6_mc_unmap(idev);
}
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type
2010-03-09 14:17 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
2010-03-09 14:18 ` [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change Jiri Pirko
@ 2010-03-09 14:19 ` Jiri Pirko
2010-03-09 14:19 ` [net-next-2.6 PATCH 3/3] bridge: forbid slave devices to change it's type Jiri Pirko
2010-03-10 8:37 ` [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
3 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-09 14:19 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
This patch adds the possibility to refuse the bonding type change for other
subsystems (such as for example bridge, vlan, etc.)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/bonding/bond_main.c | 10 +++++++++-
include/linux/netdevice.h | 2 +-
net/core/dev.c | 4 ++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c1b39b7..dd34b05 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1480,7 +1480,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_dev->name,
bond_dev->type, slave_dev->type);
- netdev_bonding_change(bond_dev, NETDEV_TYPE_CHNG_START);
+ res = netdev_bonding_change(bond_dev,
+ NETDEV_TYPE_CHNG_START);
+ res = notifier_to_errno(res);
+ if (res) {
+ pr_err("%s: refused to change device type\n",
+ bond_dev->name);
+ res = -EBUSY;
+ goto err_undo_flags;
+ }
if (slave_dev->type != ARPHRD_ETHER)
bond_setup_by_slave(bond_dev, slave_dev);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c79a88b..8cf1d50 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1975,7 +1975,7 @@ extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct
extern int dev_set_promiscuity(struct net_device *dev, int inc);
extern int dev_set_allmulti(struct net_device *dev, int inc);
extern void netdev_state_change(struct net_device *dev);
-extern void netdev_bonding_change(struct net_device *dev,
+extern int netdev_bonding_change(struct net_device *dev,
unsigned long event);
extern void netdev_features_change(struct net_device *dev);
/* Load a device via the kmod */
diff --git a/net/core/dev.c b/net/core/dev.c
index bcc490c..5de4a15 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1084,9 +1084,9 @@ void netdev_state_change(struct net_device *dev)
}
EXPORT_SYMBOL(netdev_state_change);
-void netdev_bonding_change(struct net_device *dev, unsigned long event)
+int netdev_bonding_change(struct net_device *dev, unsigned long event)
{
- call_netdevice_notifiers(event, dev);
+ return call_netdevice_notifiers(event, dev);
}
EXPORT_SYMBOL(netdev_bonding_change);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [net-next-2.6 PATCH 3/3] bridge: forbid slave devices to change it's type
2010-03-09 14:17 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
2010-03-09 14:18 ` [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change Jiri Pirko
2010-03-09 14:19 ` [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type Jiri Pirko
@ 2010-03-09 14:19 ` Jiri Pirko
2010-03-10 8:37 ` [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
3 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-09 14:19 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
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>
---
net/bridge/br_notify.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index 763a3ec..a68c692 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -82,6 +82,9 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
case NETDEV_UNREGISTER:
br_del_if(br, dev);
break;
+
+ case NETDEV_TYPE_CHNG_START:
+ return NOTIFY_BAD;
}
/* Events that may cause spanning tree to refresh */
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change
2010-03-09 14:18 ` [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change Jiri Pirko
@ 2010-03-09 22:00 ` Jiri Pirko
0 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-09 22:00 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
Hmm, maybe even better would be
NETDEV_PRE_TYPE_CHANGE
and
NETDEV_POST_TYPE_CHANGE
Tue, Mar 09, 2010 at 03:18:38PM CET, jpirko@redhat.com wrote:
>Since generally there could be more netdevices changing type other than bonding,
>making this event type name "bonding-unrelated"
>
>Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>---
> drivers/net/bonding/bond_main.c | 4 ++--
> include/linux/notifier.h | 4 ++--
> net/ipv4/devinet.c | 4 ++--
> net/ipv6/addrconf.c | 16 ++++++++--------
> 4 files changed, 14 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 430c022..c1b39b7 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -1480,14 +1480,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
> bond_dev->name,
> bond_dev->type, slave_dev->type);
>
>- netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE);
>+ netdev_bonding_change(bond_dev, NETDEV_TYPE_CHNG_START);
>
> if (slave_dev->type != ARPHRD_ETHER)
> bond_setup_by_slave(bond_dev, slave_dev);
> else
> ether_setup(bond_dev);
>
>- netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE);
>+ netdev_bonding_change(bond_dev, NETDEV_TYPE_CHNG_DONE);
> }
> } else if (bond_dev->type != slave_dev->type) {
> pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n",
>diff --git a/include/linux/notifier.h b/include/linux/notifier.h
>index fee6c2f..c8145c2 100644
>--- a/include/linux/notifier.h
>+++ b/include/linux/notifier.h
>@@ -199,8 +199,8 @@ static inline int notifier_to_errno(int ret)
> #define NETDEV_FEAT_CHANGE 0x000B
> #define NETDEV_BONDING_FAILOVER 0x000C
> #define NETDEV_PRE_UP 0x000D
>-#define NETDEV_BONDING_OLDTYPE 0x000E
>-#define NETDEV_BONDING_NEWTYPE 0x000F
>+#define NETDEV_TYPE_CHNG_START 0x000E
>+#define NETDEV_TYPE_CHNG_DONE 0x000F
> #define NETDEV_POST_INIT 0x0010
> #define NETDEV_UNREGISTER_BATCH 0x0011
>
>diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
>index 51ca946..16bfc45 100644
>--- a/net/ipv4/devinet.c
>+++ b/net/ipv4/devinet.c
>@@ -1095,10 +1095,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
> case NETDEV_DOWN:
> ip_mc_down(in_dev);
> break;
>- case NETDEV_BONDING_OLDTYPE:
>+ case NETDEV_TYPE_CHNG_START:
> ip_mc_unmap(in_dev);
> break;
>- case NETDEV_BONDING_NEWTYPE:
>+ case NETDEV_TYPE_CHNG_DONE:
> ip_mc_remap(in_dev);
> break;
> case NETDEV_CHANGEMTU:
>diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>index 88fd8c5..b2409ac 100644
>--- a/net/ipv6/addrconf.c
>+++ b/net/ipv6/addrconf.c
>@@ -137,8 +137,8 @@ static DEFINE_SPINLOCK(addrconf_verify_lock);
> static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
> static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
>
>-static void addrconf_bonding_change(struct net_device *dev,
>- unsigned long event);
>+static void addrconf_type_change(struct net_device *dev,
>+ unsigned long event);
> static int addrconf_ifdown(struct net_device *dev, int how);
>
> static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags);
>@@ -2582,9 +2582,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
> return notifier_from_errno(err);
> }
> break;
>- case NETDEV_BONDING_OLDTYPE:
>- case NETDEV_BONDING_NEWTYPE:
>- addrconf_bonding_change(dev, event);
>+ case NETDEV_TYPE_CHNG_START:
>+ case NETDEV_TYPE_CHNG_DONE:
>+ addrconf_type_change(dev, event);
> break;
> }
>
>@@ -2599,16 +2599,16 @@ static struct notifier_block ipv6_dev_notf = {
> .priority = 0
> };
>
>-static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
>+static void addrconf_type_change(struct net_device *dev, unsigned long event)
> {
> struct inet6_dev *idev;
> ASSERT_RTNL();
>
> idev = __in6_dev_get(dev);
>
>- if (event == NETDEV_BONDING_NEWTYPE)
>+ if (event == NETDEV_TYPE_CHNG_DONE)
> ipv6_mc_remap(idev);
>- else if (event == NETDEV_BONDING_OLDTYPE)
>+ else if (event == NETDEV_TYPE_CHNG_START)
> ipv6_mc_unmap(idev);
> }
>
>--
>1.6.6.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2
2010-03-09 14:17 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
` (2 preceding siblings ...)
2010-03-09 14:19 ` [net-next-2.6 PATCH 3/3] bridge: forbid slave devices to change it's type Jiri Pirko
@ 2010-03-10 8:37 ` Jiri Pirko
3 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-10 8:37 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger
Reposting.
Tue, Mar 09, 2010 at 03:17:24PM CET, jpirko@redhat.com wrote:
>Reworked version of patch/patchset. This time I use netdevice notifier as
>Stephen suggested. Changed the name of the original ones (NETDEV_BONDING_*TYPE)
>to be more general and reused them. Now the change is refused by brigde only.
>I will follow up with vlan soon.
>
>Jirka
^ permalink raw reply [flat|nested] 7+ messages in thread
* [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type
2010-03-10 20:28 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V3 Jiri Pirko
@ 2010-03-10 20:29 ` Jiri Pirko
0 siblings, 0 replies; 7+ messages in thread
From: Jiri Pirko @ 2010-03-10 20:29 UTC (permalink / raw)
To: netdev; +Cc: fubar, bonding-devel, davem, shemminger, kaber
This patch adds the possibility to refuse the bonding type change for other
subsystems (such as for example bridge, vlan, etc.)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/bonding/bond_main.c | 11 +++++++++--
include/linux/netdevice.h | 2 +-
net/core/dev.c | 4 ++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7eeb187..cbe9e35 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1480,8 +1480,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
bond_dev->name,
bond_dev->type, slave_dev->type);
- netdev_bonding_change(bond_dev,
- NETDEV_PRE_TYPE_CHANGE);
+ res = netdev_bonding_change(bond_dev,
+ NETDEV_PRE_TYPE_CHANGE);
+ res = notifier_to_errno(res);
+ if (res) {
+ pr_err("%s: refused to change device type\n",
+ bond_dev->name);
+ res = -EBUSY;
+ goto err_undo_flags;
+ }
if (slave_dev->type != ARPHRD_ETHER)
bond_setup_by_slave(bond_dev, slave_dev);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c79a88b..8cf1d50 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1975,7 +1975,7 @@ extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct
extern int dev_set_promiscuity(struct net_device *dev, int inc);
extern int dev_set_allmulti(struct net_device *dev, int inc);
extern void netdev_state_change(struct net_device *dev);
-extern void netdev_bonding_change(struct net_device *dev,
+extern int netdev_bonding_change(struct net_device *dev,
unsigned long event);
extern void netdev_features_change(struct net_device *dev);
/* Load a device via the kmod */
diff --git a/net/core/dev.c b/net/core/dev.c
index bcc490c..5de4a15 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1084,9 +1084,9 @@ void netdev_state_change(struct net_device *dev)
}
EXPORT_SYMBOL(netdev_state_change);
-void netdev_bonding_change(struct net_device *dev, unsigned long event)
+int netdev_bonding_change(struct net_device *dev, unsigned long event)
{
- call_netdevice_notifiers(event, dev);
+ return call_netdevice_notifiers(event, dev);
}
EXPORT_SYMBOL(netdev_bonding_change);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-03-10 20:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09 14:17 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
2010-03-09 14:18 ` [net-next-2.6 PATCH 1/3] rename notifier defines for netdev type change Jiri Pirko
2010-03-09 22:00 ` Jiri Pirko
2010-03-09 14:19 ` [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type Jiri Pirko
2010-03-09 14:19 ` [net-next-2.6 PATCH 3/3] bridge: forbid slave devices to change it's type Jiri Pirko
2010-03-10 8:37 ` [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V2 Jiri Pirko
-- strict thread matches above, loose matches on Subject: below --
2010-03-10 20:28 [net-next-2.6 PATCH 0/3] bonding: refuse to change bond type if it's used V3 Jiri Pirko
2010-03-10 20:29 ` [net-next-2.6 PATCH 2/3] bonding: check return value of nofitier when changing type Jiri Pirko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).