From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:34:55
This patchset is used to support sending rntl info to user in some places,
and ensure that whenever those attributes change internally or from sysfs,
that a netlink notification is sent out to listeners.
It also make some adjustment in bridge sysfs so that we can implement this
easily.
I've done some tests on this patchset, like:
[br_sysfs]
1. change all the attribute values of br or brif:
$ echo $value > /sys/class/net/br0/bridge/{*}
$ echo $value > /sys/class/net/br0/brif/eth1/{*}
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
[br_ioctl]
1. in bridge-utils package, do some changes in br_set, let brctl command
use ioctl to set attribute:
if ((ret = set_sysfs(path, value)) < 0) { -->
if (1) {
$ brctl set*
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
This test covers all the attributes that brctl and sysfs support to set.
Xin Long (6):
bridge: add rtnl_lock in fdb_flush in br_sysfs_br.c
bridge: simplify the forward_delay_store by calling store_bridge_parm
bridge: simplify the stp_state_store by calling store_bridge_parm
bridge: a netlink notification should be sent when those attributes
are changed by br_sysfs_br
bridge: a netlink notification should be sent when those attributes
are changed by br_sysfs_if
bridge: a netlink notification should be sent when those attributes
are changed by ioctl
net/bridge/br_ioctl.c | 40 +++++++++++++++-----------
net/bridge/br_sysfs_br.c | 73 ++++++++++++++++++++----------------------------
net/bridge/br_sysfs_if.c | 5 ++--
net/bridge/br_vlan.c | 30 ++++----------------
4 files changed, 62 insertions(+), 86 deletions(-)
--
2.1.0
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:02
In fdb_delete, it will send rtnl msg, so before that, we should
hold rtnl_lock in the function that call it in sysfs.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 5 +++++
1 file changed, 5 insertions(+)
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:06
There are some repetitive codes in forward_delay_store, we can remove
them by calling store_bridge_parm.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:10
There are some repetitive codes in stp_state_store, we can remove
them by calling store_bridge_parm.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:13
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_br. and we also need to remove some
rtnl_trylock in old functions so that we can call it in a common one.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 17 ++++++++---------
net/bridge/br_vlan.c | 30 +++++-------------------------
2 files changed, 13 insertions(+), 34 deletions(-)
@@ -855,21 +839,17 @@ int br_vlan_set_default_pvid(struct net_bridge *br, unsigned long val)if(val>=VLAN_VID_MASK)return-EINVAL;-if(!rtnl_trylock())-returnrestart_syscall();-if(pvid==br->default_pvid)-gotounlock;+gotoout;/* Only allow default pvid change when filtering is disabled */if(br->vlan_enabled){pr_info_once("Please disable vlan filtering to change default_pvid\n");err=-EPERM;-gotounlock;+gotoout;}err=__br_vlan_set_default_pvid(br,pvid);-unlock:-rtnl_unlock();+out:returnerr;}
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:18
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_if, and we also move br_ifinfo_notify out
of store_flag.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_if.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 13:35:22
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for ioctl.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_ioctl.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
@@ -112,7 +112,9 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd)staticintold_dev_ioctl(structnet_device*dev,structifreq*rq,intcmd){structnet_bridge*br=netdev_priv(dev);+structnet_bridge_port*p=NULL;unsignedlongargs[4];+intret=-EOPNOTSUPP;if(copy_from_user(args,rq->ifr_data,sizeof(args)))return-EFAULT;
@@ -182,25 +184,29 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;-returnbr_set_forward_delay(br,args[1]);+ret=br_set_forward_delay(br,args[1]);+break;caseBRCTL_SET_BRIDGE_HELLO_TIME:if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;-returnbr_set_hello_time(br,args[1]);+ret=br_set_hello_time(br,args[1]);+break;caseBRCTL_SET_BRIDGE_MAX_AGE:if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;-returnbr_set_max_age(br,args[1]);+ret=br_set_max_age(br,args[1]);+break;caseBRCTL_SET_AGEING_TIME:if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;-returnbr_set_ageing_time(br,args[1]);+ret=br_set_ageing_time(br,args[1]);+break;caseBRCTL_GET_PORT_INFO:{
@@ -240,20 +246,19 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return-EPERM;br_stp_set_enabled(br,args[1]);-return0;+ret=0;+break;caseBRCTL_SET_BRIDGE_PRIORITY:if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;br_stp_set_bridge_priority(br,args[1]);-return0;+ret=0;+break;caseBRCTL_SET_PORT_PRIORITY:{-structnet_bridge_port*p;-intret;-if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;
@@ -263,14 +268,11 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)elseret=br_stp_set_port_priority(p,args[2]);spin_unlock_bh(&br->lock);-returnret;+break;}caseBRCTL_SET_PATH_COST:{-structnet_bridge_port*p;-intret;-if(!ns_capable(dev_net(dev)->user_ns,CAP_NET_ADMIN))return-EPERM;
@@ -280,8 +282,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)elseret=br_stp_set_path_cost(p,args[2]);spin_unlock_bh(&br->lock);--returnret;+break;}caseBRCTL_GET_FDB_ENTRIES:
@@ -289,7 +290,14 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)args[2],args[3]);}-return-EOPNOTSUPP;+if(!ret){+if(p)+br_ifinfo_notify(RTM_NEWLINK,p);+else+netdev_state_change(br->dev);+}++returnret;}staticintold_deviceless(structnet*net,void__user*uarg)
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 13:55:49
On 03/16/2016 02:34 PM, Xin Long wrote:
In fdb_delete, it will send rtnl msg, so before that, we should
hold rtnl_lock in the function that call it in sysfs.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 5 +++++
1 file changed, 5 insertions(+)
IIRC rtnl_notify() doesn't require rtnl lock to be held so this patch is not
needed
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 13:59:03
On 03/16/2016 02:34 PM, Xin Long wrote:
There are some repetitive codes in forward_delay_store, we can remove
them by calling store_bridge_parm.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
I actually have a similar patch in my tree. :-)
Acked-by: Nikolay Aleksandrov <redacted>
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:06:26
On 03/16/2016 02:34 PM, Xin Long wrote:
There are some repetitive codes in stp_state_store, we can remove
them by calling store_bridge_parm.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
LGTM. Note: it introduces a bug (missing rtnl) until patch 04 is applied.
Acked-by: Nikolay Aleksandrov <redacted>
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:14:22
On 03/16/2016 02:34 PM, Xin Long wrote:
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_br. and we also need to remove some
rtnl_trylock in old functions so that we can call it in a common one.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 17 ++++++++---------
net/bridge/br_vlan.c | 30 +++++-------------------------
2 files changed, 13 insertions(+), 34 deletions(-)
What about the group_addr option ? Changing it will not generate a notification.
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:23:10
On 03/16/2016 02:34 PM, Xin Long wrote:
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_if, and we also move br_ifinfo_notify out
of store_flag.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_if.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Generally looks good, but it creates an inconsistency between bridge fdb_flush
and port fdb_flush since the latter will generate a notification while the
bridge flush will not.
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:28:37
On 03/16/2016 02:34 PM, Xin Long wrote:
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for ioctl.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_ioctl.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 14:29:06
On Wed, Mar 16, 2016 at 10:14 PM, Nikolay Aleksandrov
[off-list ref] wrote:
On 03/16/2016 02:34 PM, Xin Long wrote:
quoted
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_br. and we also need to remove some
rtnl_trylock in old functions so that we can call it in a common one.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 17 ++++++++---------
net/bridge/br_vlan.c | 30 +++++-------------------------
2 files changed, 13 insertions(+), 34 deletions(-)
What about the group_addr option ? Changing it will not generate a notification.
group_addr is not a string-to-long convert in sysfs. so it's hard to use
store_bridge_parm, that's why I didn't modify it.
in group_addr_store():
it also tries to hold rtnl_lock. maybe we can send rtnl msg there.
what do you think?
when I cooked this patch, I was wondering why br_recalculate_fwd_mask
"Must be protected by RTNL."
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:30:23
On 03/16/2016 02:34 PM, Xin Long wrote:
This patchset is used to support sending rntl info to user in some places,
and ensure that whenever those attributes change internally or from sysfs,
that a netlink notification is sent out to listeners.
It also make some adjustment in bridge sysfs so that we can implement this
easily.
I've done some tests on this patchset, like:
[br_sysfs]
1. change all the attribute values of br or brif:
$ echo $value > /sys/class/net/br0/bridge/{*}
$ echo $value > /sys/class/net/br0/brif/eth1/{*}
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
[br_ioctl]
1. in bridge-utils package, do some changes in br_set, let brctl command
use ioctl to set attribute:
if ((ret = set_sysfs(path, value)) < 0) { -->
if (1) {
$ brctl set*
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
This test covers all the attributes that brctl and sysfs support to set.
Please also include the bridge maintainers (CCed).
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:33:18
On 03/16/2016 03:29 PM, Xin Long wrote:
On Wed, Mar 16, 2016 at 10:14 PM, Nikolay Aleksandrov
[off-list ref] wrote:
quoted
On 03/16/2016 02:34 PM, Xin Long wrote:
quoted
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_br. and we also need to remove some
rtnl_trylock in old functions so that we can call it in a common one.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_br.c | 17 ++++++++---------
net/bridge/br_vlan.c | 30 +++++-------------------------
2 files changed, 13 insertions(+), 34 deletions(-)
What about the group_addr option ? Changing it will not generate a notification.
group_addr is not a string-to-long convert in sysfs. so it's hard to use
store_bridge_parm, that's why I didn't modify it.
in group_addr_store():
it also tries to hold rtnl_lock. maybe we can send rtnl msg there.
what do you think?
Sounds good.
when I cooked this patch, I was wondering why br_recalculate_fwd_mask
"Must be protected by RTNL."
vlan_enabled and vlan_proto are changed under rtnl, also this can race with
changing via netlink
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 14:45:13
On Wed, Mar 16, 2016 at 10:23 PM, Nikolay Aleksandrov
[off-list ref] wrote:
On 03/16/2016 02:34 PM, Xin Long wrote:
quoted
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_if, and we also move br_ifinfo_notify out
of store_flag.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_if.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Generally looks good, but it creates an inconsistency between bridge fdb_flush
and port fdb_flush since the latter will generate a notification while the
bridge flush will not.
yeah, because port fdb_flush is called by brport_store(), in the
common function.
do you think it''s redundant if we add a notification in bridge
fdb_flush to keep
consistence with port fdb_flush?
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 14:49:03
On Wed, Mar 16, 2016 at 10:45 PM, Xin Long [off-list ref] wrote:
yeah, because port fdb_flush is called by brport_store(), in the
common function.
do you think it''s redundant if we add a notification in bridge
fdb_flush to keep
consistence with port fdb_flush?
From: Nikolay Aleksandrov <hidden> Date: 2016-03-16 14:49:27
On 03/16/2016 03:45 PM, Xin Long wrote:
On Wed, Mar 16, 2016 at 10:23 PM, Nikolay Aleksandrov
[off-list ref] wrote:
quoted
On 03/16/2016 02:34 PM, Xin Long wrote:
quoted
Now when we change the attributes of bridge or br_port by netlink,
a relevant netlink notification will be sent, but if we change them
by ioctl or sysfs, no notification will be sent.
We should ensure that whenever those attributes change internally or from
sysfs/ioctl, that a netlink notification is sent out to listeners.
Also, NetworkManager will use this in the future to listen for out-of-band
bridge master attribute updates and incorporate them into the runtime
configuration.
This patch is used for br_sysfs_if, and we also move br_ifinfo_notify out
of store_flag.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_if.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Generally looks good, but it creates an inconsistency between bridge fdb_flush
and port fdb_flush since the latter will generate a notification while the
bridge flush will not.
yeah, because port fdb_flush is called by brport_store(), in the
common function.
Right.
do you think it''s redundant if we add a notification in bridge
fdb_flush to keep
consistence with port fdb_flush?
Hmm, technically we're doing this via a sysfs option and the netlink fdb flush
one will generate a notification, so I'd say let's make them all consistent and
make them all generate a notification, and also making the bridge fdb_flush use
the bridge_store_parm should be trivial.
Thanks,
Nik
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 14:58:01
On Wed, Mar 16, 2016 at 10:49 PM, Nikolay Aleksandrov
[off-list ref] wrote:
On 03/16/2016 03:45 PM, Xin Long wrote:
quoted
do you think it''s redundant if we add a notification in bridge
fdb_flush to keep
consistence with port fdb_flush?
Hmm, technically we're doing this via a sysfs option and the netlink fdb flush
one will generate a notification, so I'd say let's make them all consistent and
make them all generate a notification, and also making the bridge fdb_flush use
the bridge_store_parm should be trivial.
okay, I will also make this one use bridge_store_parm.
Thanks
From: Xin Long <lucien.xin@gmail.com> Date: 2016-03-16 14:59:37
On Wed, Mar 16, 2016 at 10:30 PM, Nikolay Aleksandrov
[off-list ref] wrote:
On 03/16/2016 02:34 PM, Xin Long wrote:
quoted
This patchset is used to support sending rntl info to user in some places,
and ensure that whenever those attributes change internally or from sysfs,
that a netlink notification is sent out to listeners.
It also make some adjustment in bridge sysfs so that we can implement this
easily.
I've done some tests on this patchset, like:
[br_sysfs]
1. change all the attribute values of br or brif:
$ echo $value > /sys/class/net/br0/bridge/{*}
$ echo $value > /sys/class/net/br0/brif/eth1/{*}
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
[br_ioctl]
1. in bridge-utils package, do some changes in br_set, let brctl command
use ioctl to set attribute:
if ((ret = set_sysfs(path, value)) < 0) { -->
if (1) {
$ brctl set*
2. meanwhile, on another terminal to observe the msg:
$ bridge monitor
This test covers all the attributes that brctl and sysfs support to set.
Please also include the bridge maintainers (CCed).
From: David Miller <davem@davemloft.net> Date: 2016-03-17 03:35:10
From: Xin Long <lucien.xin@gmail.com>
Date: Wed, 16 Mar 2016 21:34:43 +0800
This patchset is used to support sending rntl info to user in some places,
and ensure that whenever those attributes change internally or from sysfs,
that a netlink notification is sent out to listeners.
This is too late for net-next, please wait until after the merge window.
Thanks.