* [patch net-next-2.6 0/8] mostly bonding rx path changes @ 2011-03-05 10:29 Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko ` (7 more replies) 0 siblings, 8 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy This patchset focuses mainly bonding rx path changes. Depends on "fcoe: correct checking for bonding" Jiri Pirko (8): af_packet: use skb->skb_iif instead of orig_dev->ifindex bonding: register slave pointer for rx_handler net: get rid of multiple bond-related netdevice->priv_flags bonding: wrap slave state work bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag bonding: move processing of recv handlers into handle_frame() net: introduce rx_handler results and logic around that net: get rid of orig_dev parameter of packet handlers drivers/block/aoe/aoenet.c | 2 +- drivers/net/bonding/bond_3ad.c | 31 +----- drivers/net/bonding/bond_3ad.h | 4 +- drivers/net/bonding/bond_alb.c | 46 ++------ drivers/net/bonding/bond_alb.h | 1 - drivers/net/bonding/bond_main.c | 217 ++++++++++++------------------------- drivers/net/bonding/bond_sysfs.c | 20 +--- drivers/net/bonding/bonding.h | 64 ++++++----- drivers/net/hamradio/bpqether.c | 4 +- drivers/net/macvlan.c | 11 +- drivers/net/pppoe.c | 4 +- drivers/net/wan/hdlc.c | 2 +- drivers/net/wan/lapbether.c | 2 +- drivers/scsi/fcoe/fcoe.c | 12 +-- include/linux/if.h | 23 ++--- include/linux/netdevice.h | 12 ++- include/linux/skbuff.h | 5 +- include/net/ax25.h | 3 +- include/net/datalink.h | 2 +- include/net/ip.h | 2 +- include/net/ipv6.h | 3 +- include/net/irda/irda.h | 3 +- include/net/llc.h | 8 +- include/net/p8022.h | 3 +- include/net/psnap.h | 3 +- include/net/x25.h | 2 +- net/802/p8022.c | 3 +- net/802/psnap.c | 7 +- net/802/stp.c | 2 +- net/8021q/vlan.h | 2 +- net/8021q/vlan_dev.c | 2 +- net/appletalk/aarp.c | 2 +- net/appletalk/ddp.c | 6 +- net/ax25/ax25_in.c | 2 +- net/batman-adv/hard-interface.c | 6 +- net/bridge/br_input.c | 25 +++-- net/bridge/br_private.h | 2 +- net/caif/caif_dev.c | 2 +- net/can/af_can.c | 2 +- net/core/dev.c | 45 ++++---- net/core/skbuff.c | 1 - net/decnet/af_decnet.c | 2 +- net/decnet/dn_route.c | 2 +- net/dsa/tag_dsa.c | 2 +- net/dsa/tag_edsa.c | 2 +- net/dsa/tag_trailer.c | 2 +- net/econet/af_econet.c | 2 +- net/ieee802154/af_ieee802154.c | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipconfig.c | 13 ++- net/ipv6/ip6_input.c | 3 +- net/ipx/af_ipx.c | 3 +- net/irda/irlap_frame.c | 2 +- net/llc/llc_core.c | 3 +- net/llc/llc_input.c | 8 +- net/packet/af_packet.c | 10 +- net/phonet/af_phonet.c | 3 +- net/tipc/eth_media.c | 2 +- net/x25/x25_dev.c | 2 +- 60 files changed, 268 insertions(+), 397 deletions(-) -- 1.7.4 ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 14:03 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler Jiri Pirko ` (6 subsequent siblings) 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Since skb_iif has the desired value (ifindex of physical device actually received the traffic) use that instead. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- net/packet/af_packet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 5efef5b..b34294e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -627,7 +627,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; if (unlikely(po->origdev)) - sll->sll_ifindex = orig_dev->ifindex; + sll->sll_ifindex = skb->skb_iif; else sll->sll_ifindex = dev->ifindex; @@ -812,7 +812,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; if (unlikely(po->origdev)) - sll->sll_ifindex = orig_dev->ifindex; + sll->sll_ifindex = skb->skb_iif; else sll->sll_ifindex = dev->ifindex; -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex 2011-03-05 10:29 ` [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko @ 2011-03-05 14:03 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:03 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Since skb_iif has the desired value (ifindex of physical device actually > received the traffic) use that instead. This one cause orig_dev to be useless from the af_packet point of view, which is really good. > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > --- > net/packet/af_packet.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c > index 5efef5b..b34294e 100644 > --- a/net/packet/af_packet.c > +++ b/net/packet/af_packet.c > @@ -627,7 +627,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, > sll->sll_protocol = skb->protocol; > sll->sll_pkttype = skb->pkt_type; > if (unlikely(po->origdev)) > - sll->sll_ifindex = orig_dev->ifindex; > + sll->sll_ifindex = skb->skb_iif; > else > sll->sll_ifindex = dev->ifindex; > > @@ -812,7 +812,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, > sll->sll_protocol = skb->protocol; > sll->sll_pkttype = skb->pkt_type; > if (unlikely(po->origdev)) > - sll->sll_ifindex = orig_dev->ifindex; > + sll->sll_ifindex = skb->skb_iif; > else > sll->sll_ifindex = dev->ifindex; > ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 14:06 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko ` (5 subsequent siblings) 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Register slave pointer as rx_handler data. That would eventually prevent need to loop over slave devices to find the right slave. Use synchronize_net to ensure that bond_handle_frame does not get slave structure freed when working with that. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_main.c | 17 +++++++++++------ drivers/net/bonding/bonding.h | 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 0592e6d..1c19368 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1495,21 +1495,22 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, static struct sk_buff *bond_handle_frame(struct sk_buff *skb) { - struct net_device *slave_dev; + struct slave *slave; struct net_device *bond_dev; skb = skb_share_check(skb, GFP_ATOMIC); if (unlikely(!skb)) return NULL; - slave_dev = skb->dev; - bond_dev = ACCESS_ONCE(slave_dev->master); + + slave = bond_slave_get_rcu(skb->dev); + bond_dev = ACCESS_ONCE(slave->dev->master); if (unlikely(!bond_dev)) return skb; if (bond_dev->priv_flags & IFF_MASTER_ARPMON) - slave_dev->last_rx = jiffies; + slave->dev->last_rx = jiffies; - if (bond_should_deliver_exact_match(skb, slave_dev, bond_dev)) { + if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { skb->deliver_no_wcard = 1; return skb; } @@ -1703,7 +1704,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) pr_debug("Error %d calling netdev_set_bond_master\n", res); goto err_restore_mac; } - res = netdev_rx_handler_register(slave_dev, bond_handle_frame, NULL); + res = netdev_rx_handler_register(slave_dev, bond_handle_frame, + new_slave); if (res) { pr_debug("Error %d calling netdev_rx_handler_register\n", res); goto err_unset_master; @@ -1925,6 +1927,7 @@ err_close: err_unreg_rxhandler: netdev_rx_handler_unregister(slave_dev); + synchronize_net(); err_unset_master: netdev_set_bond_master(slave_dev, NULL); @@ -2108,6 +2111,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) } netdev_rx_handler_unregister(slave_dev); + synchronize_net(); netdev_set_bond_master(slave_dev, NULL); slave_disable_netpoll(slave); @@ -2222,6 +2226,7 @@ static int bond_release_all(struct net_device *bond_dev) } netdev_rx_handler_unregister(slave_dev); + synchronize_net(); netdev_set_bond_master(slave_dev, NULL); slave_disable_netpoll(slave); diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index ff4e269..1aac5cd 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -264,6 +264,9 @@ struct bonding { #endif /* CONFIG_DEBUG_FS */ }; +#define bond_slave_get_rcu(dev) \ + ((struct slave *) rcu_dereference(dev->rx_handler_data)) + /** * Returns NULL if the net_device does not belong to any of the bond's slaves * -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler 2011-03-05 10:29 ` [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler Jiri Pirko @ 2011-03-05 14:06 ` Nicolas de Pesloüan 2011-03-05 14:27 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:06 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Register slave pointer as rx_handler data. That would eventually prevent > need to loop over slave devices to find the right slave. > > Use synchronize_net to ensure that bond_handle_frame does not get slave > structure freed when working with that. > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > --- > drivers/net/bonding/bond_main.c | 17 +++++++++++------ > drivers/net/bonding/bonding.h | 3 +++ > 2 files changed, 14 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 0592e6d..1c19368 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1495,21 +1495,22 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, > > static struct sk_buff *bond_handle_frame(struct sk_buff *skb) > { > - struct net_device *slave_dev; > + struct slave *slave; > struct net_device *bond_dev; > > skb = skb_share_check(skb, GFP_ATOMIC); > if (unlikely(!skb)) > return NULL; > - slave_dev = skb->dev; > - bond_dev = ACCESS_ONCE(slave_dev->master); > + > + slave = bond_slave_get_rcu(skb->dev); > + bond_dev = ACCESS_ONCE(slave->dev->master); > if (unlikely(!bond_dev)) > return skb; > > if (bond_dev->priv_flags& IFF_MASTER_ARPMON) > - slave_dev->last_rx = jiffies; > + slave->dev->last_rx = jiffies; > > - if (bond_should_deliver_exact_match(skb, slave_dev, bond_dev)) { > + if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { > skb->deliver_no_wcard = 1; > return skb; > } Up to this point, it looks like cleanup, and unrelated to the title and description of the patch. Anyway, the cleanup looks good to me. Should just be in a separate patch. > @@ -1703,7 +1704,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) > pr_debug("Error %d calling netdev_set_bond_master\n", res); > goto err_restore_mac; > } > - res = netdev_rx_handler_register(slave_dev, bond_handle_frame, NULL); > + res = netdev_rx_handler_register(slave_dev, bond_handle_frame, > + new_slave); And using rx_handler data for this purpose sounds good to me. Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > if (res) { > pr_debug("Error %d calling netdev_rx_handler_register\n", res); > goto err_unset_master; > @@ -1925,6 +1927,7 @@ err_close: > > err_unreg_rxhandler: > netdev_rx_handler_unregister(slave_dev); > + synchronize_net(); > > err_unset_master: > netdev_set_bond_master(slave_dev, NULL); > @@ -2108,6 +2111,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) > } > > netdev_rx_handler_unregister(slave_dev); > + synchronize_net(); > netdev_set_bond_master(slave_dev, NULL); > > slave_disable_netpoll(slave); > @@ -2222,6 +2226,7 @@ static int bond_release_all(struct net_device *bond_dev) > } > > netdev_rx_handler_unregister(slave_dev); > + synchronize_net(); > netdev_set_bond_master(slave_dev, NULL); > > slave_disable_netpoll(slave); > diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h > index ff4e269..1aac5cd 100644 > --- a/drivers/net/bonding/bonding.h > +++ b/drivers/net/bonding/bonding.h > @@ -264,6 +264,9 @@ struct bonding { > #endif /* CONFIG_DEBUG_FS */ > }; > > +#define bond_slave_get_rcu(dev) \ > + ((struct slave *) rcu_dereference(dev->rx_handler_data)) > + > /** > * Returns NULL if the net_device does not belong to any of the bond's slaves > * ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler 2011-03-05 14:06 ` Nicolas de Pesloüan @ 2011-03-05 14:27 ` Jiri Pirko 2011-03-05 14:38 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 14:27 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 03:06:58PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 11:29, Jiri Pirko a écrit : >>Register slave pointer as rx_handler data. That would eventually prevent >>need to loop over slave devices to find the right slave. >> >>Use synchronize_net to ensure that bond_handle_frame does not get slave >>structure freed when working with that. >> >>Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>--- >> drivers/net/bonding/bond_main.c | 17 +++++++++++------ >> drivers/net/bonding/bonding.h | 3 +++ >> 2 files changed, 14 insertions(+), 6 deletions(-) >> >>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >>index 0592e6d..1c19368 100644 >>--- a/drivers/net/bonding/bond_main.c >>+++ b/drivers/net/bonding/bond_main.c >>@@ -1495,21 +1495,22 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, >> >> static struct sk_buff *bond_handle_frame(struct sk_buff *skb) >> { >>- struct net_device *slave_dev; >>+ struct slave *slave; >> struct net_device *bond_dev; >> >> skb = skb_share_check(skb, GFP_ATOMIC); >> if (unlikely(!skb)) >> return NULL; >>- slave_dev = skb->dev; >>- bond_dev = ACCESS_ONCE(slave_dev->master); >>+ >>+ slave = bond_slave_get_rcu(skb->dev); >>+ bond_dev = ACCESS_ONCE(slave->dev->master); >> if (unlikely(!bond_dev)) >> return skb; >> >> if (bond_dev->priv_flags& IFF_MASTER_ARPMON) >>- slave_dev->last_rx = jiffies; >>+ slave->dev->last_rx = jiffies; >> >>- if (bond_should_deliver_exact_match(skb, slave_dev, bond_dev)) { >>+ if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { >> skb->deliver_no_wcard = 1; >> return skb; >> } > >Up to this point, it looks like cleanup, and unrelated to the title and description of the patch. Nope - these are changes connected to the ability to get slave struct via bond_slave_get_rcu. Very related. > >Anyway, the cleanup looks good to me. Should just be in a separate patch. > >>@@ -1703,7 +1704,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) >> pr_debug("Error %d calling netdev_set_bond_master\n", res); >> goto err_restore_mac; >> } >>- res = netdev_rx_handler_register(slave_dev, bond_handle_frame, NULL); >>+ res = netdev_rx_handler_register(slave_dev, bond_handle_frame, >>+ new_slave); > >And using rx_handler data for this purpose sounds good to me. > >Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > >> if (res) { >> pr_debug("Error %d calling netdev_rx_handler_register\n", res); >> goto err_unset_master; >>@@ -1925,6 +1927,7 @@ err_close: >> >> err_unreg_rxhandler: >> netdev_rx_handler_unregister(slave_dev); >>+ synchronize_net(); >> >> err_unset_master: >> netdev_set_bond_master(slave_dev, NULL); >>@@ -2108,6 +2111,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) >> } >> >> netdev_rx_handler_unregister(slave_dev); >>+ synchronize_net(); >> netdev_set_bond_master(slave_dev, NULL); >> >> slave_disable_netpoll(slave); >>@@ -2222,6 +2226,7 @@ static int bond_release_all(struct net_device *bond_dev) >> } >> >> netdev_rx_handler_unregister(slave_dev); >>+ synchronize_net(); >> netdev_set_bond_master(slave_dev, NULL); >> >> slave_disable_netpoll(slave); >>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h >>index ff4e269..1aac5cd 100644 >>--- a/drivers/net/bonding/bonding.h >>+++ b/drivers/net/bonding/bonding.h >>@@ -264,6 +264,9 @@ struct bonding { >> #endif /* CONFIG_DEBUG_FS */ >> }; >> >>+#define bond_slave_get_rcu(dev) \ >>+ ((struct slave *) rcu_dereference(dev->rx_handler_data)) >>+ >> /** >> * Returns NULL if the net_device does not belong to any of the bond's slaves >> * > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler 2011-03-05 14:27 ` Jiri Pirko @ 2011-03-05 14:38 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:38 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 15:27, Jiri Pirko a écrit : > Sat, Mar 05, 2011 at 03:06:58PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 11:29, Jiri Pirko a écrit : >>> Register slave pointer as rx_handler data. That would eventually prevent >>> need to loop over slave devices to find the right slave. >>> >>> Use synchronize_net to ensure that bond_handle_frame does not get slave >>> structure freed when working with that. >>> >>> Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>> --- >>> drivers/net/bonding/bond_main.c | 17 +++++++++++------ >>> drivers/net/bonding/bonding.h | 3 +++ >>> 2 files changed, 14 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >>> index 0592e6d..1c19368 100644 >>> --- a/drivers/net/bonding/bond_main.c >>> +++ b/drivers/net/bonding/bond_main.c >>> @@ -1495,21 +1495,22 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, >>> >>> static struct sk_buff *bond_handle_frame(struct sk_buff *skb) >>> { >>> - struct net_device *slave_dev; >>> + struct slave *slave; >>> struct net_device *bond_dev; >>> >>> skb = skb_share_check(skb, GFP_ATOMIC); >>> if (unlikely(!skb)) >>> return NULL; >>> - slave_dev = skb->dev; >>> - bond_dev = ACCESS_ONCE(slave_dev->master); >>> + >>> + slave = bond_slave_get_rcu(skb->dev); >>> + bond_dev = ACCESS_ONCE(slave->dev->master); >>> if (unlikely(!bond_dev)) >>> return skb; >>> >>> if (bond_dev->priv_flags& IFF_MASTER_ARPMON) >>> - slave_dev->last_rx = jiffies; >>> + slave->dev->last_rx = jiffies; >>> >>> - if (bond_should_deliver_exact_match(skb, slave_dev, bond_dev)) { >>> + if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { >>> skb->deliver_no_wcard = 1; >>> return skb; >>> } >> >> Up to this point, it looks like cleanup, and unrelated to the title and description of the patch. > > Nope - these are changes connected to the ability to get slave struct > via bond_slave_get_rcu. Very related. Agreed. >> >> Anyway, the cleanup looks good to me. Should just be in a separate patch. >> >>> @@ -1703,7 +1704,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) >>> pr_debug("Error %d calling netdev_set_bond_master\n", res); >>> goto err_restore_mac; >>> } >>> - res = netdev_rx_handler_register(slave_dev, bond_handle_frame, NULL); >>> + res = netdev_rx_handler_register(slave_dev, bond_handle_frame, >>> + new_slave); >> >> And using rx_handler data for this purpose sounds good to me. >> >> Reviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr> >> >>> if (res) { >>> pr_debug("Error %d calling netdev_rx_handler_register\n", res); >>> goto err_unset_master; >>> @@ -1925,6 +1927,7 @@ err_close: >>> >>> err_unreg_rxhandler: >>> netdev_rx_handler_unregister(slave_dev); >>> + synchronize_net(); >>> >>> err_unset_master: >>> netdev_set_bond_master(slave_dev, NULL); >>> @@ -2108,6 +2111,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) >>> } >>> >>> netdev_rx_handler_unregister(slave_dev); >>> + synchronize_net(); >>> netdev_set_bond_master(slave_dev, NULL); >>> >>> slave_disable_netpoll(slave); >>> @@ -2222,6 +2226,7 @@ static int bond_release_all(struct net_device *bond_dev) >>> } >>> >>> netdev_rx_handler_unregister(slave_dev); >>> + synchronize_net(); >>> netdev_set_bond_master(slave_dev, NULL); >>> >>> slave_disable_netpoll(slave); >>> diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h >>> index ff4e269..1aac5cd 100644 >>> --- a/drivers/net/bonding/bonding.h >>> +++ b/drivers/net/bonding/bonding.h >>> @@ -264,6 +264,9 @@ struct bonding { >>> #endif /* CONFIG_DEBUG_FS */ >>> }; >>> >>> +#define bond_slave_get_rcu(dev) \ >>> + ((struct slave *) rcu_dereference(dev->rx_handler_data)) >>> + >>> /** >>> * Returns NULL if the net_device does not belong to any of the bond's slaves >>> * >> > ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 14:14 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 4/8] bonding: wrap slave state work Jiri Pirko ` (4 subsequent siblings) 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Now when bond-related code is moved from net/core/dev.c into bonding code, multiple priv_flags are not needed anymore. So toss them out. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_main.c | 33 ++++++++++++++------------------- drivers/net/bonding/bond_sysfs.c | 8 -------- drivers/net/bonding/bonding.h | 24 +----------------------- include/linux/if.h | 22 +++++++++------------- 4 files changed, 24 insertions(+), 63 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 1c19368..7923184 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1471,20 +1471,20 @@ static void bond_setup_by_slave(struct net_device *bond_dev, * ARP on active-backup slaves with arp_validate enabled. */ static bool bond_should_deliver_exact_match(struct sk_buff *skb, - struct net_device *slave_dev, - struct net_device *bond_dev) + struct slave *slave, + struct bonding *bond) { - if (slave_dev->priv_flags & IFF_SLAVE_INACTIVE) { - if (slave_dev->priv_flags & IFF_SLAVE_NEEDARP && + if (slave->dev->priv_flags & IFF_SLAVE_INACTIVE) { + if (slave_do_arp_validate(bond, slave) && skb->protocol == __cpu_to_be16(ETH_P_ARP)) return false; - if (bond_dev->priv_flags & IFF_MASTER_ALB && + if (bond->params.mode == BOND_MODE_ALB && skb->pkt_type != PACKET_BROADCAST && skb->pkt_type != PACKET_MULTICAST) return false; - if (bond_dev->priv_flags & IFF_MASTER_8023AD && + if (bond->params.mode == BOND_MODE_8023AD && skb->protocol == __cpu_to_be16(ETH_P_SLOW)) return false; @@ -1497,6 +1497,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) { struct slave *slave; struct net_device *bond_dev; + struct bonding *bond; skb = skb_share_check(skb, GFP_ATOMIC); if (unlikely(!skb)) @@ -1507,17 +1508,19 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) if (unlikely(!bond_dev)) return skb; - if (bond_dev->priv_flags & IFF_MASTER_ARPMON) + bond = netdev_priv(bond_dev); + + if (bond->params.arp_interval) slave->dev->last_rx = jiffies; - if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { + if (bond_should_deliver_exact_match(skb, slave, bond)) { skb->deliver_no_wcard = 1; return skb; } skb->dev = bond_dev; - if (bond_dev->priv_flags & IFF_MASTER_ALB && + if (bond->params.mode == BOND_MODE_ALB && bond_dev->priv_flags & IFF_BRIDGE_PORT && skb->pkt_type == PACKET_HOST) { u16 *dest = (u16 *) eth_hdr(skb)->h_dest; @@ -2128,9 +2131,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) dev_set_mtu(slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | - IFF_SLAVE_INACTIVE | IFF_BONDING | - IFF_SLAVE_NEEDARP); + slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_BONDING); kfree(slave); @@ -2241,8 +2242,7 @@ static int bond_release_all(struct net_device *bond_dev) dev_set_mac_address(slave_dev, &addr); } - slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | - IFF_SLAVE_INACTIVE); + slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE; kfree(slave); @@ -4718,11 +4718,9 @@ void bond_set_mode_ops(struct bonding *bond, int mode) case BOND_MODE_BROADCAST: break; case BOND_MODE_8023AD: - bond_set_master_3ad_flags(bond); bond_set_xmit_hash_policy(bond); break; case BOND_MODE_ALB: - bond_set_master_alb_flags(bond); /* FALLTHRU */ case BOND_MODE_TLB: break; @@ -4813,9 +4811,6 @@ static void bond_setup(struct net_device *bond_dev) bond_dev->priv_flags |= IFF_BONDING; bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; - if (bond->params.arp_interval) - bond_dev->priv_flags |= IFF_MASTER_ARPMON; - /* At first, we block adding VLANs. That's the only way to * prevent problems that occur when adding VLANs over an * empty bond. The block will be removed once non-challenged diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 72bb0f6..05e0ae5 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -322,11 +322,6 @@ static ssize_t bonding_store_mode(struct device *d, ret = -EINVAL; goto out; } - if (bond->params.mode == BOND_MODE_8023AD) - bond_unset_master_3ad_flags(bond); - - if (bond->params.mode == BOND_MODE_ALB) - bond_unset_master_alb_flags(bond); bond->params.mode = new_value; bond_set_mode_ops(bond, bond->params.mode); @@ -527,8 +522,6 @@ static ssize_t bonding_store_arp_interval(struct device *d, pr_info("%s: Setting ARP monitoring interval to %d.\n", bond->dev->name, new_value); bond->params.arp_interval = new_value; - if (bond->params.arp_interval) - bond->dev->priv_flags |= IFF_MASTER_ARPMON; if (bond->params.miimon) { pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", bond->dev->name, bond->dev->name); @@ -1004,7 +997,6 @@ static ssize_t bonding_store_miimon(struct device *d, pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", bond->dev->name); bond->params.arp_interval = 0; - bond->dev->priv_flags &= ~IFF_MASTER_ARPMON; if (bond->params.arp_validate) { bond_unregister_arp(bond); bond->params.arp_validate = diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 1aac5cd..ddee62f 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -354,34 +354,12 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) slave->state = BOND_STATE_BACKUP; if (!bond->params.all_slaves_active) slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; - if (slave_do_arp_validate(bond, slave)) - slave->dev->priv_flags |= IFF_SLAVE_NEEDARP; } static inline void bond_set_slave_active_flags(struct slave *slave) { slave->state = BOND_STATE_ACTIVE; - slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_SLAVE_NEEDARP); -} - -static inline void bond_set_master_3ad_flags(struct bonding *bond) -{ - bond->dev->priv_flags |= IFF_MASTER_8023AD; -} - -static inline void bond_unset_master_3ad_flags(struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_8023AD; -} - -static inline void bond_set_master_alb_flags(struct bonding *bond) -{ - bond->dev->priv_flags |= IFF_MASTER_ALB; -} - -static inline void bond_unset_master_alb_flags(struct bonding *bond) -{ - bond->dev->priv_flags &= ~IFF_MASTER_ALB; + slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; } struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); diff --git a/include/linux/if.h b/include/linux/if.h index 3bc63e6..2fdd47a 100644 --- a/include/linux/if.h +++ b/include/linux/if.h @@ -60,21 +60,17 @@ #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ #define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ -#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ -#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ -#define IFF_BONDING 0x20 /* bonding master or slave */ -#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ -#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */ -#define IFF_MASTER_ARPMON 0x100 /* bonding master, ARP mon in use */ -#define IFF_WAN_HDLC 0x200 /* WAN HDLC device */ -#define IFF_XMIT_DST_RELEASE 0x400 /* dev_hard_start_xmit() is allowed to +#define IFF_BONDING 0x8 /* bonding master or slave */ +#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ +#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ +#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to * release skb->dst */ -#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ -#define IFF_DISABLE_NETPOLL 0x1000 /* disable netpoll at run-time */ -#define IFF_MACVLAN_PORT 0x2000 /* device used as macvlan port */ -#define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */ -#define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch +#define IFF_DONT_BRIDGE 0x80 /* disallow bridging this ether dev */ +#define IFF_DISABLE_NETPOLL 0x100 /* disable netpoll at run-time */ +#define IFF_MACVLAN_PORT 0x200 /* device used as macvlan port */ +#define IFF_BRIDGE_PORT 0x400 /* device used as bridge port */ +#define IFF_OVS_DATAPATH 0x800 /* device used as Open vSwitch * datapath port */ #define IF_GET_IFACE 0x0001 /* for querying only */ -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags 2011-03-05 10:29 ` [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko @ 2011-03-05 14:14 ` Nicolas de Pesloüan 2011-03-05 14:37 ` Ben Hutchings 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:14 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Now when bond-related code is moved from net/core/dev.c into bonding > code, multiple priv_flags are not needed anymore. So toss them out. Agreed. See at the end for a single comment. > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > --- > drivers/net/bonding/bond_main.c | 33 ++++++++++++++------------------- > drivers/net/bonding/bond_sysfs.c | 8 -------- > drivers/net/bonding/bonding.h | 24 +----------------------- > include/linux/if.h | 22 +++++++++------------- > 4 files changed, 24 insertions(+), 63 deletions(-) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 1c19368..7923184 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1471,20 +1471,20 @@ static void bond_setup_by_slave(struct net_device *bond_dev, > * ARP on active-backup slaves with arp_validate enabled. > */ > static bool bond_should_deliver_exact_match(struct sk_buff *skb, > - struct net_device *slave_dev, > - struct net_device *bond_dev) > + struct slave *slave, > + struct bonding *bond) > { > - if (slave_dev->priv_flags& IFF_SLAVE_INACTIVE) { > - if (slave_dev->priv_flags& IFF_SLAVE_NEEDARP&& > + if (slave->dev->priv_flags& IFF_SLAVE_INACTIVE) { > + if (slave_do_arp_validate(bond, slave)&& > skb->protocol == __cpu_to_be16(ETH_P_ARP)) > return false; > > - if (bond_dev->priv_flags& IFF_MASTER_ALB&& > + if (bond->params.mode == BOND_MODE_ALB&& > skb->pkt_type != PACKET_BROADCAST&& > skb->pkt_type != PACKET_MULTICAST) > return false; > > - if (bond_dev->priv_flags& IFF_MASTER_8023AD&& > + if (bond->params.mode == BOND_MODE_8023AD&& > skb->protocol == __cpu_to_be16(ETH_P_SLOW)) > return false; > > @@ -1497,6 +1497,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) > { > struct slave *slave; > struct net_device *bond_dev; > + struct bonding *bond; > > skb = skb_share_check(skb, GFP_ATOMIC); > if (unlikely(!skb)) > @@ -1507,17 +1508,19 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) > if (unlikely(!bond_dev)) > return skb; > > - if (bond_dev->priv_flags& IFF_MASTER_ARPMON) > + bond = netdev_priv(bond_dev); > + > + if (bond->params.arp_interval) > slave->dev->last_rx = jiffies; > > - if (bond_should_deliver_exact_match(skb, slave->dev, bond_dev)) { > + if (bond_should_deliver_exact_match(skb, slave, bond)) { > skb->deliver_no_wcard = 1; > return skb; > } > > skb->dev = bond_dev; > > - if (bond_dev->priv_flags& IFF_MASTER_ALB&& > + if (bond->params.mode == BOND_MODE_ALB&& > bond_dev->priv_flags& IFF_BRIDGE_PORT&& > skb->pkt_type == PACKET_HOST) { > u16 *dest = (u16 *) eth_hdr(skb)->h_dest; > @@ -2128,9 +2131,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) > > dev_set_mtu(slave_dev, slave->original_mtu); > > - slave_dev->priv_flags&= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | > - IFF_SLAVE_INACTIVE | IFF_BONDING | > - IFF_SLAVE_NEEDARP); > + slave_dev->priv_flags&= ~(IFF_SLAVE_INACTIVE | IFF_BONDING); > > kfree(slave); > > @@ -2241,8 +2242,7 @@ static int bond_release_all(struct net_device *bond_dev) > dev_set_mac_address(slave_dev,&addr); > } > > - slave_dev->priv_flags&= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | > - IFF_SLAVE_INACTIVE); > + slave_dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > > kfree(slave); > > @@ -4718,11 +4718,9 @@ void bond_set_mode_ops(struct bonding *bond, int mode) > case BOND_MODE_BROADCAST: > break; > case BOND_MODE_8023AD: > - bond_set_master_3ad_flags(bond); > bond_set_xmit_hash_policy(bond); > break; > case BOND_MODE_ALB: > - bond_set_master_alb_flags(bond); > /* FALLTHRU */ > case BOND_MODE_TLB: > break; > @@ -4813,9 +4811,6 @@ static void bond_setup(struct net_device *bond_dev) > bond_dev->priv_flags |= IFF_BONDING; > bond_dev->priv_flags&= ~IFF_XMIT_DST_RELEASE; > > - if (bond->params.arp_interval) > - bond_dev->priv_flags |= IFF_MASTER_ARPMON; > - > /* At first, we block adding VLANs. That's the only way to > * prevent problems that occur when adding VLANs over an > * empty bond. The block will be removed once non-challenged > diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c > index 72bb0f6..05e0ae5 100644 > --- a/drivers/net/bonding/bond_sysfs.c > +++ b/drivers/net/bonding/bond_sysfs.c > @@ -322,11 +322,6 @@ static ssize_t bonding_store_mode(struct device *d, > ret = -EINVAL; > goto out; > } > - if (bond->params.mode == BOND_MODE_8023AD) > - bond_unset_master_3ad_flags(bond); > - > - if (bond->params.mode == BOND_MODE_ALB) > - bond_unset_master_alb_flags(bond); > > bond->params.mode = new_value; > bond_set_mode_ops(bond, bond->params.mode); > @@ -527,8 +522,6 @@ static ssize_t bonding_store_arp_interval(struct device *d, > pr_info("%s: Setting ARP monitoring interval to %d.\n", > bond->dev->name, new_value); > bond->params.arp_interval = new_value; > - if (bond->params.arp_interval) > - bond->dev->priv_flags |= IFF_MASTER_ARPMON; > if (bond->params.miimon) { > pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", > bond->dev->name, bond->dev->name); > @@ -1004,7 +997,6 @@ static ssize_t bonding_store_miimon(struct device *d, > pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", > bond->dev->name); > bond->params.arp_interval = 0; > - bond->dev->priv_flags&= ~IFF_MASTER_ARPMON; > if (bond->params.arp_validate) { > bond_unregister_arp(bond); > bond->params.arp_validate = > diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h > index 1aac5cd..ddee62f 100644 > --- a/drivers/net/bonding/bonding.h > +++ b/drivers/net/bonding/bonding.h > @@ -354,34 +354,12 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) > slave->state = BOND_STATE_BACKUP; > if (!bond->params.all_slaves_active) > slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; > - if (slave_do_arp_validate(bond, slave)) > - slave->dev->priv_flags |= IFF_SLAVE_NEEDARP; > } > > static inline void bond_set_slave_active_flags(struct slave *slave) > { > slave->state = BOND_STATE_ACTIVE; > - slave->dev->priv_flags&= ~(IFF_SLAVE_INACTIVE | IFF_SLAVE_NEEDARP); > -} > - > -static inline void bond_set_master_3ad_flags(struct bonding *bond) > -{ > - bond->dev->priv_flags |= IFF_MASTER_8023AD; > -} > - > -static inline void bond_unset_master_3ad_flags(struct bonding *bond) > -{ > - bond->dev->priv_flags&= ~IFF_MASTER_8023AD; > -} > - > -static inline void bond_set_master_alb_flags(struct bonding *bond) > -{ > - bond->dev->priv_flags |= IFF_MASTER_ALB; > -} > - > -static inline void bond_unset_master_alb_flags(struct bonding *bond) > -{ > - bond->dev->priv_flags&= ~IFF_MASTER_ALB; > + slave->dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > } > > struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); > diff --git a/include/linux/if.h b/include/linux/if.h > index 3bc63e6..2fdd47a 100644 > --- a/include/linux/if.h > +++ b/include/linux/if.h > @@ -60,21 +60,17 @@ > #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ > #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ > #define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ > -#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ > -#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ > -#define IFF_BONDING 0x20 /* bonding master or slave */ > -#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ > -#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */ > -#define IFF_MASTER_ARPMON 0x100 /* bonding master, ARP mon in use */ > -#define IFF_WAN_HDLC 0x200 /* WAN HDLC device */ > -#define IFF_XMIT_DST_RELEASE 0x400 /* dev_hard_start_xmit() is allowed to > +#define IFF_BONDING 0x8 /* bonding master or slave */ > +#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ > +#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ > +#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to > * release skb->dst > */ Why did you changed those values? Aren't those exposed to userland? Just removing the unused one sounds good to me. > -#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ > -#define IFF_DISABLE_NETPOLL 0x1000 /* disable netpoll at run-time */ > -#define IFF_MACVLAN_PORT 0x2000 /* device used as macvlan port */ > -#define IFF_BRIDGE_PORT 0x4000 /* device used as bridge port */ > -#define IFF_OVS_DATAPATH 0x8000 /* device used as Open vSwitch > +#define IFF_DONT_BRIDGE 0x80 /* disallow bridging this ether dev */ > +#define IFF_DISABLE_NETPOLL 0x100 /* disable netpoll at run-time */ > +#define IFF_MACVLAN_PORT 0x200 /* device used as macvlan port */ > +#define IFF_BRIDGE_PORT 0x400 /* device used as bridge port */ > +#define IFF_OVS_DATAPATH 0x800 /* device used as Open vSwitch > * datapath port */ > > #define IF_GET_IFACE 0x0001 /* for querying only */ ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags 2011-03-05 14:14 ` Nicolas de Pesloüan @ 2011-03-05 14:37 ` Ben Hutchings 2011-03-05 14:46 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Ben Hutchings @ 2011-03-05 14:37 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy On Sat, 2011-03-05 at 15:14 +0100, Nicolas de Pesloüan wrote: > Le 05/03/2011 11:29, Jiri Pirko a écrit : [...] > > --- a/include/linux/if.h > > +++ b/include/linux/if.h > > @@ -60,21 +60,17 @@ > > #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ > > #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ > > #define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ > > -#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ > > -#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ > > -#define IFF_BONDING 0x20 /* bonding master or slave */ > > -#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ > > -#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */ > > -#define IFF_MASTER_ARPMON 0x100 /* bonding master, ARP mon in use */ > > -#define IFF_WAN_HDLC 0x200 /* WAN HDLC device */ > > -#define IFF_XMIT_DST_RELEASE 0x400 /* dev_hard_start_xmit() is allowed to > > +#define IFF_BONDING 0x8 /* bonding master or slave */ > > +#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ > > +#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ > > +#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to > > * release skb->dst > > */ > > Why did you changed those values? Aren't those exposed to userland? Just removing the unused one > sounds good to me. [...] Look just one line further up: /* Private (from user) interface flags (netdevice->priv_flags). */ Maybe they should have a prefix IFPF_ instead of IFF_ though. Ben. -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags 2011-03-05 14:37 ` Ben Hutchings @ 2011-03-05 14:46 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:46 UTC (permalink / raw) To: Ben Hutchings Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 15:37, Ben Hutchings a écrit : > On Sat, 2011-03-05 at 15:14 +0100, Nicolas de Pesloüan wrote: >> Le 05/03/2011 11:29, Jiri Pirko a écrit : > [...] >>> --- a/include/linux/if.h >>> +++ b/include/linux/if.h >>> @@ -60,21 +60,17 @@ >>> #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ >>> #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ >>> #define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ >>> -#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ >>> -#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ >>> -#define IFF_BONDING 0x20 /* bonding master or slave */ >>> -#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ >>> -#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */ >>> -#define IFF_MASTER_ARPMON 0x100 /* bonding master, ARP mon in use */ >>> -#define IFF_WAN_HDLC 0x200 /* WAN HDLC device */ >>> -#define IFF_XMIT_DST_RELEASE 0x400 /* dev_hard_start_xmit() is allowed to >>> +#define IFF_BONDING 0x8 /* bonding master or slave */ >>> +#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ >>> +#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ >>> +#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to >>> * release skb->dst >>> */ >> >> Why did you changed those values? Aren't those exposed to userland? Just removing the unused one >> sounds good to me. > [...] > > Look just one line further up: > > /* Private (from user) interface flags (netdevice->priv_flags). */ > > Maybe they should have a prefix IFPF_ instead of IFF_ though. > > Ben. Yes, I noticed it while reviewing the next one. Sorry for the noise. So, Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko ` (2 preceding siblings ...) 2011-03-05 10:29 ` [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 15:21 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko ` (3 subsequent siblings) 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy transfers slave->state into slave->backup (that it's going to transfer into bitfield. Introduce wrapper inlines to do the work with it. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_3ad.c | 2 +- drivers/net/bonding/bond_main.c | 36 ++++++++++++++++++------------------ drivers/net/bonding/bond_sysfs.c | 2 +- drivers/net/bonding/bonding.h | 31 ++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 1024ae1..047af0b 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -246,7 +246,7 @@ static inline void __enable_port(struct port *port) */ static inline int __port_is_enabled(struct port *port) { - return port->slave->state == BOND_STATE_ACTIVE; + return bond_is_active_slave(port->slave); } /** diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7923184..62020a7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1872,7 +1872,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) break; case BOND_MODE_TLB: case BOND_MODE_ALB: - new_slave->state = BOND_STATE_ACTIVE; + bond_set_active_slave(new_slave); bond_set_slave_inactive_flags(new_slave); bond_select_active_slave(bond); break; @@ -1880,7 +1880,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) pr_debug("This slave is always active in trunk mode\n"); /* always active in trunk mode */ - new_slave->state = BOND_STATE_ACTIVE; + bond_set_active_slave(new_slave); /* In trunking mode there is little meaning to curr_active_slave * anyway (it holds no special properties of the bond device), @@ -1918,7 +1918,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) pr_info("%s: enslaving %s as a%s interface with a%s link.\n", bond_dev->name, slave_dev->name, - new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup", + bond_is_active_slave(new_slave) ? "n active" : " backup", new_slave->link != BOND_LINK_DOWN ? "n up" : " down"); /* enslave is successful */ @@ -2016,7 +2016,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) pr_info("%s: releasing %s interface %s\n", bond_dev->name, - (slave->state == BOND_STATE_ACTIVE) ? "active" : "backup", + bond_is_active_slave(slave) ? "active" : "backup", slave_dev->name); oldcurrent = bond->curr_active_slave; @@ -2357,7 +2357,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in res = 0; strcpy(info->slave_name, slave->dev->name); info->link = slave->link; - info->state = slave->state; + info->state = bond_slave_state(slave); info->link_failure_count = slave->link_failure_count; break; } @@ -2396,7 +2396,7 @@ static int bond_miimon_inspect(struct bonding *bond) bond->dev->name, (bond->params.mode == BOND_MODE_ACTIVEBACKUP) ? - ((slave->state == BOND_STATE_ACTIVE) ? + (bond_is_active_slave(slave) ? "active " : "backup ") : "", slave->dev->name, bond->params.downdelay * bond->params.miimon); @@ -2487,13 +2487,13 @@ static void bond_miimon_commit(struct bonding *bond) if (bond->params.mode == BOND_MODE_8023AD) { /* prevent it from being the active one */ - slave->state = BOND_STATE_BACKUP; + bond_set_backup_slave(slave); } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) { /* make it immediately active */ - slave->state = BOND_STATE_ACTIVE; + bond_set_active_slave(slave); } else if (slave != bond->primary_slave) { /* prevent it from being the active one */ - slave->state = BOND_STATE_BACKUP; + bond_set_backup_slave(slave); } bond_update_speed_duplex(slave); @@ -2871,7 +2871,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack memcpy(&tip, arp_ptr, 4); pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", - bond->dev->name, slave->dev->name, slave->state, + bond->dev->name, slave->dev->name, bond_slave_state(slave), bond->params.arp_validate, slave_do_arp_validate(bond, slave), &sip, &tip); @@ -2883,7 +2883,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack * the active, through one switch, the router, then the other * switch before reaching the backup. */ - if (slave->state == BOND_STATE_ACTIVE) + if (bond_is_active_slave(slave)) bond_validate_arp(bond, slave, sip, tip); else bond_validate_arp(bond, slave, tip, sip); @@ -2945,7 +2945,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) slave->dev->last_rx + delta_in_ticks)) { slave->link = BOND_LINK_UP; - slave->state = BOND_STATE_ACTIVE; + bond_set_active_slave(slave); /* primary_slave has no meaning in round-robin * mode. the window of a slave being up and @@ -2978,7 +2978,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) slave->dev->last_rx + 2 * delta_in_ticks)) { slave->link = BOND_LINK_DOWN; - slave->state = BOND_STATE_BACKUP; + bond_set_backup_slave(slave); if (slave->link_failure_count < UINT_MAX) slave->link_failure_count++; @@ -3072,7 +3072,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) * gives each slave a chance to tx/rx traffic * before being taken out */ - if (slave->state == BOND_STATE_BACKUP && + if (!bond_is_active_slave(slave) && !bond->current_arp_slave && !time_in_range(jiffies, slave_last_rx(bond, slave) - delta_in_ticks, @@ -3089,7 +3089,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) * the bond has an IP address) */ trans_start = dev_trans_start(slave->dev); - if ((slave->state == BOND_STATE_ACTIVE) && + if (bond_is_active_slave(slave) && (!time_in_range(jiffies, trans_start - delta_in_ticks, trans_start + 2 * delta_in_ticks) || @@ -4446,7 +4446,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev bond_for_each_slave_from(bond, slave, i, start_at) { if (IS_UP(slave->dev) && (slave->link == BOND_LINK_UP) && - (slave->state == BOND_STATE_ACTIVE)) { + bond_is_active_slave(slave)) { res = bond_dev_queue_xmit(bond, skb, slave->dev); break; } @@ -4523,7 +4523,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) bond_for_each_slave_from(bond, slave, i, start_at) { if (IS_UP(slave->dev) && (slave->link == BOND_LINK_UP) && - (slave->state == BOND_STATE_ACTIVE)) { + bond_is_active_slave(slave)) { res = bond_dev_queue_xmit(bond, skb, slave->dev); break; } @@ -4564,7 +4564,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) bond_for_each_slave_from(bond, slave, i, start_at) { if (IS_UP(slave->dev) && (slave->link == BOND_LINK_UP) && - (slave->state == BOND_STATE_ACTIVE)) { + bond_is_active_slave(slave)) { if (tx_dev) { struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); if (!skb2) { diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 05e0ae5..344d23f 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -1579,7 +1579,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, } bond_for_each_slave(bond, slave, i) { - if (slave->state == BOND_STATE_BACKUP) { + if (!bond_is_active_slave(slave)) { if (new_value) slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; else diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index ddee62f..8a3718b 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -53,7 +53,7 @@ (((slave)->dev->flags & IFF_UP) && \ netif_running((slave)->dev) && \ ((slave)->link == BOND_LINK_UP) && \ - ((slave)->state == BOND_STATE_ACTIVE)) + bond_is_active_slave(slave)) #define USES_PRIMARY(mode) \ @@ -190,7 +190,8 @@ struct slave { unsigned long last_arp_rx; s8 link; /* one of BOND_LINK_XXXX */ s8 new_link; - s8 state; /* one of BOND_STATE_XXXX */ + u8 backup; /* indicates backup slave. Value corresponds with + BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ u32 original_mtu; u32 link_failure_count; u8 perm_hwaddr[ETH_ALEN]; @@ -302,6 +303,26 @@ static inline bool bond_is_lb(const struct bonding *bond) bond->params.mode == BOND_MODE_ALB); } +static inline void bond_set_active_slave(struct slave *slave) +{ + slave->backup = 0; +} + +static inline void bond_set_backup_slave(struct slave *slave) +{ + slave->backup = 1; +} + +static inline int bond_slave_state(struct slave *slave) +{ + return slave->backup; +} + +static inline bool bond_is_active_slave(struct slave *slave) +{ + return !bond_slave_state(slave); +} + #define BOND_PRI_RESELECT_ALWAYS 0 #define BOND_PRI_RESELECT_BETTER 1 #define BOND_PRI_RESELECT_FAILURE 2 @@ -319,7 +340,7 @@ static inline bool bond_is_lb(const struct bonding *bond) static inline int slave_do_arp_validate(struct bonding *bond, struct slave *slave) { - return bond->params.arp_validate & (1 << slave->state); + return bond->params.arp_validate & (1 << bond_slave_state(slave)); } static inline unsigned long slave_last_rx(struct bonding *bond, @@ -351,14 +372,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) { struct bonding *bond = netdev_priv(slave->dev->master); if (!bond_is_lb(bond)) - slave->state = BOND_STATE_BACKUP; + bond_set_backup_slave(slave); if (!bond->params.all_slaves_active) slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; } static inline void bond_set_slave_active_flags(struct slave *slave) { - slave->state = BOND_STATE_ACTIVE; + bond_set_active_slave(slave); slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; } -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-05 10:29 ` [patch net-next-2.6 4/8] bonding: wrap slave state work Jiri Pirko @ 2011-03-05 15:21 ` Nicolas de Pesloüan 2011-03-07 9:58 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 15:21 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > transfers slave->state into slave->backup (that it's going to transfer > into bitfield. Introduce wrapper inlines to do the work with it. > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > --- > drivers/net/bonding/bond_3ad.c | 2 +- > drivers/net/bonding/bond_main.c | 36 ++++++++++++++++++------------------ > drivers/net/bonding/bond_sysfs.c | 2 +- > drivers/net/bonding/bonding.h | 31 ++++++++++++++++++++++++++----- > 4 files changed, 46 insertions(+), 25 deletions(-) > > diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c > index 1024ae1..047af0b 100644 > --- a/drivers/net/bonding/bond_3ad.c > +++ b/drivers/net/bonding/bond_3ad.c > @@ -246,7 +246,7 @@ static inline void __enable_port(struct port *port) > */ > static inline int __port_is_enabled(struct port *port) > { > - return port->slave->state == BOND_STATE_ACTIVE; > + return bond_is_active_slave(port->slave); > } > > /** > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 7923184..62020a7 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1872,7 +1872,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) > break; > case BOND_MODE_TLB: > case BOND_MODE_ALB: > - new_slave->state = BOND_STATE_ACTIVE; > + bond_set_active_slave(new_slave); > bond_set_slave_inactive_flags(new_slave); > bond_select_active_slave(bond); > break; > @@ -1880,7 +1880,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) > pr_debug("This slave is always active in trunk mode\n"); > > /* always active in trunk mode */ > - new_slave->state = BOND_STATE_ACTIVE; > + bond_set_active_slave(new_slave); > > /* In trunking mode there is little meaning to curr_active_slave > * anyway (it holds no special properties of the bond device), > @@ -1918,7 +1918,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) > > pr_info("%s: enslaving %s as a%s interface with a%s link.\n", > bond_dev->name, slave_dev->name, > - new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup", > + bond_is_active_slave(new_slave) ? "n active" : " backup", > new_slave->link != BOND_LINK_DOWN ? "n up" : " down"); I would prefer the following, for the benefit of non native English readers: pr_info("%s: enslaving %s as %s interface with %s link.\n", bond_is_active_slave(new_slave) ? "an active" : "a backup", new_slave->link != BOND_LINK_DOWN ? "an up" : "a down"); It can be in a follow-up patch. > > /* enslave is successful */ > @@ -2016,7 +2016,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) > > pr_info("%s: releasing %s interface %s\n", > bond_dev->name, > - (slave->state == BOND_STATE_ACTIVE) ? "active" : "backup", > + bond_is_active_slave(slave) ? "active" : "backup", > slave_dev->name); > > oldcurrent = bond->curr_active_slave; > @@ -2357,7 +2357,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in > res = 0; > strcpy(info->slave_name, slave->dev->name); > info->link = slave->link; > - info->state = slave->state; > + info->state = bond_slave_state(slave); > info->link_failure_count = slave->link_failure_count; > break; > } > @@ -2396,7 +2396,7 @@ static int bond_miimon_inspect(struct bonding *bond) > bond->dev->name, > (bond->params.mode == > BOND_MODE_ACTIVEBACKUP) ? > - ((slave->state == BOND_STATE_ACTIVE) ? > + (bond_is_active_slave(slave) ? > "active " : "backup ") : "", > slave->dev->name, > bond->params.downdelay * bond->params.miimon); > @@ -2487,13 +2487,13 @@ static void bond_miimon_commit(struct bonding *bond) > > if (bond->params.mode == BOND_MODE_8023AD) { > /* prevent it from being the active one */ > - slave->state = BOND_STATE_BACKUP; > + bond_set_backup_slave(slave); > } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) { > /* make it immediately active */ > - slave->state = BOND_STATE_ACTIVE; > + bond_set_active_slave(slave); > } else if (slave != bond->primary_slave) { > /* prevent it from being the active one */ > - slave->state = BOND_STATE_BACKUP; > + bond_set_backup_slave(slave); > } > > bond_update_speed_duplex(slave); > @@ -2871,7 +2871,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack > memcpy(&tip, arp_ptr, 4); > > pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", > - bond->dev->name, slave->dev->name, slave->state, > + bond->dev->name, slave->dev->name, bond_slave_state(slave), > bond->params.arp_validate, slave_do_arp_validate(bond, slave), > &sip,&tip); > > @@ -2883,7 +2883,7 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack > * the active, through one switch, the router, then the other > * switch before reaching the backup. > */ > - if (slave->state == BOND_STATE_ACTIVE) > + if (bond_is_active_slave(slave)) > bond_validate_arp(bond, slave, sip, tip); > else > bond_validate_arp(bond, slave, tip, sip); > @@ -2945,7 +2945,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) > slave->dev->last_rx + delta_in_ticks)) { > > slave->link = BOND_LINK_UP; > - slave->state = BOND_STATE_ACTIVE; > + bond_set_active_slave(slave); > > /* primary_slave has no meaning in round-robin > * mode. the window of a slave being up and > @@ -2978,7 +2978,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work) > slave->dev->last_rx + 2 * delta_in_ticks)) { > > slave->link = BOND_LINK_DOWN; > - slave->state = BOND_STATE_BACKUP; > + bond_set_backup_slave(slave); > > if (slave->link_failure_count< UINT_MAX) > slave->link_failure_count++; > @@ -3072,7 +3072,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) > * gives each slave a chance to tx/rx traffic > * before being taken out > */ > - if (slave->state == BOND_STATE_BACKUP&& > + if (!bond_is_active_slave(slave)&& > !bond->current_arp_slave&& > !time_in_range(jiffies, > slave_last_rx(bond, slave) - delta_in_ticks, > @@ -3089,7 +3089,7 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) > * the bond has an IP address) > */ > trans_start = dev_trans_start(slave->dev); > - if ((slave->state == BOND_STATE_ACTIVE)&& > + if (bond_is_active_slave(slave)&& > (!time_in_range(jiffies, > trans_start - delta_in_ticks, > trans_start + 2 * delta_in_ticks) || > @@ -4446,7 +4446,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev > bond_for_each_slave_from(bond, slave, i, start_at) { > if (IS_UP(slave->dev)&& > (slave->link == BOND_LINK_UP)&& > - (slave->state == BOND_STATE_ACTIVE)) { > + bond_is_active_slave(slave)) { > res = bond_dev_queue_xmit(bond, skb, slave->dev); > break; > } > @@ -4523,7 +4523,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) > bond_for_each_slave_from(bond, slave, i, start_at) { > if (IS_UP(slave->dev)&& > (slave->link == BOND_LINK_UP)&& > - (slave->state == BOND_STATE_ACTIVE)) { > + bond_is_active_slave(slave)) { > res = bond_dev_queue_xmit(bond, skb, slave->dev); > break; > } > @@ -4564,7 +4564,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) > bond_for_each_slave_from(bond, slave, i, start_at) { > if (IS_UP(slave->dev)&& > (slave->link == BOND_LINK_UP)&& > - (slave->state == BOND_STATE_ACTIVE)) { > + bond_is_active_slave(slave)) { > if (tx_dev) { > struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); > if (!skb2) { > diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c > index 05e0ae5..344d23f 100644 > --- a/drivers/net/bonding/bond_sysfs.c > +++ b/drivers/net/bonding/bond_sysfs.c > @@ -1579,7 +1579,7 @@ static ssize_t bonding_store_slaves_active(struct device *d, > } > > bond_for_each_slave(bond, slave, i) { > - if (slave->state == BOND_STATE_BACKUP) { > + if (!bond_is_active_slave(slave)) { > if (new_value) > slave->dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > else > diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h > index ddee62f..8a3718b 100644 > --- a/drivers/net/bonding/bonding.h > +++ b/drivers/net/bonding/bonding.h > @@ -53,7 +53,7 @@ > (((slave)->dev->flags& IFF_UP)&& \ > netif_running((slave)->dev)&& \ > ((slave)->link == BOND_LINK_UP)&& \ > - ((slave)->state == BOND_STATE_ACTIVE)) > + bond_is_active_slave(slave)) > > > #define USES_PRIMARY(mode) \ > @@ -190,7 +190,8 @@ struct slave { > unsigned long last_arp_rx; > s8 link; /* one of BOND_LINK_XXXX */ > s8 new_link; > - s8 state; /* one of BOND_STATE_XXXX */ > + u8 backup; /* indicates backup slave. Value corresponds with > + BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ > u32 original_mtu; > u32 link_failure_count; > u8 perm_hwaddr[ETH_ALEN]; > @@ -302,6 +303,26 @@ static inline bool bond_is_lb(const struct bonding *bond) > bond->params.mode == BOND_MODE_ALB); > } > > +static inline void bond_set_active_slave(struct slave *slave) > +{ > + slave->backup = 0; In the comment above, you said that the possible value for backup corresponds with BOND_STATE_ACTIVE and BOND_STATE_BACKUP. So, should be: slave->backup = BOND_STATE_ACTIVE; > +} > + > +static inline void bond_set_backup_slave(struct slave *slave) > +{ > + slave->backup = 1; slave->backup = BOND_STATE_BACKUP; > +} > + > +static inline int bond_slave_state(struct slave *slave) > +{ > + return slave->backup; > +} > + > +static inline bool bond_is_active_slave(struct slave *slave) > +{ > + return !bond_slave_state(slave); > +} > + > #define BOND_PRI_RESELECT_ALWAYS 0 > #define BOND_PRI_RESELECT_BETTER 1 > #define BOND_PRI_RESELECT_FAILURE 2 > @@ -319,7 +340,7 @@ static inline bool bond_is_lb(const struct bonding *bond) > static inline int slave_do_arp_validate(struct bonding *bond, > struct slave *slave) > { > - return bond->params.arp_validate& (1<< slave->state); > + return bond->params.arp_validate& (1<< bond_slave_state(slave)); > } > > static inline unsigned long slave_last_rx(struct bonding *bond, > @@ -351,14 +372,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) > { > struct bonding *bond = netdev_priv(slave->dev->master); > if (!bond_is_lb(bond)) > - slave->state = BOND_STATE_BACKUP; > + bond_set_backup_slave(slave); > if (!bond->params.all_slaves_active) > slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; > } > > static inline void bond_set_slave_active_flags(struct slave *slave) > { > - slave->state = BOND_STATE_ACTIVE; > + bond_set_active_slave(slave); > slave->dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > } > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-05 15:21 ` Nicolas de Pesloüan @ 2011-03-07 9:58 ` Jiri Pirko 2011-03-07 19:55 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-07 9:58 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy >> >>+static inline void bond_set_active_slave(struct slave *slave) >>+{ >>+ slave->backup = 0; > >In the comment above, you said that the possible value for backup >corresponds with BOND_STATE_ACTIVE and BOND_STATE_BACKUP. > >So, should be: > >slave->backup = BOND_STATE_ACTIVE; > >>+} >>+ >>+static inline void bond_set_backup_slave(struct slave *slave) >>+{ >>+ slave->backup = 1; > >slave->backup = BOND_STATE_BACKUP; > Well, I think it's weird and misleading to assign some define to :1 bitfield. Should be 0 or 1, nothing else. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-07 9:58 ` Jiri Pirko @ 2011-03-07 19:55 ` Nicolas de Pesloüan 2011-03-08 7:18 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-07 19:55 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 07/03/2011 10:58, Jiri Pirko a écrit : >>> >>> +static inline void bond_set_active_slave(struct slave *slave) >>> +{ >>> + slave->backup = 0; >> >> In the comment above, you said that the possible value for backup >> corresponds with BOND_STATE_ACTIVE and BOND_STATE_BACKUP. >> >> So, should be: >> >> slave->backup = BOND_STATE_ACTIVE; >> >>> +} >>> + >>> +static inline void bond_set_backup_slave(struct slave *slave) >>> +{ >>> + slave->backup = 1; >> >> slave->backup = BOND_STATE_BACKUP; >> > > Well, I think it's weird and misleading to assign some define to :1 > bitfield. Should be 0 or 1, nothing else. Agreed, but the comment appears missleading... May be you should fix the comment, not the code. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-07 19:55 ` Nicolas de Pesloüan @ 2011-03-08 7:18 ` Jiri Pirko 2011-03-08 21:23 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-08 7:18 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Mon, Mar 07, 2011 at 08:55:12PM CET, nicolas.2p.debian@gmail.com wrote: >Le 07/03/2011 10:58, Jiri Pirko a écrit : >>>> >>>>+static inline void bond_set_active_slave(struct slave *slave) >>>>+{ >>>>+ slave->backup = 0; >>> >>>In the comment above, you said that the possible value for backup >>>corresponds with BOND_STATE_ACTIVE and BOND_STATE_BACKUP. >>> >>>So, should be: >>> >>>slave->backup = BOND_STATE_ACTIVE; >>> >>>>+} >>>>+ >>>>+static inline void bond_set_backup_slave(struct slave *slave) >>>>+{ >>>>+ slave->backup = 1; >>> >>>slave->backup = BOND_STATE_BACKUP; >>> >> >>Well, I think it's weird and misleading to assign some define to :1 >>bitfield. Should be 0 or 1, nothing else. > >Agreed, but the comment appears missleading... May be you should fix the comment, not the code. Hmm. I thought that the comment is accurate. BOND_STATE_ACTIVE corresponds with 0, BOND_STATE_BACKUP corresponds with 1. Anyway, let me know how would you like to formulate this and I can repost (or do a little comment-changing followup) Thanks Nicolas > > Nicolas. > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 4/8] bonding: wrap slave state work 2011-03-08 7:18 ` Jiri Pirko @ 2011-03-08 21:23 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-08 21:23 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 08/03/2011 08:18, Jiri Pirko a écrit : > Mon, Mar 07, 2011 at 08:55:12PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 07/03/2011 10:58, Jiri Pirko a écrit : >>>>> >>>>> +static inline void bond_set_active_slave(struct slave *slave) >>>>> +{ >>>>> + slave->backup = 0; >>>> >>>> In the comment above, you said that the possible value for backup >>>> corresponds with BOND_STATE_ACTIVE and BOND_STATE_BACKUP. >>>> >>>> So, should be: >>>> >>>> slave->backup = BOND_STATE_ACTIVE; >>>> >>>>> +} >>>>> + >>>>> +static inline void bond_set_backup_slave(struct slave *slave) >>>>> +{ >>>>> + slave->backup = 1; >>>> >>>> slave->backup = BOND_STATE_BACKUP; >>>> >>> >>> Well, I think it's weird and misleading to assign some define to :1 >>> bitfield. Should be 0 or 1, nothing else. >> >> Agreed, but the comment appears missleading... May be you should fix the comment, not the code. > > Hmm. I thought that the comment is accurate. BOND_STATE_ACTIVE > corresponds with 0, BOND_STATE_BACKUP corresponds with 1. Anyway, let me > know how would you like to formulate this and I can repost (or do a > little comment-changing followup) > > Thanks Nicolas Hi Jiri, I'm probably too perfectionist. Keep it the way it is. Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko ` (3 preceding siblings ...) 2011-03-05 10:29 ` [patch net-next-2.6 4/8] bonding: wrap slave state work Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 14:18 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() Jiri Pirko ` (2 subsequent siblings) 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Since bond-related code was moved from net/core/dev.c into bonding, IFF_SLAVE_INACTIVE is no longer needed. Replace is with flag "inactive" stored in slave structure Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_main.c | 6 ++---- drivers/net/bonding/bond_sysfs.c | 4 ++-- drivers/net/bonding/bonding.h | 14 ++++++++++---- include/linux/if.h | 19 +++++++++---------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 62020a7..dbe182c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1474,7 +1474,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, struct slave *slave, struct bonding *bond) { - if (slave->dev->priv_flags & IFF_SLAVE_INACTIVE) { + if (bond_is_slave_inactive(slave)) { if (slave_do_arp_validate(bond, slave) && skb->protocol == __cpu_to_be16(ETH_P_ARP)) return false; @@ -2131,7 +2131,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) dev_set_mtu(slave_dev, slave->original_mtu); - slave_dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_BONDING); + slave_dev->priv_flags &= ~IFF_BONDING; kfree(slave); @@ -2242,8 +2242,6 @@ static int bond_release_all(struct net_device *bond_dev) dev_set_mac_address(slave_dev, &addr); } - slave_dev->priv_flags &= ~IFF_SLAVE_INACTIVE; - kfree(slave); /* re-acquire the lock before getting the next slave */ diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 344d23f..5161183 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -1581,9 +1581,9 @@ static ssize_t bonding_store_slaves_active(struct device *d, bond_for_each_slave(bond, slave, i) { if (!bond_is_active_slave(slave)) { if (new_value) - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; + slave->inactive = 0; else - slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; + slave->inactive = 1; } } out: diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 8a3718b..8f78166 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -190,8 +190,9 @@ struct slave { unsigned long last_arp_rx; s8 link; /* one of BOND_LINK_XXXX */ s8 new_link; - u8 backup; /* indicates backup slave. Value corresponds with - BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + u8 backup:1, /* indicates backup slave. Value corresponds with + BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ + inactive:1; /* indicates inactive slave */ u32 original_mtu; u32 link_failure_count; u8 perm_hwaddr[ETH_ALEN]; @@ -374,13 +375,18 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) if (!bond_is_lb(bond)) bond_set_backup_slave(slave); if (!bond->params.all_slaves_active) - slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; + slave->inactive = 1; } static inline void bond_set_slave_active_flags(struct slave *slave) { bond_set_active_slave(slave); - slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; + slave->inactive = 0; +} + +static inline bool bond_is_slave_inactive(struct slave *slave) +{ + return slave->inactive; } struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); diff --git a/include/linux/if.h b/include/linux/if.h index 2fdd47a..0da7991 100644 --- a/include/linux/if.h +++ b/include/linux/if.h @@ -59,18 +59,17 @@ /* Private (from user) interface flags (netdevice->priv_flags). */ #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ -#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ -#define IFF_BONDING 0x8 /* bonding master or slave */ -#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ -#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ -#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to +#define IFF_BONDING 0x4 /* bonding master or slave */ +#define IFF_ISATAP 0x8 /* ISATAP interface (RFC4214) */ +#define IFF_WAN_HDLC 0x10 /* WAN HDLC device */ +#define IFF_XMIT_DST_RELEASE 0x20 /* dev_hard_start_xmit() is allowed to * release skb->dst */ -#define IFF_DONT_BRIDGE 0x80 /* disallow bridging this ether dev */ -#define IFF_DISABLE_NETPOLL 0x100 /* disable netpoll at run-time */ -#define IFF_MACVLAN_PORT 0x200 /* device used as macvlan port */ -#define IFF_BRIDGE_PORT 0x400 /* device used as bridge port */ -#define IFF_OVS_DATAPATH 0x800 /* device used as Open vSwitch +#define IFF_DONT_BRIDGE 0x40 /* disallow bridging this ether dev */ +#define IFF_DISABLE_NETPOLL 0x80 /* disable netpoll at run-time */ +#define IFF_MACVLAN_PORT 0x100 /* device used as macvlan port */ +#define IFF_BRIDGE_PORT 0x200 /* device used as bridge port */ +#define IFF_OVS_DATAPATH 0x400 /* device used as Open vSwitch * datapath port */ #define IF_GET_IFACE 0x0001 /* for querying only */ -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag 2011-03-05 10:29 ` [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko @ 2011-03-05 14:18 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:18 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Since bond-related code was moved from net/core/dev.c into bonding, > IFF_SLAVE_INACTIVE is no longer needed. Replace is with flag "inactive" > stored in slave structure > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > --- > drivers/net/bonding/bond_main.c | 6 ++---- > drivers/net/bonding/bond_sysfs.c | 4 ++-- > drivers/net/bonding/bonding.h | 14 ++++++++++---- > include/linux/if.h | 19 +++++++++---------- > 4 files changed, 23 insertions(+), 20 deletions(-) > > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index 62020a7..dbe182c 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1474,7 +1474,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, > struct slave *slave, > struct bonding *bond) > { > - if (slave->dev->priv_flags& IFF_SLAVE_INACTIVE) { > + if (bond_is_slave_inactive(slave)) { > if (slave_do_arp_validate(bond, slave)&& > skb->protocol == __cpu_to_be16(ETH_P_ARP)) > return false; > @@ -2131,7 +2131,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) > > dev_set_mtu(slave_dev, slave->original_mtu); > > - slave_dev->priv_flags&= ~(IFF_SLAVE_INACTIVE | IFF_BONDING); > + slave_dev->priv_flags&= ~IFF_BONDING; > > kfree(slave); > > @@ -2242,8 +2242,6 @@ static int bond_release_all(struct net_device *bond_dev) > dev_set_mac_address(slave_dev,&addr); > } > > - slave_dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > - > kfree(slave); > > /* re-acquire the lock before getting the next slave */ > diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c > index 344d23f..5161183 100644 > --- a/drivers/net/bonding/bond_sysfs.c > +++ b/drivers/net/bonding/bond_sysfs.c > @@ -1581,9 +1581,9 @@ static ssize_t bonding_store_slaves_active(struct device *d, > bond_for_each_slave(bond, slave, i) { > if (!bond_is_active_slave(slave)) { > if (new_value) > - slave->dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > + slave->inactive = 0; > else > - slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; > + slave->inactive = 1; > } > } > out: > diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h > index 8a3718b..8f78166 100644 > --- a/drivers/net/bonding/bonding.h > +++ b/drivers/net/bonding/bonding.h > @@ -190,8 +190,9 @@ struct slave { > unsigned long last_arp_rx; > s8 link; /* one of BOND_LINK_XXXX */ > s8 new_link; > - u8 backup; /* indicates backup slave. Value corresponds with > - BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ > + u8 backup:1, /* indicates backup slave. Value corresponds with > + BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ > + inactive:1; /* indicates inactive slave */ > u32 original_mtu; > u32 link_failure_count; > u8 perm_hwaddr[ETH_ALEN]; > @@ -374,13 +375,18 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave) > if (!bond_is_lb(bond)) > bond_set_backup_slave(slave); > if (!bond->params.all_slaves_active) > - slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; > + slave->inactive = 1; > } > > static inline void bond_set_slave_active_flags(struct slave *slave) > { > bond_set_active_slave(slave); > - slave->dev->priv_flags&= ~IFF_SLAVE_INACTIVE; > + slave->inactive = 0; > +} > + > +static inline bool bond_is_slave_inactive(struct slave *slave) > +{ > + return slave->inactive; > } > > struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); > diff --git a/include/linux/if.h b/include/linux/if.h > index 2fdd47a..0da7991 100644 > --- a/include/linux/if.h > +++ b/include/linux/if.h > @@ -59,18 +59,17 @@ > /* Private (from user) interface flags (netdevice->priv_flags). */ > #define IFF_802_1Q_VLAN 0x1 /* 802.1Q VLAN device. */ > #define IFF_EBRIDGE 0x2 /* Ethernet bridging device. */ > -#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ > -#define IFF_BONDING 0x8 /* bonding master or slave */ > -#define IFF_ISATAP 0x10 /* ISATAP interface (RFC4214) */ > -#define IFF_WAN_HDLC 0x20 /* WAN HDLC device */ > -#define IFF_XMIT_DST_RELEASE 0x40 /* dev_hard_start_xmit() is allowed to > +#define IFF_BONDING 0x4 /* bonding master or slave */ > +#define IFF_ISATAP 0x8 /* ISATAP interface (RFC4214) */ > +#define IFF_WAN_HDLC 0x10 /* WAN HDLC device */ > +#define IFF_XMIT_DST_RELEASE 0x20 /* dev_hard_start_xmit() is allowed to > * release skb->dst > */ > -#define IFF_DONT_BRIDGE 0x80 /* disallow bridging this ether dev */ > -#define IFF_DISABLE_NETPOLL 0x100 /* disable netpoll at run-time */ > -#define IFF_MACVLAN_PORT 0x200 /* device used as macvlan port */ > -#define IFF_BRIDGE_PORT 0x400 /* device used as bridge port */ > -#define IFF_OVS_DATAPATH 0x800 /* device used as Open vSwitch > +#define IFF_DONT_BRIDGE 0x40 /* disallow bridging this ether dev */ > +#define IFF_DISABLE_NETPOLL 0x80 /* disable netpoll at run-time */ > +#define IFF_MACVLAN_PORT 0x100 /* device used as macvlan port */ > +#define IFF_BRIDGE_PORT 0x200 /* device used as bridge port */ > +#define IFF_OVS_DATAPATH 0x400 /* device used as Open vSwitch > * datapath port */ > > #define IF_GET_IFACE 0x0001 /* for querying only */ ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko ` (4 preceding siblings ...) 2011-03-05 10:29 ` [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 14:33 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers Jiri Pirko 7 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Since now when bonding uses rx_handler, all traffic going into bond device goes thru bond_handle_frame. So there's no need to go back into bonding code later via ptype handlers. This patch converts original ptype handlers into "bonding receive probes". These functions are called from bond_handle_frame and they are registered per-mode. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_3ad.c | 29 ++-------- drivers/net/bonding/bond_3ad.h | 4 +- drivers/net/bonding/bond_alb.c | 46 ++++----------- drivers/net/bonding/bond_alb.h | 1 - drivers/net/bonding/bond_main.c | 121 +++++++------------------------------ drivers/net/bonding/bond_sysfs.c | 6 -- drivers/net/bonding/bonding.h | 4 +- 7 files changed, 43 insertions(+), 168 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 047af0b..194aaf7 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -2461,35 +2461,16 @@ out: return NETDEV_TX_OK; } -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { - struct bonding *bond = netdev_priv(dev); - struct slave *slave = NULL; - int ret = NET_RX_DROP; - - if (!(dev->flags & IFF_MASTER)) - goto out; - - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out; + if (skb->protocol != PKT_TYPE_LACPDU) + return; if (!pskb_may_pull(skb, sizeof(struct lacpdu))) - goto out; + return; read_lock(&bond->lock); - slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev); - if (!slave) - goto out_unlock; - bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len); - - ret = NET_RX_SUCCESS; - -out_unlock: read_unlock(&bond->lock); -out: - dev_kfree_skb(skb); - - return ret; } diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 2c46a154..56a88ff 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h @@ -258,7 +258,6 @@ struct ad_bond_info { * requested */ struct timer_list ad_timer; - struct packet_type ad_pkt_type; }; struct ad_slave_info { @@ -279,7 +278,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave); void bond_3ad_handle_link_change(struct slave *slave, char link); int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info); int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev); -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev); +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave); int bond_3ad_set_carrier(struct bonding *bond); #endif //__BOND_3AD_H__ diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 9bc5de3..96d28f9 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -308,49 +308,33 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp) _unlock_rx_hashtbl(bond); } -static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev) +static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { - struct bonding *bond; - struct arp_pkt *arp = (struct arp_pkt *)skb->data; - int res = NET_RX_DROP; + struct arp_pkt *arp; - while (bond_dev->priv_flags & IFF_802_1Q_VLAN) - bond_dev = vlan_dev_real_dev(bond_dev); - - if (!(bond_dev->priv_flags & IFF_BONDING) || - !(bond_dev->flags & IFF_MASTER)) - goto out; + if (skb->protocol != cpu_to_be16(ETH_P_ARP)) + return; + arp = (struct arp_pkt *) skb->data; if (!arp) { pr_debug("Packet has no ARP data\n"); - goto out; + return; } - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out; - - if (!pskb_may_pull(skb, arp_hdr_len(bond_dev))) - goto out; + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) + return; if (skb->len < sizeof(struct arp_pkt)) { pr_debug("Packet is too small to be an ARP\n"); - goto out; + return; } if (arp->op_code == htons(ARPOP_REPLY)) { /* update rx hash table for this ARP */ - bond = netdev_priv(bond_dev); rlb_update_entry_from_arp(bond, arp); pr_debug("Server received an ARP Reply from client\n"); } - - res = NET_RX_SUCCESS; - -out: - dev_kfree_skb(skb); - - return res; } /* Caller must hold bond lock for read */ @@ -759,7 +743,6 @@ static void rlb_init_table_entry(struct rlb_client_info *entry) static int rlb_initialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); struct rlb_client_info *new_hashtbl; int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); int i; @@ -784,13 +767,8 @@ static int rlb_initialize(struct bonding *bond) _unlock_rx_hashtbl(bond); - /*initialize packet type*/ - pk_type->type = cpu_to_be16(ETH_P_ARP); - pk_type->dev = bond->dev; - pk_type->func = rlb_arp_recv; - /* register to receive ARPs */ - dev_add_pack(pk_type); + bond->recv_probe = rlb_arp_recv; return 0; } @@ -799,8 +777,6 @@ static void rlb_deinitialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - dev_remove_pack(&(bond_info->rlb_pkt_type)); - _lock_rx_hashtbl(bond); kfree(bond_info->rx_hashtbl); diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index 118c28a..6605e9e 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h @@ -130,7 +130,6 @@ struct alb_bond_info { int lp_counter; /* -------- rlb parameters -------- */ int rlb_enabled; - struct packet_type rlb_pkt_type; struct rlb_client_info *rx_hashtbl; /* Receive hash table */ spinlock_t rx_hashtbl_lock; u32 rx_hashtbl_head; diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index dbe182c..8ba7faa 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1467,27 +1467,17 @@ static void bond_setup_by_slave(struct net_device *bond_dev, } /* On bonding slaves other than the currently active slave, suppress - * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and - * ARP on active-backup slaves with arp_validate enabled. + * duplicates except for alb non-mcast/bcast. */ static bool bond_should_deliver_exact_match(struct sk_buff *skb, struct slave *slave, struct bonding *bond) { if (bond_is_slave_inactive(slave)) { - if (slave_do_arp_validate(bond, slave) && - skb->protocol == __cpu_to_be16(ETH_P_ARP)) - return false; - if (bond->params.mode == BOND_MODE_ALB && skb->pkt_type != PACKET_BROADCAST && skb->pkt_type != PACKET_MULTICAST) - return false; - - if (bond->params.mode == BOND_MODE_8023AD && - skb->protocol == __cpu_to_be16(ETH_P_SLOW)) return false; - return true; } return false; @@ -1513,6 +1503,15 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) if (bond->params.arp_interval) slave->dev->last_rx = jiffies; + if (bond->recv_probe) { + struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); + + if (likely(nskb)) { + bond->recv_probe(nskb, bond, slave); + dev_kfree_skb(nskb); + } + } + if (bond_should_deliver_exact_match(skb, slave, bond)) { skb->deliver_no_wcard = 1; return skb; @@ -2813,48 +2812,26 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 } } -static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { struct arphdr *arp; - struct slave *slave; - struct bonding *bond; unsigned char *arp_ptr; __be32 sip, tip; - if (dev->priv_flags & IFF_802_1Q_VLAN) { - /* - * When using VLANS and bonding, dev and oriv_dev may be - * incorrect if the physical interface supports VLAN - * acceleration. With this change ARP validation now - * works for hosts only reachable on the VLAN interface. - */ - dev = vlan_dev_real_dev(dev); - orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); - } - - if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER)) - goto out; + if (skb->protocol != __cpu_to_be16(ETH_P_ARP)) + return; - bond = netdev_priv(dev); read_lock(&bond->lock); - pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", - bond->dev->name, skb->dev ? skb->dev->name : "NULL", - orig_dev ? orig_dev->name : "NULL"); + pr_debug("bond_arp_rcv: bond %s skb->dev %s\n", + bond->dev->name, skb->dev->name); - slave = bond_get_slave_by_dev(bond, orig_dev); - if (!slave || !slave_do_arp_validate(bond, slave)) - goto out_unlock; - - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out_unlock; - - if (!pskb_may_pull(skb, arp_hdr_len(dev))) + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) goto out_unlock; arp = arp_hdr(skb); - if (arp->ar_hln != dev->addr_len || + if (arp->ar_hln != bond->dev->addr_len || skb->pkt_type == PACKET_OTHERHOST || skb->pkt_type == PACKET_LOOPBACK || arp->ar_hrd != htons(ARPHRD_ETHER) || @@ -2863,9 +2840,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack goto out_unlock; arp_ptr = (unsigned char *)(arp + 1); - arp_ptr += dev->addr_len; + arp_ptr += bond->dev->addr_len; memcpy(&sip, arp_ptr, 4); - arp_ptr += 4 + dev->addr_len; + arp_ptr += 4 + bond->dev->addr_len; memcpy(&tip, arp_ptr, 4); pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", @@ -2888,9 +2865,6 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack out_unlock: read_unlock(&bond->lock); -out: - dev_kfree_skb(skb); - return NET_RX_SUCCESS; } /* @@ -3782,48 +3756,6 @@ static struct notifier_block bond_inetaddr_notifier = { .notifier_call = bond_inetaddr_event, }; -/*-------------------------- Packet type handling ---------------------------*/ - -/* register to receive lacpdus on a bond */ -static void bond_register_lacpdu(struct bonding *bond) -{ - struct packet_type *pk_type = &(BOND_AD_INFO(bond).ad_pkt_type); - - /* initialize packet type */ - pk_type->type = PKT_TYPE_LACPDU; - pk_type->dev = bond->dev; - pk_type->func = bond_3ad_lacpdu_recv; - - dev_add_pack(pk_type); -} - -/* unregister to receive lacpdus on a bond */ -static void bond_unregister_lacpdu(struct bonding *bond) -{ - dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); -} - -void bond_register_arp(struct bonding *bond) -{ - struct packet_type *pt = &bond->arp_mon_pt; - - if (pt->type) - return; - - pt->type = htons(ETH_P_ARP); - pt->dev = bond->dev; - pt->func = bond_arp_rcv; - dev_add_pack(pt); -} - -void bond_unregister_arp(struct bonding *bond) -{ - struct packet_type *pt = &bond->arp_mon_pt; - - dev_remove_pack(pt); - pt->type = 0; -} - /*---------------------------- Hashing Policies -----------------------------*/ /* @@ -3917,14 +3849,14 @@ static int bond_open(struct net_device *bond_dev) queue_delayed_work(bond->wq, &bond->arp_work, 0); if (bond->params.arp_validate) - bond_register_arp(bond); + bond->recv_probe = bond_arp_rcv; } if (bond->params.mode == BOND_MODE_8023AD) { INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); queue_delayed_work(bond->wq, &bond->ad_work, 0); /* register to receive LACPDUs */ - bond_register_lacpdu(bond); + bond->recv_probe = bond_3ad_lacpdu_recv; bond_3ad_initiate_agg_selection(bond, 1); } @@ -3935,14 +3867,6 @@ static int bond_close(struct net_device *bond_dev) { struct bonding *bond = netdev_priv(bond_dev); - if (bond->params.mode == BOND_MODE_8023AD) { - /* Unregister the receive of LACPDUs */ - bond_unregister_lacpdu(bond); - } - - if (bond->params.arp_validate) - bond_unregister_arp(bond); - write_lock_bh(&bond->lock); bond->send_grat_arp = 0; @@ -3982,6 +3906,7 @@ static int bond_close(struct net_device *bond_dev) */ bond_alb_deinitialize(bond); } + bond->recv_probe = NULL; return 0; } diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5161183..6804efe 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -419,11 +419,6 @@ static ssize_t bonding_store_arp_validate(struct device *d, bond->dev->name, arp_validate_tbl[new_value].modename, new_value); - if (!bond->params.arp_validate && new_value) - bond_register_arp(bond); - else if (bond->params.arp_validate && !new_value) - bond_unregister_arp(bond); - bond->params.arp_validate = new_value; return count; @@ -998,7 +993,6 @@ static ssize_t bonding_store_miimon(struct device *d, bond->dev->name); bond->params.arp_interval = 0; if (bond->params.arp_validate) { - bond_unregister_arp(bond); bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; } diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 8f78166..75a1308 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -228,6 +228,8 @@ struct bonding { struct slave *primary_slave; bool force_primary; s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ + void (*recv_probe)(struct sk_buff *, struct bonding *, + struct slave *); rwlock_t lock; rwlock_t curr_slave_lock; s8 kill_timers; @@ -406,8 +408,6 @@ void bond_set_mode_ops(struct bonding *bond, int mode); int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); void bond_select_active_slave(struct bonding *bond); void bond_change_active_slave(struct bonding *bond, struct slave *new_active); -void bond_register_arp(struct bonding *); -void bond_unregister_arp(struct bonding *); void bond_create_debugfs(void); void bond_destroy_debugfs(void); void bond_debug_register(struct bonding *bond); -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 10:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() Jiri Pirko @ 2011-03-05 14:33 ` Nicolas de Pesloüan 2011-03-05 14:43 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:33 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Since now when bonding uses rx_handler, all traffic going into bond > device goes thru bond_handle_frame. So there's no need to go back into > bonding code later via ptype handlers. This patch converts > original ptype handlers into "bonding receive probes". These functions > are called from bond_handle_frame and they are registered per-mode. Does this still support having the arp_ip_target on a vlan? (eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable through bond0.100). > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > --- > drivers/net/bonding/bond_3ad.c | 29 ++-------- > drivers/net/bonding/bond_3ad.h | 4 +- > drivers/net/bonding/bond_alb.c | 46 ++++----------- > drivers/net/bonding/bond_alb.h | 1 - > drivers/net/bonding/bond_main.c | 121 +++++++------------------------------ > drivers/net/bonding/bond_sysfs.c | 6 -- > drivers/net/bonding/bonding.h | 4 +- > 7 files changed, 43 insertions(+), 168 deletions(-) > > diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c > index 047af0b..194aaf7 100644 > --- a/drivers/net/bonding/bond_3ad.c > +++ b/drivers/net/bonding/bond_3ad.c > @@ -2461,35 +2461,16 @@ out: > return NETDEV_TX_OK; > } > > -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) > +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, > + struct slave *slave) > { > - struct bonding *bond = netdev_priv(dev); > - struct slave *slave = NULL; > - int ret = NET_RX_DROP; > - > - if (!(dev->flags& IFF_MASTER)) > - goto out; > - > - skb = skb_share_check(skb, GFP_ATOMIC); > - if (!skb) > - goto out; > + if (skb->protocol != PKT_TYPE_LACPDU) > + return; > > if (!pskb_may_pull(skb, sizeof(struct lacpdu))) > - goto out; > + return; > > read_lock(&bond->lock); > - slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev); > - if (!slave) > - goto out_unlock; > - > bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len); > - > - ret = NET_RX_SUCCESS; > - > -out_unlock: > read_unlock(&bond->lock); > -out: > - dev_kfree_skb(skb); > - > - return ret; > } > diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h > index 2c46a154..56a88ff 100644 > --- a/drivers/net/bonding/bond_3ad.h > +++ b/drivers/net/bonding/bond_3ad.h > @@ -258,7 +258,6 @@ struct ad_bond_info { > * requested > */ > struct timer_list ad_timer; > - struct packet_type ad_pkt_type; > }; > > struct ad_slave_info { > @@ -279,7 +278,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave); > void bond_3ad_handle_link_change(struct slave *slave, char link); > int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info); > int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev); > -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev); > +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, > + struct slave *slave); > int bond_3ad_set_carrier(struct bonding *bond); > #endif //__BOND_3AD_H__ > > diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c > index 9bc5de3..96d28f9 100644 > --- a/drivers/net/bonding/bond_alb.c > +++ b/drivers/net/bonding/bond_alb.c > @@ -308,49 +308,33 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp) > _unlock_rx_hashtbl(bond); > } > > -static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev) > +static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond, > + struct slave *slave) > { > - struct bonding *bond; > - struct arp_pkt *arp = (struct arp_pkt *)skb->data; > - int res = NET_RX_DROP; > + struct arp_pkt *arp; > > - while (bond_dev->priv_flags& IFF_802_1Q_VLAN) > - bond_dev = vlan_dev_real_dev(bond_dev); > - > - if (!(bond_dev->priv_flags& IFF_BONDING) || > - !(bond_dev->flags& IFF_MASTER)) > - goto out; > + if (skb->protocol != cpu_to_be16(ETH_P_ARP)) > + return; > > + arp = (struct arp_pkt *) skb->data; > if (!arp) { > pr_debug("Packet has no ARP data\n"); > - goto out; > + return; > } > > - skb = skb_share_check(skb, GFP_ATOMIC); > - if (!skb) > - goto out; > - > - if (!pskb_may_pull(skb, arp_hdr_len(bond_dev))) > - goto out; > + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) > + return; > > if (skb->len< sizeof(struct arp_pkt)) { > pr_debug("Packet is too small to be an ARP\n"); > - goto out; > + return; > } > > if (arp->op_code == htons(ARPOP_REPLY)) { > /* update rx hash table for this ARP */ > - bond = netdev_priv(bond_dev); > rlb_update_entry_from_arp(bond, arp); > pr_debug("Server received an ARP Reply from client\n"); > } > - > - res = NET_RX_SUCCESS; > - > -out: > - dev_kfree_skb(skb); > - > - return res; > } > > /* Caller must hold bond lock for read */ > @@ -759,7 +743,6 @@ static void rlb_init_table_entry(struct rlb_client_info *entry) > static int rlb_initialize(struct bonding *bond) > { > struct alb_bond_info *bond_info =&(BOND_ALB_INFO(bond)); > - struct packet_type *pk_type =&(BOND_ALB_INFO(bond).rlb_pkt_type); > struct rlb_client_info *new_hashtbl; > int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); > int i; > @@ -784,13 +767,8 @@ static int rlb_initialize(struct bonding *bond) > > _unlock_rx_hashtbl(bond); > > - /*initialize packet type*/ > - pk_type->type = cpu_to_be16(ETH_P_ARP); > - pk_type->dev = bond->dev; > - pk_type->func = rlb_arp_recv; > - > /* register to receive ARPs */ > - dev_add_pack(pk_type); > + bond->recv_probe = rlb_arp_recv; > > return 0; > } > @@ -799,8 +777,6 @@ static void rlb_deinitialize(struct bonding *bond) > { > struct alb_bond_info *bond_info =&(BOND_ALB_INFO(bond)); > > - dev_remove_pack(&(bond_info->rlb_pkt_type)); > - > _lock_rx_hashtbl(bond); > > kfree(bond_info->rx_hashtbl); > diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h > index 118c28a..6605e9e 100644 > --- a/drivers/net/bonding/bond_alb.h > +++ b/drivers/net/bonding/bond_alb.h > @@ -130,7 +130,6 @@ struct alb_bond_info { > int lp_counter; > /* -------- rlb parameters -------- */ > int rlb_enabled; > - struct packet_type rlb_pkt_type; > struct rlb_client_info *rx_hashtbl; /* Receive hash table */ > spinlock_t rx_hashtbl_lock; > u32 rx_hashtbl_head; > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index dbe182c..8ba7faa 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -1467,27 +1467,17 @@ static void bond_setup_by_slave(struct net_device *bond_dev, > } > > /* On bonding slaves other than the currently active slave, suppress > - * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and > - * ARP on active-backup slaves with arp_validate enabled. > + * duplicates except for alb non-mcast/bcast. > */ > static bool bond_should_deliver_exact_match(struct sk_buff *skb, > struct slave *slave, > struct bonding *bond) > { > if (bond_is_slave_inactive(slave)) { > - if (slave_do_arp_validate(bond, slave)&& > - skb->protocol == __cpu_to_be16(ETH_P_ARP)) > - return false; > - > if (bond->params.mode == BOND_MODE_ALB&& > skb->pkt_type != PACKET_BROADCAST&& > skb->pkt_type != PACKET_MULTICAST) > - return false; > - > - if (bond->params.mode == BOND_MODE_8023AD&& > - skb->protocol == __cpu_to_be16(ETH_P_SLOW)) > return false; > - > return true; > } > return false; > @@ -1513,6 +1503,15 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) > if (bond->params.arp_interval) > slave->dev->last_rx = jiffies; > > + if (bond->recv_probe) { > + struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); > + > + if (likely(nskb)) { > + bond->recv_probe(nskb, bond, slave); > + dev_kfree_skb(nskb); > + } > + } > + > if (bond_should_deliver_exact_match(skb, slave, bond)) { > skb->deliver_no_wcard = 1; > return skb; > @@ -2813,48 +2812,26 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 > } > } > > -static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) > +static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond, > + struct slave *slave) > { > struct arphdr *arp; > - struct slave *slave; > - struct bonding *bond; > unsigned char *arp_ptr; > __be32 sip, tip; > > - if (dev->priv_flags& IFF_802_1Q_VLAN) { > - /* > - * When using VLANS and bonding, dev and oriv_dev may be > - * incorrect if the physical interface supports VLAN > - * acceleration. With this change ARP validation now > - * works for hosts only reachable on the VLAN interface. > - */ > - dev = vlan_dev_real_dev(dev); > - orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); > - } > - > - if (!(dev->priv_flags& IFF_BONDING) || !(dev->flags& IFF_MASTER)) > - goto out; > + if (skb->protocol != __cpu_to_be16(ETH_P_ARP)) > + return; What happens if the skb that hold the ARP request/reply is vlan tagged? The ARP ptype_base handler for bonding used to be called after vlan processing. > - bond = netdev_priv(dev); > read_lock(&bond->lock); > > - pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", > - bond->dev->name, skb->dev ? skb->dev->name : "NULL", > - orig_dev ? orig_dev->name : "NULL"); > + pr_debug("bond_arp_rcv: bond %s skb->dev %s\n", > + bond->dev->name, skb->dev->name); > > - slave = bond_get_slave_by_dev(bond, orig_dev); > - if (!slave || !slave_do_arp_validate(bond, slave)) > - goto out_unlock; > - > - skb = skb_share_check(skb, GFP_ATOMIC); > - if (!skb) > - goto out_unlock; > - > - if (!pskb_may_pull(skb, arp_hdr_len(dev))) > + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) > goto out_unlock; > > arp = arp_hdr(skb); > - if (arp->ar_hln != dev->addr_len || > + if (arp->ar_hln != bond->dev->addr_len || > skb->pkt_type == PACKET_OTHERHOST || > skb->pkt_type == PACKET_LOOPBACK || > arp->ar_hrd != htons(ARPHRD_ETHER) || > @@ -2863,9 +2840,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack > goto out_unlock; > > arp_ptr = (unsigned char *)(arp + 1); > - arp_ptr += dev->addr_len; > + arp_ptr += bond->dev->addr_len; > memcpy(&sip, arp_ptr, 4); > - arp_ptr += 4 + dev->addr_len; > + arp_ptr += 4 + bond->dev->addr_len; > memcpy(&tip, arp_ptr, 4); > > pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", > @@ -2888,9 +2865,6 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack > > out_unlock: > read_unlock(&bond->lock); > -out: > - dev_kfree_skb(skb); > - return NET_RX_SUCCESS; > } > > /* > @@ -3782,48 +3756,6 @@ static struct notifier_block bond_inetaddr_notifier = { > .notifier_call = bond_inetaddr_event, > }; > > -/*-------------------------- Packet type handling ---------------------------*/ > - > -/* register to receive lacpdus on a bond */ > -static void bond_register_lacpdu(struct bonding *bond) > -{ > - struct packet_type *pk_type =&(BOND_AD_INFO(bond).ad_pkt_type); > - > - /* initialize packet type */ > - pk_type->type = PKT_TYPE_LACPDU; > - pk_type->dev = bond->dev; > - pk_type->func = bond_3ad_lacpdu_recv; > - > - dev_add_pack(pk_type); > -} > - > -/* unregister to receive lacpdus on a bond */ > -static void bond_unregister_lacpdu(struct bonding *bond) > -{ > - dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); > -} > - > -void bond_register_arp(struct bonding *bond) > -{ > - struct packet_type *pt =&bond->arp_mon_pt; > - > - if (pt->type) > - return; > - > - pt->type = htons(ETH_P_ARP); > - pt->dev = bond->dev; > - pt->func = bond_arp_rcv; > - dev_add_pack(pt); > -} > - > -void bond_unregister_arp(struct bonding *bond) > -{ > - struct packet_type *pt =&bond->arp_mon_pt; > - > - dev_remove_pack(pt); > - pt->type = 0; > -} > - > /*---------------------------- Hashing Policies -----------------------------*/ > > /* > @@ -3917,14 +3849,14 @@ static int bond_open(struct net_device *bond_dev) > > queue_delayed_work(bond->wq,&bond->arp_work, 0); > if (bond->params.arp_validate) > - bond_register_arp(bond); > + bond->recv_probe = bond_arp_rcv; > } > > if (bond->params.mode == BOND_MODE_8023AD) { > INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); > queue_delayed_work(bond->wq,&bond->ad_work, 0); > /* register to receive LACPDUs */ > - bond_register_lacpdu(bond); > + bond->recv_probe = bond_3ad_lacpdu_recv; > bond_3ad_initiate_agg_selection(bond, 1); > } > > @@ -3935,14 +3867,6 @@ static int bond_close(struct net_device *bond_dev) > { > struct bonding *bond = netdev_priv(bond_dev); > > - if (bond->params.mode == BOND_MODE_8023AD) { > - /* Unregister the receive of LACPDUs */ > - bond_unregister_lacpdu(bond); > - } > - > - if (bond->params.arp_validate) > - bond_unregister_arp(bond); > - > write_lock_bh(&bond->lock); > > bond->send_grat_arp = 0; > @@ -3982,6 +3906,7 @@ static int bond_close(struct net_device *bond_dev) > */ > bond_alb_deinitialize(bond); > } > + bond->recv_probe = NULL; > > return 0; > } > diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c > index 5161183..6804efe 100644 > --- a/drivers/net/bonding/bond_sysfs.c > +++ b/drivers/net/bonding/bond_sysfs.c > @@ -419,11 +419,6 @@ static ssize_t bonding_store_arp_validate(struct device *d, > bond->dev->name, arp_validate_tbl[new_value].modename, > new_value); > > - if (!bond->params.arp_validate&& new_value) > - bond_register_arp(bond); > - else if (bond->params.arp_validate&& !new_value) > - bond_unregister_arp(bond); > - > bond->params.arp_validate = new_value; > > return count; > @@ -998,7 +993,6 @@ static ssize_t bonding_store_miimon(struct device *d, > bond->dev->name); > bond->params.arp_interval = 0; > if (bond->params.arp_validate) { > - bond_unregister_arp(bond); > bond->params.arp_validate = > BOND_ARP_VALIDATE_NONE; > } > diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h > index 8f78166..75a1308 100644 > --- a/drivers/net/bonding/bonding.h > +++ b/drivers/net/bonding/bonding.h > @@ -228,6 +228,8 @@ struct bonding { > struct slave *primary_slave; > bool force_primary; > s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ > + void (*recv_probe)(struct sk_buff *, struct bonding *, > + struct slave *); > rwlock_t lock; > rwlock_t curr_slave_lock; > s8 kill_timers; > @@ -406,8 +408,6 @@ void bond_set_mode_ops(struct bonding *bond, int mode); > int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); > void bond_select_active_slave(struct bonding *bond); > void bond_change_active_slave(struct bonding *bond, struct slave *new_active); > -void bond_register_arp(struct bonding *); > -void bond_unregister_arp(struct bonding *); > void bond_create_debugfs(void); > void bond_destroy_debugfs(void); > void bond_debug_register(struct bonding *bond); ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 14:33 ` Nicolas de Pesloüan @ 2011-03-05 14:43 ` Jiri Pirko 2011-03-05 14:50 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 14:43 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 03:33:30PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 11:29, Jiri Pirko a écrit : >>Since now when bonding uses rx_handler, all traffic going into bond >>device goes thru bond_handle_frame. So there's no need to go back into >>bonding code later via ptype handlers. This patch converts >>original ptype handlers into "bonding receive probes". These functions >>are called from bond_handle_frame and they are registered per-mode. > >Does this still support having the arp_ip_target on a vlan? > >(eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable through bond0.100). This case is still covered with vlan_on_bond_hook eth0-> bond_handle_frame bond0-> vlan_hwaccel_do_receive bond0.5-> vlan_on_bond_hook -> reinject into bond0 -> bond_handle_frame (here it is processed) > >> >>Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>--- >> drivers/net/bonding/bond_3ad.c | 29 ++-------- >> drivers/net/bonding/bond_3ad.h | 4 +- >> drivers/net/bonding/bond_alb.c | 46 ++++----------- >> drivers/net/bonding/bond_alb.h | 1 - >> drivers/net/bonding/bond_main.c | 121 +++++++------------------------------ >> drivers/net/bonding/bond_sysfs.c | 6 -- >> drivers/net/bonding/bonding.h | 4 +- >> 7 files changed, 43 insertions(+), 168 deletions(-) >> >>diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c >>index 047af0b..194aaf7 100644 >>--- a/drivers/net/bonding/bond_3ad.c >>+++ b/drivers/net/bonding/bond_3ad.c >>@@ -2461,35 +2461,16 @@ out: >> return NETDEV_TX_OK; >> } >> >>-int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) >>+void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, >>+ struct slave *slave) >> { >>- struct bonding *bond = netdev_priv(dev); >>- struct slave *slave = NULL; >>- int ret = NET_RX_DROP; >>- >>- if (!(dev->flags& IFF_MASTER)) >>- goto out; >>- >>- skb = skb_share_check(skb, GFP_ATOMIC); >>- if (!skb) >>- goto out; >>+ if (skb->protocol != PKT_TYPE_LACPDU) >>+ return; >> >> if (!pskb_may_pull(skb, sizeof(struct lacpdu))) >>- goto out; >>+ return; >> >> read_lock(&bond->lock); >>- slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev); >>- if (!slave) >>- goto out_unlock; >>- >> bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len); >>- >>- ret = NET_RX_SUCCESS; >>- >>-out_unlock: >> read_unlock(&bond->lock); >>-out: >>- dev_kfree_skb(skb); >>- >>- return ret; >> } >>diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h >>index 2c46a154..56a88ff 100644 >>--- a/drivers/net/bonding/bond_3ad.h >>+++ b/drivers/net/bonding/bond_3ad.h >>@@ -258,7 +258,6 @@ struct ad_bond_info { >> * requested >> */ >> struct timer_list ad_timer; >>- struct packet_type ad_pkt_type; >> }; >> >> struct ad_slave_info { >>@@ -279,7 +278,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave); >> void bond_3ad_handle_link_change(struct slave *slave, char link); >> int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info); >> int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev); >>-int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev); >>+void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, >>+ struct slave *slave); >> int bond_3ad_set_carrier(struct bonding *bond); >> #endif //__BOND_3AD_H__ >> >>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c >>index 9bc5de3..96d28f9 100644 >>--- a/drivers/net/bonding/bond_alb.c >>+++ b/drivers/net/bonding/bond_alb.c >>@@ -308,49 +308,33 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp) >> _unlock_rx_hashtbl(bond); >> } >> >>-static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev) >>+static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond, >>+ struct slave *slave) >> { >>- struct bonding *bond; >>- struct arp_pkt *arp = (struct arp_pkt *)skb->data; >>- int res = NET_RX_DROP; >>+ struct arp_pkt *arp; >> >>- while (bond_dev->priv_flags& IFF_802_1Q_VLAN) >>- bond_dev = vlan_dev_real_dev(bond_dev); >>- >>- if (!(bond_dev->priv_flags& IFF_BONDING) || >>- !(bond_dev->flags& IFF_MASTER)) >>- goto out; >>+ if (skb->protocol != cpu_to_be16(ETH_P_ARP)) >>+ return; >> >>+ arp = (struct arp_pkt *) skb->data; >> if (!arp) { >> pr_debug("Packet has no ARP data\n"); >>- goto out; >>+ return; >> } >> >>- skb = skb_share_check(skb, GFP_ATOMIC); >>- if (!skb) >>- goto out; >>- >>- if (!pskb_may_pull(skb, arp_hdr_len(bond_dev))) >>- goto out; >>+ if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) >>+ return; >> >> if (skb->len< sizeof(struct arp_pkt)) { >> pr_debug("Packet is too small to be an ARP\n"); >>- goto out; >>+ return; >> } >> >> if (arp->op_code == htons(ARPOP_REPLY)) { >> /* update rx hash table for this ARP */ >>- bond = netdev_priv(bond_dev); >> rlb_update_entry_from_arp(bond, arp); >> pr_debug("Server received an ARP Reply from client\n"); >> } >>- >>- res = NET_RX_SUCCESS; >>- >>-out: >>- dev_kfree_skb(skb); >>- >>- return res; >> } >> >> /* Caller must hold bond lock for read */ >>@@ -759,7 +743,6 @@ static void rlb_init_table_entry(struct rlb_client_info *entry) >> static int rlb_initialize(struct bonding *bond) >> { >> struct alb_bond_info *bond_info =&(BOND_ALB_INFO(bond)); >>- struct packet_type *pk_type =&(BOND_ALB_INFO(bond).rlb_pkt_type); >> struct rlb_client_info *new_hashtbl; >> int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); >> int i; >>@@ -784,13 +767,8 @@ static int rlb_initialize(struct bonding *bond) >> >> _unlock_rx_hashtbl(bond); >> >>- /*initialize packet type*/ >>- pk_type->type = cpu_to_be16(ETH_P_ARP); >>- pk_type->dev = bond->dev; >>- pk_type->func = rlb_arp_recv; >>- >> /* register to receive ARPs */ >>- dev_add_pack(pk_type); >>+ bond->recv_probe = rlb_arp_recv; >> >> return 0; >> } >>@@ -799,8 +777,6 @@ static void rlb_deinitialize(struct bonding *bond) >> { >> struct alb_bond_info *bond_info =&(BOND_ALB_INFO(bond)); >> >>- dev_remove_pack(&(bond_info->rlb_pkt_type)); >>- >> _lock_rx_hashtbl(bond); >> >> kfree(bond_info->rx_hashtbl); >>diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h >>index 118c28a..6605e9e 100644 >>--- a/drivers/net/bonding/bond_alb.h >>+++ b/drivers/net/bonding/bond_alb.h >>@@ -130,7 +130,6 @@ struct alb_bond_info { >> int lp_counter; >> /* -------- rlb parameters -------- */ >> int rlb_enabled; >>- struct packet_type rlb_pkt_type; >> struct rlb_client_info *rx_hashtbl; /* Receive hash table */ >> spinlock_t rx_hashtbl_lock; >> u32 rx_hashtbl_head; >>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c >>index dbe182c..8ba7faa 100644 >>--- a/drivers/net/bonding/bond_main.c >>+++ b/drivers/net/bonding/bond_main.c >>@@ -1467,27 +1467,17 @@ static void bond_setup_by_slave(struct net_device *bond_dev, >> } >> >> /* On bonding slaves other than the currently active slave, suppress >>- * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and >>- * ARP on active-backup slaves with arp_validate enabled. >>+ * duplicates except for alb non-mcast/bcast. >> */ >> static bool bond_should_deliver_exact_match(struct sk_buff *skb, >> struct slave *slave, >> struct bonding *bond) >> { >> if (bond_is_slave_inactive(slave)) { >>- if (slave_do_arp_validate(bond, slave)&& >>- skb->protocol == __cpu_to_be16(ETH_P_ARP)) >>- return false; >>- >> if (bond->params.mode == BOND_MODE_ALB&& >> skb->pkt_type != PACKET_BROADCAST&& >> skb->pkt_type != PACKET_MULTICAST) >>- return false; >>- >>- if (bond->params.mode == BOND_MODE_8023AD&& >>- skb->protocol == __cpu_to_be16(ETH_P_SLOW)) >> return false; >>- >> return true; >> } >> return false; >>@@ -1513,6 +1503,15 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) >> if (bond->params.arp_interval) >> slave->dev->last_rx = jiffies; >> >>+ if (bond->recv_probe) { >>+ struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); >>+ >>+ if (likely(nskb)) { >>+ bond->recv_probe(nskb, bond, slave); >>+ dev_kfree_skb(nskb); >>+ } >>+ } >>+ >> if (bond_should_deliver_exact_match(skb, slave, bond)) { >> skb->deliver_no_wcard = 1; >> return skb; >>@@ -2813,48 +2812,26 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 >> } >> } >> >>-static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) >>+static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond, >>+ struct slave *slave) >> { >> struct arphdr *arp; >>- struct slave *slave; >>- struct bonding *bond; >> unsigned char *arp_ptr; >> __be32 sip, tip; >> >>- if (dev->priv_flags& IFF_802_1Q_VLAN) { >>- /* >>- * When using VLANS and bonding, dev and oriv_dev may be >>- * incorrect if the physical interface supports VLAN >>- * acceleration. With this change ARP validation now >>- * works for hosts only reachable on the VLAN interface. >>- */ >>- dev = vlan_dev_real_dev(dev); >>- orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); >>- } >>- >>- if (!(dev->priv_flags& IFF_BONDING) || !(dev->flags& IFF_MASTER)) >>- goto out; >>+ if (skb->protocol != __cpu_to_be16(ETH_P_ARP)) >>+ return; > >What happens if the skb that hold the ARP request/reply is vlan >tagged? The ARP ptype_base handler for bonding used to be called >after vlan processing. > >>- bond = netdev_priv(dev); >> read_lock(&bond->lock); >> >>- pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", >>- bond->dev->name, skb->dev ? skb->dev->name : "NULL", >>- orig_dev ? orig_dev->name : "NULL"); >>+ pr_debug("bond_arp_rcv: bond %s skb->dev %s\n", >>+ bond->dev->name, skb->dev->name); >> >>- slave = bond_get_slave_by_dev(bond, orig_dev); >>- if (!slave || !slave_do_arp_validate(bond, slave)) >>- goto out_unlock; >>- >>- skb = skb_share_check(skb, GFP_ATOMIC); >>- if (!skb) >>- goto out_unlock; >>- >>- if (!pskb_may_pull(skb, arp_hdr_len(dev))) >>+ if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) >> goto out_unlock; >> >> arp = arp_hdr(skb); >>- if (arp->ar_hln != dev->addr_len || >>+ if (arp->ar_hln != bond->dev->addr_len || >> skb->pkt_type == PACKET_OTHERHOST || >> skb->pkt_type == PACKET_LOOPBACK || >> arp->ar_hrd != htons(ARPHRD_ETHER) || >>@@ -2863,9 +2840,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack >> goto out_unlock; >> >> arp_ptr = (unsigned char *)(arp + 1); >>- arp_ptr += dev->addr_len; >>+ arp_ptr += bond->dev->addr_len; >> memcpy(&sip, arp_ptr, 4); >>- arp_ptr += 4 + dev->addr_len; >>+ arp_ptr += 4 + bond->dev->addr_len; >> memcpy(&tip, arp_ptr, 4); >> >> pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", >>@@ -2888,9 +2865,6 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack >> >> out_unlock: >> read_unlock(&bond->lock); >>-out: >>- dev_kfree_skb(skb); >>- return NET_RX_SUCCESS; >> } >> >> /* >>@@ -3782,48 +3756,6 @@ static struct notifier_block bond_inetaddr_notifier = { >> .notifier_call = bond_inetaddr_event, >> }; >> >>-/*-------------------------- Packet type handling ---------------------------*/ >>- >>-/* register to receive lacpdus on a bond */ >>-static void bond_register_lacpdu(struct bonding *bond) >>-{ >>- struct packet_type *pk_type =&(BOND_AD_INFO(bond).ad_pkt_type); >>- >>- /* initialize packet type */ >>- pk_type->type = PKT_TYPE_LACPDU; >>- pk_type->dev = bond->dev; >>- pk_type->func = bond_3ad_lacpdu_recv; >>- >>- dev_add_pack(pk_type); >>-} >>- >>-/* unregister to receive lacpdus on a bond */ >>-static void bond_unregister_lacpdu(struct bonding *bond) >>-{ >>- dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); >>-} >>- >>-void bond_register_arp(struct bonding *bond) >>-{ >>- struct packet_type *pt =&bond->arp_mon_pt; >>- >>- if (pt->type) >>- return; >>- >>- pt->type = htons(ETH_P_ARP); >>- pt->dev = bond->dev; >>- pt->func = bond_arp_rcv; >>- dev_add_pack(pt); >>-} >>- >>-void bond_unregister_arp(struct bonding *bond) >>-{ >>- struct packet_type *pt =&bond->arp_mon_pt; >>- >>- dev_remove_pack(pt); >>- pt->type = 0; >>-} >>- >> /*---------------------------- Hashing Policies -----------------------------*/ >> >> /* >>@@ -3917,14 +3849,14 @@ static int bond_open(struct net_device *bond_dev) >> >> queue_delayed_work(bond->wq,&bond->arp_work, 0); >> if (bond->params.arp_validate) >>- bond_register_arp(bond); >>+ bond->recv_probe = bond_arp_rcv; >> } >> >> if (bond->params.mode == BOND_MODE_8023AD) { >> INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); >> queue_delayed_work(bond->wq,&bond->ad_work, 0); >> /* register to receive LACPDUs */ >>- bond_register_lacpdu(bond); >>+ bond->recv_probe = bond_3ad_lacpdu_recv; >> bond_3ad_initiate_agg_selection(bond, 1); >> } >> >>@@ -3935,14 +3867,6 @@ static int bond_close(struct net_device *bond_dev) >> { >> struct bonding *bond = netdev_priv(bond_dev); >> >>- if (bond->params.mode == BOND_MODE_8023AD) { >>- /* Unregister the receive of LACPDUs */ >>- bond_unregister_lacpdu(bond); >>- } >>- >>- if (bond->params.arp_validate) >>- bond_unregister_arp(bond); >>- >> write_lock_bh(&bond->lock); >> >> bond->send_grat_arp = 0; >>@@ -3982,6 +3906,7 @@ static int bond_close(struct net_device *bond_dev) >> */ >> bond_alb_deinitialize(bond); >> } >>+ bond->recv_probe = NULL; >> >> return 0; >> } >>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c >>index 5161183..6804efe 100644 >>--- a/drivers/net/bonding/bond_sysfs.c >>+++ b/drivers/net/bonding/bond_sysfs.c >>@@ -419,11 +419,6 @@ static ssize_t bonding_store_arp_validate(struct device *d, >> bond->dev->name, arp_validate_tbl[new_value].modename, >> new_value); >> >>- if (!bond->params.arp_validate&& new_value) >>- bond_register_arp(bond); >>- else if (bond->params.arp_validate&& !new_value) >>- bond_unregister_arp(bond); >>- >> bond->params.arp_validate = new_value; >> >> return count; >>@@ -998,7 +993,6 @@ static ssize_t bonding_store_miimon(struct device *d, >> bond->dev->name); >> bond->params.arp_interval = 0; >> if (bond->params.arp_validate) { >>- bond_unregister_arp(bond); >> bond->params.arp_validate = >> BOND_ARP_VALIDATE_NONE; >> } >>diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h >>index 8f78166..75a1308 100644 >>--- a/drivers/net/bonding/bonding.h >>+++ b/drivers/net/bonding/bonding.h >>@@ -228,6 +228,8 @@ struct bonding { >> struct slave *primary_slave; >> bool force_primary; >> s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ >>+ void (*recv_probe)(struct sk_buff *, struct bonding *, >>+ struct slave *); >> rwlock_t lock; >> rwlock_t curr_slave_lock; >> s8 kill_timers; >>@@ -406,8 +408,6 @@ void bond_set_mode_ops(struct bonding *bond, int mode); >> int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); >> void bond_select_active_slave(struct bonding *bond); >> void bond_change_active_slave(struct bonding *bond, struct slave *new_active); >>-void bond_register_arp(struct bonding *); >>-void bond_unregister_arp(struct bonding *); >> void bond_create_debugfs(void); >> void bond_destroy_debugfs(void); >> void bond_debug_register(struct bonding *bond); > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 14:43 ` Jiri Pirko @ 2011-03-05 14:50 ` Nicolas de Pesloüan 2011-03-06 12:24 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:50 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 15:43, Jiri Pirko a écrit : > Sat, Mar 05, 2011 at 03:33:30PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 11:29, Jiri Pirko a écrit : >>> Since now when bonding uses rx_handler, all traffic going into bond >>> device goes thru bond_handle_frame. So there's no need to go back into >>> bonding code later via ptype handlers. This patch converts >>> original ptype handlers into "bonding receive probes". These functions >>> are called from bond_handle_frame and they are registered per-mode. >> >> Does this still support having the arp_ip_target on a vlan? >> >> (eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable through bond0.100). > > This case is still covered with vlan_on_bond_hook > eth0-> > bond_handle_frame > bond0-> > vlan_hwaccel_do_receive > bond0.5-> > vlan_on_bond_hook -> reinject into bond0 > -> bond_handle_frame (here it is processed) Sound good to me. Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 14:50 ` Nicolas de Pesloüan @ 2011-03-06 12:24 ` Nicolas de Pesloüan 2011-03-06 13:34 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-06 12:24 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 15:50, Nicolas de Pesloüan a écrit : > Le 05/03/2011 15:43, Jiri Pirko a écrit : >> Sat, Mar 05, 2011 at 03:33:30PM CET, nicolas.2p.debian@gmail.com wrote: >>> Le 05/03/2011 11:29, Jiri Pirko a écrit : >>>> Since now when bonding uses rx_handler, all traffic going into bond >>>> device goes thru bond_handle_frame. So there's no need to go back into >>>> bonding code later via ptype handlers. This patch converts >>>> original ptype handlers into "bonding receive probes". These functions >>>> are called from bond_handle_frame and they are registered per-mode. >>> >>> Does this still support having the arp_ip_target on a vlan? >>> >>> (eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable >>> through bond0.100). >> >> This case is still covered with vlan_on_bond_hook >> eth0-> >> bond_handle_frame >> bond0-> >> vlan_hwaccel_do_receive >> bond0.5-> >> vlan_on_bond_hook -> reinject into bond0 >> -> bond_handle_frame (here it is processed) > > Sound good to me. > > Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> After another review, I think it won't work. vlan_on_bond() will reinject into bond0, but bond_handle_frame() is registered as the rx_handler for the slaves (eth0 in the above setup), not as the rx_handler for the master (bond0 in the above setup). So, bond_handlee_frame() will never see the untagged ARP request/reply and bonding ARP monitoring will fail. That being said, the current vlan_on_bond_hook() hack already suffer other troubles and for example won't support the following setup: eth0 -> bond0 -> br0 -> br0.100. I think we need to fix this stacking issue in a more general way. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-06 12:24 ` Nicolas de Pesloüan @ 2011-03-06 13:34 ` Jiri Pirko 2011-03-06 14:25 ` Nicolas de Pesloüan 2011-03-07 12:51 ` [patch net-next-2.6] net: reinject arps into bonding slave instead of master Jiri Pirko 0 siblings, 2 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-06 13:34 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sun, Mar 06, 2011 at 01:24:32PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 15:50, Nicolas de Pesloüan a écrit : >>Le 05/03/2011 15:43, Jiri Pirko a écrit : >>>Sat, Mar 05, 2011 at 03:33:30PM CET, nicolas.2p.debian@gmail.com wrote: >>>>Le 05/03/2011 11:29, Jiri Pirko a écrit : >>>>>Since now when bonding uses rx_handler, all traffic going into bond >>>>>device goes thru bond_handle_frame. So there's no need to go back into >>>>>bonding code later via ptype handlers. This patch converts >>>>>original ptype handlers into "bonding receive probes". These functions >>>>>are called from bond_handle_frame and they are registered per-mode. >>>> >>>>Does this still support having the arp_ip_target on a vlan? >>>> >>>>(eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable >>>>through bond0.100). >>> >>>This case is still covered with vlan_on_bond_hook >>>eth0-> >>>bond_handle_frame >>>bond0-> >>>vlan_hwaccel_do_receive >>>bond0.5-> >>>vlan_on_bond_hook -> reinject into bond0 >>>-> bond_handle_frame (here it is processed) >> >>Sound good to me. >> >>Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > >After another review, I think it won't work. > >vlan_on_bond() will reinject into bond0, but bond_handle_frame() is >registered as the rx_handler for the slaves (eth0 in the above >setup), not as the rx_handler for the master (bond0 in the above >setup). So, bond_handlee_frame() will never see the untagged ARP >request/reply and bonding ARP monitoring will fail. Damn, you are right. I mislooked. > >That being said, the current vlan_on_bond_hook() hack already suffer >other troubles and for example won't support the following setup: > >eth0 -> bond0 -> br0 -> br0.100. blah. Well correct me if my thinking is wrong but I cannot imagine a scenario where there's not other way how to do arp monitoring than over vlan. So how about to just remove the vlan_on_bond_hook and forbid the possibility. IMHO it should have never been introduced in the first place. > >I think we need to fix this stacking issue in a more general way. Well this issue is more or less out of the concept and breaks layering. I cannot think of how to resolve this nicely atm. > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-06 13:34 ` Jiri Pirko @ 2011-03-06 14:25 ` Nicolas de Pesloüan 2011-03-06 16:32 ` Michał Mirosław 2011-03-07 12:51 ` [patch net-next-2.6] net: reinject arps into bonding slave instead of master Jiri Pirko 1 sibling, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-06 14:25 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 06/03/2011 14:34, Jiri Pirko a écrit : > Sun, Mar 06, 2011 at 01:24:32PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 15:50, Nicolas de Pesloüan a écrit : >>> Le 05/03/2011 15:43, Jiri Pirko a écrit : >>>> Sat, Mar 05, 2011 at 03:33:30PM CET, nicolas.2p.debian@gmail.com wrote: >>>>> Le 05/03/2011 11:29, Jiri Pirko a écrit : >>>>>> Since now when bonding uses rx_handler, all traffic going into bond >>>>>> device goes thru bond_handle_frame. So there's no need to go back into >>>>>> bonding code later via ptype handlers. This patch converts >>>>>> original ptype handlers into "bonding receive probes". These functions >>>>>> are called from bond_handle_frame and they are registered per-mode. >>>>> >>>>> Does this still support having the arp_ip_target on a vlan? >>>>> >>>>> (eth0 -> bond0 -> bond0.100, with arp_ip_target only reachable >>>>> through bond0.100). >>>> >>>> This case is still covered with vlan_on_bond_hook >>>> eth0-> >>>> bond_handle_frame >>>> bond0-> >>>> vlan_hwaccel_do_receive >>>> bond0.5-> >>>> vlan_on_bond_hook -> reinject into bond0 >>>> -> bond_handle_frame (here it is processed) >>> >>> Sound good to me. >>> >>> Reviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr> >> >> After another review, I think it won't work. >> >> vlan_on_bond() will reinject into bond0, but bond_handle_frame() is >> registered as the rx_handler for the slaves (eth0 in the above >> setup), not as the rx_handler for the master (bond0 in the above >> setup). So, bond_handlee_frame() will never see the untagged ARP >> request/reply and bonding ARP monitoring will fail. > > Damn, you are right. I mislooked. So do I :-D >> That being said, the current vlan_on_bond_hook() hack already suffer >> other troubles and for example won't support the following setup: >> >> eth0 -> bond0 -> br0 -> br0.100. > > blah. Well correct me if my thinking is wrong but I cannot imagine > a scenario where there's not other way how to do arp monitoring than > over vlan. If you are connected to a switch smart enough to allow non tagged delivery for one vlan and all you arp_ip_targets are reachable through that vlan, then, yes, this hack might been useless... But... In real life, you may be connected to any kind of switch, including the most stupid one... or you may have trouble explaining to the network team the reason why you need all packets to be tagged expect for one vlan... or simply, some of your arp_ip_targets will be reachable through a router in another vlan. > So how about to just remove the vlan_on_bond_hook and forbid the > possibility. IMHO it should have never been introduced in the first > place. If it was never introduced, we would have been able to simply forbid it, but the feature exist since December 14th 2009, so I'm afraid we must keep it... :-/ And as a more general rule, I think we should support "all possible" interface stacking setups, because this would force us to think generic, instead of adding special hacks for special stacking setups. >> I think we need to fix this stacking issue in a more general way. > > Well this issue is more or less out of the concept and breaks layering. > I cannot think of how to resolve this nicely atm. The only way I can imagine atm is something I described a few days ago: 1/ Add a late_delivery property to packet_type: struct packet_type { __be16 type; /* This is really htons(ether_type). */ struct net_device *dev; /* NULL is wildcarded here */ int (*func) (struct sk_buff *, struct net_device *, struct packet_type *); struct sk_buff *(*gso_segment)(struct sk_buff *skb, u32 features); int (*gso_send_check)(struct sk_buff *skb); struct sk_buff **(*gro_receive)(struct sk_buff **head, struct sk_buff *skb); int (*gro_complete)(struct sk_buff *skb); void *af_packet_priv; + bool late_delivery; struct list_head list; }; 2/ Use the late_delivery property inside the ptype_all and ptype_base loops in __netif_receive_skb(), to skip the protocol handlers whose late_delivery property is false, while we walk the rx_handler path. 3/ At the end of __netif_receive_skb(), deliver the final skb to those ptype_all and ptype_base handlers whose late_delivery property is true. 4/ And revert back the bonding ARP monitoring to a normal protocol handler, having late_delivery == true. This would work with eth0 -> bond0 -> bond0.100 and eth0 -> bond0 -> br0 -> br0.100. This would also be reasonably generic, from my point of view. No reference to vlan, bonding, bridge or whatever... Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-06 14:25 ` Nicolas de Pesloüan @ 2011-03-06 16:32 ` Michał Mirosław 2011-03-06 17:37 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Michał Mirosław @ 2011-03-06 16:32 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy 2011/3/6 Nicolas de Pesloüan <nicolas.2p.debian@gmail.com>: > Le 06/03/2011 14:34, Jiri Pirko a écrit : >> Sun, Mar 06, 2011 at 01:24:32PM CET, nicolas.2p.debian@gmail.com wrote: [...] >>> That being said, the current vlan_on_bond_hook() hack already suffer >>> other troubles and for example won't support the following setup: >>> >>> eth0 -> bond0 -> br0 -> br0.100. >> >> blah. Well correct me if my thinking is wrong but I cannot imagine >> a scenario where there's not other way how to do arp monitoring than >> over vlan. > > If you are connected to a switch smart enough to allow non tagged delivery > for one vlan and all you arp_ip_targets are reachable through that vlan, > then, yes, this hack might been useless... > > But... > > In real life, you may be connected to any kind of switch, including the most > stupid one... or you may have trouble explaining to the network team the > reason why you need all packets to be tagged expect for one vlan... or > simply, some of your arp_ip_targets will be reachable through a router in > another vlan. > >> So how about to just remove the vlan_on_bond_hook and forbid the >> possibility. IMHO it should have never been introduced in the first >> place. > > If it was never introduced, we would have been able to simply forbid it, but > the feature exist since December 14th 2009, so I'm afraid we must keep it... > :-/ > > And as a more general rule, I think we should support "all possible" > interface stacking setups, because this would force us to think generic, > instead of adding special hacks for special stacking setups. > >>> I think we need to fix this stacking issue in a more general way. >> >> Well this issue is more or less out of the concept and breaks layering. >> I cannot think of how to resolve this nicely atm. > > The only way I can imagine atm is something I described a few days ago: > > 1/ Add a late_delivery property to packet_type: > > struct packet_type { > __be16 type; /* This is really > htons(ether_type). */ > struct net_device *dev; /* NULL is wildcarded here > */ > int (*func) (struct sk_buff *, > struct net_device *, > struct packet_type *); > struct sk_buff *(*gso_segment)(struct sk_buff *skb, > u32 features); > int (*gso_send_check)(struct sk_buff > *skb); > struct sk_buff **(*gro_receive)(struct sk_buff > **head, > struct sk_buff *skb); > int (*gro_complete)(struct sk_buff *skb); > void *af_packet_priv; > + bool late_delivery; > struct list_head list; > }; > > 2/ Use the late_delivery property inside the ptype_all and ptype_base loops > in __netif_receive_skb(), to skip the protocol handlers whose late_delivery > property is false, while we walk the rx_handler path. > > 3/ At the end of __netif_receive_skb(), deliver the final skb to those > ptype_all and ptype_base handlers whose late_delivery property is true. > > 4/ And revert back the bonding ARP monitoring to a normal protocol handler, > having late_delivery == true. > > This would work with eth0 -> bond0 -> bond0.100 and eth0 -> bond0 -> br0 -> > br0.100. > > This would also be reasonably generic, from my point of view. No reference > to vlan, bonding, bridge or whatever... Is there a particular reason why this ARP monitoring can't be done in userspace (e.g. on AF_PACKET with suitable filter)? Marking slaves up/down as their link goes in that direction is easy, but as more and more link-state detecting methods/algorithms get added this is becoming more of a mess. Best Regards, Michał Mirosław ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-06 16:32 ` Michał Mirosław @ 2011-03-06 17:37 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-06 17:37 UTC (permalink / raw) To: Michał Mirosław Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 06/03/2011 17:32, Michał Mirosław a écrit : [snip] > Is there a particular reason why this ARP monitoring can't be done in > userspace (e.g. on AF_PACKET with suitable filter)? Marking slaves > up/down as their link goes in that direction is easy, but as more and > more link-state detecting methods/algorithms get added this is > becoming more of a mess. Moving as much as possible of bonding into userspace is a long standing target. I think we currently lack a good way to notify the bonding driver that a given slave is available or not. Bringing the slave down on link failure is not appropriate, because it would prevent userspace from receiving the ARP packets that would bring the slave up again upon link return. The only thing we can do is writing into /sys/class/net/bond0/bonding/active_slave, to force the active_slave. And this is strictly limited to active-backup mode. I will let Jay / Andy comment on the general problem. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-06 13:34 ` Jiri Pirko 2011-03-06 14:25 ` Nicolas de Pesloüan @ 2011-03-07 12:51 ` Jiri Pirko 2011-03-07 14:32 ` Andy Gospodarek 2011-03-07 22:43 ` Andy Gospodarek 1 sibling, 2 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-07 12:51 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Recent patch "bonding: move processing of recv handlers into handle_frame()" caused a regression on following net scheme: eth0 - bond0 - bond0.5 where arp monitoring is happening over vlan. This patch fixes it by reinjecting the arp packet into bonding slave device so the bonding rx_handler can pickup and process it. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- net/core/dev.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index c71bd18..3d88458 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) } EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); -static void vlan_on_bond_hook(struct sk_buff *skb) +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) { /* * Make sure ARP frames received on VLAN interfaces stacked on * bonding interfaces still make their way to any base bonding - * device that may have registered for a specific ptype. + * device by reinjecting the frame into bonding slave (orig_dev) */ if (skb->dev->priv_flags & IFF_802_1Q_VLAN && vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) if (!skb2) return; - skb2->dev = vlan_dev_real_dev(skb->dev); + skb2->dev = orig_dev; netif_rx(skb2); } } @@ -3202,7 +3202,7 @@ ncls: goto out; } - vlan_on_bond_hook(skb); + vlan_on_bond_hook(skb, orig_dev); /* deliver only exact match when indicated */ null_or_dev = deliver_exact ? skb->dev : NULL; -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 12:51 ` [patch net-next-2.6] net: reinject arps into bonding slave instead of master Jiri Pirko @ 2011-03-07 14:32 ` Andy Gospodarek 2011-03-07 20:12 ` Nicolas de Pesloüan 2011-03-07 22:43 ` Andy Gospodarek 1 sibling, 1 reply; 74+ messages in thread From: Andy Gospodarek @ 2011-03-07 14:32 UTC (permalink / raw) To: Jiri Pirko Cc: Nicolas de Pesloüan, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy On Mon, Mar 07, 2011 at 01:51:00PM +0100, Jiri Pirko wrote: > Recent patch "bonding: move processing of recv handlers into > handle_frame()" caused a regression on following net scheme: > > eth0 - bond0 - bond0.5 > > where arp monitoring is happening over vlan. This patch fixes it by > reinjecting the arp packet into bonding slave device so the bonding > rx_handler can pickup and process it. > > Signed-off-by: Jiri Pirko <jpirko@redhat.com> Thanks, Jiri. I will test and make sure it works correctly now. I know several users who would be quite disappointed if this feature was removed. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 14:32 ` Andy Gospodarek @ 2011-03-07 20:12 ` Nicolas de Pesloüan 2011-03-07 21:19 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-07 20:12 UTC (permalink / raw) To: Andy Gospodarek Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 07/03/2011 15:32, Andy Gospodarek a écrit : > On Mon, Mar 07, 2011 at 01:51:00PM +0100, Jiri Pirko wrote: >> Recent patch "bonding: move processing of recv handlers into >> handle_frame()" caused a regression on following net scheme: >> >> eth0 - bond0 - bond0.5 >> >> where arp monitoring is happening over vlan. This patch fixes it by >> reinjecting the arp packet into bonding slave device so the bonding >> rx_handler can pickup and process it. >> >> Signed-off-by: Jiri Pirko<jpirko@redhat.com> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > Thanks, Jiri. I will test and make sure it works correctly now. I know > several users who would be quite disappointed if this feature was > removed. Andy, while you are testing it, can you ensure it also works for the following setup? eth0 -> bond0 -> br0 -> br0.100 I think it should, as long as the slave is the first device in the path. Can you imagine a bonding setup where the slaves are not first in the path? eth0 -> br0 -> bond0? eth0 -> eth1(macvlan) -> bond0? eth0 -> eth0.100 -> bond0? Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 20:12 ` Nicolas de Pesloüan @ 2011-03-07 21:19 ` Jiri Pirko 2011-03-07 21:30 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-07 21:19 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet > >Andy, while you are testing it, can you ensure it also works for the following setup? > >eth0 -> bond0 -> br0 -> br0.100 > I do not think this will work (it never did). Bridge reinjects skb, does not do another loop. Therefore when skb->dev == br0 and vlan_on_bond hook is called, orig_dev == br0 as well. + No IFF_BONDING is set. I have some kind nice solution in mind and I'm going to submit that as a patch later (too many patches are in the wind atm). Jirka ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 21:19 ` Jiri Pirko @ 2011-03-07 21:30 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-07 21:30 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 07/03/2011 22:19, Jiri Pirko a écrit : >> >> Andy, while you are testing it, can you ensure it also works for the following setup? >> >> eth0 -> bond0 -> br0 -> br0.100 >> > > I do not think this will work (it never did). Yes, but it should... > Bridge reinjects skb, does not do another loop. Yes, but it should... > Therefore when skb->dev == br0 and vlan_on_bond hook is called, orig_dev == br0 as well. + No > IFF_BONDING is set. If only bridge returned RX_HANDLER_ANOTHER with skb->dev changed to br0... instead of re-injecting the skb... One more reason to avoid re-injecting. > I have some kind nice solution in mind and I'm going to submit that as a patch later (too many > patches are in the wind atm). Agreed. It's time for others to review, test and ack :-D Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 12:51 ` [patch net-next-2.6] net: reinject arps into bonding slave instead of master Jiri Pirko 2011-03-07 14:32 ` Andy Gospodarek @ 2011-03-07 22:43 ` Andy Gospodarek 2011-03-07 23:09 ` Nicolas de Pesloüan 2011-03-08 7:13 ` Jiri Pirko 1 sibling, 2 replies; 74+ messages in thread From: Andy Gospodarek @ 2011-03-07 22:43 UTC (permalink / raw) To: Jiri Pirko Cc: Nicolas de Pesloüan, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy On Mon, Mar 07, 2011 at 01:51:00PM +0100, Jiri Pirko wrote: > Recent patch "bonding: move processing of recv handlers into > handle_frame()" caused a regression on following net scheme: > > eth0 - bond0 - bond0.5 > > where arp monitoring is happening over vlan. This patch fixes it by > reinjecting the arp packet into bonding slave device so the bonding > rx_handler can pickup and process it. > > Signed-off-by: Jiri Pirko <jpirko@redhat.com> > --- > net/core/dev.c | 8 ++++---- > 1 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index c71bd18..3d88458 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) > } > EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); > > -static void vlan_on_bond_hook(struct sk_buff *skb) > +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) > { > /* > * Make sure ARP frames received on VLAN interfaces stacked on > * bonding interfaces still make their way to any base bonding > - * device that may have registered for a specific ptype. > + * device by reinjecting the frame into bonding slave (orig_dev) > */ > if (skb->dev->priv_flags & IFF_802_1Q_VLAN && > vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && > @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) > > if (!skb2) > return; > - skb2->dev = vlan_dev_real_dev(skb->dev); > + skb2->dev = orig_dev; > netif_rx(skb2); > } > } > @@ -3202,7 +3202,7 @@ ncls: > goto out; > } > > - vlan_on_bond_hook(skb); > + vlan_on_bond_hook(skb, orig_dev); > > /* deliver only exact match when indicated */ > null_or_dev = deliver_exact ? skb->dev : NULL; This patch doesn't work. My setup has bond0.100 -> bond0 -> eth2 and eth3. ARP monitoring is enabled as is arp_valiate. The initial problem was just that just before vlan_on_bond_hook is called, skb->dev = bond0.100 and orig_dev = eth2. (This is after running goto another_route and having been called back through __netif_receive_skb since vlan_hwaccel_do_receive it true.) Now vlan_on_bond_hook is called and we have 2 skbs. The original skb still have skb->dev = bond0.100 and orig_dev = eth2. Since bond_arp_rcv is registered for traffic only to bond0, the handler is not hit and the frame is dropped (or processed by another handler). The cloned skb has skb->dev = bond0 and is put back on the receive queue and comes back through __netif_receive_skb. This frame will match the ptype entry for bond_arp_rcv, but since orig_dev = bond0 in this case, the code in bond_arp_rcv will not handle the frame. If we truly want to track the original interface that received the frame, the following is a better option. With the recursive nature of __netif_receive_skb at this point, we should really consider setting orig_dev from skb_iif rather than just from skb->dev. diff --git a/net/core/dev.c b/net/core/dev.c index 30440e7..500fdbc 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3135,7 +3135,6 @@ static int __netif_receive_skb(struct sk_buff *skb) if (!skb->skb_iif) skb->skb_iif = skb->dev->ifindex; - orig_dev = skb->dev; skb_reset_network_header(skb); skb_reset_transport_header(skb); @@ -3145,6 +3144,7 @@ static int __netif_receive_skb(struct sk_buff *skb) rcu_read_lock(); + orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); another_round: __this_cpu_inc(softnet_data.processed); ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 22:43 ` Andy Gospodarek @ 2011-03-07 23:09 ` Nicolas de Pesloüan 2011-03-08 2:43 ` Andy Gospodarek 2011-03-08 7:13 ` Jiri Pirko 1 sibling, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-07 23:09 UTC (permalink / raw) To: Andy Gospodarek Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 07/03/2011 23:43, Andy Gospodarek a écrit : > On Mon, Mar 07, 2011 at 01:51:00PM +0100, Jiri Pirko wrote: >> Recent patch "bonding: move processing of recv handlers into >> handle_frame()" caused a regression on following net scheme: >> >> eth0 - bond0 - bond0.5 >> >> where arp monitoring is happening over vlan. This patch fixes it by >> reinjecting the arp packet into bonding slave device so the bonding >> rx_handler can pickup and process it. >> >> Signed-off-by: Jiri Pirko<jpirko@redhat.com> >> --- >> net/core/dev.c | 8 ++++---- >> 1 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/net/core/dev.c b/net/core/dev.c >> index c71bd18..3d88458 100644 >> --- a/net/core/dev.c >> +++ b/net/core/dev.c >> @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) >> } >> EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); >> >> -static void vlan_on_bond_hook(struct sk_buff *skb) >> +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) >> { >> /* >> * Make sure ARP frames received on VLAN interfaces stacked on >> * bonding interfaces still make their way to any base bonding >> - * device that may have registered for a specific ptype. >> + * device by reinjecting the frame into bonding slave (orig_dev) >> */ >> if (skb->dev->priv_flags& IFF_802_1Q_VLAN&& >> vlan_dev_real_dev(skb->dev)->priv_flags& IFF_BONDING&& >> @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) >> >> if (!skb2) >> return; >> - skb2->dev = vlan_dev_real_dev(skb->dev); >> + skb2->dev = orig_dev; >> netif_rx(skb2); >> } >> } >> @@ -3202,7 +3202,7 @@ ncls: >> goto out; >> } >> >> - vlan_on_bond_hook(skb); >> + vlan_on_bond_hook(skb, orig_dev); >> >> /* deliver only exact match when indicated */ >> null_or_dev = deliver_exact ? skb->dev : NULL; > > This patch doesn't work. > > My setup has bond0.100 -> bond0 -> eth2 and eth3. ARP monitoring is > enabled as is arp_valiate. > > The initial problem was just that just before vlan_on_bond_hook is > called, skb->dev = bond0.100 and orig_dev = eth2. (This is after > running goto another_route and having been called back through > __netif_receive_skb since vlan_hwaccel_do_receive it true.) > > Now vlan_on_bond_hook is called and we have 2 skbs. > > The original skb still have skb->dev = bond0.100 and orig_dev = eth2. > Since bond_arp_rcv is registered for traffic only to bond0, the handler > is not hit and the frame is dropped (or processed by another handler). After Jiri's last patch series, bond_arp_rcv() is not registered anymore as a protocol handler on bond0, but directly called from inside bond_handle_frame(), through bond->recv_probe. Because bond_handler_frame() is a rx_handler for the slave interfaces, bond_arp_rcv() is now called at the slave level and not a the master level anymore. Hence this patch and the reason I thought it should work. Did you tested this patch with Jiri's previous patches applied before? > The cloned skb has skb->dev = bond0 and is put back on the receive queue > and comes back through __netif_receive_skb. This frame will match the > ptype entry for bond_arp_rcv, but since orig_dev = bond0 in this case, > the code in bond_arp_rcv will not handle the frame. I definitely hate all those unnecessary reinjects from rx_handler. The another_round loop is designed to allow for stacking inside __netif_receive_skb(). Jiri apparently has another (better) solution in mind. I hope to see it, but Jiri arguably want some of the patchs in the queue to flow before adding more. Does someone had a look at my proposal of a late_delivery property for packet_type, previously in this thread, to handle the situation where a given protocol handler registered on a particular device would like to receive the final skb instead of the one at the time it crossed that particular device? > > If we truly want to track the original interface that received the > frame, the following is a better option. With the recursive nature of > __netif_receive_skb at this point, we should really consider setting > orig_dev from skb_iif rather than just from skb->dev. Or we can remove all this orig_dev stuff... Nicolas. > diff --git a/net/core/dev.c b/net/core/dev.c > index 30440e7..500fdbc 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -3135,7 +3135,6 @@ static int __netif_receive_skb(struct sk_buff *skb) > > if (!skb->skb_iif) > skb->skb_iif = skb->dev->ifindex; > - orig_dev = skb->dev; > > skb_reset_network_header(skb); > skb_reset_transport_header(skb); > @@ -3145,6 +3144,7 @@ static int __netif_receive_skb(struct sk_buff *skb) > > rcu_read_lock(); > > + orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); > another_round: > > __this_cpu_inc(softnet_data.processed); > > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 23:09 ` Nicolas de Pesloüan @ 2011-03-08 2:43 ` Andy Gospodarek 2011-03-08 21:34 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Andy Gospodarek @ 2011-03-08 2:43 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet On Tue, Mar 08, 2011 at 12:09:48AM +0100, Nicolas de Pesloüan wrote: > > After Jiri's last patch series, bond_arp_rcv() is not registered anymore > as a protocol handler on bond0, but directly called from inside > bond_handle_frame(), through bond->recv_probe. > > Because bond_handler_frame() is a rx_handler for the slave interfaces, > bond_arp_rcv() is now called at the slave level and not a the master > level anymore. > > Hence this patch and the reason I thought it should work. > > Did you tested this patch with Jiri's previous patches applied before? > No, I have not tested them yet. I looked at this problem first as Jiri's patch did not fix a regression in code that is actually in net-next right now. I don't have a problem with the work you and Jiri are doing on this latest patch series, but the frequency of patch revisions and now regressions concerns me. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-08 2:43 ` Andy Gospodarek @ 2011-03-08 21:34 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-08 21:34 UTC (permalink / raw) To: Andy Gospodarek Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 08/03/2011 03:43, Andy Gospodarek a écrit : > On Tue, Mar 08, 2011 at 12:09:48AM +0100, Nicolas de Pesloüan wrote: >> >> After Jiri's last patch series, bond_arp_rcv() is not registered anymore >> as a protocol handler on bond0, but directly called from inside >> bond_handle_frame(), through bond->recv_probe. >> >> Because bond_handler_frame() is a rx_handler for the slave interfaces, >> bond_arp_rcv() is now called at the slave level and not a the master >> level anymore. >> >> Hence this patch and the reason I thought it should work. >> >> Did you tested this patch with Jiri's previous patches applied before? >> > > No, I have not tested them yet. I looked at this problem first as > Jiri's patch did not fix a regression in code that is actually in > net-next right now. For as far as I understand, the regression was introduced by Jiri's patches that are not yet accepted in net-next-2.6, so this path definitely need the full patch series to be applied before. And there is no special urgency to fix this regression, because it doesn't "exist" yet anywhere except in some sandboxes. This patch change the reinjection to inject at the slave level instead of the master level, because in Jiri's patch series, ARP handling moved from a normal protocol handler registered at the master level to the rx_handler at the slave level. Jiri, do I miss something ? > I don't have a problem with the work you and Jiri are doing on this > latest patch series, but the frequency of patch revisions and now > regressions concerns me. I agree with your concerns, and this is the reason why Jiri and I are working hard to try and fight every possible problems in the whole package of patch. I think that, at the end, Jiri and I will have to properly resubmit the whole thing, for the convenient of those who will have to decide to accept it or not. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-07 22:43 ` Andy Gospodarek 2011-03-07 23:09 ` Nicolas de Pesloüan @ 2011-03-08 7:13 ` Jiri Pirko 2011-03-08 13:42 ` Andy Gospodarek 1 sibling, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-08 7:13 UTC (permalink / raw) To: Andy Gospodarek Cc: Nicolas de Pesloüan, netdev, davem, shemminger, kaber, fubar, eric.dumazet Mon, Mar 07, 2011 at 11:43:38PM CET, andy@greyhouse.net wrote: >On Mon, Mar 07, 2011 at 01:51:00PM +0100, Jiri Pirko wrote: >> Recent patch "bonding: move processing of recv handlers into >> handle_frame()" caused a regression on following net scheme: >> >> eth0 - bond0 - bond0.5 >> >> where arp monitoring is happening over vlan. This patch fixes it by >> reinjecting the arp packet into bonding slave device so the bonding >> rx_handler can pickup and process it. >> >> Signed-off-by: Jiri Pirko <jpirko@redhat.com> >> --- >> net/core/dev.c | 8 ++++---- >> 1 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/net/core/dev.c b/net/core/dev.c >> index c71bd18..3d88458 100644 >> --- a/net/core/dev.c >> +++ b/net/core/dev.c >> @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) >> } >> EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); >> >> -static void vlan_on_bond_hook(struct sk_buff *skb) >> +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) >> { >> /* >> * Make sure ARP frames received on VLAN interfaces stacked on >> * bonding interfaces still make their way to any base bonding >> - * device that may have registered for a specific ptype. >> + * device by reinjecting the frame into bonding slave (orig_dev) >> */ >> if (skb->dev->priv_flags & IFF_802_1Q_VLAN && >> vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && >> @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) >> >> if (!skb2) >> return; >> - skb2->dev = vlan_dev_real_dev(skb->dev); >> + skb2->dev = orig_dev; >> netif_rx(skb2); >> } >> } >> @@ -3202,7 +3202,7 @@ ncls: >> goto out; >> } >> >> - vlan_on_bond_hook(skb); >> + vlan_on_bond_hook(skb, orig_dev); >> >> /* deliver only exact match when indicated */ >> null_or_dev = deliver_exact ? skb->dev : NULL; > >This patch doesn't work. > >My setup has bond0.100 -> bond0 -> eth2 and eth3. ARP monitoring is >enabled as is arp_valiate. > >The initial problem was just that just before vlan_on_bond_hook is >called, skb->dev = bond0.100 and orig_dev = eth2. (This is after >running goto another_route and having been called back through >__netif_receive_skb since vlan_hwaccel_do_receive it true.) > >Now vlan_on_bond_hook is called and we have 2 skbs. > >The original skb still have skb->dev = bond0.100 and orig_dev = eth2. >Since bond_arp_rcv is registered for traffic only to bond0, the handler >is not hit and the frame is dropped (or processed by another handler). > >The cloned skb has skb->dev = bond0 and is put back on the receive queue >and comes back through __netif_receive_skb. This frame will match the >ptype entry for bond_arp_rcv, but since orig_dev = bond0 in this case, >the code in bond_arp_rcv will not handle the frame. > >If we truly want to track the original interface that received the >frame, the following is a better option. With the recursive nature of >__netif_receive_skb at this point, we should really consider setting >orig_dev from skb_iif rather than just from skb->dev. > >diff --git a/net/core/dev.c b/net/core/dev.c >index 30440e7..500fdbc 100644 >--- a/net/core/dev.c >+++ b/net/core/dev.c >@@ -3135,7 +3135,6 @@ static int __netif_receive_skb(struct sk_buff *skb) > > if (!skb->skb_iif) > skb->skb_iif = skb->dev->ifindex; >- orig_dev = skb->dev; > > skb_reset_network_header(skb); > skb_reset_transport_header(skb); >@@ -3145,6 +3144,7 @@ static int __netif_receive_skb(struct sk_buff *skb) > > rcu_read_lock(); > >+ orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); > another_round: > > __this_cpu_inc(softnet_data.processed); > This was proposed earlier. people did not like this very much :( I forgot to include crucial part of "goto another_round for vlan". Following patch should work (will test it once I get to work): Subject: [patch net-next 2.6] net: reinject arps into bonding slave instead of master Recent patch "bonding: move processing of recv handlers into handle_frame()" caused a regression on following net scheme: eth0 - bond0 - bond0.5 where arp monitoring is happening over vlan. This patch fixes it by reinjecting the arp packet into bonding slave device so the bonding rx_handler can pickup and process it. also instead of calling __netif_receive_skb recursively, "goto another round" does this recursion. The point is the orig_dev variable remains intact. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- net/core/dev.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index c71bd18..ec330e1 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) } EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); -static void vlan_on_bond_hook(struct sk_buff *skb) +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) { /* * Make sure ARP frames received on VLAN interfaces stacked on * bonding interfaces still make their way to any base bonding - * device that may have registered for a specific ptype. + * device by reinjecting the frame into bonding slave (orig_dev) */ if (skb->dev->priv_flags & IFF_802_1Q_VLAN && vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) if (!skb2) return; - skb2->dev = vlan_dev_real_dev(skb->dev); + skb2->dev = orig_dev; netif_rx(skb2); } } @@ -3196,13 +3196,12 @@ ncls: pt_prev = NULL; } if (vlan_hwaccel_do_receive(&skb)) { - ret = __netif_receive_skb(skb); - goto out; + goto another_round; } else if (unlikely(!skb)) goto out; } - vlan_on_bond_hook(skb); + vlan_on_bond_hook(skb, orig_dev); /* deliver only exact match when indicated */ null_or_dev = deliver_exact ? skb->dev : NULL; -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-08 7:13 ` Jiri Pirko @ 2011-03-08 13:42 ` Andy Gospodarek 2011-03-08 21:44 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Andy Gospodarek @ 2011-03-08 13:42 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, Nicolas de Pesloüan, netdev, davem, shemminger, kaber, fubar, eric.dumazet On Tue, Mar 08, 2011 at 08:13:51AM +0100, Jiri Pirko wrote: > Mon, Mar 07, 2011 at 11:43:38PM CET, andy@greyhouse.net wrote: [...] > > > >This patch doesn't work. > > > >My setup has bond0.100 -> bond0 -> eth2 and eth3. ARP monitoring is > >enabled as is arp_valiate. > > > >The initial problem was just that just before vlan_on_bond_hook is > >called, skb->dev = bond0.100 and orig_dev = eth2. (This is after > >running goto another_route and having been called back through > >__netif_receive_skb since vlan_hwaccel_do_receive it true.) > > > >Now vlan_on_bond_hook is called and we have 2 skbs. > > > >The original skb still have skb->dev = bond0.100 and orig_dev = eth2. > >Since bond_arp_rcv is registered for traffic only to bond0, the handler > >is not hit and the frame is dropped (or processed by another handler). > > > >The cloned skb has skb->dev = bond0 and is put back on the receive queue > >and comes back through __netif_receive_skb. This frame will match the > >ptype entry for bond_arp_rcv, but since orig_dev = bond0 in this case, > >the code in bond_arp_rcv will not handle the frame. > > > >If we truly want to track the original interface that received the > >frame, the following is a better option. With the recursive nature of > >__netif_receive_skb at this point, we should really consider setting > >orig_dev from skb_iif rather than just from skb->dev. > > > >diff --git a/net/core/dev.c b/net/core/dev.c > >index 30440e7..500fdbc 100644 > >--- a/net/core/dev.c > >+++ b/net/core/dev.c > >@@ -3135,7 +3135,6 @@ static int __netif_receive_skb(struct sk_buff *skb) > > > > if (!skb->skb_iif) > > skb->skb_iif = skb->dev->ifindex; > >- orig_dev = skb->dev; > > > > skb_reset_network_header(skb); > > skb_reset_transport_header(skb); > >@@ -3145,6 +3144,7 @@ static int __netif_receive_skb(struct sk_buff *skb) > > > > rcu_read_lock(); > > > >+ orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); > > another_round: > > > > __this_cpu_inc(softnet_data.processed); > > > > This was proposed earlier. people did not like this very much :( > Interesting. I'll have to look back at the discussion. > I forgot to include crucial part of "goto another_round for vlan". > Following patch should work (will test it once I get to work): > > Subject: [patch net-next 2.6] net: reinject arps into bonding slave instead of master > > Recent patch "bonding: move processing of recv handlers into > handle_frame()" caused a regression on following net scheme: > > eth0 - bond0 - bond0.5 > > where arp monitoring is happening over vlan. This patch fixes it by > reinjecting the arp packet into bonding slave device so the bonding > rx_handler can pickup and process it. > > also instead of calling __netif_receive_skb recursively, "goto another > round" does this recursion. The point is the orig_dev variable remains > intact. > > Signed-off-by: Jiri Pirko <jpirko@redhat.com> > --- > net/core/dev.c | 11 +++++------ > 1 files changed, 5 insertions(+), 6 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index c71bd18..ec330e1 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -3094,12 +3094,12 @@ void netdev_rx_handler_unregister(struct net_device *dev) > } > EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister); > > -static void vlan_on_bond_hook(struct sk_buff *skb) > +static void vlan_on_bond_hook(struct sk_buff *skb, struct net_device *orig_dev) > { > /* > * Make sure ARP frames received on VLAN interfaces stacked on > * bonding interfaces still make their way to any base bonding > - * device that may have registered for a specific ptype. > + * device by reinjecting the frame into bonding slave (orig_dev) > */ > if (skb->dev->priv_flags & IFF_802_1Q_VLAN && > vlan_dev_real_dev(skb->dev)->priv_flags & IFF_BONDING && > @@ -3108,7 +3108,7 @@ static void vlan_on_bond_hook(struct sk_buff *skb) > > if (!skb2) > return; > - skb2->dev = vlan_dev_real_dev(skb->dev); > + skb2->dev = orig_dev; > netif_rx(skb2); > } > I'm pretty sure this patch will have the same catastrophic problem your last one did. By cloning and setting skb2->dev = orig_dev you just inserted a frame identical to the one we received right back into the stack. It only took a few minutes for my box to melt as one frame on the wire will cause an infinite number of frames to be received by the stack. > @@ -3196,13 +3196,12 @@ ncls: > pt_prev = NULL; > } > if (vlan_hwaccel_do_receive(&skb)) { > - ret = __netif_receive_skb(skb); > - goto out; > + goto another_round; > } else if (unlikely(!skb)) > goto out; > } > > - vlan_on_bond_hook(skb); > + vlan_on_bond_hook(skb, orig_dev); > > /* deliver only exact match when indicated */ > null_or_dev = deliver_exact ? skb->dev : NULL; ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-08 13:42 ` Andy Gospodarek @ 2011-03-08 21:44 ` Nicolas de Pesloüan 2011-03-09 7:45 ` Jiri Pirko 2011-03-09 13:33 ` Neil Horman 0 siblings, 2 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-08 21:44 UTC (permalink / raw) To: Andy Gospodarek Cc: Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 08/03/2011 14:42, Andy Gospodarek a écrit : > I'm pretty sure this patch will have the same catastrophic problem your > last one did. By cloning and setting skb2->dev = orig_dev you just > inserted a frame identical to the one we received right back into the > stack. It only took a few minutes for my box to melt as one frame on > the wire will cause an infinite number of frames to be received by the > stack. I agree with Andy. We still keep one reinject (netif_rx), which is probably better that two (__netif_receive_skb), but not enough. I really think we need a general framework for late delivery of final packets to packet handler registered somewhere in the rx_handler path. Jiri, is this patch the one you announced as "I have some kind nice solution in mind and I'm going to submit that as a patch later (too many patches are in the wind atm)" ? ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-08 21:44 ` Nicolas de Pesloüan @ 2011-03-09 7:45 ` Jiri Pirko 2011-03-09 14:49 ` Nicolas de Pesloüan 2011-03-09 20:51 ` Jiri Pirko 2011-03-09 13:33 ` Neil Horman 1 sibling, 2 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-09 7:45 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>I'm pretty sure this patch will have the same catastrophic problem your >>last one did. By cloning and setting skb2->dev = orig_dev you just >>inserted a frame identical to the one we received right back into the >>stack. It only took a few minutes for my box to melt as one frame on >>the wire will cause an infinite number of frames to be received by the >>stack. > >I agree with Andy. We still keep one reinject (netif_rx), which is >probably better that two (__netif_receive_skb), but not enough. > >I really think we need a general framework for late delivery of final >packets to packet handler registered somewhere in the rx_handler >path. > >Jiri, is this patch the one you announced as "I have some kind nice >solution in mind and I'm going to submit that as a patch later (too >many patches are in the wind atm)" ? I did not had time to verify my thought yet but I think that the only think needed against my original patch (bonding: move processing of recv handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. Because all incoming arps are seen by bond_handle_frame => bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. Jirka ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 7:45 ` Jiri Pirko @ 2011-03-09 14:49 ` Nicolas de Pesloüan 2011-03-09 15:09 ` Jiri Pirko 2011-03-09 20:51 ` Jiri Pirko 1 sibling, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-09 14:49 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 09/03/2011 08:45, Jiri Pirko a écrit : > Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>> I'm pretty sure this patch will have the same catastrophic problem your >>> last one did. By cloning and setting skb2->dev = orig_dev you just >>> inserted a frame identical to the one we received right back into the >>> stack. It only took a few minutes for my box to melt as one frame on >>> the wire will cause an infinite number of frames to be received by the >>> stack. >> >> I agree with Andy. We still keep one reinject (netif_rx), which is >> probably better that two (__netif_receive_skb), but not enough. >> >> I really think we need a general framework for late delivery of final >> packets to packet handler registered somewhere in the rx_handler >> path. >> >> Jiri, is this patch the one you announced as "I have some kind nice >> solution in mind and I'm going to submit that as a patch later (too >> many patches are in the wind atm)" ? > > > I did not had time to verify my thought yet but I think that the only > think needed against my original patch (bonding: move processing of recv > handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. > > Because all incoming arps are seen by bond_handle_frame => > bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 > work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. All incoming ARPs are seen by bond_handle_frame, even vlan ones, definitely true. But as some of them *are* vlan ones, you will have to untag those "by hand" inside bond_handle_frame. It might work, but I wouldn't support the idea, for two reasons : - It would duplicate code, or at least, duplicate places where untagging happens. - It would cause some vlan hacks to sit inside bond, which is not nice from a layering point of view. You recently advocated against breaking layering and you are right. We should avoid putting X related stuff into Y part of the network stack, as much as possible. Again, I think we should try and find a generic way to have the final frame delivered to whoever needs it. And this way should not be limited to "vlan untagging" nor to bonding. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 14:49 ` Nicolas de Pesloüan @ 2011-03-09 15:09 ` Jiri Pirko 2011-03-09 15:28 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-09 15:09 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Wed, Mar 09, 2011 at 03:49:49PM CET, nicolas.2p.debian@gmail.com wrote: >Le 09/03/2011 08:45, Jiri Pirko a écrit : >>Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >>>Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>>>I'm pretty sure this patch will have the same catastrophic problem your >>>>last one did. By cloning and setting skb2->dev = orig_dev you just >>>>inserted a frame identical to the one we received right back into the >>>>stack. It only took a few minutes for my box to melt as one frame on >>>>the wire will cause an infinite number of frames to be received by the >>>>stack. >>> >>>I agree with Andy. We still keep one reinject (netif_rx), which is >>>probably better that two (__netif_receive_skb), but not enough. >>> >>>I really think we need a general framework for late delivery of final >>>packets to packet handler registered somewhere in the rx_handler >>>path. >>> >>>Jiri, is this patch the one you announced as "I have some kind nice >>>solution in mind and I'm going to submit that as a patch later (too >>>many patches are in the wind atm)" ? >> >> >>I did not had time to verify my thought yet but I think that the only >>think needed against my original patch (bonding: move processing of recv >>handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. >> >>Because all incoming arps are seen by bond_handle_frame => >>bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 >>work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. > >All incoming ARPs are seen by bond_handle_frame, even vlan ones, definitely true. > >But as some of them *are* vlan ones, you will have to untag those "by hand" inside bond_handle_frame. Hmm. For hw vlan accel this would not be needed. But for non-hw-vlan-accel the frame is wrapped when going thru handle_frame. And yes, in that case untagging would be necessary. Unless the vlan untagging happening now in ptype_base handler is moved in rx path somewhere before __netif_receive_skb. That would result in two things: 1) Bond would be able to scope vlan packets 2) The rx path for hw-vlan-accel and non-hw-vlan-accel would be the same (should be desirable + one reinjection would be avoided for non-hw-vlan-accel) > >It might work, but I wouldn't support the idea, for two reasons : > >- It would duplicate code, or at least, duplicate places where untagging happens. >- It would cause some vlan hacks to sit inside bond, which is not >nice from a layering point of view. You recently advocated against >breaking layering and you are right. We should avoid putting X >related stuff into Y part of the network stack, as much as possible. > >Again, I think we should try and find a generic way to have the final >frame delivered to whoever needs it. And this way should not be >limited to "vlan untagging" nor to bonding. > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 15:09 ` Jiri Pirko @ 2011-03-09 15:28 ` Nicolas de Pesloüan 2011-03-09 17:11 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-09 15:28 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 09/03/2011 16:09, Jiri Pirko a écrit : > Wed, Mar 09, 2011 at 03:49:49PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 09/03/2011 08:45, Jiri Pirko a écrit : >>> Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >>>> Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>>>> I'm pretty sure this patch will have the same catastrophic problem your >>>>> last one did. By cloning and setting skb2->dev = orig_dev you just >>>>> inserted a frame identical to the one we received right back into the >>>>> stack. It only took a few minutes for my box to melt as one frame on >>>>> the wire will cause an infinite number of frames to be received by the >>>>> stack. >>>> >>>> I agree with Andy. We still keep one reinject (netif_rx), which is >>>> probably better that two (__netif_receive_skb), but not enough. >>>> >>>> I really think we need a general framework for late delivery of final >>>> packets to packet handler registered somewhere in the rx_handler >>>> path. >>>> >>>> Jiri, is this patch the one you announced as "I have some kind nice >>>> solution in mind and I'm going to submit that as a patch later (too >>>> many patches are in the wind atm)" ? >>> >>> >>> I did not had time to verify my thought yet but I think that the only >>> think needed against my original patch (bonding: move processing of recv >>> handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. >>> >>> Because all incoming arps are seen by bond_handle_frame => >>> bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 >>> work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. >> >> All incoming ARPs are seen by bond_handle_frame, even vlan ones, definitely true. >> >> But as some of them *are* vlan ones, you will have to untag those "by hand" inside bond_handle_frame. > > Hmm. For hw vlan accel this would not be needed. Agreed. > But for non-hw-vlan-accel the frame is wrapped when going thru handle_frame. And yes, in that > case untagging would be necessary. Unless the vlan untagging happening now in ptype_base handler > is moved in rx path somewhere before __netif_receive_skb. Can't it me moved not before, but inside __netif_receive_skb, as a rx_handler? At the time we setup eth0.100, we can arrange for a vlan_untag rx_handler to be registered on eth0. This is exactly the way it works now for macvlan. Should it be possible (and desirable) for vlan too? This might re-open the discussion about the need for several rx_handlers per interface, but that is another story. Also, moving it before __netif_receive_skb would cause every protocol handlers to receive the frame untagged. At least protocol sniffers registered at ptype_all may want to receive the tagged frame, for diagnostic purpose. That would result in two things: > > 1) Bond would be able to scope vlan packets > 2) The rx path for hw-vlan-accel and non-hw-vlan-accel would be the same > (should be desirable + one reinjection would be avoided for > non-hw-vlan-accel) Agreed, but moving it inside __netif_receive_skb should have the same effects. If we move non-hw-accel-vlan to a rx_handler, the skb would be COW before being untagged only if shared. This sounds good to me. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 15:28 ` Nicolas de Pesloüan @ 2011-03-09 17:11 ` Jiri Pirko 2011-03-09 22:18 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-09 17:11 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Wed, Mar 09, 2011 at 04:28:34PM CET, nicolas.2p.debian@gmail.com wrote: >Le 09/03/2011 16:09, Jiri Pirko a écrit : >>Wed, Mar 09, 2011 at 03:49:49PM CET, nicolas.2p.debian@gmail.com wrote: >>>Le 09/03/2011 08:45, Jiri Pirko a écrit : >>>>Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >>>>>Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>>>>>I'm pretty sure this patch will have the same catastrophic problem your >>>>>>last one did. By cloning and setting skb2->dev = orig_dev you just >>>>>>inserted a frame identical to the one we received right back into the >>>>>>stack. It only took a few minutes for my box to melt as one frame on >>>>>>the wire will cause an infinite number of frames to be received by the >>>>>>stack. >>>>> >>>>>I agree with Andy. We still keep one reinject (netif_rx), which is >>>>>probably better that two (__netif_receive_skb), but not enough. >>>>> >>>>>I really think we need a general framework for late delivery of final >>>>>packets to packet handler registered somewhere in the rx_handler >>>>>path. >>>>> >>>>>Jiri, is this patch the one you announced as "I have some kind nice >>>>>solution in mind and I'm going to submit that as a patch later (too >>>>>many patches are in the wind atm)" ? >>>> >>>> >>>>I did not had time to verify my thought yet but I think that the only >>>>think needed against my original patch (bonding: move processing of recv >>>>handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. >>>> >>>>Because all incoming arps are seen by bond_handle_frame => >>>>bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 >>>>work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. >>> >>>All incoming ARPs are seen by bond_handle_frame, even vlan ones, definitely true. >>> >>>But as some of them *are* vlan ones, you will have to untag those "by hand" inside bond_handle_frame. >> > >>Hmm. For hw vlan accel this would not be needed. > >Agreed. > >>But for non-hw-vlan-accel the frame is wrapped when going thru handle_frame. And yes, in that >>case untagging would be necessary. Unless the vlan untagging happening now in ptype_base handler >>is moved in rx path somewhere before __netif_receive_skb. > >Can't it me moved not before, but inside __netif_receive_skb, as a rx_handler? I don't think so - rx_handler is not right place to untag. rx_handler is per device. untaging should happen idealy on realdev skb injection. That way the rx path for hw-vlan-accel and non-he-vlan-accel would be very similar. > >At the time we setup eth0.100, we can arrange for a vlan_untag >rx_handler to be registered on eth0. This is exactly the way it works >now for macvlan. Should it be possible (and desirable) for vlan too? > >This might re-open the discussion about the need for several >rx_handlers per interface, but that is another story. > >Also, moving it before __netif_receive_skb would cause every protocol >handlers to receive the frame untagged. At least protocol sniffers >registered at ptype_all may want to receive the tagged frame, for >diagnostic purpose. Thats how its done for hw-vlan-accel. No problem here. > >That would result in two things: >> >>1) Bond would be able to scope vlan packets >>2) The rx path for hw-vlan-accel and non-hw-vlan-accel would be the same >> (should be desirable + one reinjection would be avoided for >> non-hw-vlan-accel) > >Agreed, but moving it inside __netif_receive_skb should have the same >effects. If we move non-hw-accel-vlan to a rx_handler, the skb would >be COW before being untagged only if shared. This sounds good to me. > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 17:11 ` Jiri Pirko @ 2011-03-09 22:18 ` Nicolas de Pesloüan 2011-03-10 6:48 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-09 22:18 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 09/03/2011 18:11, Jiri Pirko a écrit : > Wed, Mar 09, 2011 at 04:28:34PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 09/03/2011 16:09, Jiri Pirko a écrit : >>> Wed, Mar 09, 2011 at 03:49:49PM CET, nicolas.2p.debian@gmail.com wrote: >>>> Le 09/03/2011 08:45, Jiri Pirko a écrit : >>>>> Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >>>>>> Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>>>>>> I'm pretty sure this patch will have the same catastrophic problem your >>>>>>> last one did. By cloning and setting skb2->dev = orig_dev you just >>>>>>> inserted a frame identical to the one we received right back into the >>>>>>> stack. It only took a few minutes for my box to melt as one frame on >>>>>>> the wire will cause an infinite number of frames to be received by the >>>>>>> stack. >>>>>> >>>>>> I agree with Andy. We still keep one reinject (netif_rx), which is >>>>>> probably better that two (__netif_receive_skb), but not enough. >>>>>> >>>>>> I really think we need a general framework for late delivery of final >>>>>> packets to packet handler registered somewhere in the rx_handler >>>>>> path. >>>>>> >>>>>> Jiri, is this patch the one you announced as "I have some kind nice >>>>>> solution in mind and I'm going to submit that as a patch later (too >>>>>> many patches are in the wind atm)" ? >>>>> >>>>> >>>>> I did not had time to verify my thought yet but I think that the only >>>>> think needed against my original patch (bonding: move processing of recv >>>>> handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. >>>>> >>>>> Because all incoming arps are seen by bond_handle_frame => >>>>> bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 >>>>> work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. >>>> >>>> All incoming ARPs are seen by bond_handle_frame, even vlan ones, definitely true. >>>> >>>> But as some of them *are* vlan ones, you will have to untag those "by hand" inside bond_handle_frame. >>> >> >>> Hmm. For hw vlan accel this would not be needed. >> >> Agreed. >> >>> But for non-hw-vlan-accel the frame is wrapped when going thru handle_frame. And yes, in that >>> case untagging would be necessary. Unless the vlan untagging happening now in ptype_base handler >>> is moved in rx path somewhere before __netif_receive_skb. >> >> Can't it me moved not before, but inside __netif_receive_skb, as a rx_handler? > > I don't think so - rx_handler is not right place to untag. rx_handler is > per device. untaging should happen idealy on realdev skb injection. That > way the rx path for hw-vlan-accel and non-he-vlan-accel would be very > similar. I don't understand your argument about "rx_handler is per device". A vlan interface is by design built on top a parent (physical or logical) interface. Why can't we use the rx_handler of the parent device to untag? Untagging the frame very early (before __netif_receive_skb() would work if the value of skb->dev, at the time the frame enter __netif_receive_skb, is the parent interface for the vlan interface: eth0 -> eth0.100. This is exactly what happens for hw-accel vlan frame and it sounds logical at first to do it the same way for non-hw-accel device. But for all others setups, where there exist some net_devices before the "untagging" one, you would face some troubles. For example, with eth0+eth1 -> br0 -> br0.100, you cannot untag before entering __netif_receive_skb. If you do so, the bridge would receive untagged frame and if the frame is not for the local host, the bridge would forward an untagged frame while it is expected to forward a tagged one. Even if the bridge is in a position to know the frame *was* tagged, we cannot expect the bridge to do special processing to handle this situation. Doing so would break layering. On another setup, eth0 -> eth0.100 -> br0 -> eth1.200 -> eth1, on the opposite, we expect the bridge to receive and to forward an untagged frame, that has been untagged while crossing eth0.100 and will be tagged while crossing eth1.200. If we want to avoid reinjection as much as possible (and I advocate for that, you know :-)), then the only place to untag is in the rx_header for the parent device of the vlan device. I still don't understand the problem you see with this proposal. And the only remaining discrepancy would be in hw-accel vs non-hw-accel. A protocol handler registered on eth0 -> eth0.100 would receive: - a tagged frame for non-hw-accel. - an untagged frame for hw-accel. I think it is already true today, so I don't consider this a problem. We might arrange to fix this discrepancy later, if someone consider this a problem. Nicolas. >> At the time we setup eth0.100, we can arrange for a vlan_untag >> rx_handler to be registered on eth0. This is exactly the way it works >> now for macvlan. Should it be possible (and desirable) for vlan too? >> >> This might re-open the discussion about the need for several >> rx_handlers per interface, but that is another story. >> >> Also, moving it before __netif_receive_skb would cause every protocol >> handlers to receive the frame untagged. At least protocol sniffers >> registered at ptype_all may want to receive the tagged frame, for >> diagnostic purpose. > > Thats how its done for hw-vlan-accel. No problem here. > >> >> That would result in two things: >>> >>> 1) Bond would be able to scope vlan packets >>> 2) The rx path for hw-vlan-accel and non-hw-vlan-accel would be the same >>> (should be desirable + one reinjection would be avoided for >>> non-hw-vlan-accel) >> >> Agreed, but moving it inside __netif_receive_skb should have the same >> effects. If we move non-hw-accel-vlan to a rx_handler, the skb would >> be COW before being untagged only if shared. This sounds good to me. >> >> Nicolas. > ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 22:18 ` Nicolas de Pesloüan @ 2011-03-10 6:48 ` Jiri Pirko 2011-03-10 20:44 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-10 6:48 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet >But for all others setups, where there exist some net_devices before >the "untagging" one, you would face some troubles. For example, with >eth0+eth1 -> br0 -> br0.100, you cannot untag before entering >__netif_receive_skb. If you do so, the bridge would receive untagged >frame and if the frame is not for the local host, the bridge would >forward an untagged frame while it is expected to forward a tagged >one. Even if the bridge is in a position to know the frame *was* >tagged, we cannot expect the bridge to do special processing to >handle this situation. Doing so would break layering. I disagree. eth0 -> untag on early __netif_receive_skb (sets up skb->vlan_tci) ->rx_handler of bridge ->br0 -> tag is detected by vlan_tx_tag_present() -> reinject to __netif_receive_skb with skb->dev == br0.100 This way the flow would be very similar to vlan-hw-accel, am I right? I have following patch in mind. Note it's raw DRAFT. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- include/linux/if_vlan.h | 5 ++ net/8021q/vlan.c | 8 -- net/8021q/vlan_core.c | 106 +++++++++++++++++++++++++++++ net/8021q/vlan_dev.c | 172 ----------------------------------------------- net/core/dev.c | 18 ++++- 5 files changed, 125 insertions(+), 184 deletions(-) diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 635e1fa..dd914e2 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -133,6 +133,7 @@ extern u16 vlan_dev_vlan_id(const struct net_device *dev); extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, u16 vlan_tci, int polling); extern bool vlan_hwaccel_do_receive(struct sk_buff **skb); +extern void vlan_emulate_hwaccel(struct sk_buff **skbp); extern gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, unsigned int vlan_tci, struct sk_buff *skb); @@ -173,6 +174,10 @@ static inline bool vlan_hwaccel_do_receive(struct sk_buff **skb) return false; } +void vlan_emulate_hwaccel(struct sk_buff **skbp) +{ +} + static inline gro_result_t vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp, unsigned int vlan_tci, struct sk_buff *skb) diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 7850412..59f0a9d 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -49,11 +49,6 @@ const char vlan_version[] = DRV_VERSION; static const char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; static const char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; -static struct packet_type vlan_packet_type __read_mostly = { - .type = cpu_to_be16(ETH_P_8021Q), - .func = vlan_skb_recv, /* VLAN receive method */ -}; - /* End of global variables definitions. */ static void vlan_group_free(struct vlan_group *grp) @@ -688,7 +683,6 @@ static int __init vlan_proto_init(void) if (err < 0) goto err4; - dev_add_pack(&vlan_packet_type); vlan_ioctl_set(vlan_ioctl_handler); return 0; @@ -709,8 +703,6 @@ static void __exit vlan_cleanup_module(void) unregister_netdevice_notifier(&vlan_notifier_block); - dev_remove_pack(&vlan_packet_type); - unregister_pernet_subsys(&vlan_net_ops); rcu_barrier(); /* Wait for completion of call_rcu()'s */ diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index ce8e3ab..c324e4d 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -88,3 +88,109 @@ gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp, return napi_gro_frags(napi); } EXPORT_SYMBOL(vlan_gro_frags); + +static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb) +{ + if (vlan_dev_info(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) { + if (skb_cow(skb, skb_headroom(skb)) < 0) + skb = NULL; + if (skb) { + /* Lifted from Gleb's VLAN code... */ + memmove(skb->data - ETH_HLEN, + skb->data - VLAN_ETH_HLEN, 12); + skb->mac_header += VLAN_HLEN; + } + } + + return skb; +} + +static inline void vlan_set_encap_proto(struct sk_buff *skb, + struct vlan_hdr *vhdr) +{ + __be16 proto; + unsigned char *rawp; + + /* + * Was a VLAN packet, grab the encapsulated protocol, which the layer + * three protocols care about. + */ + + proto = vhdr->h_vlan_encapsulated_proto; + if (ntohs(proto) >= 1536) { + skb->protocol = proto; + return; + } + + rawp = skb->data; + if (*(unsigned short *)rawp == 0xFFFF) + /* + * This is a magic hack to spot IPX packets. Older Novell + * breaks the protocol design and runs IPX over 802.3 without + * an 802.2 LLC layer. We look for FFFF which isn't a used + * 802.2 SSAP/DSAP. This won't work for fault tolerant netware + * but does for the rest. + */ + skb->protocol = htons(ETH_P_802_3); + else + /* + * Real 802.2 LLC + */ + skb->protocol = htons(ETH_P_802_2); +} + +/* + * Determine the packet's protocol ID. The rule here is that we + * assume 802.3 if the type field is short enough to be a length. + * This is normal practice and works for any 'now in use' protocol. + * + * Also, at this point we assume that we ARE dealing exclusively with + * VLAN packets, or packets that should be made into VLAN packets based + * on a default VLAN ID. + * + * NOTE: Should be similar to ethernet/eth.c. + * + * SANITY NOTE: This method is called when a packet is moving up the stack + * towards userland. To get here, it would have already passed + * through the ethernet/eth.c eth_type_trans() method. + * SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be + * stored UNALIGNED in the memory. RISC systems don't like + * such cases very much... + * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be + * aligned, so there doesn't need to be any of the unaligned + * stuff. It has been commented out now... --Ben + * + */ +void vlan_emulate_hwaccel(struct sk_buff **skbp) +{ + struct sk_buff *skb = *skbp; + struct vlan_hdr *vhdr; + u16 vlan_tci; + + *skbp = skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + goto err_free; + + if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) + goto err_free; + + vhdr = (struct vlan_hdr *) skb->data; + vlan_tci = ntohs(vhdr->h_vlan_TCI); + __vlan_hwaccel_put_tag(skb, vlan_tci); + + skb_pull_rcsum(skb, VLAN_HLEN); + vlan_set_encap_proto(skb, vhdr); + + skb = vlan_check_reorder_header(skb); + if (unlikely(!skb)) { + goto err_free; + } + + return; + +err_free: + kfree_skb(skb); + *skbp = NULL; + return; +} + diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index ae610f0..57d2f40 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -65,178 +65,6 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb) return 0; } -static inline struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb) -{ - if (vlan_dev_info(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) { - if (skb_cow(skb, skb_headroom(skb)) < 0) - skb = NULL; - if (skb) { - /* Lifted from Gleb's VLAN code... */ - memmove(skb->data - ETH_HLEN, - skb->data - VLAN_ETH_HLEN, 12); - skb->mac_header += VLAN_HLEN; - } - } - - return skb; -} - -static inline void vlan_set_encap_proto(struct sk_buff *skb, - struct vlan_hdr *vhdr) -{ - __be16 proto; - unsigned char *rawp; - - /* - * Was a VLAN packet, grab the encapsulated protocol, which the layer - * three protocols care about. - */ - - proto = vhdr->h_vlan_encapsulated_proto; - if (ntohs(proto) >= 1536) { - skb->protocol = proto; - return; - } - - rawp = skb->data; - if (*(unsigned short *)rawp == 0xFFFF) - /* - * This is a magic hack to spot IPX packets. Older Novell - * breaks the protocol design and runs IPX over 802.3 without - * an 802.2 LLC layer. We look for FFFF which isn't a used - * 802.2 SSAP/DSAP. This won't work for fault tolerant netware - * but does for the rest. - */ - skb->protocol = htons(ETH_P_802_3); - else - /* - * Real 802.2 LLC - */ - skb->protocol = htons(ETH_P_802_2); -} - -/* - * Determine the packet's protocol ID. The rule here is that we - * assume 802.3 if the type field is short enough to be a length. - * This is normal practice and works for any 'now in use' protocol. - * - * Also, at this point we assume that we ARE dealing exclusively with - * VLAN packets, or packets that should be made into VLAN packets based - * on a default VLAN ID. - * - * NOTE: Should be similar to ethernet/eth.c. - * - * SANITY NOTE: This method is called when a packet is moving up the stack - * towards userland. To get here, it would have already passed - * through the ethernet/eth.c eth_type_trans() method. - * SANITY NOTE 2: We are referencing to the VLAN_HDR frields, which MAY be - * stored UNALIGNED in the memory. RISC systems don't like - * such cases very much... - * SANITY NOTE 2a: According to Dave Miller & Alexey, it will always be - * aligned, so there doesn't need to be any of the unaligned - * stuff. It has been commented out now... --Ben - * - */ -int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) -{ - struct vlan_hdr *vhdr; - struct vlan_pcpu_stats *rx_stats; - struct net_device *vlan_dev; - u16 vlan_id; - u16 vlan_tci; - - skb = skb_share_check(skb, GFP_ATOMIC); - if (skb == NULL) - goto err_free; - - if (unlikely(!pskb_may_pull(skb, VLAN_HLEN))) - goto err_free; - - vhdr = (struct vlan_hdr *)skb->data; - vlan_tci = ntohs(vhdr->h_vlan_TCI); - vlan_id = vlan_tci & VLAN_VID_MASK; - - rcu_read_lock(); - vlan_dev = vlan_find_dev(dev, vlan_id); - - /* If the VLAN device is defined, we use it. - * If not, and the VID is 0, it is a 802.1p packet (not - * really a VLAN), so we will just netif_rx it later to the - * original interface, but with the skb->proto set to the - * wrapped proto: we do nothing here. - */ - - if (!vlan_dev) { - if (vlan_id) { - pr_debug("%s: ERROR: No net_device for VID: %u on dev: %s\n", - __func__, vlan_id, dev->name); - goto err_unlock; - } - rx_stats = NULL; - } else { - skb->dev = vlan_dev; - - rx_stats = this_cpu_ptr(vlan_dev_info(skb->dev)->vlan_pcpu_stats); - - u64_stats_update_begin(&rx_stats->syncp); - rx_stats->rx_packets++; - rx_stats->rx_bytes += skb->len; - - skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tci); - - pr_debug("%s: priority: %u for TCI: %hu\n", - __func__, skb->priority, vlan_tci); - - switch (skb->pkt_type) { - case PACKET_BROADCAST: - /* Yeah, stats collect these together.. */ - /* stats->broadcast ++; // no such counter :-( */ - break; - - case PACKET_MULTICAST: - rx_stats->rx_multicast++; - break; - - case PACKET_OTHERHOST: - /* Our lower layer thinks this is not local, let's make - * sure. - * This allows the VLAN to have a different MAC than the - * underlying device, and still route correctly. - */ - if (!compare_ether_addr(eth_hdr(skb)->h_dest, - skb->dev->dev_addr)) - skb->pkt_type = PACKET_HOST; - break; - default: - break; - } - u64_stats_update_end(&rx_stats->syncp); - } - - skb_pull_rcsum(skb, VLAN_HLEN); - vlan_set_encap_proto(skb, vhdr); - - if (vlan_dev) { - skb = vlan_check_reorder_header(skb); - if (!skb) { - rx_stats->rx_errors++; - goto err_unlock; - } - } - - netif_rx(skb); - - rcu_read_unlock(); - return NET_RX_SUCCESS; - -err_unlock: - rcu_read_unlock(); -err_free: - atomic_long_inc(&dev->rx_dropped); - kfree_skb(skb); - return NET_RX_DROP; -} static inline u16 vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb) diff --git a/net/core/dev.c b/net/core/dev.c index 9f66de9..f3315ef 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3133,10 +3133,6 @@ static int __netif_receive_skb(struct sk_buff *skb) if (netpoll_receive_skb(skb)) return NET_RX_DROP; - if (!skb->skb_iif) - skb->skb_iif = skb->dev->ifindex; - orig_dev = skb->dev; - skb_reset_network_header(skb); skb_reset_transport_header(skb); skb->mac_len = skb->network_header - skb->mac_header; @@ -3145,6 +3141,20 @@ static int __netif_receive_skb(struct sk_buff *skb) rcu_read_lock(); + if (!skb->skb_iif) { + skb->skb_iif = skb->dev->ifindex; + /* + * frame is here for the first time so lets check if it's vlan + * one and emulate vlan hwaccel in that case + */ + if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) { + vlan_emulate_hwaccel(&skb); + if (!skb) + goto out; + } + } + orig_dev = skb->dev; + another_round: __this_cpu_inc(softnet_data.processed); -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-10 6:48 ` Jiri Pirko @ 2011-03-10 20:44 ` Nicolas de Pesloüan 2011-03-10 20:52 ` Jiri Pirko 2011-03-10 21:05 ` Jiri Pirko 0 siblings, 2 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-10 20:44 UTC (permalink / raw) To: Jiri Pirko Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Le 10/03/2011 07:48, Jiri Pirko a écrit : >> But for all others setups, where there exist some net_devices before >> the "untagging" one, you would face some troubles. For example, with >> eth0+eth1 -> br0 -> br0.100, you cannot untag before entering >> __netif_receive_skb. If you do so, the bridge would receive untagged >> frame and if the frame is not for the local host, the bridge would >> forward an untagged frame while it is expected to forward a tagged >> one. Even if the bridge is in a position to know the frame *was* >> tagged, we cannot expect the bridge to do special processing to >> handle this situation. Doing so would break layering. > > I disagree. > eth0 -> untag on early __netif_receive_skb (sets up skb->vlan_tci) > ->rx_handler of bridge > ->br0 -> tag is detected by vlan_tx_tag_present() > -> reinject to __netif_receive_skb with skb->dev == br0.100 For local delivery, is should work. But if the bridge must forward the frame to another host (bridges are designed for such things :-)), it will have to insert the vlan header back into the frame. I don't understand how it could work automagically in this situation. > This way the flow would be very similar to vlan-hw-accel, am I right? So your point is to remove any 802.1Q header in any ingres frame, whatever the local interface setup. Right? How would this support nested vlan headers? eth0 -> eth0.100 -> eth0.100.200 -> eth0.100.200.300. Who will choose eth0.100.200.300 as the last skb->dev? > I have following patch in mind. Note it's raw DRAFT. I need to take some time to review your patch. In the mean time, what is the status of the whole patch series? Can we expect an ACK from someone? Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-10 20:44 ` Nicolas de Pesloüan @ 2011-03-10 20:52 ` Jiri Pirko 2011-03-10 21:05 ` Jiri Pirko 1 sibling, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-10 20:52 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Thu, Mar 10, 2011 at 09:44:53PM CET, nicolas.2p.debian@gmail.com wrote: >Le 10/03/2011 07:48, Jiri Pirko a écrit : >>>But for all others setups, where there exist some net_devices before >>>the "untagging" one, you would face some troubles. For example, with >>>eth0+eth1 -> br0 -> br0.100, you cannot untag before entering >>>__netif_receive_skb. If you do so, the bridge would receive untagged >>>frame and if the frame is not for the local host, the bridge would >>>forward an untagged frame while it is expected to forward a tagged >>>one. Even if the bridge is in a position to know the frame *was* >>>tagged, we cannot expect the bridge to do special processing to >>>handle this situation. Doing so would break layering. >> >>I disagree. >>eth0 -> untag on early __netif_receive_skb (sets up skb->vlan_tci) >> ->rx_handler of bridge >>->br0 -> tag is detected by vlan_tx_tag_present() >> -> reinject to __netif_receive_skb with skb->dev == br0.100 > >For local delivery, is should work. > >But if the bridge must forward the frame to another host (bridges are >designed for such things :-)), it will have to insert the vlan header >back into the frame. I don't understand how it could work >automagically in this situation. This works for hw_accel path. Would look the same. > >>This way the flow would be very similar to vlan-hw-accel, am I right? > >So your point is to remove any 802.1Q header in any ingres frame, >whatever the local interface setup. Right? > >How would this support nested vlan headers? > >eth0 -> eth0.100 -> eth0.100.200 -> eth0.100.200.300. > >Who will choose eth0.100.200.300 as the last skb->dev? Hate to think about this more, that's for sure. > >>I have following patch in mind. Note it's raw DRAFT. > >I need to take some time to review your patch. > >In the mean time, what is the status of the whole patch series? Can we expect an ACK from someone? It was posponed by davem. I plan to solve vlans first, then repost the whole series (so that bond recv_probe would see vlan arps) > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-10 20:44 ` Nicolas de Pesloüan 2011-03-10 20:52 ` Jiri Pirko @ 2011-03-10 21:05 ` Jiri Pirko 1 sibling, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-10 21:05 UTC (permalink / raw) To: Nicolas de Pesloüan; +Cc: netdev Thu, Mar 10, 2011 at 09:44:53PM CET, nicolas.2p.debian@gmail.com wrote: >Le 10/03/2011 07:48, Jiri Pirko a écrit : >>>But for all others setups, where there exist some net_devices before >>>the "untagging" one, you would face some troubles. For example, with >>>eth0+eth1 -> br0 -> br0.100, you cannot untag before entering >>>__netif_receive_skb. If you do so, the bridge would receive untagged >>>frame and if the frame is not for the local host, the bridge would >>>forward an untagged frame while it is expected to forward a tagged >>>one. Even if the bridge is in a position to know the frame *was* >>>tagged, we cannot expect the bridge to do special processing to >>>handle this situation. Doing so would break layering. >> >>I disagree. >>eth0 -> untag on early __netif_receive_skb (sets up skb->vlan_tci) >> ->rx_handler of bridge >>->br0 -> tag is detected by vlan_tx_tag_present() >> -> reinject to __netif_receive_skb with skb->dev == br0.100 > >For local delivery, is should work. > >But if the bridge must forward the frame to another host (bridges are >designed for such things :-)), it will have to insert the vlan header >back into the frame. I don't understand how it could work >automagically in this situation. See dev_hard_start_xmit and search for vlan :) ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-09 7:45 ` Jiri Pirko 2011-03-09 14:49 ` Nicolas de Pesloüan @ 2011-03-09 20:51 ` Jiri Pirko 1 sibling, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-09 20:51 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, netdev, davem, shemminger, kaber, fubar, eric.dumazet Wed, Mar 09, 2011 at 08:45:48AM CET, jpirko@redhat.com wrote: >Tue, Mar 08, 2011 at 10:44:37PM CET, nicolas.2p.debian@gmail.com wrote: >>Le 08/03/2011 14:42, Andy Gospodarek a écrit : >>>I'm pretty sure this patch will have the same catastrophic problem your >>>last one did. By cloning and setting skb2->dev = orig_dev you just >>>inserted a frame identical to the one we received right back into the >>>stack. It only took a few minutes for my box to melt as one frame on >>>the wire will cause an infinite number of frames to be received by the >>>stack. >> >>I agree with Andy. We still keep one reinject (netif_rx), which is >>probably better that two (__netif_receive_skb), but not enough. >> >>I really think we need a general framework for late delivery of final >>packets to packet handler registered somewhere in the rx_handler >>path. >> >>Jiri, is this patch the one you announced as "I have some kind nice >>solution in mind and I'm going to submit that as a patch later (too >>many patches are in the wind atm)" ? > > >I did not had time to verify my thought yet but I think that the only >think needed against my original patch (bonding: move processing of recv >handlers into handle_frame()) is ro remove vlan_on_bond_hook, period. > >Because all incoming arps are seen by bond_handle_frame => >bond->recv_probe , even vlan ones - that would make eth0-bond0-bond0.5 >work and eth0-bond0-br0-bond0.5 as well. But again, need to verify this. Working good even for eth0-bond0-br0-bond0.5 mode1 arp_validate, hwvlanaccel. Looking good so far. > >Jirka ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: reinject arps into bonding slave instead of master 2011-03-08 21:44 ` Nicolas de Pesloüan 2011-03-09 7:45 ` Jiri Pirko @ 2011-03-09 13:33 ` Neil Horman 1 sibling, 0 replies; 74+ messages in thread From: Neil Horman @ 2011-03-09 13:33 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Andy Gospodarek, Jiri Pirko, netdev, davem, shemminger, kaber, fubar, eric.dumazet On Tue, Mar 08, 2011 at 10:44:37PM +0100, Nicolas de Pesloüan wrote: > Le 08/03/2011 14:42, Andy Gospodarek a écrit : > >I'm pretty sure this patch will have the same catastrophic problem your > >last one did. By cloning and setting skb2->dev = orig_dev you just > >inserted a frame identical to the one we received right back into the > >stack. It only took a few minutes for my box to melt as one frame on > >the wire will cause an infinite number of frames to be received by the > >stack. > > I agree with Andy. We still keep one reinject (netif_rx), which is > probably better that two (__netif_receive_skb), but not enough. > > I really think we need a general framework for late delivery of > final packets to packet handler registered somewhere in the > rx_handler path. > > Jiri, is this patch the one you announced as "I have some kind nice > solution in mind and I'm going to submit that as a patch later (too > many patches are in the wind atm)" ? I've not had time to flesh any of this out, but have you considered the use of privately allocated net namespaces to define the receive order of frames when doing multiple re-injections through netif_rx/netif_receive_skb. If you modified the ptype list traversals so validate that dev_net(ptype->dev) == dev_net(skb->dev) before delivery, you could allocate private net namespaces in your virutal master drivers (bridges/bonds/vlans) and place the slave devices in those spaces, so that only the parent device could receive frames on them. Of course thats going to have its own set of problems to deal with, but it might be worth considering. Neil > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > > ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko ` (5 preceding siblings ...) 2011-03-05 10:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 12:48 ` Ben Hutchings 2011-03-05 15:31 ` [patch net-next-2.6 7/8 v2] net: introduce rx_handler results and logic around that Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers Jiri Pirko 7 siblings, 2 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy This patch allows rx_handlers to better signalize what to do next to it's caller. That makes skb->deliver_no_wcard no longer needed. Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_main.c | 20 +++++++++++--------- drivers/net/macvlan.c | 11 ++++++----- include/linux/netdevice.h | 9 ++++++++- include/linux/skbuff.h | 5 +---- net/bridge/br_input.c | 25 +++++++++++++++---------- net/bridge/br_private.h | 2 +- net/core/dev.c | 19 ++++++++++++------- 7 files changed, 54 insertions(+), 37 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 8ba7faa..ab56190 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1483,20 +1483,23 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, return false; } -static struct sk_buff *bond_handle_frame(struct sk_buff *skb) +static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) { + struct sk_buff *skb = *pskb; struct slave *slave; struct net_device *bond_dev; struct bonding *bond; - skb = skb_share_check(skb, GFP_ATOMIC); - if (unlikely(!skb)) - return NULL; - slave = bond_slave_get_rcu(skb->dev); bond_dev = ACCESS_ONCE(slave->dev->master); if (unlikely(!bond_dev)) - return skb; + return RX_HANDLER_PASS; + + skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + return RX_HANDLER_CONSUMED; + + *pskb = skb; bond = netdev_priv(bond_dev); @@ -1513,8 +1516,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) } if (bond_should_deliver_exact_match(skb, slave, bond)) { - skb->deliver_no_wcard = 1; - return skb; + return RX_HANDLER_EXACT; } skb->dev = bond_dev; @@ -1527,7 +1529,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) memcpy(dest, bond_dev->dev_addr, ETH_ALEN); } - return skb; + return RX_HANDLER_ANOTHER; } /* enslave device <slave> to bond device <master> */ diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 6ed577b..ead9a8f 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -152,9 +152,10 @@ static void macvlan_broadcast(struct sk_buff *skb, } /* called under rcu_read_lock() from netif_receive_skb */ -static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) +static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) { struct macvlan_port *port; + struct sk_buff *skb = *pskb; const struct ethhdr *eth = eth_hdr(skb); const struct macvlan_dev *vlan; const struct macvlan_dev *src; @@ -184,7 +185,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) */ macvlan_broadcast(skb, port, src->dev, MACVLAN_MODE_VEPA); - return skb; + return RX_HANDLER_PASS; } if (port->passthru) @@ -192,12 +193,12 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) else vlan = macvlan_hash_lookup(port, eth->h_dest); if (vlan == NULL) - return skb; + return RX_HANDLER_PASS; dev = vlan->dev; if (unlikely(!(dev->flags & IFF_UP))) { kfree_skb(skb); - return NULL; + return RX_HANDLER_CONSUMED; } len = skb->len + ETH_HLEN; skb = skb_share_check(skb, GFP_ATOMIC); @@ -211,7 +212,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) out: macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, 0); - return NULL; + return RX_HANDLER_CONSUMED; } static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8be4056..ff386a4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -390,7 +390,14 @@ enum gro_result { }; typedef enum gro_result gro_result_t; -typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); +enum rx_handler_result { + RX_HANDLER_CONSUMED, + RX_HANDLER_ANOTHER, + RX_HANDLER_EXACT, + RX_HANDLER_PASS, +}; +typedef enum rx_handler_result rx_handler_result_t; +typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); extern void __napi_schedule(struct napi_struct *n); diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 31f02d0..24cfa62 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -388,10 +388,7 @@ struct sk_buff { kmemcheck_bitfield_begin(flags2); __u16 queue_mapping:16; #ifdef CONFIG_IPV6_NDISC_NODETYPE - __u8 ndisc_nodetype:2, - deliver_no_wcard:1; -#else - __u8 deliver_no_wcard:1; + __u8 ndisc_nodetype:2; #endif __u8 ooo_okay:1; kmemcheck_bitfield_end(flags2); diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 88e4aa9..e216079 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -139,21 +139,22 @@ static inline int is_link_local(const unsigned char *dest) * Return NULL if skb is handled * note: already called with rcu_read_lock */ -struct sk_buff *br_handle_frame(struct sk_buff *skb) +rx_handler_result_t br_handle_frame(struct sk_buff **pskb) { struct net_bridge_port *p; + struct sk_buff *skb = *pskb; const unsigned char *dest = eth_hdr(skb)->h_dest; br_should_route_hook_t *rhook; if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) - return skb; + return RX_HANDLER_PASS; if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) goto drop; skb = skb_share_check(skb, GFP_ATOMIC); if (!skb) - return NULL; + return RX_HANDLER_CONSUMED; p = br_port_get_rcu(skb->dev); @@ -167,10 +168,12 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb) goto forward; if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, - NULL, br_handle_local_finish)) - return NULL; /* frame consumed by filter */ - else - return skb; /* continue processing */ + NULL, br_handle_local_finish)) { + return RX_HANDLER_CONSUMED; /* consumed by filter */ + } else { + *pskb = skb; + return RX_HANDLER_PASS; /* continue processing */ + } } forward: @@ -178,8 +181,10 @@ forward: case BR_STATE_FORWARDING: rhook = rcu_dereference(br_should_route_hook); if (rhook) { - if ((*rhook)(skb)) - return skb; + if ((*rhook)(skb)) { + *pskb = skb; + return RX_HANDLER_PASS; + } dest = eth_hdr(skb)->h_dest; } /* fall through */ @@ -194,5 +199,5 @@ forward: drop: kfree_skb(skb); } - return NULL; + return RX_HANDLER_CONSUMED; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index f7afc36..19e2f46 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -379,7 +379,7 @@ extern void br_features_recompute(struct net_bridge *br); /* br_input.c */ extern int br_handle_frame_finish(struct sk_buff *skb); -extern struct sk_buff *br_handle_frame(struct sk_buff *skb); +extern rx_handler_result_t br_handle_frame(struct sk_buff **pskb); /* br_ioctl.c */ extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); diff --git a/net/core/dev.c b/net/core/dev.c index 9f66de9..58daddb 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3121,6 +3121,7 @@ static int __netif_receive_skb(struct sk_buff *skb) rx_handler_func_t *rx_handler; struct net_device *orig_dev; struct net_device *null_or_dev; + bool deliver_exact = false; int ret = NET_RX_DROP; __be16 type; @@ -3173,18 +3174,22 @@ ncls: rx_handler = rcu_dereference(skb->dev->rx_handler); if (rx_handler) { - struct net_device *prev_dev; - if (pt_prev) { ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = NULL; } - prev_dev = skb->dev; - skb = rx_handler(skb); - if (!skb) + switch (rx_handler(&skb)) { + case RX_HANDLER_CONSUMED: goto out; - if (skb->dev != prev_dev) + case RX_HANDLER_ANOTHER: goto another_round; + case RX_HANDLER_EXACT: + deliver_exact = true; + case RX_HANDLER_PASS: + break; + default: + BUG(); + } } if (vlan_tx_tag_present(skb)) { @@ -3202,7 +3207,7 @@ ncls: vlan_on_bond_hook(skb); /* deliver only exact match when indicated */ - null_or_dev = skb->deliver_no_wcard ? skb->dev : NULL; + null_or_dev = deliver_exact ? skb->dev : NULL; type = skb->protocol; list_for_each_entry_rcu(ptype, -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that 2011-03-05 10:29 ` [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that Jiri Pirko @ 2011-03-05 12:48 ` Ben Hutchings 2011-03-05 14:52 ` Nicolas de Pesloüan 2011-03-05 15:13 ` [patch net-next-2.6] net: comment rx_handler results Jiri Pirko 2011-03-05 15:31 ` [patch net-next-2.6 7/8 v2] net: introduce rx_handler results and logic around that Jiri Pirko 1 sibling, 2 replies; 74+ messages in thread From: Ben Hutchings @ 2011-03-05 12:48 UTC (permalink / raw) To: Jiri Pirko Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy On Sat, 2011-03-05 at 11:29 +0100, Jiri Pirko wrote: > This patch allows rx_handlers to better signalize what to do next to > it's caller. That makes skb->deliver_no_wcard no longer needed. [...] > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -390,7 +390,14 @@ enum gro_result { > }; > typedef enum gro_result gro_result_t; > > -typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); > +enum rx_handler_result { > + RX_HANDLER_CONSUMED, > + RX_HANDLER_ANOTHER, > + RX_HANDLER_EXACT, > + RX_HANDLER_PASS, > +}; [...] This should have a comment (preferably kernel-doc) clearly specifying the meaning of each code, as the differences between ANOTHER/EXACT/PASS are fairly subtle. Ben, -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that 2011-03-05 12:48 ` Ben Hutchings @ 2011-03-05 14:52 ` Nicolas de Pesloüan 2011-03-05 14:54 ` Jiri Pirko 2011-03-05 15:13 ` [patch net-next-2.6] net: comment rx_handler results Jiri Pirko 1 sibling, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 14:52 UTC (permalink / raw) To: Jiri Pirko Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 13:48, Ben Hutchings a écrit : > On Sat, 2011-03-05 at 11:29 +0100, Jiri Pirko wrote: >> This patch allows rx_handlers to better signalize what to do next to >> it's caller. That makes skb->deliver_no_wcard no longer needed. > [...] >> --- a/include/linux/netdevice.h >> +++ b/include/linux/netdevice.h >> @@ -390,7 +390,14 @@ enum gro_result { >> }; >> typedef enum gro_result gro_result_t; >> >> -typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); >> +enum rx_handler_result { >> + RX_HANDLER_CONSUMED, >> + RX_HANDLER_ANOTHER, >> + RX_HANDLER_EXACT, >> + RX_HANDLER_PASS, >> +}; > [...] > > This should have a comment (preferably kernel-doc) clearly specifying > the meaning of each code, as the differences between ANOTHER/EXACT/PASS > are fairly subtle. > > Ben, Except from the lack of proper documentation, this patch looks very good. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that 2011-03-05 14:52 ` Nicolas de Pesloüan @ 2011-03-05 14:54 ` Jiri Pirko 2011-03-05 15:06 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 14:54 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 03:52:19PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 13:48, Ben Hutchings a écrit : >>On Sat, 2011-03-05 at 11:29 +0100, Jiri Pirko wrote: >>>This patch allows rx_handlers to better signalize what to do next to >>>it's caller. That makes skb->deliver_no_wcard no longer needed. >>[...] >>>--- a/include/linux/netdevice.h >>>+++ b/include/linux/netdevice.h >>>@@ -390,7 +390,14 @@ enum gro_result { >>> }; >>> typedef enum gro_result gro_result_t; >>> >>>-typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); >>>+enum rx_handler_result { >>>+ RX_HANDLER_CONSUMED, >>>+ RX_HANDLER_ANOTHER, >>>+ RX_HANDLER_EXACT, >>>+ RX_HANDLER_PASS, >>>+}; >>[...] >> >>This should have a comment (preferably kernel-doc) clearly specifying >>the meaning of each code, as the differences between ANOTHER/EXACT/PASS >>are fairly subtle. >> >>Ben, > >Except from the lack of proper documentation, this patch looks very good. Okay guys, I'll write something about that and send it in another patch. > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that 2011-03-05 14:54 ` Jiri Pirko @ 2011-03-05 15:06 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 15:06 UTC (permalink / raw) To: Jiri Pirko Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 15:54, Jiri Pirko a écrit : > Sat, Mar 05, 2011 at 03:52:19PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 13:48, Ben Hutchings a écrit : >>> On Sat, 2011-03-05 at 11:29 +0100, Jiri Pirko wrote: >>>> This patch allows rx_handlers to better signalize what to do next to >>>> it's caller. That makes skb->deliver_no_wcard no longer needed. >>> [...] >>>> --- a/include/linux/netdevice.h >>>> +++ b/include/linux/netdevice.h >>>> @@ -390,7 +390,14 @@ enum gro_result { >>>> }; >>>> typedef enum gro_result gro_result_t; >>>> >>>> -typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); >>>> +enum rx_handler_result { >>>> + RX_HANDLER_CONSUMED, >>>> + RX_HANDLER_ANOTHER, >>>> + RX_HANDLER_EXACT, >>>> + RX_HANDLER_PASS, >>>> +}; >>> [...] >>> >>> This should have a comment (preferably kernel-doc) clearly specifying >>> the meaning of each code, as the differences between ANOTHER/EXACT/PASS >>> are fairly subtle. >>> >>> Ben, >> >> Except from the lack of proper documentation, this patch looks very good. > > Okay guys, I'll write something about that and send it in another patch. Agreed that it can be in a follow-up patch. Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6] net: comment rx_handler results 2011-03-05 12:48 ` Ben Hutchings 2011-03-05 14:52 ` Nicolas de Pesloüan @ 2011-03-05 15:13 ` Jiri Pirko 2011-03-05 15:27 ` Nicolas de Pesloüan 1 sibling, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 15:13 UTC (permalink / raw) To: Ben Hutchings Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- include/linux/netdevice.h | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 48a9638..26e03f9 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -391,10 +391,14 @@ enum gro_result { typedef enum gro_result gro_result_t; enum rx_handler_result { - RX_HANDLER_CONSUMED, - RX_HANDLER_ANOTHER, - RX_HANDLER_EXACT, - RX_HANDLER_PASS, + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, + do not process it further. */ + RX_HANDLER_ANOTHER, /* Do another round in receive path. + This is indicated in case skb->dev + was changed by rx_handler */ + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ + RX_HANDLER_PASS, /* Do nothing, pass the skb as if + no rx_handler was called */ }; typedef enum rx_handler_result rx_handler_result_t; typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: comment rx_handler results 2011-03-05 15:13 ` [patch net-next-2.6] net: comment rx_handler results Jiri Pirko @ 2011-03-05 15:27 ` Nicolas de Pesloüan 2011-03-05 15:37 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 15:27 UTC (permalink / raw) To: Jiri Pirko Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 16:13, Jiri Pirko a écrit : > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > --- > include/linux/netdevice.h | 12 ++++++++---- > 1 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 48a9638..26e03f9 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -391,10 +391,14 @@ enum gro_result { > typedef enum gro_result gro_result_t; > > enum rx_handler_result { > - RX_HANDLER_CONSUMED, > - RX_HANDLER_ANOTHER, > - RX_HANDLER_EXACT, > - RX_HANDLER_PASS, > + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, > + do not process it further. */ > + RX_HANDLER_ANOTHER, /* Do another round in receive path. > + This is indicated in case skb->dev > + was changed by rx_handler */ > + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ > + RX_HANDLER_PASS, /* Do nothing, pass the skb as if > + no rx_handler was called */ Changing skb->dev should always cause another_round. So, RX_HANDLER_ANOTHER could be removed and replaced with a test for skb->dev change, with RX_HANDER_EXACT and RX_HANDLER_PASS. > + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, > + do not process it further. */ > + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ > + RX_HANDLER_PASS, /* Do normal (wildcard and exact) delivery */ And any rx_handler returning RX_HANDLER_EXACT should cause exact delivery, even if possible next rx_handlers return RX_HANDLER_PASS. Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: comment rx_handler results 2011-03-05 15:27 ` Nicolas de Pesloüan @ 2011-03-05 15:37 ` Jiri Pirko 2011-03-05 15:50 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 15:37 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 04:27:52PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 16:13, Jiri Pirko a écrit : >> >>Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>--- >> include/linux/netdevice.h | 12 ++++++++---- >> 1 files changed, 8 insertions(+), 4 deletions(-) >> >>diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h >>index 48a9638..26e03f9 100644 >>--- a/include/linux/netdevice.h >>+++ b/include/linux/netdevice.h >>@@ -391,10 +391,14 @@ enum gro_result { >> typedef enum gro_result gro_result_t; >> >> enum rx_handler_result { >>- RX_HANDLER_CONSUMED, >>- RX_HANDLER_ANOTHER, >>- RX_HANDLER_EXACT, >>- RX_HANDLER_PASS, >>+ RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, >>+ do not process it further. */ >>+ RX_HANDLER_ANOTHER, /* Do another round in receive path. >>+ This is indicated in case skb->dev >>+ was changed by rx_handler */ >>+ RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ >>+ RX_HANDLER_PASS, /* Do nothing, pass the skb as if >>+ no rx_handler was called */ > >Changing skb->dev should always cause another_round. Not if you reinject the skb. > >So, RX_HANDLER_ANOTHER could be removed and replaced with a test for >skb->dev change, with RX_HANDER_EXACT and RX_HANDLER_PASS. That was there before. Needs extra variable and I think this way, via results the code is much easier to read. > >> + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, >> + do not process it further. */ >> + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ >> + RX_HANDLER_PASS, /* Do normal (wildcard and exact) delivery */ > >And any rx_handler returning RX_HANDLER_EXACT should cause exact >delivery, even if possible next rx_handlers return RX_HANDLER_PASS. When rx_handler returns RX_HANDLER_EXACT, there will bo no other call to any rx_handler (that is the case only when RX_HANDLER_ANOTHER is returned) > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6] net: comment rx_handler results 2011-03-05 15:37 ` Jiri Pirko @ 2011-03-05 15:50 ` Nicolas de Pesloüan 2011-03-06 20:00 ` [PATCH net-next-2.6] net: enhance the documentation for rx_handler Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 15:50 UTC (permalink / raw) To: Jiri Pirko Cc: Ben Hutchings, netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 16:37, Jiri Pirko a écrit : > Sat, Mar 05, 2011 at 04:27:52PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 16:13, Jiri Pirko a écrit : >>> >>> Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>> --- >>> include/linux/netdevice.h | 12 ++++++++---- >>> 1 files changed, 8 insertions(+), 4 deletions(-) >>> >>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h >>> index 48a9638..26e03f9 100644 >>> --- a/include/linux/netdevice.h >>> +++ b/include/linux/netdevice.h >>> @@ -391,10 +391,14 @@ enum gro_result { >>> typedef enum gro_result gro_result_t; >>> >>> enum rx_handler_result { >>> - RX_HANDLER_CONSUMED, >>> - RX_HANDLER_ANOTHER, >>> - RX_HANDLER_EXACT, >>> - RX_HANDLER_PASS, >>> + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, >>> + do not process it further. */ >>> + RX_HANDLER_ANOTHER, /* Do another round in receive path. >>> + This is indicated in case skb->dev >>> + was changed by rx_handler */ >>> + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ >>> + RX_HANDLER_PASS, /* Do nothing, pass the skb as if >>> + no rx_handler was called */ >> >> Changing skb->dev should always cause another_round. > > Not if you reinject the skb. > >> >> So, RX_HANDLER_ANOTHER could be removed and replaced with a test for >> skb->dev change, with RX_HANDER_EXACT and RX_HANDLER_PASS. > > That was there before. Needs extra variable and I think this way, via > results the code is much easier to read. > >> >>> + RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, >>> + do not process it further. */ >>> + RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ >>> + RX_HANDLER_PASS, /* Do normal (wildcard and exact) delivery */ >> >> And any rx_handler returning RX_HANDLER_EXACT should cause exact >> delivery, even if possible next rx_handlers return RX_HANDLER_PASS. > > When rx_handler returns RX_HANDLER_EXACT, there will bo no other call to > any rx_handler (that is the case only when RX_HANDLER_ANOTHER is > returned) I agree, but we clearly need a kernel-doc that explain in more detail the expected behavior of every return values. Some examples, showing some normal and some stacking setups, would help, I think. One more follow-up patch... Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* [PATCH net-next-2.6] net: enhance the documentation for rx_handler. 2011-03-05 15:50 ` Nicolas de Pesloüan @ 2011-03-06 20:00 ` Nicolas de Pesloüan 2011-03-07 9:54 ` Jiri Pirko 2011-03-07 16:36 ` Stephen Hemminger 0 siblings, 2 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-06 20:00 UTC (permalink / raw) To: netdev Cc: davem, shemminger, eric.dumazet, kaber, fubar, andy, Nicolas de Pesloüan Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> --- This apply on top of Jiri's last patch serie, including the last one that commented the RX_HANDLER_* values. include/linux/netdevice.h | 53 ++++++++++++++++++++++++++++++++++++++------ net/core/dev.c | 2 + 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 26e03f9..0c9dc93 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -390,15 +390,52 @@ enum gro_result { }; typedef enum gro_result gro_result_t; +/** + * enum rx_handler_result - Possible return values for rx_handlers. + * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it + * further. + * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in + * case skb->dev was changed by rx_handler. + * @RX_HANDLER_EXACT: Force exact delivery, no wildcard. + * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called. + * + * rx_handlers are functions called from inside __netif_receive_skb(), to do + * special processing of the skb, prior to delivery to protocol handlers. + * + * Currently, a net_device can only have a single rx_handler registered. Trying + * to register a second rx_handler will return -EBUSY. + * + * To register a rx_handler on a net_device, use netdev_rx_handler_register(). + * To unregister a rx_handler on a net_device, use + * netdev_rx_handler_unregister(). + * + * Upon return, rx_handler is expected to tell __netif_receive_skb() what to + * do with the skb. + * + * If the rx_handler consumed to skb in some way, it should return + * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for + * the skb to be delivered in some other ways. + * + * If the rx_handler changed skb->dev, to divert the skb to another + * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the + * new device will be called if it exists. + * + * If the rx_handler consider the skb should be ignored, it should return + * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that + * are registred on exact device (ptype->dev == skb->dev). + * + * If the rx_handler didn't changed skb->dev, but want the skb to be normally + * delivered, it should return RX_HANDLER_PASS. + * + * A device without a registered rx_handler will behave as if rx_handler + * returned RX_HANDLER_PASS. + */ + enum rx_handler_result { - RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, - do not process it further. */ - RX_HANDLER_ANOTHER, /* Do another round in receive path. - This is indicated in case skb->dev - was changed by rx_handler */ - RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ - RX_HANDLER_PASS, /* Do nothing, pass the skb as if - no rx_handler was called */ + RX_HANDLER_CONSUMED, + RX_HANDLER_ANOTHER, + RX_HANDLER_EXACT, + RX_HANDLER_PASS, }; typedef enum rx_handler_result rx_handler_result_t; typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); diff --git a/net/core/dev.c b/net/core/dev.c index a368223..3630722 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3060,6 +3060,8 @@ out: * on a failure. * * The caller must hold the rtnl_mutex. + * + * For a general description of rx_handler, see enum rx_handler_result. */ int netdev_rx_handler_register(struct net_device *dev, rx_handler_func_t *rx_handler, -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [PATCH net-next-2.6] net: enhance the documentation for rx_handler. 2011-03-06 20:00 ` [PATCH net-next-2.6] net: enhance the documentation for rx_handler Nicolas de Pesloüan @ 2011-03-07 9:54 ` Jiri Pirko 2011-03-07 16:36 ` Stephen Hemminger 1 sibling, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-07 9:54 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, eric.dumazet, kaber, fubar, andy Sun, Mar 06, 2011 at 09:00:08PM CET, nicolas.2p.debian@free.fr wrote: >Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> >--- >This apply on top of Jiri's last patch serie, including the last one that >commented the RX_HANDLER_* values. > > include/linux/netdevice.h | 53 ++++++++++++++++++++++++++++++++++++++------ > net/core/dev.c | 2 + > 2 files changed, 47 insertions(+), 8 deletions(-) > >diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h >index 26e03f9..0c9dc93 100644 >--- a/include/linux/netdevice.h >+++ b/include/linux/netdevice.h >@@ -390,15 +390,52 @@ enum gro_result { > }; > typedef enum gro_result gro_result_t; > >+/** >+ * enum rx_handler_result - Possible return values for rx_handlers. >+ * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it >+ * further. >+ * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in >+ * case skb->dev was changed by rx_handler. >+ * @RX_HANDLER_EXACT: Force exact delivery, no wildcard. >+ * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called. >+ * >+ * rx_handlers are functions called from inside __netif_receive_skb(), to do >+ * special processing of the skb, prior to delivery to protocol handlers. >+ * >+ * Currently, a net_device can only have a single rx_handler registered. Trying >+ * to register a second rx_handler will return -EBUSY. >+ * >+ * To register a rx_handler on a net_device, use netdev_rx_handler_register(). >+ * To unregister a rx_handler on a net_device, use >+ * netdev_rx_handler_unregister(). >+ * >+ * Upon return, rx_handler is expected to tell __netif_receive_skb() what to >+ * do with the skb. >+ * >+ * If the rx_handler consumed to skb in some way, it should return >+ * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for >+ * the skb to be delivered in some other ways. >+ * >+ * If the rx_handler changed skb->dev, to divert the skb to another >+ * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the >+ * new device will be called if it exists. >+ * >+ * If the rx_handler consider the skb should be ignored, it should return >+ * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that >+ * are registred on exact device (ptype->dev == skb->dev). >+ * >+ * If the rx_handler didn't changed skb->dev, but want the skb to be normally >+ * delivered, it should return RX_HANDLER_PASS. >+ * >+ * A device without a registered rx_handler will behave as if rx_handler >+ * returned RX_HANDLER_PASS. >+ */ >+ > enum rx_handler_result { >- RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, >- do not process it further. */ >- RX_HANDLER_ANOTHER, /* Do another round in receive path. >- This is indicated in case skb->dev >- was changed by rx_handler */ >- RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ >- RX_HANDLER_PASS, /* Do nothing, pass the skb as if >- no rx_handler was called */ >+ RX_HANDLER_CONSUMED, >+ RX_HANDLER_ANOTHER, >+ RX_HANDLER_EXACT, >+ RX_HANDLER_PASS, > }; > typedef enum rx_handler_result rx_handler_result_t; > typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); >diff --git a/net/core/dev.c b/net/core/dev.c >index a368223..3630722 100644 >--- a/net/core/dev.c >+++ b/net/core/dev.c >@@ -3060,6 +3060,8 @@ out: > * on a failure. > * > * The caller must hold the rtnl_mutex. >+ * >+ * For a general description of rx_handler, see enum rx_handler_result. > */ > int netdev_rx_handler_register(struct net_device *dev, > rx_handler_func_t *rx_handler, >-- >1.7.2.3 > >-- >To unsubscribe from this list: send the line "unsubscribe netdev" in >the body of a message to majordomo@vger.kernel.org >More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Jiri Pirko <jpirko@redhat.com> ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [PATCH net-next-2.6] net: enhance the documentation for rx_handler. 2011-03-06 20:00 ` [PATCH net-next-2.6] net: enhance the documentation for rx_handler Nicolas de Pesloüan 2011-03-07 9:54 ` Jiri Pirko @ 2011-03-07 16:36 ` Stephen Hemminger 2011-03-07 20:01 ` [PATCH net-next-2.6 V2] " Nicolas de Pesloüan 1 sibling, 1 reply; 74+ messages in thread From: Stephen Hemminger @ 2011-03-07 16:36 UTC (permalink / raw) To: Nicolas de Pesloüan; +Cc: netdev, davem, eric.dumazet, kaber, fubar, andy On Sun, 6 Mar 2011 21:00:08 +0100 Nicolas de Pesloüan <nicolas.2p.debian@free.fr> wrote: > Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > --- > This apply on top of Jiri's last patch serie, including the last one that > commented the RX_HANDLER_* values. > > include/linux/netdevice.h | 53 ++++++++++++++++++++++++++++++++++++++------ > net/core/dev.c | 2 + > 2 files changed, 47 insertions(+), 8 deletions(-) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 26e03f9..0c9dc93 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -390,15 +390,52 @@ enum gro_result { > }; > typedef enum gro_result gro_result_t; > > +/** > + * enum rx_handler_result - Possible return values for rx_handlers. > + * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it > + * further. > + * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in > + * case skb->dev was changed by rx_handler. > + * @RX_HANDLER_EXACT: Force exact delivery, no wildcard. > + * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called. s/passe/process/ ^ permalink raw reply [flat|nested] 74+ messages in thread
* [PATCH net-next-2.6 V2] net: enhance the documentation for rx_handler. 2011-03-07 16:36 ` Stephen Hemminger @ 2011-03-07 20:01 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-07 20:01 UTC (permalink / raw) To: netdev Cc: davem, shemminger, eric.dumazet, kaber, fubar, andy, Nicolas de Pesloüan Signed-off-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> Reviewed-by: Jiri Pirko <jpirko@redhat.com> --- This apply on top of Jiri's last patch serie, including the last one that commented the RX_HANDLER_* values. include/linux/netdevice.h | 53 ++++++++++++++++++++++++++++++++++++++------ net/core/dev.c | 2 + 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 26e03f9..0c9dc93 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -390,15 +390,52 @@ enum gro_result { }; typedef enum gro_result gro_result_t; +/** + * enum rx_handler_result - Possible return values for rx_handlers. + * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it + * further. + * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in + * case skb->dev was changed by rx_handler. + * @RX_HANDLER_EXACT: Force exact delivery, no wildcard. + * @RX_HANDLER_PASS: Do nothing, process the skb as if no rx_handler was called. + * + * rx_handlers are functions called from inside __netif_receive_skb(), to do + * special processing of the skb, prior to delivery to protocol handlers. + * + * Currently, a net_device can only have a single rx_handler registered. Trying + * to register a second rx_handler will return -EBUSY. + * + * To register a rx_handler on a net_device, use netdev_rx_handler_register(). + * To unregister a rx_handler on a net_device, use + * netdev_rx_handler_unregister(). + * + * Upon return, rx_handler is expected to tell __netif_receive_skb() what to + * do with the skb. + * + * If the rx_handler consumed to skb in some way, it should return + * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for + * the skb to be delivered in some other ways. + * + * If the rx_handler changed skb->dev, to divert the skb to another + * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the + * new device will be called if it exists. + * + * If the rx_handler consider the skb should be ignored, it should return + * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that + * are registred on exact device (ptype->dev == skb->dev). + * + * If the rx_handler didn't changed skb->dev, but want the skb to be normally + * delivered, it should return RX_HANDLER_PASS. + * + * A device without a registered rx_handler will behave as if rx_handler + * returned RX_HANDLER_PASS. + */ + enum rx_handler_result { - RX_HANDLER_CONSUMED, /* skb was consumed by rx_handler, - do not process it further. */ - RX_HANDLER_ANOTHER, /* Do another round in receive path. - This is indicated in case skb->dev - was changed by rx_handler */ - RX_HANDLER_EXACT, /* Force exact delivery, no wildcard */ - RX_HANDLER_PASS, /* Do nothing, pass the skb as if - no rx_handler was called */ + RX_HANDLER_CONSUMED, + RX_HANDLER_ANOTHER, + RX_HANDLER_EXACT, + RX_HANDLER_PASS, }; typedef enum rx_handler_result rx_handler_result_t; typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); diff --git a/net/core/dev.c b/net/core/dev.c index a368223..3630722 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3060,6 +3060,8 @@ out: * on a failure. * * The caller must hold the rtnl_mutex. + * + * For a general description of rx_handler, see enum rx_handler_result. */ int netdev_rx_handler_register(struct net_device *dev, rx_handler_func_t *rx_handler, -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* [patch net-next-2.6 7/8 v2] net: introduce rx_handler results and logic around that 2011-03-05 10:29 ` [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that Jiri Pirko 2011-03-05 12:48 ` Ben Hutchings @ 2011-03-05 15:31 ` Jiri Pirko 1 sibling, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 15:31 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy This patch allows rx_handlers to better signalize what to do next to it's caller. That makes skb->deliver_no_wcard no longer needed. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> v1->v2: moved __copy_skb_header hunk from 8/8 here --- drivers/net/bonding/bond_main.c | 20 +++++++++++--------- drivers/net/macvlan.c | 11 ++++++----- include/linux/netdevice.h | 9 ++++++++- include/linux/skbuff.h | 5 +---- net/bridge/br_input.c | 25 +++++++++++++++---------- net/bridge/br_private.h | 2 +- net/core/dev.c | 19 ++++++++++++------- net/core/skbuff.c | 1 - 8 files changed, 54 insertions(+), 38 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 8ba7faa..ab56190 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1483,20 +1483,23 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, return false; } -static struct sk_buff *bond_handle_frame(struct sk_buff *skb) +static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) { + struct sk_buff *skb = *pskb; struct slave *slave; struct net_device *bond_dev; struct bonding *bond; - skb = skb_share_check(skb, GFP_ATOMIC); - if (unlikely(!skb)) - return NULL; - slave = bond_slave_get_rcu(skb->dev); bond_dev = ACCESS_ONCE(slave->dev->master); if (unlikely(!bond_dev)) - return skb; + return RX_HANDLER_PASS; + + skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + return RX_HANDLER_CONSUMED; + + *pskb = skb; bond = netdev_priv(bond_dev); @@ -1513,8 +1516,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) } if (bond_should_deliver_exact_match(skb, slave, bond)) { - skb->deliver_no_wcard = 1; - return skb; + return RX_HANDLER_EXACT; } skb->dev = bond_dev; @@ -1527,7 +1529,7 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) memcpy(dest, bond_dev->dev_addr, ETH_ALEN); } - return skb; + return RX_HANDLER_ANOTHER; } /* enslave device <slave> to bond device <master> */ diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 6ed577b..ead9a8f 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -152,9 +152,10 @@ static void macvlan_broadcast(struct sk_buff *skb, } /* called under rcu_read_lock() from netif_receive_skb */ -static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) +static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) { struct macvlan_port *port; + struct sk_buff *skb = *pskb; const struct ethhdr *eth = eth_hdr(skb); const struct macvlan_dev *vlan; const struct macvlan_dev *src; @@ -184,7 +185,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) */ macvlan_broadcast(skb, port, src->dev, MACVLAN_MODE_VEPA); - return skb; + return RX_HANDLER_PASS; } if (port->passthru) @@ -192,12 +193,12 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) else vlan = macvlan_hash_lookup(port, eth->h_dest); if (vlan == NULL) - return skb; + return RX_HANDLER_PASS; dev = vlan->dev; if (unlikely(!(dev->flags & IFF_UP))) { kfree_skb(skb); - return NULL; + return RX_HANDLER_CONSUMED; } len = skb->len + ETH_HLEN; skb = skb_share_check(skb, GFP_ATOMIC); @@ -211,7 +212,7 @@ static struct sk_buff *macvlan_handle_frame(struct sk_buff *skb) out: macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, 0); - return NULL; + return RX_HANDLER_CONSUMED; } static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8be4056..ff386a4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -390,7 +390,14 @@ enum gro_result { }; typedef enum gro_result gro_result_t; -typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); +enum rx_handler_result { + RX_HANDLER_CONSUMED, + RX_HANDLER_ANOTHER, + RX_HANDLER_EXACT, + RX_HANDLER_PASS, +}; +typedef enum rx_handler_result rx_handler_result_t; +typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); extern void __napi_schedule(struct napi_struct *n); diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 31f02d0..24cfa62 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -388,10 +388,7 @@ struct sk_buff { kmemcheck_bitfield_begin(flags2); __u16 queue_mapping:16; #ifdef CONFIG_IPV6_NDISC_NODETYPE - __u8 ndisc_nodetype:2, - deliver_no_wcard:1; -#else - __u8 deliver_no_wcard:1; + __u8 ndisc_nodetype:2; #endif __u8 ooo_okay:1; kmemcheck_bitfield_end(flags2); diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 88e4aa9..e216079 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -139,21 +139,22 @@ static inline int is_link_local(const unsigned char *dest) * Return NULL if skb is handled * note: already called with rcu_read_lock */ -struct sk_buff *br_handle_frame(struct sk_buff *skb) +rx_handler_result_t br_handle_frame(struct sk_buff **pskb) { struct net_bridge_port *p; + struct sk_buff *skb = *pskb; const unsigned char *dest = eth_hdr(skb)->h_dest; br_should_route_hook_t *rhook; if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) - return skb; + return RX_HANDLER_PASS; if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) goto drop; skb = skb_share_check(skb, GFP_ATOMIC); if (!skb) - return NULL; + return RX_HANDLER_CONSUMED; p = br_port_get_rcu(skb->dev); @@ -167,10 +168,12 @@ struct sk_buff *br_handle_frame(struct sk_buff *skb) goto forward; if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev, - NULL, br_handle_local_finish)) - return NULL; /* frame consumed by filter */ - else - return skb; /* continue processing */ + NULL, br_handle_local_finish)) { + return RX_HANDLER_CONSUMED; /* consumed by filter */ + } else { + *pskb = skb; + return RX_HANDLER_PASS; /* continue processing */ + } } forward: @@ -178,8 +181,10 @@ forward: case BR_STATE_FORWARDING: rhook = rcu_dereference(br_should_route_hook); if (rhook) { - if ((*rhook)(skb)) - return skb; + if ((*rhook)(skb)) { + *pskb = skb; + return RX_HANDLER_PASS; + } dest = eth_hdr(skb)->h_dest; } /* fall through */ @@ -194,5 +199,5 @@ forward: drop: kfree_skb(skb); } - return NULL; + return RX_HANDLER_CONSUMED; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index f7afc36..19e2f46 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -379,7 +379,7 @@ extern void br_features_recompute(struct net_bridge *br); /* br_input.c */ extern int br_handle_frame_finish(struct sk_buff *skb); -extern struct sk_buff *br_handle_frame(struct sk_buff *skb); +extern rx_handler_result_t br_handle_frame(struct sk_buff **pskb); /* br_ioctl.c */ extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); diff --git a/net/core/dev.c b/net/core/dev.c index 9f66de9..58daddb 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3121,6 +3121,7 @@ static int __netif_receive_skb(struct sk_buff *skb) rx_handler_func_t *rx_handler; struct net_device *orig_dev; struct net_device *null_or_dev; + bool deliver_exact = false; int ret = NET_RX_DROP; __be16 type; @@ -3173,18 +3174,22 @@ ncls: rx_handler = rcu_dereference(skb->dev->rx_handler); if (rx_handler) { - struct net_device *prev_dev; - if (pt_prev) { ret = deliver_skb(skb, pt_prev, orig_dev); pt_prev = NULL; } - prev_dev = skb->dev; - skb = rx_handler(skb); - if (!skb) + switch (rx_handler(&skb)) { + case RX_HANDLER_CONSUMED: goto out; - if (skb->dev != prev_dev) + case RX_HANDLER_ANOTHER: goto another_round; + case RX_HANDLER_EXACT: + deliver_exact = true; + case RX_HANDLER_PASS: + break; + default: + BUG(); + } } if (vlan_tx_tag_present(skb)) { @@ -3202,7 +3207,7 @@ ncls: vlan_on_bond_hook(skb); /* deliver only exact match when indicated */ - null_or_dev = skb->deliver_no_wcard ? skb->dev : NULL; + null_or_dev = deliver_exact ? skb->dev : NULL; type = skb->protocol; list_for_each_entry_rcu(ptype, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1eb526a..801dd08 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -523,7 +523,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->ip_summed = old->ip_summed; skb_copy_queue_mapping(new, old); new->priority = old->priority; - new->deliver_no_wcard = old->deliver_no_wcard; #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) new->ipvs_property = old->ipvs_property; #endif -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko ` (6 preceding siblings ...) 2011-03-05 10:29 ` [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that Jiri Pirko @ 2011-03-05 10:29 ` Jiri Pirko 2011-03-05 15:05 ` Nicolas de Pesloüan 2011-03-05 15:32 ` [patch net-next-2.6 8/8 v2] " Jiri Pirko 7 siblings, 2 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 10:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Since orig_dev was used in af_packet (where it was replaced) and by bonding ptype handlers (which are no longer with us) only, orig_dev parameter is no longer needed -> toss it out Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/block/aoe/aoenet.c | 2 +- drivers/net/hamradio/bpqether.c | 4 ++-- drivers/net/pppoe.c | 4 ++-- drivers/net/wan/hdlc.c | 2 +- drivers/net/wan/lapbether.c | 2 +- drivers/scsi/fcoe/fcoe.c | 12 ++++-------- include/linux/netdevice.h | 3 +-- include/net/ax25.h | 3 ++- include/net/datalink.h | 2 +- include/net/ip.h | 2 +- include/net/ipv6.h | 3 +-- include/net/irda/irda.h | 3 +-- include/net/llc.h | 8 +++----- include/net/p8022.h | 3 +-- include/net/psnap.h | 3 +-- include/net/x25.h | 2 +- net/802/p8022.c | 3 +-- net/802/psnap.c | 7 +++---- net/802/stp.c | 2 +- net/8021q/vlan.h | 2 +- net/8021q/vlan_dev.c | 2 +- net/appletalk/aarp.c | 2 +- net/appletalk/ddp.c | 6 +++--- net/ax25/ax25_in.c | 2 +- net/batman-adv/hard-interface.c | 6 ++---- net/caif/caif_dev.c | 2 +- net/can/af_can.c | 2 +- net/core/dev.c | 26 ++++++++++++-------------- net/core/skbuff.c | 1 - net/decnet/af_decnet.c | 2 +- net/decnet/dn_route.c | 2 +- net/dsa/tag_dsa.c | 2 +- net/dsa/tag_edsa.c | 2 +- net/dsa/tag_trailer.c | 2 +- net/econet/af_econet.c | 2 +- net/ieee802154/af_ieee802154.c | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipconfig.c | 13 ++++++++----- net/ipv6/ip6_input.c | 3 ++- net/ipx/af_ipx.c | 3 ++- net/irda/irlap_frame.c | 2 +- net/llc/llc_core.c | 3 +-- net/llc/llc_input.c | 8 ++++---- net/packet/af_packet.c | 6 +++--- net/phonet/af_phonet.c | 3 +-- net/tipc/eth_media.c | 2 +- net/x25/x25_dev.c | 2 +- 48 files changed, 85 insertions(+), 99 deletions(-) diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 4d3bc0d..c12e14b 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -99,7 +99,7 @@ aoenet_xmit(struct sk_buff_head *queue) * (1) len doesn't include the header by default. I want this. */ static int -aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev) +aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt) { struct aoe_hdr *h; u32 n; diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 8931168..f17ca33 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -95,7 +95,7 @@ static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; static char bpq_eth_addr[6]; -static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *); static int bpq_device_event(struct notifier_block *, unsigned long, void *); static struct packet_type bpq_packet_type __read_mostly = { @@ -177,7 +177,7 @@ static inline int dev_is_ethdev(struct net_device *dev) /* * Receive an AX.25 frame via an ethernet interface. */ -static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) +static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype) { int len; char * ptr; diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 78c0e3c..b99cdaa 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -419,7 +419,7 @@ abort_kfree: * ***********************************************************************/ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct pppoe_hdr *ph; struct pppox_sock *po; @@ -467,7 +467,7 @@ out: * ***********************************************************************/ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct pppoe_hdr *ph; diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 5d4bb61..0ac4f27 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -53,7 +53,7 @@ int hdlc_change_mtu(struct net_device *dev, int new_mtu) } static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *p, struct net_device *orig_dev) + struct packet_type *p) { struct hdlc_device *hdlc = dev_to_hdlc(dev); diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index 7f5bb91..993d71a 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -86,7 +86,7 @@ static __inline__ int dev_is_ethdev(struct net_device *dev) /* * Receive a LAPB frame via an ethernet interface. */ -static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) +static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype) { int len, err; struct lapbethdev *lapbeth; diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 3becc6a..d7442b6 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -70,7 +70,7 @@ DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); static int fcoe_reset(struct Scsi_Host *); static int fcoe_xmit(struct fc_lport *, struct fc_frame *); static int fcoe_rcv(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); static int fcoe_percpu_receive_thread(void *); static void fcoe_clean_pending_queue(struct fc_lport *); static void fcoe_percpu_clean(struct fc_lport *); @@ -88,7 +88,7 @@ static struct fcoe_interface *fcoe_hostlist_lookup_port(const struct net_device *); static int fcoe_fip_recv(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *); static void fcoe_update_src_mac(struct fc_lport *, u8 *); @@ -465,14 +465,11 @@ static inline void fcoe_interface_put(struct fcoe_interface *fcoe) * @skb: The receive skb * @netdev: The associated net device * @ptype: The packet_type structure which was used to register this handler - * @orig_dev: The original net_device the the skb was received on. - * (in case dev is a bond) * * Returns: 0 for success */ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, - struct packet_type *ptype, - struct net_device *orig_dev) + struct packet_type *ptype) { struct fcoe_interface *fcoe; @@ -1228,7 +1225,6 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, * @skb: The received packet * @netdev: The net device that the packet was received on * @ptype: The packet type context - * @olddev: The last device net device * * This routine is called by NET_RX_SOFTIRQ. It receives a packet, builds a * FC frame and passes the frame to libfc. @@ -1236,7 +1232,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, * Returns: 0 for success */ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, - struct packet_type *ptype, struct net_device *olddev) + struct packet_type *ptype) { struct fc_lport *lport; struct fcoe_rcv_info *fr; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ff386a4..48a9638 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1456,8 +1456,7 @@ struct packet_type { struct net_device *dev; /* NULL is wildcarded here */ int (*func) (struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *); + struct packet_type *); struct sk_buff *(*gso_segment)(struct sk_buff *skb, u32 features); int (*gso_send_check)(struct sk_buff *skb); diff --git a/include/net/ax25.h b/include/net/ax25.h index 206d222..fcbe6d8 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h @@ -362,7 +362,8 @@ extern int ax25_protocol_is_registered(unsigned int); /* ax25_in.c */ extern int ax25_rx_iframe(ax25_cb *, struct sk_buff *); -extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, + struct packet_type *); /* ax25_ip.c */ extern int ax25_hard_header(struct sk_buff *, struct net_device *, diff --git a/include/net/datalink.h b/include/net/datalink.h index deb7ca7..5797ba3 100644 --- a/include/net/datalink.h +++ b/include/net/datalink.h @@ -9,7 +9,7 @@ struct datalink_proto { unsigned short header_length; int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); int (*request)(struct datalink_proto *, struct sk_buff *, unsigned char *); struct list_head node; diff --git a/include/net/ip.h b/include/net/ip.h index a4f6311..3b04c24 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -94,7 +94,7 @@ extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, __be32 saddr, __be32 daddr, struct ip_options *opt); extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev); + struct packet_type *pt); extern int ip_local_deliver(struct sk_buff *skb); extern int ip_mr_input(struct sk_buff *skb); extern int ip_output(struct sk_buff *skb); diff --git a/include/net/ipv6.h b/include/net/ipv6.h index d6d077d..990f90b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -470,8 +470,7 @@ static __inline__ void ipv6_select_ident(struct frag_hdr *fhdr) extern int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev); + struct packet_type *pt); extern int ip6_rcv_finish(struct sk_buff *skb); diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h index 3bed61d..2c6e25d 100644 --- a/include/net/irda/irda.h +++ b/include/net/irda/irda.h @@ -125,7 +125,6 @@ extern int irda_nl_register(void); extern void irda_nl_unregister(void); extern int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev); + struct packet_type *ptype); #endif /* NET_IRDA_H */ diff --git a/include/net/llc.h b/include/net/llc.h index 5503b74..73bfea5 100644 --- a/include/net/llc.h +++ b/include/net/llc.h @@ -58,8 +58,7 @@ struct llc_sap { atomic_t refcnt; int (*rcv_func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev); + struct packet_type *pt); struct llc_addr laddr; struct list_head node; spinlock_t sk_lock; @@ -96,7 +95,7 @@ extern struct list_head llc_sap_list; extern spinlock_t llc_sap_list_lock; extern int llc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev); + struct packet_type *pt); extern int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa, const unsigned char *da); @@ -110,8 +109,7 @@ extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb)); extern struct llc_sap *llc_sap_open(unsigned char lsap, int (*rcv)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)); + struct packet_type *pt)); static inline void llc_sap_hold(struct llc_sap *sap) { atomic_inc(&sap->refcnt); diff --git a/include/net/p8022.h b/include/net/p8022.h index 42e9fac..6d878ae 100644 --- a/include/net/p8022.h +++ b/include/net/p8022.h @@ -4,8 +4,7 @@ extern struct datalink_proto * register_8022_client(unsigned char type, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)); + struct packet_type *pt)); extern void unregister_8022_client(struct datalink_proto *proto); extern struct datalink_proto *make_8023_client(void); diff --git a/include/net/psnap.h b/include/net/psnap.h index fe456c2..604bf4b 100644 --- a/include/net/psnap.h +++ b/include/net/psnap.h @@ -4,8 +4,7 @@ extern struct datalink_proto * register_snap_client(const unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *orig_dev)); + struct packet_type *)); extern void unregister_snap_client(struct datalink_proto *proto); #endif diff --git a/include/net/x25.h b/include/net/x25.h index a06119a..3f1c0df2 100644 --- a/include/net/x25.h +++ b/include/net/x25.h @@ -202,7 +202,7 @@ extern void x25_kill_by_neigh(struct x25_neigh *); /* x25_dev.c */ extern void x25_send_frame(struct sk_buff *, struct x25_neigh *); -extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *); extern void x25_establish_link(struct x25_neigh *); extern void x25_terminate_link(struct x25_neigh *); diff --git a/net/802/p8022.c b/net/802/p8022.c index 7f353c4..4ab1339 100644 --- a/net/802/p8022.c +++ b/net/802/p8022.c @@ -36,8 +36,7 @@ static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb, struct datalink_proto *register_8022_client(unsigned char type, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)) + struct packet_type *pt)) { struct datalink_proto *proto; diff --git a/net/802/psnap.c b/net/802/psnap.c index 21cde8f..e74b48e 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c @@ -47,7 +47,7 @@ static struct datalink_proto *find_snap_client(const unsigned char *desc) * A SNAP packet has arrived */ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { int rc = 1; struct datalink_proto *proto; @@ -64,7 +64,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, /* Pass the frame on. */ skb->transport_header += 5; skb_pull_rcsum(skb, 5); - rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev); + rc = proto->rcvfunc(skb, dev, &snap_packet_type); } rcu_read_unlock(); @@ -126,8 +126,7 @@ module_exit(snap_exit); struct datalink_proto *register_snap_client(const unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *)) + struct packet_type *)) { struct datalink_proto *proto = NULL; diff --git a/net/802/stp.c b/net/802/stp.c index 978c30b..dec1f88 100644 --- a/net/802/stp.c +++ b/net/802/stp.c @@ -30,7 +30,7 @@ static DEFINE_MUTEX(stp_proto_mutex); /* Called under rcu_read_lock from LLC */ static int stp_pdu_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { const struct ethhdr *eh = eth_hdr(skb); const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 5687c9b..6f8941e 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -76,7 +76,7 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev) /* found in vlan_dev.c */ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev); + struct packet_type *ptype); void vlan_dev_set_ingress_priority(const struct net_device *dev, u32 skb_prio, u16 vlan_prio); int vlan_dev_set_egress_priority(const struct net_device *dev, diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index be73753..6e396b9 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -138,7 +138,7 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb, * */ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct vlan_hdr *vhdr; struct vlan_pcpu_stats *rx_stats; diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c index 50dce79..996f366 100644 --- a/net/appletalk/aarp.c +++ b/net/appletalk/aarp.c @@ -715,7 +715,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a, * frame. We currently only support Ethernet. */ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct elapaarp *ea = aarp_hdr(skb); int hash, ret = 0; diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index c410b93..61b4983 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1425,7 +1425,7 @@ drop: * layer. [ie ARPHRD_ETHERTALK] */ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct ddpehdr *ddp; struct sock *sock; @@ -1522,7 +1522,7 @@ out: * header and append a long one. */ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { if (!net_eq(dev_net(dev), &init_net)) goto freeit; @@ -1568,7 +1568,7 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, } skb_reset_transport_header(skb); - return atalk_rcv(skb, dev, pt, orig_dev); + return atalk_rcv(skb, dev, pt); freeit: kfree_skb(skb); return 0; diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c index 9bb7765..f6f94e6 100644 --- a/net/ax25/ax25_in.c +++ b/net/ax25/ax25_in.c @@ -436,7 +436,7 @@ free: * Receive an AX.25 frame via a SLIP interface. */ int ax25_kiss_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { skb_orphan(skb); diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index f2131f4..08579b0 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -37,8 +37,7 @@ static DEFINE_SPINLOCK(if_list_lock); static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev); + struct packet_type *ptype); static void hardif_free_rcu(struct rcu_head *rcu) { @@ -556,8 +555,7 @@ out: /* receive a packet with the batman ethertype coming on a hard * interface */ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev) + struct packet_type *ptype) { struct bat_priv *bat_priv; struct batman_packet *batman_packet; diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index a42a408..9f016f0 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -165,7 +165,7 @@ static int modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) * On error, returns non-zero and releases the skb. */ static int receive(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pkttype, struct net_device *orig_dev) + struct packet_type *pkttype) { struct net *net; struct cfpkt *pkt; diff --git a/net/can/af_can.c b/net/can/af_can.c index 702be5a..ad32de5 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c @@ -616,7 +616,7 @@ static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb) } static int can_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dev_rcv_lists *d; struct can_frame *cf = (struct can_frame *)skb->data; diff --git a/net/core/dev.c b/net/core/dev.c index 58daddb..c71bd18 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1534,11 +1534,10 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) EXPORT_SYMBOL_GPL(dev_forward_skb); static inline int deliver_skb(struct sk_buff *skb, - struct packet_type *pt_prev, - struct net_device *orig_dev) + struct packet_type *pt_prev) { atomic_inc(&skb->users); - return pt_prev->func(skb, skb->dev, pt_prev, orig_dev); + return pt_prev->func(skb, skb->dev, pt_prev); } /* @@ -1561,7 +1560,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) (ptype->af_packet_priv == NULL || (struct sock *)ptype->af_packet_priv != skb->sk)) { if (pt_prev) { - deliver_skb(skb2, pt_prev, skb->dev); + deliver_skb(skb2, pt_prev); pt_prev = ptype; continue; } @@ -1594,7 +1593,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) } } if (pt_prev) - pt_prev->func(skb2, skb->dev, pt_prev, skb->dev); + pt_prev->func(skb2, skb->dev, pt_prev); rcu_read_unlock(); } @@ -3025,8 +3024,7 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) } static inline struct sk_buff *handle_ing(struct sk_buff *skb, - struct packet_type **pt_prev, - int *ret, struct net_device *orig_dev) + struct packet_type **pt_prev, int *ret) { struct netdev_queue *rxq = rcu_dereference(skb->dev->ingress_queue); @@ -3034,7 +3032,7 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb, goto out; if (*pt_prev) { - *ret = deliver_skb(skb, *pt_prev, orig_dev); + *ret = deliver_skb(skb, *pt_prev); *pt_prev = NULL; } @@ -3160,13 +3158,13 @@ another_round: list_for_each_entry_rcu(ptype, &ptype_all, list) { if (!ptype->dev || ptype->dev == skb->dev) { if (pt_prev) - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = ptype; } } #ifdef CONFIG_NET_CLS_ACT - skb = handle_ing(skb, &pt_prev, &ret, orig_dev); + skb = handle_ing(skb, &pt_prev, &ret); if (!skb) goto out; ncls: @@ -3175,7 +3173,7 @@ ncls: rx_handler = rcu_dereference(skb->dev->rx_handler); if (rx_handler) { if (pt_prev) { - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = NULL; } switch (rx_handler(&skb)) { @@ -3194,7 +3192,7 @@ ncls: if (vlan_tx_tag_present(skb)) { if (pt_prev) { - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = NULL; } if (vlan_hwaccel_do_receive(&skb)) { @@ -3216,13 +3214,13 @@ ncls: (ptype->dev == null_or_dev || ptype->dev == skb->dev || ptype->dev == orig_dev)) { if (pt_prev) - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = ptype; } } if (pt_prev) { - ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); + ret = pt_prev->func(skb, skb->dev, pt_prev); } else { atomic_long_inc(&skb->dev->rx_dropped); kfree_skb(skb); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1eb526a..801dd08 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -523,7 +523,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->ip_summed = old->ip_summed; skb_copy_queue_mapping(new, old); new->priority = old->priority; - new->deliver_no_wcard = old->deliver_no_wcard; #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) new->ipvs_property = old->ipvs_property; #endif diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 2af15b1..1421721 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -2106,7 +2106,7 @@ static struct notifier_block dn_dev_notifier = { .notifier_call = dn_device_event, }; -extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *); static struct packet_type dn_dix_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_DNA_RT), diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 484fdbf..20abc79 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -588,7 +588,7 @@ static int dn_route_ptp_hello(struct sk_buff *skb) return NET_RX_SUCCESS; } -int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct dn_skb_cb *cb; unsigned char flags = 0; diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 98dfe80..56b686e 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -77,7 +77,7 @@ out_free: } static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 6f38332..474a955 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c @@ -90,7 +90,7 @@ out_free: } static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index d6d7d0a..f8f36ad 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -67,7 +67,7 @@ netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev) } static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 0c28263..edeea09 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -1052,7 +1052,7 @@ release: * Receive an Econet frame from a device. */ -static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct ec_framehdr *hdr; struct sock *sk = NULL; diff --git a/net/ieee802154/af_ieee802154.c b/net/ieee802154/af_ieee802154.c index 6df6ecf..68d5bce 100644 --- a/net/ieee802154/af_ieee802154.c +++ b/net/ieee802154/af_ieee802154.c @@ -299,7 +299,7 @@ static const struct net_proto_family ieee802154_family_ops = { }; static int ieee802154_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { if (!netif_running(dev)) return -ENODEV; diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index fa9988d..53a8f14 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -974,7 +974,7 @@ static void parp_redo(struct sk_buff *skb) */ static int arp_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct arphdr *arp; diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index d7b2b09..639b69b 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -372,7 +372,7 @@ drop: /* * Main IP Receive routine. */ -int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct iphdr *iph; u32 len; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 2b09775..5669509 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -438,7 +438,8 @@ static int __init ic_defaults(void) #ifdef IPCONFIG_RARP -static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); +static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt); static struct packet_type rarp_packet_type __initdata = { .type = cpu_to_be16(ETH_P_RARP), @@ -458,8 +459,8 @@ static inline void __init ic_rarp_cleanup(void) /* * Process received RARP packet. */ -static int __init -ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int __init ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct arphdr *rarp; unsigned char *rarp_ptr; @@ -600,7 +601,8 @@ struct bootp_pkt { /* BOOTP packet format */ #define DHCPRELEASE 7 #define DHCPINFORM 8 -static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); +static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev + struct packet_type *pt); static struct packet_type bootp_packet_type __initdata = { .type = cpu_to_be16(ETH_P_IP), @@ -893,7 +895,8 @@ static void __init ic_do_bootp_ext(u8 *ext) /* * Receive BOOTP reply. */ -static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct bootp_pkt *b; struct iphdr *h; diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index a83e920..dd72591 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -55,7 +55,8 @@ inline int ip6_rcv_finish( struct sk_buff *skb) return dst_input(skb); } -int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct ipv6hdr *hdr; u32 pkt_len; diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index da3d21c..614e207 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1665,7 +1665,8 @@ static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock, return rc; } -static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { /* NULL here for pt means the packet was looped back */ struct ipx_interface *intrfc; diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c index 688222c..7850321 100644 --- a/net/irda/irlap_frame.c +++ b/net/irda/irlap_frame.c @@ -1306,7 +1306,7 @@ static void irlap_recv_test_frame(struct irlap_cb *self, struct sk_buff *skb, * Jean II */ int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct irlap_info info; struct irlap_cb *self; diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index 2bb0ddf..dfeda38 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c @@ -91,8 +91,7 @@ struct llc_sap *llc_sap_find(unsigned char sap_value) struct llc_sap *llc_sap_open(unsigned char lsap, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)) + struct packet_type *pt)) { struct llc_sap *sap = NULL; diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c index 058f1e9..d884e23 100644 --- a/net/llc/llc_input.c +++ b/net/llc/llc_input.c @@ -143,13 +143,13 @@ static inline int llc_fixup_skb(struct sk_buff *skb) * data now), it queues this frame in the connection's backlog. */ int llc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct llc_sap *sap; struct llc_pdu_sn *pdu; int dest; int (*rcv)(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); if (!net_eq(dev_net(dev), &init_net)) goto drop; @@ -184,14 +184,14 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev, dest = llc_pdu_type(skb); if (unlikely(!dest || !llc_type_handlers[dest - 1])) { if (rcv) - rcv(skb, dev, pt, orig_dev); + rcv(skb, dev, pt); else kfree_skb(skb); } else { if (rcv) { struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC); if (cskb) - rcv(cskb, dev, pt, orig_dev); + rcv(cskb, dev, pt); } llc_type_handlers[dest - 1](sap, skb); } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index b34294e..85e2493 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -350,7 +350,7 @@ static const struct proto_ops packet_ops; static const struct proto_ops packet_ops_spkt; static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct sockaddr_pkt *spkt; @@ -557,7 +557,7 @@ static inline unsigned int run_filter(const struct sk_buff *skb, */ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct sockaddr_ll *sll; @@ -667,7 +667,7 @@ drop: } static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct packet_sock *po; diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 30cc676..2fb5bf2 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -372,8 +372,7 @@ static int send_reset_indications(struct sk_buff *rskb) * On error, returns non-zero and releases the skb. */ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pkttype, - struct net_device *orig_dev) + struct packet_type *pkttype) { struct net *net = dev_net(dev); struct phonethdr *ph; diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index b69092e..21c8fe4 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c @@ -100,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, */ static int recv_msg(struct sk_buff *buf, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c index 9005f6d..4b049ec 100644 --- a/net/x25/x25_dev.c +++ b/net/x25/x25_dev.c @@ -92,7 +92,7 @@ static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb) } int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct sk_buff *nskb; struct x25_neigh *nb; -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers 2011-03-05 10:29 ` [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers Jiri Pirko @ 2011-03-05 15:05 ` Nicolas de Pesloüan 2011-03-05 15:15 ` Jiri Pirko 2011-03-05 15:32 ` [patch net-next-2.6 8/8 v2] " Jiri Pirko 1 sibling, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 15:05 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 11:29, Jiri Pirko a écrit : > Since orig_dev was used in af_packet (where it was replaced) and by > bonding ptype handlers (which are no longer with us) only, orig_dev > parameter is no longer needed -> toss it out > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> [snip] > - new->deliver_no_wcard = old->deliver_no_wcard; deliver_no_wcard was removed from sk_buff in your #7 patch. Shouldn't the above line be part of the #7 patch? Except from this point, Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers 2011-03-05 15:05 ` Nicolas de Pesloüan @ 2011-03-05 15:15 ` Jiri Pirko 0 siblings, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 15:15 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 04:05:16PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 11:29, Jiri Pirko a écrit : >>Since orig_dev was used in af_packet (where it was replaced) and by >>bonding ptype handlers (which are no longer with us) only, orig_dev >>parameter is no longer needed -> toss it out >> >>Signed-off-by: Jiri Pirko<jpirko@redhat.com> > >[snip] >>- new->deliver_no_wcard = old->deliver_no_wcard; > >deliver_no_wcard was removed from sk_buff in your #7 patch. Shouldn't >the above line be part of the #7 patch? Indeed, I wonder how if got here. Will repost to correct this. > >Except from this point, > >Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> > > Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 8/8 v2] net: get rid of orig_dev parameter of packet handlers 2011-03-05 10:29 ` [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers Jiri Pirko 2011-03-05 15:05 ` Nicolas de Pesloüan @ 2011-03-05 15:32 ` Jiri Pirko 2011-03-05 16:56 ` Nicolas de Pesloüan 1 sibling, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 15:32 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Since orig_dev was used in af_packet (where it was replaced) and by bonding ptype handlers (which are no longer with us) only, orig_dev parameter is no longer needed -> toss it out Signed-off-by: Jiri Pirko <jpirko@redhat.com> Reviewed-by: Nicolas de Pesloüan <nicolas.2p.debian@free.fr> v1->v2: moved __copy_skb_header hunk to 7/8 --- drivers/block/aoe/aoenet.c | 2 +- drivers/net/hamradio/bpqether.c | 4 ++-- drivers/net/pppoe.c | 4 ++-- drivers/net/wan/hdlc.c | 2 +- drivers/net/wan/lapbether.c | 2 +- drivers/scsi/fcoe/fcoe.c | 12 ++++-------- include/linux/netdevice.h | 3 +-- include/net/ax25.h | 3 ++- include/net/datalink.h | 2 +- include/net/ip.h | 2 +- include/net/ipv6.h | 3 +-- include/net/irda/irda.h | 3 +-- include/net/llc.h | 8 +++----- include/net/p8022.h | 3 +-- include/net/psnap.h | 3 +-- include/net/x25.h | 2 +- net/802/p8022.c | 3 +-- net/802/psnap.c | 7 +++---- net/802/stp.c | 2 +- net/8021q/vlan.h | 2 +- net/8021q/vlan_dev.c | 2 +- net/appletalk/aarp.c | 2 +- net/appletalk/ddp.c | 6 +++--- net/ax25/ax25_in.c | 2 +- net/batman-adv/hard-interface.c | 6 ++---- net/caif/caif_dev.c | 2 +- net/can/af_can.c | 2 +- net/core/dev.c | 26 ++++++++++++-------------- net/decnet/af_decnet.c | 2 +- net/decnet/dn_route.c | 2 +- net/dsa/tag_dsa.c | 2 +- net/dsa/tag_edsa.c | 2 +- net/dsa/tag_trailer.c | 2 +- net/econet/af_econet.c | 2 +- net/ieee802154/af_ieee802154.c | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipconfig.c | 13 ++++++++----- net/ipv6/ip6_input.c | 3 ++- net/ipx/af_ipx.c | 3 ++- net/irda/irlap_frame.c | 2 +- net/llc/llc_core.c | 3 +-- net/llc/llc_input.c | 8 ++++---- net/packet/af_packet.c | 6 +++--- net/phonet/af_phonet.c | 3 +-- net/tipc/eth_media.c | 2 +- net/x25/x25_dev.c | 2 +- 47 files changed, 85 insertions(+), 98 deletions(-) diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 4d3bc0d..c12e14b 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -99,7 +99,7 @@ aoenet_xmit(struct sk_buff_head *queue) * (1) len doesn't include the header by default. I want this. */ static int -aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev) +aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt) { struct aoe_hdr *h; u32 n; diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 8931168..f17ca33 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -95,7 +95,7 @@ static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; static char bpq_eth_addr[6]; -static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *); static int bpq_device_event(struct notifier_block *, unsigned long, void *); static struct packet_type bpq_packet_type __read_mostly = { @@ -177,7 +177,7 @@ static inline int dev_is_ethdev(struct net_device *dev) /* * Receive an AX.25 frame via an ethernet interface. */ -static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) +static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype) { int len; char * ptr; diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 78c0e3c..b99cdaa 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -419,7 +419,7 @@ abort_kfree: * ***********************************************************************/ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct pppoe_hdr *ph; struct pppox_sock *po; @@ -467,7 +467,7 @@ out: * ***********************************************************************/ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct pppoe_hdr *ph; diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 5d4bb61..0ac4f27 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -53,7 +53,7 @@ int hdlc_change_mtu(struct net_device *dev, int new_mtu) } static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *p, struct net_device *orig_dev) + struct packet_type *p) { struct hdlc_device *hdlc = dev_to_hdlc(dev); diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index 7f5bb91..993d71a 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -86,7 +86,7 @@ static __inline__ int dev_is_ethdev(struct net_device *dev) /* * Receive a LAPB frame via an ethernet interface. */ -static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype, struct net_device *orig_dev) +static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *ptype) { int len, err; struct lapbethdev *lapbeth; diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 3becc6a..d7442b6 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -70,7 +70,7 @@ DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu); static int fcoe_reset(struct Scsi_Host *); static int fcoe_xmit(struct fc_lport *, struct fc_frame *); static int fcoe_rcv(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); static int fcoe_percpu_receive_thread(void *); static void fcoe_clean_pending_queue(struct fc_lport *); static void fcoe_percpu_clean(struct fc_lport *); @@ -88,7 +88,7 @@ static struct fcoe_interface *fcoe_hostlist_lookup_port(const struct net_device *); static int fcoe_fip_recv(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *); static void fcoe_update_src_mac(struct fc_lport *, u8 *); @@ -465,14 +465,11 @@ static inline void fcoe_interface_put(struct fcoe_interface *fcoe) * @skb: The receive skb * @netdev: The associated net device * @ptype: The packet_type structure which was used to register this handler - * @orig_dev: The original net_device the the skb was received on. - * (in case dev is a bond) * * Returns: 0 for success */ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, - struct packet_type *ptype, - struct net_device *orig_dev) + struct packet_type *ptype) { struct fcoe_interface *fcoe; @@ -1228,7 +1225,6 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, * @skb: The received packet * @netdev: The net device that the packet was received on * @ptype: The packet type context - * @olddev: The last device net device * * This routine is called by NET_RX_SOFTIRQ. It receives a packet, builds a * FC frame and passes the frame to libfc. @@ -1236,7 +1232,7 @@ static int fcoe_cpu_callback(struct notifier_block *nfb, * Returns: 0 for success */ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, - struct packet_type *ptype, struct net_device *olddev) + struct packet_type *ptype) { struct fc_lport *lport; struct fcoe_rcv_info *fr; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ff386a4..48a9638 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1456,8 +1456,7 @@ struct packet_type { struct net_device *dev; /* NULL is wildcarded here */ int (*func) (struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *); + struct packet_type *); struct sk_buff *(*gso_segment)(struct sk_buff *skb, u32 features); int (*gso_send_check)(struct sk_buff *skb); diff --git a/include/net/ax25.h b/include/net/ax25.h index 206d222..fcbe6d8 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h @@ -362,7 +362,8 @@ extern int ax25_protocol_is_registered(unsigned int); /* ax25_in.c */ extern int ax25_rx_iframe(ax25_cb *, struct sk_buff *); -extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, + struct packet_type *); /* ax25_ip.c */ extern int ax25_hard_header(struct sk_buff *, struct net_device *, diff --git a/include/net/datalink.h b/include/net/datalink.h index deb7ca7..5797ba3 100644 --- a/include/net/datalink.h +++ b/include/net/datalink.h @@ -9,7 +9,7 @@ struct datalink_proto { unsigned short header_length; int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); int (*request)(struct datalink_proto *, struct sk_buff *, unsigned char *); struct list_head node; diff --git a/include/net/ip.h b/include/net/ip.h index a4f6311..3b04c24 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -94,7 +94,7 @@ extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, __be32 saddr, __be32 daddr, struct ip_options *opt); extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev); + struct packet_type *pt); extern int ip_local_deliver(struct sk_buff *skb); extern int ip_mr_input(struct sk_buff *skb); extern int ip_output(struct sk_buff *skb); diff --git a/include/net/ipv6.h b/include/net/ipv6.h index d6d077d..990f90b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -470,8 +470,7 @@ static __inline__ void ipv6_select_ident(struct frag_hdr *fhdr) extern int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev); + struct packet_type *pt); extern int ip6_rcv_finish(struct sk_buff *skb); diff --git a/include/net/irda/irda.h b/include/net/irda/irda.h index 3bed61d..2c6e25d 100644 --- a/include/net/irda/irda.h +++ b/include/net/irda/irda.h @@ -125,7 +125,6 @@ extern int irda_nl_register(void); extern void irda_nl_unregister(void); extern int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev); + struct packet_type *ptype); #endif /* NET_IRDA_H */ diff --git a/include/net/llc.h b/include/net/llc.h index 5503b74..73bfea5 100644 --- a/include/net/llc.h +++ b/include/net/llc.h @@ -58,8 +58,7 @@ struct llc_sap { atomic_t refcnt; int (*rcv_func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev); + struct packet_type *pt); struct llc_addr laddr; struct list_head node; spinlock_t sk_lock; @@ -96,7 +95,7 @@ extern struct list_head llc_sap_list; extern spinlock_t llc_sap_list_lock; extern int llc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev); + struct packet_type *pt); extern int llc_mac_hdr_init(struct sk_buff *skb, const unsigned char *sa, const unsigned char *da); @@ -110,8 +109,7 @@ extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb)); extern struct llc_sap *llc_sap_open(unsigned char lsap, int (*rcv)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)); + struct packet_type *pt)); static inline void llc_sap_hold(struct llc_sap *sap) { atomic_inc(&sap->refcnt); diff --git a/include/net/p8022.h b/include/net/p8022.h index 42e9fac..6d878ae 100644 --- a/include/net/p8022.h +++ b/include/net/p8022.h @@ -4,8 +4,7 @@ extern struct datalink_proto * register_8022_client(unsigned char type, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)); + struct packet_type *pt)); extern void unregister_8022_client(struct datalink_proto *proto); extern struct datalink_proto *make_8023_client(void); diff --git a/include/net/psnap.h b/include/net/psnap.h index fe456c2..604bf4b 100644 --- a/include/net/psnap.h +++ b/include/net/psnap.h @@ -4,8 +4,7 @@ extern struct datalink_proto * register_snap_client(const unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *orig_dev)); + struct packet_type *)); extern void unregister_snap_client(struct datalink_proto *proto); #endif diff --git a/include/net/x25.h b/include/net/x25.h index a06119a..3f1c0df2 100644 --- a/include/net/x25.h +++ b/include/net/x25.h @@ -202,7 +202,7 @@ extern void x25_kill_by_neigh(struct x25_neigh *); /* x25_dev.c */ extern void x25_send_frame(struct sk_buff *, struct x25_neigh *); -extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int x25_lapb_receive_frame(struct sk_buff *, struct net_device *, struct packet_type *); extern void x25_establish_link(struct x25_neigh *); extern void x25_terminate_link(struct x25_neigh *); diff --git a/net/802/p8022.c b/net/802/p8022.c index 7f353c4..4ab1339 100644 --- a/net/802/p8022.c +++ b/net/802/p8022.c @@ -36,8 +36,7 @@ static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb, struct datalink_proto *register_8022_client(unsigned char type, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)) + struct packet_type *pt)) { struct datalink_proto *proto; diff --git a/net/802/psnap.c b/net/802/psnap.c index 21cde8f..e74b48e 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c @@ -47,7 +47,7 @@ static struct datalink_proto *find_snap_client(const unsigned char *desc) * A SNAP packet has arrived */ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { int rc = 1; struct datalink_proto *proto; @@ -64,7 +64,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, /* Pass the frame on. */ skb->transport_header += 5; skb_pull_rcsum(skb, 5); - rc = proto->rcvfunc(skb, dev, &snap_packet_type, orig_dev); + rc = proto->rcvfunc(skb, dev, &snap_packet_type); } rcu_read_unlock(); @@ -126,8 +126,7 @@ module_exit(snap_exit); struct datalink_proto *register_snap_client(const unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, - struct packet_type *, - struct net_device *)) + struct packet_type *)) { struct datalink_proto *proto = NULL; diff --git a/net/802/stp.c b/net/802/stp.c index 978c30b..dec1f88 100644 --- a/net/802/stp.c +++ b/net/802/stp.c @@ -30,7 +30,7 @@ static DEFINE_MUTEX(stp_proto_mutex); /* Called under rcu_read_lock from LLC */ static int stp_pdu_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { const struct ethhdr *eh = eth_hdr(skb); const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 5687c9b..6f8941e 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -76,7 +76,7 @@ static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev) /* found in vlan_dev.c */ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev); + struct packet_type *ptype); void vlan_dev_set_ingress_priority(const struct net_device *dev, u32 skb_prio, u16 vlan_prio); int vlan_dev_set_egress_priority(const struct net_device *dev, diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index be73753..6e396b9 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -138,7 +138,7 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb, * */ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct vlan_hdr *vhdr; struct vlan_pcpu_stats *rx_stats; diff --git a/net/appletalk/aarp.c b/net/appletalk/aarp.c index 50dce79..996f366 100644 --- a/net/appletalk/aarp.c +++ b/net/appletalk/aarp.c @@ -715,7 +715,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a, * frame. We currently only support Ethernet. */ static int aarp_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct elapaarp *ea = aarp_hdr(skb); int hash, ret = 0; diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index c410b93..61b4983 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1425,7 +1425,7 @@ drop: * layer. [ie ARPHRD_ETHERTALK] */ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct ddpehdr *ddp; struct sock *sock; @@ -1522,7 +1522,7 @@ out: * header and append a long one. */ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { if (!net_eq(dev_net(dev), &init_net)) goto freeit; @@ -1568,7 +1568,7 @@ static int ltalk_rcv(struct sk_buff *skb, struct net_device *dev, } skb_reset_transport_header(skb); - return atalk_rcv(skb, dev, pt, orig_dev); + return atalk_rcv(skb, dev, pt); freeit: kfree_skb(skb); return 0; diff --git a/net/ax25/ax25_in.c b/net/ax25/ax25_in.c index 9bb7765..f6f94e6 100644 --- a/net/ax25/ax25_in.c +++ b/net/ax25/ax25_in.c @@ -436,7 +436,7 @@ free: * Receive an AX.25 frame via a SLIP interface. */ int ax25_kiss_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { skb_orphan(skb); diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index f2131f4..08579b0 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -37,8 +37,7 @@ static DEFINE_SPINLOCK(if_list_lock); static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev); + struct packet_type *ptype); static void hardif_free_rcu(struct rcu_head *rcu) { @@ -556,8 +555,7 @@ out: /* receive a packet with the batman ethertype coming on a hard * interface */ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, - struct net_device *orig_dev) + struct packet_type *ptype) { struct bat_priv *bat_priv; struct batman_packet *batman_packet; diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index a42a408..9f016f0 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -165,7 +165,7 @@ static int modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) * On error, returns non-zero and releases the skb. */ static int receive(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pkttype, struct net_device *orig_dev) + struct packet_type *pkttype) { struct net *net; struct cfpkt *pkt; diff --git a/net/can/af_can.c b/net/can/af_can.c index 702be5a..ad32de5 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c @@ -616,7 +616,7 @@ static int can_rcv_filter(struct dev_rcv_lists *d, struct sk_buff *skb) } static int can_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dev_rcv_lists *d; struct can_frame *cf = (struct can_frame *)skb->data; diff --git a/net/core/dev.c b/net/core/dev.c index 58daddb..c71bd18 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1534,11 +1534,10 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) EXPORT_SYMBOL_GPL(dev_forward_skb); static inline int deliver_skb(struct sk_buff *skb, - struct packet_type *pt_prev, - struct net_device *orig_dev) + struct packet_type *pt_prev) { atomic_inc(&skb->users); - return pt_prev->func(skb, skb->dev, pt_prev, orig_dev); + return pt_prev->func(skb, skb->dev, pt_prev); } /* @@ -1561,7 +1560,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) (ptype->af_packet_priv == NULL || (struct sock *)ptype->af_packet_priv != skb->sk)) { if (pt_prev) { - deliver_skb(skb2, pt_prev, skb->dev); + deliver_skb(skb2, pt_prev); pt_prev = ptype; continue; } @@ -1594,7 +1593,7 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) } } if (pt_prev) - pt_prev->func(skb2, skb->dev, pt_prev, skb->dev); + pt_prev->func(skb2, skb->dev, pt_prev); rcu_read_unlock(); } @@ -3025,8 +3024,7 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq) } static inline struct sk_buff *handle_ing(struct sk_buff *skb, - struct packet_type **pt_prev, - int *ret, struct net_device *orig_dev) + struct packet_type **pt_prev, int *ret) { struct netdev_queue *rxq = rcu_dereference(skb->dev->ingress_queue); @@ -3034,7 +3032,7 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb, goto out; if (*pt_prev) { - *ret = deliver_skb(skb, *pt_prev, orig_dev); + *ret = deliver_skb(skb, *pt_prev); *pt_prev = NULL; } @@ -3160,13 +3158,13 @@ another_round: list_for_each_entry_rcu(ptype, &ptype_all, list) { if (!ptype->dev || ptype->dev == skb->dev) { if (pt_prev) - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = ptype; } } #ifdef CONFIG_NET_CLS_ACT - skb = handle_ing(skb, &pt_prev, &ret, orig_dev); + skb = handle_ing(skb, &pt_prev, &ret); if (!skb) goto out; ncls: @@ -3175,7 +3173,7 @@ ncls: rx_handler = rcu_dereference(skb->dev->rx_handler); if (rx_handler) { if (pt_prev) { - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = NULL; } switch (rx_handler(&skb)) { @@ -3194,7 +3192,7 @@ ncls: if (vlan_tx_tag_present(skb)) { if (pt_prev) { - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = NULL; } if (vlan_hwaccel_do_receive(&skb)) { @@ -3216,13 +3214,13 @@ ncls: (ptype->dev == null_or_dev || ptype->dev == skb->dev || ptype->dev == orig_dev)) { if (pt_prev) - ret = deliver_skb(skb, pt_prev, orig_dev); + ret = deliver_skb(skb, pt_prev); pt_prev = ptype; } } if (pt_prev) { - ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); + ret = pt_prev->func(skb, skb->dev, pt_prev); } else { atomic_long_inc(&skb->dev->rx_dropped); kfree_skb(skb); diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 2af15b1..1421721 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -2106,7 +2106,7 @@ static struct notifier_block dn_dev_notifier = { .notifier_call = dn_device_event, }; -extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); +extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *); static struct packet_type dn_dix_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_DNA_RT), diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 484fdbf..20abc79 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -588,7 +588,7 @@ static int dn_route_ptp_hello(struct sk_buff *skb) return NET_RX_SUCCESS; } -int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int dn_route_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct dn_skb_cb *cb; unsigned char flags = 0; diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 98dfe80..56b686e 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -77,7 +77,7 @@ out_free: } static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 6f38332..474a955 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c @@ -90,7 +90,7 @@ out_free: } static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index d6d7d0a..f8f36ad 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -67,7 +67,7 @@ netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev) } static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_switch *ds; diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 0c28263..edeea09 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -1052,7 +1052,7 @@ release: * Receive an Econet frame from a device. */ -static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int econet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct ec_framehdr *hdr; struct sock *sk = NULL; diff --git a/net/ieee802154/af_ieee802154.c b/net/ieee802154/af_ieee802154.c index 6df6ecf..68d5bce 100644 --- a/net/ieee802154/af_ieee802154.c +++ b/net/ieee802154/af_ieee802154.c @@ -299,7 +299,7 @@ static const struct net_proto_family ieee802154_family_ops = { }; static int ieee802154_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { if (!netif_running(dev)) return -ENODEV; diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index fa9988d..53a8f14 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -974,7 +974,7 @@ static void parp_redo(struct sk_buff *skb) */ static int arp_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct arphdr *arp; diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index d7b2b09..639b69b 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -372,7 +372,7 @@ drop: /* * Main IP Receive routine. */ -int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { struct iphdr *iph; u32 len; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 2b09775..5669509 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -438,7 +438,8 @@ static int __init ic_defaults(void) #ifdef IPCONFIG_RARP -static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); +static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt); static struct packet_type rarp_packet_type __initdata = { .type = cpu_to_be16(ETH_P_RARP), @@ -458,8 +459,8 @@ static inline void __init ic_rarp_cleanup(void) /* * Process received RARP packet. */ -static int __init -ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int __init ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct arphdr *rarp; unsigned char *rarp_ptr; @@ -600,7 +601,8 @@ struct bootp_pkt { /* BOOTP packet format */ #define DHCPRELEASE 7 #define DHCPINFORM 8 -static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); +static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev + struct packet_type *pt); static struct packet_type bootp_packet_type __initdata = { .type = cpu_to_be16(ETH_P_IP), @@ -893,7 +895,8 @@ static void __init ic_do_bootp_ext(u8 *ext) /* * Receive BOOTP reply. */ -static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct bootp_pkt *b; struct iphdr *h; diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index a83e920..dd72591 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c @@ -55,7 +55,8 @@ inline int ip6_rcv_finish( struct sk_buff *skb) return dst_input(skb); } -int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { struct ipv6hdr *hdr; u32 pkt_len; diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index da3d21c..614e207 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1665,7 +1665,8 @@ static unsigned int ipx_datagram_poll(struct file *file, struct socket *sock, return rc; } -static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static int ipx_rcv(struct sk_buff *skb, struct net_device *dev, + struct packet_type *pt) { /* NULL here for pt means the packet was looped back */ struct ipx_interface *intrfc; diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c index 688222c..7850321 100644 --- a/net/irda/irlap_frame.c +++ b/net/irda/irlap_frame.c @@ -1306,7 +1306,7 @@ static void irlap_recv_test_frame(struct irlap_cb *self, struct sk_buff *skb, * Jean II */ int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct irlap_info info; struct irlap_cb *self; diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index 2bb0ddf..dfeda38 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c @@ -91,8 +91,7 @@ struct llc_sap *llc_sap_find(unsigned char sap_value) struct llc_sap *llc_sap_open(unsigned char lsap, int (*func)(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, - struct net_device *orig_dev)) + struct packet_type *pt)) { struct llc_sap *sap = NULL; diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c index 058f1e9..d884e23 100644 --- a/net/llc/llc_input.c +++ b/net/llc/llc_input.c @@ -143,13 +143,13 @@ static inline int llc_fixup_skb(struct sk_buff *skb) * data now), it queues this frame in the connection's backlog. */ int llc_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct llc_sap *sap; struct llc_pdu_sn *pdu; int dest; int (*rcv)(struct sk_buff *, struct net_device *, - struct packet_type *, struct net_device *); + struct packet_type *); if (!net_eq(dev_net(dev), &init_net)) goto drop; @@ -184,14 +184,14 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev, dest = llc_pdu_type(skb); if (unlikely(!dest || !llc_type_handlers[dest - 1])) { if (rcv) - rcv(skb, dev, pt, orig_dev); + rcv(skb, dev, pt); else kfree_skb(skb); } else { if (rcv) { struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC); if (cskb) - rcv(cskb, dev, pt, orig_dev); + rcv(cskb, dev, pt); } llc_type_handlers[dest - 1](sap, skb); } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index b34294e..85e2493 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -350,7 +350,7 @@ static const struct proto_ops packet_ops; static const struct proto_ops packet_ops_spkt; static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct sockaddr_pkt *spkt; @@ -557,7 +557,7 @@ static inline unsigned int run_filter(const struct sk_buff *skb, */ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct sockaddr_ll *sll; @@ -667,7 +667,7 @@ drop: } static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct sock *sk; struct packet_sock *po; diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 30cc676..2fb5bf2 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -372,8 +372,7 @@ static int send_reset_indications(struct sk_buff *rskb) * On error, returns non-zero and releases the skb. */ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev, - struct packet_type *pkttype, - struct net_device *orig_dev) + struct packet_type *pkttype) { struct net *net = dev_net(dev); struct phonethdr *ph; diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index b69092e..21c8fe4 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c @@ -100,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, */ static int recv_msg(struct sk_buff *buf, struct net_device *dev, - struct packet_type *pt, struct net_device *orig_dev) + struct packet_type *pt) { struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c index 9005f6d..4b049ec 100644 --- a/net/x25/x25_dev.c +++ b/net/x25/x25_dev.c @@ -92,7 +92,7 @@ static int x25_receive_data(struct sk_buff *skb, struct x25_neigh *nb) } int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev, - struct packet_type *ptype, struct net_device *orig_dev) + struct packet_type *ptype) { struct sk_buff *nskb; struct x25_neigh *nb; -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 8/8 v2] net: get rid of orig_dev parameter of packet handlers 2011-03-05 15:32 ` [patch net-next-2.6 8/8 v2] " Jiri Pirko @ 2011-03-05 16:56 ` Nicolas de Pesloüan 2011-03-05 22:07 ` Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 16:56 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 16:32, Jiri Pirko a écrit : > Since orig_dev was used in af_packet (where it was replaced) and by > bonding ptype handlers (which are no longer with us) only, orig_dev > parameter is no longer needed -> toss it out > > Signed-off-by: Jiri Pirko<jpirko@redhat.com> > Reviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr> > [snip] > diff --git a/net/core/dev.c b/net/core/dev.c > index 58daddb..c71bd18 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c [snip] > @@ -3216,13 +3214,13 @@ ncls: > (ptype->dev == null_or_dev || ptype->dev == skb->dev || > ptype->dev == orig_dev)) { > if (pt_prev) > - ret = deliver_skb(skb, pt_prev, orig_dev); > + ret = deliver_skb(skb, pt_prev); > pt_prev = ptype; > } > } > > if (pt_prev) { > - ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); > + ret = pt_prev->func(skb, skb->dev, pt_prev); > } else { > atomic_long_inc(&skb->dev->rx_dropped); > kfree_skb(skb); This part does not properly apply on top of current net-next-2.6. Line 3216 is currently (ptype->dev == null_or_dev || ptype->dev == skb->dev)) { Nicolas. ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 8/8 v2] net: get rid of orig_dev parameter of packet handlers 2011-03-05 16:56 ` Nicolas de Pesloüan @ 2011-03-05 22:07 ` Jiri Pirko 2011-03-05 22:18 ` Nicolas de Pesloüan 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 22:07 UTC (permalink / raw) To: Nicolas de Pesloüan Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Sat, Mar 05, 2011 at 05:56:24PM CET, nicolas.2p.debian@gmail.com wrote: >Le 05/03/2011 16:32, Jiri Pirko a écrit : >>Since orig_dev was used in af_packet (where it was replaced) and by >>bonding ptype handlers (which are no longer with us) only, orig_dev >>parameter is no longer needed -> toss it out >> >>Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>Reviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr> >> >[snip] > >>diff --git a/net/core/dev.c b/net/core/dev.c >>index 58daddb..c71bd18 100644 >>--- a/net/core/dev.c >>+++ b/net/core/dev.c >[snip] >>@@ -3216,13 +3214,13 @@ ncls: >> (ptype->dev == null_or_dev || ptype->dev == skb->dev || >> ptype->dev == orig_dev)) { >> if (pt_prev) >>- ret = deliver_skb(skb, pt_prev, orig_dev); >>+ ret = deliver_skb(skb, pt_prev); >> pt_prev = ptype; >> } >> } >> >> if (pt_prev) { >>- ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); >>+ ret = pt_prev->func(skb, skb->dev, pt_prev); >> } else { >> atomic_long_inc(&skb->dev->rx_dropped); >> kfree_skb(skb); > >This part does not properly apply on top of current net-next-2.6. > >Line 3216 is currently > > (ptype->dev == null_or_dev || ptype->dev == skb->dev)) { > > Nicolas. depends on "net: allow handlers to be processed for orig_dev" which is a regression fixer ^ permalink raw reply [flat|nested] 74+ messages in thread
* Re: [patch net-next-2.6 8/8 v2] net: get rid of orig_dev parameter of packet handlers 2011-03-05 22:07 ` Jiri Pirko @ 2011-03-05 22:18 ` Nicolas de Pesloüan 0 siblings, 0 replies; 74+ messages in thread From: Nicolas de Pesloüan @ 2011-03-05 22:18 UTC (permalink / raw) To: Jiri Pirko; +Cc: netdev, davem, shemminger, kaber, fubar, eric.dumazet, andy Le 05/03/2011 23:07, Jiri Pirko a écrit : > Sat, Mar 05, 2011 at 05:56:24PM CET, nicolas.2p.debian@gmail.com wrote: >> Le 05/03/2011 16:32, Jiri Pirko a écrit : >>> Since orig_dev was used in af_packet (where it was replaced) and by >>> bonding ptype handlers (which are no longer with us) only, orig_dev >>> parameter is no longer needed -> toss it out >>> >>> Signed-off-by: Jiri Pirko<jpirko@redhat.com> >>> Reviewed-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr> >>> >> [snip] >> >>> diff --git a/net/core/dev.c b/net/core/dev.c >>> index 58daddb..c71bd18 100644 >>> --- a/net/core/dev.c >>> +++ b/net/core/dev.c >> [snip] >>> @@ -3216,13 +3214,13 @@ ncls: >>> (ptype->dev == null_or_dev || ptype->dev == skb->dev || >>> ptype->dev == orig_dev)) { >>> if (pt_prev) >>> - ret = deliver_skb(skb, pt_prev, orig_dev); >>> + ret = deliver_skb(skb, pt_prev); >>> pt_prev = ptype; >>> } >>> } >>> >>> if (pt_prev) { >>> - ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev); >>> + ret = pt_prev->func(skb, skb->dev, pt_prev); >>> } else { >>> atomic_long_inc(&skb->dev->rx_dropped); >>> kfree_skb(skb); >> >> This part does not properly apply on top of current net-next-2.6. >> >> Line 3216 is currently >> >> (ptype->dev == null_or_dev || ptype->dev == skb->dev)) { >> >> Nicolas. > > > depends on "net: allow handlers to be processed for orig_dev" which is a > regression fixer > You are right. I reviewed this patch. :-) ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 0/8] mostly bonding rx path changes @ 2011-03-05 8:29 Jiri Pirko 2011-03-05 8:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() Jiri Pirko 0 siblings, 1 reply; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 8:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy This patchset focuses mainly bonding rx path changes. Depends on "fcoe: correct checking for bonding" Jiri Pirko (8): af_packet: use skb->skb_iif instead of orig_dev->ifindex bonding: register slave pointer for rx_handler net: get rid of multiple bond-related netdevice->priv_flags bonding: wrap slave state work bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag bonding: move processing of recv handlers into handle_frame() net: introduce rx_handler results and logic around that net: get rid of orig_dev parameter of packet handlers drivers/block/aoe/aoenet.c | 2 +- drivers/net/bonding/bond_3ad.c | 31 +----- drivers/net/bonding/bond_3ad.h | 4 +- drivers/net/bonding/bond_alb.c | 46 ++------ drivers/net/bonding/bond_alb.h | 1 - drivers/net/bonding/bond_main.c | 217 ++++++++++++------------------------- drivers/net/bonding/bond_sysfs.c | 20 +--- drivers/net/bonding/bonding.h | 64 ++++++----- drivers/net/hamradio/bpqether.c | 4 +- drivers/net/macvlan.c | 11 +- drivers/net/pppoe.c | 4 +- drivers/net/wan/hdlc.c | 2 +- drivers/net/wan/lapbether.c | 2 +- drivers/scsi/fcoe/fcoe.c | 12 +-- include/linux/if.h | 23 ++--- include/linux/netdevice.h | 12 ++- include/linux/skbuff.h | 5 +- include/net/ax25.h | 3 +- include/net/datalink.h | 2 +- include/net/ip.h | 2 +- include/net/ipv6.h | 3 +- include/net/irda/irda.h | 3 +- include/net/llc.h | 8 +- include/net/p8022.h | 3 +- include/net/psnap.h | 3 +- include/net/x25.h | 2 +- net/802/p8022.c | 3 +- net/802/psnap.c | 7 +- net/802/stp.c | 2 +- net/8021q/vlan.h | 2 +- net/8021q/vlan_dev.c | 2 +- net/appletalk/aarp.c | 2 +- net/appletalk/ddp.c | 6 +- net/ax25/ax25_in.c | 2 +- net/batman-adv/hard-interface.c | 6 +- net/bridge/br_input.c | 25 +++-- net/bridge/br_private.h | 2 +- net/caif/caif_dev.c | 2 +- net/can/af_can.c | 2 +- net/core/dev.c | 45 ++++---- net/core/skbuff.c | 1 - net/decnet/af_decnet.c | 2 +- net/decnet/dn_route.c | 2 +- net/dsa/tag_dsa.c | 2 +- net/dsa/tag_edsa.c | 2 +- net/dsa/tag_trailer.c | 2 +- net/econet/af_econet.c | 2 +- net/ieee802154/af_ieee802154.c | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipconfig.c | 13 ++- net/ipv6/ip6_input.c | 3 +- net/ipx/af_ipx.c | 3 +- net/irda/irlap_frame.c | 2 +- net/llc/llc_core.c | 3 +- net/llc/llc_input.c | 8 +- net/packet/af_packet.c | 10 +- net/phonet/af_phonet.c | 3 +- net/tipc/eth_media.c | 2 +- net/x25/x25_dev.c | 2 +- 60 files changed, 268 insertions(+), 397 deletions(-) -- 1.7.4 ^ permalink raw reply [flat|nested] 74+ messages in thread
* [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 2011-03-05 8:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko @ 2011-03-05 8:29 ` Jiri Pirko 0 siblings, 0 replies; 74+ messages in thread From: Jiri Pirko @ 2011-03-05 8:29 UTC (permalink / raw) To: netdev Cc: davem, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian, andy Signed-off-by: Jiri Pirko <jpirko@redhat.com> --- drivers/net/bonding/bond_3ad.c | 29 ++-------- drivers/net/bonding/bond_3ad.h | 4 +- drivers/net/bonding/bond_alb.c | 46 ++++----------- drivers/net/bonding/bond_alb.h | 1 - drivers/net/bonding/bond_main.c | 121 +++++++------------------------------ drivers/net/bonding/bond_sysfs.c | 6 -- drivers/net/bonding/bonding.h | 4 +- 7 files changed, 43 insertions(+), 168 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 047af0b..194aaf7 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -2461,35 +2461,16 @@ out: return NETDEV_TX_OK; } -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { - struct bonding *bond = netdev_priv(dev); - struct slave *slave = NULL; - int ret = NET_RX_DROP; - - if (!(dev->flags & IFF_MASTER)) - goto out; - - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out; + if (skb->protocol != PKT_TYPE_LACPDU) + return; if (!pskb_may_pull(skb, sizeof(struct lacpdu))) - goto out; + return; read_lock(&bond->lock); - slave = bond_get_slave_by_dev(netdev_priv(dev), orig_dev); - if (!slave) - goto out_unlock; - bond_3ad_rx_indication((struct lacpdu *) skb->data, slave, skb->len); - - ret = NET_RX_SUCCESS; - -out_unlock: read_unlock(&bond->lock); -out: - dev_kfree_skb(skb); - - return ret; } diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 2c46a154..56a88ff 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h @@ -258,7 +258,6 @@ struct ad_bond_info { * requested */ struct timer_list ad_timer; - struct packet_type ad_pkt_type; }; struct ad_slave_info { @@ -279,7 +278,8 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave); void bond_3ad_handle_link_change(struct slave *slave, char link); int bond_3ad_get_active_agg_info(struct bonding *bond, struct ad_info *ad_info); int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev); -int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev); +void bond_3ad_lacpdu_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave); int bond_3ad_set_carrier(struct bonding *bond); #endif //__BOND_3AD_H__ diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 9bc5de3..96d28f9 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -308,49 +308,33 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp) _unlock_rx_hashtbl(bond); } -static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct packet_type *ptype, struct net_device *orig_dev) +static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { - struct bonding *bond; - struct arp_pkt *arp = (struct arp_pkt *)skb->data; - int res = NET_RX_DROP; + struct arp_pkt *arp; - while (bond_dev->priv_flags & IFF_802_1Q_VLAN) - bond_dev = vlan_dev_real_dev(bond_dev); - - if (!(bond_dev->priv_flags & IFF_BONDING) || - !(bond_dev->flags & IFF_MASTER)) - goto out; + if (skb->protocol != cpu_to_be16(ETH_P_ARP)) + return; + arp = (struct arp_pkt *) skb->data; if (!arp) { pr_debug("Packet has no ARP data\n"); - goto out; + return; } - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out; - - if (!pskb_may_pull(skb, arp_hdr_len(bond_dev))) - goto out; + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) + return; if (skb->len < sizeof(struct arp_pkt)) { pr_debug("Packet is too small to be an ARP\n"); - goto out; + return; } if (arp->op_code == htons(ARPOP_REPLY)) { /* update rx hash table for this ARP */ - bond = netdev_priv(bond_dev); rlb_update_entry_from_arp(bond, arp); pr_debug("Server received an ARP Reply from client\n"); } - - res = NET_RX_SUCCESS; - -out: - dev_kfree_skb(skb); - - return res; } /* Caller must hold bond lock for read */ @@ -759,7 +743,6 @@ static void rlb_init_table_entry(struct rlb_client_info *entry) static int rlb_initialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); struct rlb_client_info *new_hashtbl; int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); int i; @@ -784,13 +767,8 @@ static int rlb_initialize(struct bonding *bond) _unlock_rx_hashtbl(bond); - /*initialize packet type*/ - pk_type->type = cpu_to_be16(ETH_P_ARP); - pk_type->dev = bond->dev; - pk_type->func = rlb_arp_recv; - /* register to receive ARPs */ - dev_add_pack(pk_type); + bond->recv_probe = rlb_arp_recv; return 0; } @@ -799,8 +777,6 @@ static void rlb_deinitialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); - dev_remove_pack(&(bond_info->rlb_pkt_type)); - _lock_rx_hashtbl(bond); kfree(bond_info->rx_hashtbl); diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index 118c28a..6605e9e 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h @@ -130,7 +130,6 @@ struct alb_bond_info { int lp_counter; /* -------- rlb parameters -------- */ int rlb_enabled; - struct packet_type rlb_pkt_type; struct rlb_client_info *rx_hashtbl; /* Receive hash table */ spinlock_t rx_hashtbl_lock; u32 rx_hashtbl_head; diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index dbe182c..8ba7faa 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1467,27 +1467,17 @@ static void bond_setup_by_slave(struct net_device *bond_dev, } /* On bonding slaves other than the currently active slave, suppress - * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and - * ARP on active-backup slaves with arp_validate enabled. + * duplicates except for alb non-mcast/bcast. */ static bool bond_should_deliver_exact_match(struct sk_buff *skb, struct slave *slave, struct bonding *bond) { if (bond_is_slave_inactive(slave)) { - if (slave_do_arp_validate(bond, slave) && - skb->protocol == __cpu_to_be16(ETH_P_ARP)) - return false; - if (bond->params.mode == BOND_MODE_ALB && skb->pkt_type != PACKET_BROADCAST && skb->pkt_type != PACKET_MULTICAST) - return false; - - if (bond->params.mode == BOND_MODE_8023AD && - skb->protocol == __cpu_to_be16(ETH_P_SLOW)) return false; - return true; } return false; @@ -1513,6 +1503,15 @@ static struct sk_buff *bond_handle_frame(struct sk_buff *skb) if (bond->params.arp_interval) slave->dev->last_rx = jiffies; + if (bond->recv_probe) { + struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); + + if (likely(nskb)) { + bond->recv_probe(nskb, bond, slave); + dev_kfree_skb(nskb); + } + } + if (bond_should_deliver_exact_match(skb, slave, bond)) { skb->deliver_no_wcard = 1; return skb; @@ -2813,48 +2812,26 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32 } } -static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) +static void bond_arp_rcv(struct sk_buff *skb, struct bonding *bond, + struct slave *slave) { struct arphdr *arp; - struct slave *slave; - struct bonding *bond; unsigned char *arp_ptr; __be32 sip, tip; - if (dev->priv_flags & IFF_802_1Q_VLAN) { - /* - * When using VLANS and bonding, dev and oriv_dev may be - * incorrect if the physical interface supports VLAN - * acceleration. With this change ARP validation now - * works for hosts only reachable on the VLAN interface. - */ - dev = vlan_dev_real_dev(dev); - orig_dev = dev_get_by_index_rcu(dev_net(skb->dev),skb->skb_iif); - } - - if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER)) - goto out; + if (skb->protocol != __cpu_to_be16(ETH_P_ARP)) + return; - bond = netdev_priv(dev); read_lock(&bond->lock); - pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n", - bond->dev->name, skb->dev ? skb->dev->name : "NULL", - orig_dev ? orig_dev->name : "NULL"); + pr_debug("bond_arp_rcv: bond %s skb->dev %s\n", + bond->dev->name, skb->dev->name); - slave = bond_get_slave_by_dev(bond, orig_dev); - if (!slave || !slave_do_arp_validate(bond, slave)) - goto out_unlock; - - skb = skb_share_check(skb, GFP_ATOMIC); - if (!skb) - goto out_unlock; - - if (!pskb_may_pull(skb, arp_hdr_len(dev))) + if (!pskb_may_pull(skb, arp_hdr_len(bond->dev))) goto out_unlock; arp = arp_hdr(skb); - if (arp->ar_hln != dev->addr_len || + if (arp->ar_hln != bond->dev->addr_len || skb->pkt_type == PACKET_OTHERHOST || skb->pkt_type == PACKET_LOOPBACK || arp->ar_hrd != htons(ARPHRD_ETHER) || @@ -2863,9 +2840,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack goto out_unlock; arp_ptr = (unsigned char *)(arp + 1); - arp_ptr += dev->addr_len; + arp_ptr += bond->dev->addr_len; memcpy(&sip, arp_ptr, 4); - arp_ptr += 4 + dev->addr_len; + arp_ptr += 4 + bond->dev->addr_len; memcpy(&tip, arp_ptr, 4); pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n", @@ -2888,9 +2865,6 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack out_unlock: read_unlock(&bond->lock); -out: - dev_kfree_skb(skb); - return NET_RX_SUCCESS; } /* @@ -3782,48 +3756,6 @@ static struct notifier_block bond_inetaddr_notifier = { .notifier_call = bond_inetaddr_event, }; -/*-------------------------- Packet type handling ---------------------------*/ - -/* register to receive lacpdus on a bond */ -static void bond_register_lacpdu(struct bonding *bond) -{ - struct packet_type *pk_type = &(BOND_AD_INFO(bond).ad_pkt_type); - - /* initialize packet type */ - pk_type->type = PKT_TYPE_LACPDU; - pk_type->dev = bond->dev; - pk_type->func = bond_3ad_lacpdu_recv; - - dev_add_pack(pk_type); -} - -/* unregister to receive lacpdus on a bond */ -static void bond_unregister_lacpdu(struct bonding *bond) -{ - dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); -} - -void bond_register_arp(struct bonding *bond) -{ - struct packet_type *pt = &bond->arp_mon_pt; - - if (pt->type) - return; - - pt->type = htons(ETH_P_ARP); - pt->dev = bond->dev; - pt->func = bond_arp_rcv; - dev_add_pack(pt); -} - -void bond_unregister_arp(struct bonding *bond) -{ - struct packet_type *pt = &bond->arp_mon_pt; - - dev_remove_pack(pt); - pt->type = 0; -} - /*---------------------------- Hashing Policies -----------------------------*/ /* @@ -3917,14 +3849,14 @@ static int bond_open(struct net_device *bond_dev) queue_delayed_work(bond->wq, &bond->arp_work, 0); if (bond->params.arp_validate) - bond_register_arp(bond); + bond->recv_probe = bond_arp_rcv; } if (bond->params.mode == BOND_MODE_8023AD) { INIT_DELAYED_WORK(&bond->ad_work, bond_3ad_state_machine_handler); queue_delayed_work(bond->wq, &bond->ad_work, 0); /* register to receive LACPDUs */ - bond_register_lacpdu(bond); + bond->recv_probe = bond_3ad_lacpdu_recv; bond_3ad_initiate_agg_selection(bond, 1); } @@ -3935,14 +3867,6 @@ static int bond_close(struct net_device *bond_dev) { struct bonding *bond = netdev_priv(bond_dev); - if (bond->params.mode == BOND_MODE_8023AD) { - /* Unregister the receive of LACPDUs */ - bond_unregister_lacpdu(bond); - } - - if (bond->params.arp_validate) - bond_unregister_arp(bond); - write_lock_bh(&bond->lock); bond->send_grat_arp = 0; @@ -3982,6 +3906,7 @@ static int bond_close(struct net_device *bond_dev) */ bond_alb_deinitialize(bond); } + bond->recv_probe = NULL; return 0; } diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5161183..6804efe 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -419,11 +419,6 @@ static ssize_t bonding_store_arp_validate(struct device *d, bond->dev->name, arp_validate_tbl[new_value].modename, new_value); - if (!bond->params.arp_validate && new_value) - bond_register_arp(bond); - else if (bond->params.arp_validate && !new_value) - bond_unregister_arp(bond); - bond->params.arp_validate = new_value; return count; @@ -998,7 +993,6 @@ static ssize_t bonding_store_miimon(struct device *d, bond->dev->name); bond->params.arp_interval = 0; if (bond->params.arp_validate) { - bond_unregister_arp(bond); bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; } diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 8f78166..75a1308 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -228,6 +228,8 @@ struct bonding { struct slave *primary_slave; bool force_primary; s32 slave_cnt; /* never change this value outside the attach/detach wrappers */ + void (*recv_probe)(struct sk_buff *, struct bonding *, + struct slave *); rwlock_t lock; rwlock_t curr_slave_lock; s8 kill_timers; @@ -406,8 +408,6 @@ void bond_set_mode_ops(struct bonding *bond, int mode); int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); void bond_select_active_slave(struct bonding *bond); void bond_change_active_slave(struct bonding *bond, struct slave *new_active); -void bond_register_arp(struct bonding *); -void bond_unregister_arp(struct bonding *); void bond_create_debugfs(void); void bond_destroy_debugfs(void); void bond_debug_register(struct bonding *bond); -- 1.7.4 ^ permalink raw reply related [flat|nested] 74+ messages in thread
end of thread, other threads:[~2011-03-10 21:05 UTC | newest] Thread overview: 74+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-03-05 10:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 1/8] af_packet: use skb->skb_iif instead of orig_dev->ifindex Jiri Pirko 2011-03-05 14:03 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 2/8] bonding: register slave pointer for rx_handler Jiri Pirko 2011-03-05 14:06 ` Nicolas de Pesloüan 2011-03-05 14:27 ` Jiri Pirko 2011-03-05 14:38 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 3/8] net: get rid of multiple bond-related netdevice->priv_flags Jiri Pirko 2011-03-05 14:14 ` Nicolas de Pesloüan 2011-03-05 14:37 ` Ben Hutchings 2011-03-05 14:46 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 4/8] bonding: wrap slave state work Jiri Pirko 2011-03-05 15:21 ` Nicolas de Pesloüan 2011-03-07 9:58 ` Jiri Pirko 2011-03-07 19:55 ` Nicolas de Pesloüan 2011-03-08 7:18 ` Jiri Pirko 2011-03-08 21:23 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 5/8] bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag Jiri Pirko 2011-03-05 14:18 ` Nicolas de Pesloüan 2011-03-05 10:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() Jiri Pirko 2011-03-05 14:33 ` Nicolas de Pesloüan 2011-03-05 14:43 ` Jiri Pirko 2011-03-05 14:50 ` Nicolas de Pesloüan 2011-03-06 12:24 ` Nicolas de Pesloüan 2011-03-06 13:34 ` Jiri Pirko 2011-03-06 14:25 ` Nicolas de Pesloüan 2011-03-06 16:32 ` Michał Mirosław 2011-03-06 17:37 ` Nicolas de Pesloüan 2011-03-07 12:51 ` [patch net-next-2.6] net: reinject arps into bonding slave instead of master Jiri Pirko 2011-03-07 14:32 ` Andy Gospodarek 2011-03-07 20:12 ` Nicolas de Pesloüan 2011-03-07 21:19 ` Jiri Pirko 2011-03-07 21:30 ` Nicolas de Pesloüan 2011-03-07 22:43 ` Andy Gospodarek 2011-03-07 23:09 ` Nicolas de Pesloüan 2011-03-08 2:43 ` Andy Gospodarek 2011-03-08 21:34 ` Nicolas de Pesloüan 2011-03-08 7:13 ` Jiri Pirko 2011-03-08 13:42 ` Andy Gospodarek 2011-03-08 21:44 ` Nicolas de Pesloüan 2011-03-09 7:45 ` Jiri Pirko 2011-03-09 14:49 ` Nicolas de Pesloüan 2011-03-09 15:09 ` Jiri Pirko 2011-03-09 15:28 ` Nicolas de Pesloüan 2011-03-09 17:11 ` Jiri Pirko 2011-03-09 22:18 ` Nicolas de Pesloüan 2011-03-10 6:48 ` Jiri Pirko 2011-03-10 20:44 ` Nicolas de Pesloüan 2011-03-10 20:52 ` Jiri Pirko 2011-03-10 21:05 ` Jiri Pirko 2011-03-09 20:51 ` Jiri Pirko 2011-03-09 13:33 ` Neil Horman 2011-03-05 10:29 ` [patch net-next-2.6 7/8] net: introduce rx_handler results and logic around that Jiri Pirko 2011-03-05 12:48 ` Ben Hutchings 2011-03-05 14:52 ` Nicolas de Pesloüan 2011-03-05 14:54 ` Jiri Pirko 2011-03-05 15:06 ` Nicolas de Pesloüan 2011-03-05 15:13 ` [patch net-next-2.6] net: comment rx_handler results Jiri Pirko 2011-03-05 15:27 ` Nicolas de Pesloüan 2011-03-05 15:37 ` Jiri Pirko 2011-03-05 15:50 ` Nicolas de Pesloüan 2011-03-06 20:00 ` [PATCH net-next-2.6] net: enhance the documentation for rx_handler Nicolas de Pesloüan 2011-03-07 9:54 ` Jiri Pirko 2011-03-07 16:36 ` Stephen Hemminger 2011-03-07 20:01 ` [PATCH net-next-2.6 V2] " Nicolas de Pesloüan 2011-03-05 15:31 ` [patch net-next-2.6 7/8 v2] net: introduce rx_handler results and logic around that Jiri Pirko 2011-03-05 10:29 ` [patch net-next-2.6 8/8] net: get rid of orig_dev parameter of packet handlers Jiri Pirko 2011-03-05 15:05 ` Nicolas de Pesloüan 2011-03-05 15:15 ` Jiri Pirko 2011-03-05 15:32 ` [patch net-next-2.6 8/8 v2] " Jiri Pirko 2011-03-05 16:56 ` Nicolas de Pesloüan 2011-03-05 22:07 ` Jiri Pirko 2011-03-05 22:18 ` Nicolas de Pesloüan -- strict thread matches above, loose matches on Subject: below -- 2011-03-05 8:29 [patch net-next-2.6 0/8] mostly bonding rx path changes Jiri Pirko 2011-03-05 8:29 ` [patch net-next-2.6 6/8] bonding: move processing of recv handlers into handle_frame() 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).