* [patch net-next-2.6] bonding: use ndo_change_rx_flags callback
@ 2011-08-16 9:30 Jiri Pirko
2011-08-16 10:03 ` Michał Mirosław
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2011-08-16 9:30 UTC (permalink / raw)
To: netdev; +Cc: davem, fubar, andy
Benefit from use of ndo_change_rx_flags in handling change of promisc
and allmulti. No need to store previous state locally.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/bonding/bond_main.c | 44 ++++++++++++--------------------------
drivers/net/bonding/bonding.h | 1 -
2 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 854aa8d..731763a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3686,44 +3686,27 @@ static bool bond_addr_in_mc_list(unsigned char *addr,
return false;
}
-static void bond_set_multicast_list(struct net_device *bond_dev)
+static void bond_change_rx_flags(struct net_device *bond_dev, int change)
{
struct bonding *bond = netdev_priv(bond_dev);
- struct netdev_hw_addr *ha;
- bool found;
- /*
- * Do promisc before checking multicast_mode
- */
- if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC))
- /*
- * FIXME: Need to handle the error when one of the multi-slaves
- * encounters error.
- */
- bond_set_promiscuity(bond, 1);
-
-
- if (!(bond_dev->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC))
- bond_set_promiscuity(bond, -1);
+ if (change & IFF_PROMISC)
+ bond_set_promiscuity(bond,
+ bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
+ if (change & IFF_ALLMULTI)
+ bond_set_allmulti(bond,
+ bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
+}
- /* set allmulti flag to slaves */
- if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI))
- /*
- * FIXME: Need to handle the error when one of the multi-slaves
- * encounters error.
- */
- bond_set_allmulti(bond, 1);
-
-
- if (!(bond_dev->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI))
- bond_set_allmulti(bond, -1);
-
+static void bond_set_multicast_list(struct net_device *bond_dev)
+{
+ struct bonding *bond = netdev_priv(bond_dev);
+ struct netdev_hw_addr *ha;
+ bool found;
read_lock(&bond->lock);
- bond->flags = bond_dev->flags;
-
/* looking for addresses to add to slaves' mc list */
netdev_for_each_mc_addr(ha, bond_dev) {
found = bond_addr_in_mc_list(ha->addr, &bond->mc_list,
@@ -4282,6 +4265,7 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_select_queue = bond_select_queue,
.ndo_get_stats64 = bond_get_stats,
.ndo_do_ioctl = bond_do_ioctl,
+ .ndo_change_rx_flags = bond_change_rx_flags,
.ndo_set_multicast_list = bond_set_multicast_list,
.ndo_change_mtu = bond_change_mtu,
.ndo_set_mac_address = bond_set_mac_address,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 43526a2..e823366 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -234,7 +234,6 @@ struct bonding {
struct netdev_hw_addr_list mc_list;
int (*xmit_hash_policy)(struct sk_buff *, int);
__be32 master_ip;
- u16 flags;
u16 rr_tx_counter;
struct ad_bond_info ad_info;
struct alb_bond_info alb_info;
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch net-next-2.6] bonding: use ndo_change_rx_flags callback
2011-08-16 9:30 [patch net-next-2.6] bonding: use ndo_change_rx_flags callback Jiri Pirko
@ 2011-08-16 10:03 ` Michał Mirosław
2011-08-16 13:15 ` Jiri Pirko
0 siblings, 1 reply; 4+ messages in thread
From: Michał Mirosław @ 2011-08-16 10:03 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, fubar, andy
2011/8/16 Jiri Pirko <jpirko@redhat.com>:
> Benefit from use of ndo_change_rx_flags in handling change of promisc
> and allmulti. No need to store previous state locally.
[...]
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 854aa8d..731763a 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
[...]
> -static void bond_set_multicast_list(struct net_device *bond_dev)
> +static void bond_change_rx_flags(struct net_device *bond_dev, int change)
> {
[...]
> + if (change & IFF_PROMISC)
> + bond_set_promiscuity(bond,
> + bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
Typo: flags & IFF_PROMISC ?
Best Regards,
Michał Mirosław
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch net-next-2.6] bonding: use ndo_change_rx_flags callback
2011-08-16 10:03 ` Michał Mirosław
@ 2011-08-16 13:15 ` Jiri Pirko
2011-08-18 3:18 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2011-08-16 13:15 UTC (permalink / raw)
To: Michał Mirosław; +Cc: netdev, davem, fubar, andy
Tue, Aug 16, 2011 at 12:03:42PM CEST, mirqus@gmail.com wrote:
>2011/8/16 Jiri Pirko <jpirko@redhat.com>:
>> Benefit from use of ndo_change_rx_flags in handling change of promisc
>> and allmulti. No need to store previous state locally.
>[...]
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 854aa8d..731763a 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>[...]
>> -static void bond_set_multicast_list(struct net_device *bond_dev)
>> +static void bond_change_rx_flags(struct net_device *bond_dev, int change)
>> {
>[...]
>> + if (change & IFF_PROMISC)
>> + bond_set_promiscuity(bond,
>> + bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
>
>Typo: flags & IFF_PROMISC ?
Sure, thanks Michał
V2:
Subject: [patch net-next-2.6 v2] bonding: use ndo_change_rx_flags callback
Benefit from use of ndo_change_rx_flags in handling change of promisc
and allmulti. No need to store previous state locally.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
v1->v2: fixed IFF_ALLMULTI/IFF_PROMISC c&p typo
---
drivers/net/bonding/bond_main.c | 44 ++++++++++++--------------------------
drivers/net/bonding/bonding.h | 1 -
2 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 854aa8d..c3e4683 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3686,44 +3686,27 @@ static bool bond_addr_in_mc_list(unsigned char *addr,
return false;
}
-static void bond_set_multicast_list(struct net_device *bond_dev)
+static void bond_change_rx_flags(struct net_device *bond_dev, int change)
{
struct bonding *bond = netdev_priv(bond_dev);
- struct netdev_hw_addr *ha;
- bool found;
- /*
- * Do promisc before checking multicast_mode
- */
- if ((bond_dev->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC))
- /*
- * FIXME: Need to handle the error when one of the multi-slaves
- * encounters error.
- */
- bond_set_promiscuity(bond, 1);
-
-
- if (!(bond_dev->flags & IFF_PROMISC) && (bond->flags & IFF_PROMISC))
- bond_set_promiscuity(bond, -1);
+ if (change & IFF_PROMISC)
+ bond_set_promiscuity(bond,
+ bond_dev->flags & IFF_PROMISC ? 1 : -1);
+ if (change & IFF_ALLMULTI)
+ bond_set_allmulti(bond,
+ bond_dev->flags & IFF_ALLMULTI ? 1 : -1);
+}
- /* set allmulti flag to slaves */
- if ((bond_dev->flags & IFF_ALLMULTI) && !(bond->flags & IFF_ALLMULTI))
- /*
- * FIXME: Need to handle the error when one of the multi-slaves
- * encounters error.
- */
- bond_set_allmulti(bond, 1);
-
-
- if (!(bond_dev->flags & IFF_ALLMULTI) && (bond->flags & IFF_ALLMULTI))
- bond_set_allmulti(bond, -1);
-
+static void bond_set_multicast_list(struct net_device *bond_dev)
+{
+ struct bonding *bond = netdev_priv(bond_dev);
+ struct netdev_hw_addr *ha;
+ bool found;
read_lock(&bond->lock);
- bond->flags = bond_dev->flags;
-
/* looking for addresses to add to slaves' mc list */
netdev_for_each_mc_addr(ha, bond_dev) {
found = bond_addr_in_mc_list(ha->addr, &bond->mc_list,
@@ -4282,6 +4265,7 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_select_queue = bond_select_queue,
.ndo_get_stats64 = bond_get_stats,
.ndo_do_ioctl = bond_do_ioctl,
+ .ndo_change_rx_flags = bond_change_rx_flags,
.ndo_set_multicast_list = bond_set_multicast_list,
.ndo_change_mtu = bond_change_mtu,
.ndo_set_mac_address = bond_set_mac_address,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 43526a2..e823366 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -234,7 +234,6 @@ struct bonding {
struct netdev_hw_addr_list mc_list;
int (*xmit_hash_policy)(struct sk_buff *, int);
__be32 master_ip;
- u16 flags;
u16 rr_tx_counter;
struct ad_bond_info ad_info;
struct alb_bond_info alb_info;
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch net-next-2.6] bonding: use ndo_change_rx_flags callback
2011-08-16 13:15 ` Jiri Pirko
@ 2011-08-18 3:18 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-08-18 3:18 UTC (permalink / raw)
To: jpirko; +Cc: mirqus, netdev, fubar, andy
From: Jiri Pirko <jpirko@redhat.com>
Date: Tue, 16 Aug 2011 15:15:04 +0200
> V2:
>
> Subject: [patch net-next-2.6 v2] bonding: use ndo_change_rx_flags callback
>
> Benefit from use of ndo_change_rx_flags in handling change of promisc
> and allmulti. No need to store previous state locally.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
> v1->v2: fixed IFF_ALLMULTI/IFF_PROMISC c&p typo
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-18 3:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-16 9:30 [patch net-next-2.6] bonding: use ndo_change_rx_flags callback Jiri Pirko
2011-08-16 10:03 ` Michał Mirosław
2011-08-16 13:15 ` Jiri Pirko
2011-08-18 3: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).