* [PATCH net] team: set slave to promisc if team is already in promisc mode
@ 2019-04-04 12:47 Hangbin Liu
2019-04-04 18:35 ` Marcelo Ricardo Leitner
2019-04-08 8:45 ` [PATCHv2 " Hangbin Liu
0 siblings, 2 replies; 4+ messages in thread
From: Hangbin Liu @ 2019-04-04 12:47 UTC (permalink / raw)
To: netdev
Cc: David Miller, Stefano Brivio, Jiri Pirko, Marcelo Ricardo Leitner,
Hangbin Liu
After adding a team interface to bridge, the team interface will enter
promisc mode. Then if we add a new slave to team0, the slave will keep
promisc off. Fix it by setting slave to promisc on if team master is
already in promisc mode, also do the same for allmulti.
Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
drivers/net/team/team.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 6ed96fdfd96d..bbaa198d0960 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1246,6 +1246,23 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
goto err_option_port_add;
}
+ /* set promiscuity level to new slave */
+ if (team->dev->flags & IFF_PROMISC) {
+ err = dev_set_promiscuity(port_dev, 1);
+ if (err)
+ goto err_set_slave_promisc;
+ }
+
+ /* set allmulti level to new slave */
+ if (team->dev->flags & IFF_ALLMULTI) {
+ err = dev_set_allmulti(port_dev, 1);
+ if (err) {
+ if (team->dev->flags & IFF_PROMISC)
+ dev_set_promiscuity(port_dev, -1);
+ goto err_set_slave_promisc;
+ }
+ }
+
netif_addr_lock_bh(dev);
dev_uc_sync_multiple(port_dev, dev);
dev_mc_sync_multiple(port_dev, dev);
@@ -1262,6 +1279,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
return 0;
+err_set_slave_promisc:
+ __team_option_inst_del_port(team, port);
+
err_option_port_add:
team_upper_dev_unlink(team, port);
--
2.19.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] team: set slave to promisc if team is already in promisc mode
2019-04-04 12:47 [PATCH net] team: set slave to promisc if team is already in promisc mode Hangbin Liu
@ 2019-04-04 18:35 ` Marcelo Ricardo Leitner
2019-04-08 8:45 ` [PATCHv2 " Hangbin Liu
1 sibling, 0 replies; 4+ messages in thread
From: Marcelo Ricardo Leitner @ 2019-04-04 18:35 UTC (permalink / raw)
To: Hangbin Liu; +Cc: netdev, David Miller, Stefano Brivio, Jiri Pirko
On Thu, Apr 04, 2019 at 08:47:02PM +0800, Hangbin Liu wrote:
> After adding a team interface to bridge, the team interface will enter
> promisc mode. Then if we add a new slave to team0, the slave will keep
> promisc off. Fix it by setting slave to promisc on if team master is
> already in promisc mode, also do the same for allmulti.
>
> Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> ---
> drivers/net/team/team.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
> index 6ed96fdfd96d..bbaa198d0960 100644
> --- a/drivers/net/team/team.c
> +++ b/drivers/net/team/team.c
> @@ -1246,6 +1246,23 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
> goto err_option_port_add;
> }
>
> + /* set promiscuity level to new slave */
> + if (team->dev->flags & IFF_PROMISC) {
> + err = dev_set_promiscuity(port_dev, 1);
> + if (err)
> + goto err_set_slave_promisc;
> + }
> +
> + /* set allmulti level to new slave */
> + if (team->dev->flags & IFF_ALLMULTI) {
> + err = dev_set_allmulti(port_dev, 1);
> + if (err) {
> + if (team->dev->flags & IFF_PROMISC)
> + dev_set_promiscuity(port_dev, -1);
> + goto err_set_slave_promisc;
> + }
> + }
> +
> netif_addr_lock_bh(dev);
> dev_uc_sync_multiple(port_dev, dev);
> dev_mc_sync_multiple(port_dev, dev);
> @@ -1262,6 +1279,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
>
> return 0;
>
> +err_set_slave_promisc:
> + __team_option_inst_del_port(team, port);
> +
> err_option_port_add:
> team_upper_dev_unlink(team, port);
>
> --
> 2.19.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCHv2 net] team: set slave to promisc if team is already in promisc mode
2019-04-04 12:47 [PATCH net] team: set slave to promisc if team is already in promisc mode Hangbin Liu
2019-04-04 18:35 ` Marcelo Ricardo Leitner
@ 2019-04-08 8:45 ` Hangbin Liu
2019-04-11 2:18 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Hangbin Liu @ 2019-04-08 8:45 UTC (permalink / raw)
To: netdev
Cc: David Miller, Stefano Brivio, Jiri Pirko, Marcelo Ricardo Leitner,
Hangbin Liu
After adding a team interface to bridge, the team interface will enter
promisc mode. Then if we add a new slave to team0, the slave will keep
promisc off. Fix it by setting slave to promisc on if team master is
already in promisc mode, also do the same for allmulti.
v2: add promisc and allmulti checking when delete ports
Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
drivers/net/team/team.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 6ed96fdfd96d..9ce61b019aad 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1246,6 +1246,23 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
goto err_option_port_add;
}
+ /* set promiscuity level to new slave */
+ if (dev->flags & IFF_PROMISC) {
+ err = dev_set_promiscuity(port_dev, 1);
+ if (err)
+ goto err_set_slave_promisc;
+ }
+
+ /* set allmulti level to new slave */
+ if (dev->flags & IFF_ALLMULTI) {
+ err = dev_set_allmulti(port_dev, 1);
+ if (err) {
+ if (dev->flags & IFF_PROMISC)
+ dev_set_promiscuity(port_dev, -1);
+ goto err_set_slave_promisc;
+ }
+ }
+
netif_addr_lock_bh(dev);
dev_uc_sync_multiple(port_dev, dev);
dev_mc_sync_multiple(port_dev, dev);
@@ -1262,6 +1279,9 @@ static int team_port_add(struct team *team, struct net_device *port_dev,
return 0;
+err_set_slave_promisc:
+ __team_option_inst_del_port(team, port);
+
err_option_port_add:
team_upper_dev_unlink(team, port);
@@ -1307,6 +1327,12 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
team_port_disable(team, port);
list_del_rcu(&port->list);
+
+ if (dev->flags & IFF_PROMISC)
+ dev_set_promiscuity(port_dev, -1);
+ if (dev->flags & IFF_ALLMULTI)
+ dev_set_allmulti(port_dev, -1);
+
team_upper_dev_unlink(team, port);
netdev_rx_handler_unregister(port_dev);
team_port_disable_netpoll(port);
--
2.19.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv2 net] team: set slave to promisc if team is already in promisc mode
2019-04-08 8:45 ` [PATCHv2 " Hangbin Liu
@ 2019-04-11 2:18 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-04-11 2:18 UTC (permalink / raw)
To: liuhangbin; +Cc: netdev, sbrivio, jiri, mleitner
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Mon, 8 Apr 2019 16:45:17 +0800
> After adding a team interface to bridge, the team interface will enter
> promisc mode. Then if we add a new slave to team0, the slave will keep
> promisc off. Fix it by setting slave to promisc on if team master is
> already in promisc mode, also do the same for allmulti.
>
> v2: add promisc and allmulti checking when delete ports
>
> Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-11 2:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-04 12:47 [PATCH net] team: set slave to promisc if team is already in promisc mode Hangbin Liu
2019-04-04 18:35 ` Marcelo Ricardo Leitner
2019-04-08 8:45 ` [PATCHv2 " Hangbin Liu
2019-04-11 2:18 ` David Miller
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).