diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2011-07-25 13:59:46 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-07-25 14:53:52 -0400 |
commit | 5f00bcb38ef9a980a33c6dbdc0044964b05f22dd (patch) | |
tree | 3175fb9375aecb50bde1be0bf4fa8aa8155131d6 /net/batman-adv/soft-interface.c | |
parent | 34006cee28f7344f9557a4be3816c7891b1bbab1 (diff) | |
parent | b6844e8f64920cdee620157252169ba63afb0c89 (diff) |
Merge branch 'master' into devel and apply fixup from Stephen Rothwell:
vfs/nfs: fixup for nfs_open_context change
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/batman-adv/soft-interface.c')
-rw-r--r-- | net/batman-adv/soft-interface.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d5aa60999e83..3e2f91ffa4e2 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gateway_common.h" | 30 | #include "gateway_common.h" |
31 | #include "gateway_client.h" | 31 | #include "gateway_client.h" |
32 | #include "bat_sysfs.h" | 32 | #include "bat_sysfs.h" |
33 | #include "originator.h" | ||
33 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
34 | #include <linux/ethtool.h> | 35 | #include <linux/ethtool.h> |
35 | #include <linux/etherdevice.h> | 36 | #include <linux/etherdevice.h> |
@@ -123,8 +124,7 @@ static struct softif_neigh_vid *softif_neigh_vid_get(struct bat_priv *bat_priv, | |||
123 | goto out; | 124 | goto out; |
124 | } | 125 | } |
125 | 126 | ||
126 | softif_neigh_vid = kzalloc(sizeof(struct softif_neigh_vid), | 127 | softif_neigh_vid = kzalloc(sizeof(*softif_neigh_vid), GFP_ATOMIC); |
127 | GFP_ATOMIC); | ||
128 | if (!softif_neigh_vid) | 128 | if (!softif_neigh_vid) |
129 | goto out; | 129 | goto out; |
130 | 130 | ||
@@ -146,7 +146,7 @@ out: | |||
146 | } | 146 | } |
147 | 147 | ||
148 | static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv, | 148 | static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv, |
149 | uint8_t *addr, short vid) | 149 | const uint8_t *addr, short vid) |
150 | { | 150 | { |
151 | struct softif_neigh_vid *softif_neigh_vid; | 151 | struct softif_neigh_vid *softif_neigh_vid; |
152 | struct softif_neigh *softif_neigh = NULL; | 152 | struct softif_neigh *softif_neigh = NULL; |
@@ -170,7 +170,7 @@ static struct softif_neigh *softif_neigh_get(struct bat_priv *bat_priv, | |||
170 | goto unlock; | 170 | goto unlock; |
171 | } | 171 | } |
172 | 172 | ||
173 | softif_neigh = kzalloc(sizeof(struct softif_neigh), GFP_ATOMIC); | 173 | softif_neigh = kzalloc(sizeof(*softif_neigh), GFP_ATOMIC); |
174 | if (!softif_neigh) | 174 | if (!softif_neigh) |
175 | goto unlock; | 175 | goto unlock; |
176 | 176 | ||
@@ -242,7 +242,8 @@ static void softif_neigh_vid_select(struct bat_priv *bat_priv, | |||
242 | if (new_neigh && !atomic_inc_not_zero(&new_neigh->refcount)) | 242 | if (new_neigh && !atomic_inc_not_zero(&new_neigh->refcount)) |
243 | new_neigh = NULL; | 243 | new_neigh = NULL; |
244 | 244 | ||
245 | curr_neigh = softif_neigh_vid->softif_neigh; | 245 | curr_neigh = rcu_dereference_protected(softif_neigh_vid->softif_neigh, |
246 | 1); | ||
246 | rcu_assign_pointer(softif_neigh_vid->softif_neigh, new_neigh); | 247 | rcu_assign_pointer(softif_neigh_vid->softif_neigh, new_neigh); |
247 | 248 | ||
248 | if ((curr_neigh) && (!new_neigh)) | 249 | if ((curr_neigh) && (!new_neigh)) |
@@ -380,7 +381,7 @@ void softif_neigh_purge(struct bat_priv *bat_priv) | |||
380 | struct softif_neigh *softif_neigh, *curr_softif_neigh; | 381 | struct softif_neigh *softif_neigh, *curr_softif_neigh; |
381 | struct softif_neigh_vid *softif_neigh_vid; | 382 | struct softif_neigh_vid *softif_neigh_vid; |
382 | struct hlist_node *node, *node_tmp, *node_tmp2; | 383 | struct hlist_node *node, *node_tmp, *node_tmp2; |
383 | char do_deselect; | 384 | int do_deselect; |
384 | 385 | ||
385 | rcu_read_lock(); | 386 | rcu_read_lock(); |
386 | hlist_for_each_entry_rcu(softif_neigh_vid, node, | 387 | hlist_for_each_entry_rcu(softif_neigh_vid, node, |
@@ -534,7 +535,7 @@ static int interface_set_mac_addr(struct net_device *dev, void *p) | |||
534 | /* only modify transtable if it has been initialised before */ | 535 | /* only modify transtable if it has been initialised before */ |
535 | if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { | 536 | if (atomic_read(&bat_priv->mesh_state) == MESH_ACTIVE) { |
536 | tt_local_remove(bat_priv, dev->dev_addr, | 537 | tt_local_remove(bat_priv, dev->dev_addr, |
537 | "mac address changed"); | 538 | "mac address changed", false); |
538 | tt_local_add(dev, addr->sa_data); | 539 | tt_local_add(dev, addr->sa_data); |
539 | } | 540 | } |
540 | 541 | ||
@@ -553,7 +554,7 @@ static int interface_change_mtu(struct net_device *dev, int new_mtu) | |||
553 | return 0; | 554 | return 0; |
554 | } | 555 | } |
555 | 556 | ||
556 | int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | 557 | static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) |
557 | { | 558 | { |
558 | struct ethhdr *ethhdr = (struct ethhdr *)skb->data; | 559 | struct ethhdr *ethhdr = (struct ethhdr *)skb->data; |
559 | struct bat_priv *bat_priv = netdev_priv(soft_iface); | 560 | struct bat_priv *bat_priv = netdev_priv(soft_iface); |
@@ -561,6 +562,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
561 | struct bcast_packet *bcast_packet; | 562 | struct bcast_packet *bcast_packet; |
562 | struct vlan_ethhdr *vhdr; | 563 | struct vlan_ethhdr *vhdr; |
563 | struct softif_neigh *curr_softif_neigh = NULL; | 564 | struct softif_neigh *curr_softif_neigh = NULL; |
565 | struct orig_node *orig_node = NULL; | ||
564 | int data_len = skb->len, ret; | 566 | int data_len = skb->len, ret; |
565 | short vid = -1; | 567 | short vid = -1; |
566 | bool do_bcast = false; | 568 | bool do_bcast = false; |
@@ -592,11 +594,13 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
592 | if (curr_softif_neigh) | 594 | if (curr_softif_neigh) |
593 | goto dropped; | 595 | goto dropped; |
594 | 596 | ||
595 | /* TODO: check this for locks */ | 597 | /* Register the client MAC in the transtable */ |
596 | tt_local_add(soft_iface, ethhdr->h_source); | 598 | tt_local_add(soft_iface, ethhdr->h_source); |
597 | 599 | ||
598 | if (is_multicast_ether_addr(ethhdr->h_dest)) { | 600 | orig_node = transtable_search(bat_priv, ethhdr->h_dest); |
599 | ret = gw_is_target(bat_priv, skb); | 601 | if (is_multicast_ether_addr(ethhdr->h_dest) || |
602 | (orig_node && orig_node->gw_flags)) { | ||
603 | ret = gw_is_target(bat_priv, skb, orig_node); | ||
600 | 604 | ||
601 | if (ret < 0) | 605 | if (ret < 0) |
602 | goto dropped; | 606 | goto dropped; |
@@ -611,7 +615,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
611 | if (!primary_if) | 615 | if (!primary_if) |
612 | goto dropped; | 616 | goto dropped; |
613 | 617 | ||
614 | if (my_skb_head_push(skb, sizeof(struct bcast_packet)) < 0) | 618 | if (my_skb_head_push(skb, sizeof(*bcast_packet)) < 0) |
615 | goto dropped; | 619 | goto dropped; |
616 | 620 | ||
617 | bcast_packet = (struct bcast_packet *)skb->data; | 621 | bcast_packet = (struct bcast_packet *)skb->data; |
@@ -630,7 +634,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
630 | bcast_packet->seqno = | 634 | bcast_packet->seqno = |
631 | htonl(atomic_inc_return(&bat_priv->bcast_seqno)); | 635 | htonl(atomic_inc_return(&bat_priv->bcast_seqno)); |
632 | 636 | ||
633 | add_bcast_packet_to_list(bat_priv, skb); | 637 | add_bcast_packet_to_list(bat_priv, skb, 1); |
634 | 638 | ||
635 | /* a copy is stored in the bcast list, therefore removing | 639 | /* a copy is stored in the bcast list, therefore removing |
636 | * the original skb. */ | 640 | * the original skb. */ |
@@ -656,6 +660,8 @@ end: | |||
656 | softif_neigh_free_ref(curr_softif_neigh); | 660 | softif_neigh_free_ref(curr_softif_neigh); |
657 | if (primary_if) | 661 | if (primary_if) |
658 | hardif_free_ref(primary_if); | 662 | hardif_free_ref(primary_if); |
663 | if (orig_node) | ||
664 | orig_node_free_ref(orig_node); | ||
659 | return NETDEV_TX_OK; | 665 | return NETDEV_TX_OK; |
660 | } | 666 | } |
661 | 667 | ||
@@ -744,7 +750,6 @@ out: | |||
744 | return; | 750 | return; |
745 | } | 751 | } |
746 | 752 | ||
747 | #ifdef HAVE_NET_DEVICE_OPS | ||
748 | static const struct net_device_ops bat_netdev_ops = { | 753 | static const struct net_device_ops bat_netdev_ops = { |
749 | .ndo_open = interface_open, | 754 | .ndo_open = interface_open, |
750 | .ndo_stop = interface_release, | 755 | .ndo_stop = interface_release, |
@@ -754,7 +759,6 @@ static const struct net_device_ops bat_netdev_ops = { | |||
754 | .ndo_start_xmit = interface_tx, | 759 | .ndo_start_xmit = interface_tx, |
755 | .ndo_validate_addr = eth_validate_addr | 760 | .ndo_validate_addr = eth_validate_addr |
756 | }; | 761 | }; |
757 | #endif | ||
758 | 762 | ||
759 | static void interface_setup(struct net_device *dev) | 763 | static void interface_setup(struct net_device *dev) |
760 | { | 764 | { |
@@ -763,16 +767,7 @@ static void interface_setup(struct net_device *dev) | |||
763 | 767 | ||
764 | ether_setup(dev); | 768 | ether_setup(dev); |
765 | 769 | ||
766 | #ifdef HAVE_NET_DEVICE_OPS | ||
767 | dev->netdev_ops = &bat_netdev_ops; | 770 | dev->netdev_ops = &bat_netdev_ops; |
768 | #else | ||
769 | dev->open = interface_open; | ||
770 | dev->stop = interface_release; | ||
771 | dev->get_stats = interface_stats; | ||
772 | dev->set_mac_address = interface_set_mac_addr; | ||
773 | dev->change_mtu = interface_change_mtu; | ||
774 | dev->hard_start_xmit = interface_tx; | ||
775 | #endif | ||
776 | dev->destructor = free_netdev; | 771 | dev->destructor = free_netdev; |
777 | dev->tx_queue_len = 0; | 772 | dev->tx_queue_len = 0; |
778 | 773 | ||
@@ -790,17 +785,16 @@ static void interface_setup(struct net_device *dev) | |||
790 | 785 | ||
791 | SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); | 786 | SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); |
792 | 787 | ||
793 | memset(priv, 0, sizeof(struct bat_priv)); | 788 | memset(priv, 0, sizeof(*priv)); |
794 | } | 789 | } |
795 | 790 | ||
796 | struct net_device *softif_create(char *name) | 791 | struct net_device *softif_create(const char *name) |
797 | { | 792 | { |
798 | struct net_device *soft_iface; | 793 | struct net_device *soft_iface; |
799 | struct bat_priv *bat_priv; | 794 | struct bat_priv *bat_priv; |
800 | int ret; | 795 | int ret; |
801 | 796 | ||
802 | soft_iface = alloc_netdev(sizeof(struct bat_priv) , name, | 797 | soft_iface = alloc_netdev(sizeof(*bat_priv), name, interface_setup); |
803 | interface_setup); | ||
804 | 798 | ||
805 | if (!soft_iface) { | 799 | if (!soft_iface) { |
806 | pr_err("Unable to allocate the batman interface: %s\n", name); | 800 | pr_err("Unable to allocate the batman interface: %s\n", name); |
@@ -831,7 +825,13 @@ struct net_device *softif_create(char *name) | |||
831 | 825 | ||
832 | atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); | 826 | atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); |
833 | atomic_set(&bat_priv->bcast_seqno, 1); | 827 | atomic_set(&bat_priv->bcast_seqno, 1); |
834 | atomic_set(&bat_priv->tt_local_changed, 0); | 828 | atomic_set(&bat_priv->ttvn, 0); |
829 | atomic_set(&bat_priv->tt_local_changes, 0); | ||
830 | atomic_set(&bat_priv->tt_ogm_append_cnt, 0); | ||
831 | |||
832 | bat_priv->tt_buff = NULL; | ||
833 | bat_priv->tt_buff_len = 0; | ||
834 | bat_priv->tt_poss_change = false; | ||
835 | 835 | ||
836 | bat_priv->primary_if = NULL; | 836 | bat_priv->primary_if = NULL; |
837 | bat_priv->num_ifaces = 0; | 837 | bat_priv->num_ifaces = 0; |
@@ -872,15 +872,10 @@ void softif_destroy(struct net_device *soft_iface) | |||
872 | unregister_netdevice(soft_iface); | 872 | unregister_netdevice(soft_iface); |
873 | } | 873 | } |
874 | 874 | ||
875 | int softif_is_valid(struct net_device *net_dev) | 875 | int softif_is_valid(const struct net_device *net_dev) |
876 | { | 876 | { |
877 | #ifdef HAVE_NET_DEVICE_OPS | ||
878 | if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) | 877 | if (net_dev->netdev_ops->ndo_start_xmit == interface_tx) |
879 | return 1; | 878 | return 1; |
880 | #else | ||
881 | if (net_dev->hard_start_xmit == interface_tx) | ||
882 | return 1; | ||
883 | #endif | ||
884 | 879 | ||
885 | return 0; | 880 | return 0; |
886 | } | 881 | } |
@@ -924,4 +919,3 @@ static u32 bat_get_link(struct net_device *dev) | |||
924 | { | 919 | { |
925 | return 1; | 920 | return 1; |
926 | } | 921 | } |
927 | |||