diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2011-09-08 07:12:53 -0400 |
---|---|---|
committer | Sven Eckelmann <sven@narfation.org> | 2011-11-20 07:08:32 -0500 |
commit | be7af5cf9cae5e088a9783ccd6e47469ce9d43f4 (patch) | |
tree | bdbe10d4fbc6792df1a76b17a539e9c72b0dd8b2 /net/batman-adv/soft-interface.c | |
parent | 25a92b138dcd1eb46e82d1afdf03fd787837c019 (diff) |
batman-adv: refactoring gateway handling code
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Acked-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/soft-interface.c')
-rw-r--r-- | net/batman-adv/soft-interface.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index f9cc95728989..45297c843092 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
@@ -563,10 +563,10 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
563 | struct bcast_packet *bcast_packet; | 563 | struct bcast_packet *bcast_packet; |
564 | struct vlan_ethhdr *vhdr; | 564 | struct vlan_ethhdr *vhdr; |
565 | struct softif_neigh *curr_softif_neigh = NULL; | 565 | struct softif_neigh *curr_softif_neigh = NULL; |
566 | struct orig_node *orig_node = NULL; | 566 | unsigned int header_len = 0; |
567 | int data_len = skb->len, ret; | 567 | int data_len = skb->len, ret; |
568 | short vid = -1; | 568 | short vid = -1; |
569 | bool do_bcast; | 569 | bool do_bcast = false; |
570 | 570 | ||
571 | if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) | 571 | if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE) |
572 | goto dropped; | 572 | goto dropped; |
@@ -598,17 +598,28 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
598 | /* Register the client MAC in the transtable */ | 598 | /* Register the client MAC in the transtable */ |
599 | tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); | 599 | tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); |
600 | 600 | ||
601 | orig_node = transtable_search(bat_priv, ethhdr->h_source, | 601 | if (is_multicast_ether_addr(ethhdr->h_dest)) { |
602 | ethhdr->h_dest); | 602 | do_bcast = true; |
603 | do_bcast = is_multicast_ether_addr(ethhdr->h_dest); | ||
604 | if (do_bcast || (orig_node && orig_node->gw_flags)) { | ||
605 | ret = gw_is_target(bat_priv, skb, orig_node); | ||
606 | 603 | ||
607 | if (ret < 0) | 604 | switch (atomic_read(&bat_priv->gw_mode)) { |
608 | goto dropped; | 605 | case GW_MODE_SERVER: |
609 | 606 | /* gateway servers should not send dhcp | |
610 | if (ret) | 607 | * requests into the mesh */ |
611 | do_bcast = false; | 608 | ret = gw_is_dhcp_target(skb, &header_len); |
609 | if (ret) | ||
610 | goto dropped; | ||
611 | break; | ||
612 | case GW_MODE_CLIENT: | ||
613 | /* gateway clients should send dhcp requests | ||
614 | * via unicast to their gateway */ | ||
615 | ret = gw_is_dhcp_target(skb, &header_len); | ||
616 | if (ret) | ||
617 | do_bcast = false; | ||
618 | break; | ||
619 | case GW_MODE_OFF: | ||
620 | default: | ||
621 | break; | ||
622 | } | ||
612 | } | 623 | } |
613 | 624 | ||
614 | /* ethernet packet should be broadcasted */ | 625 | /* ethernet packet should be broadcasted */ |
@@ -644,6 +655,12 @@ static int interface_tx(struct sk_buff *skb, struct net_device *soft_iface) | |||
644 | 655 | ||
645 | /* unicast packet */ | 656 | /* unicast packet */ |
646 | } else { | 657 | } else { |
658 | if (atomic_read(&bat_priv->gw_mode) != GW_MODE_OFF) { | ||
659 | ret = gw_out_of_range(bat_priv, skb, ethhdr); | ||
660 | if (ret) | ||
661 | goto dropped; | ||
662 | } | ||
663 | |||
647 | ret = unicast_send_skb(skb, bat_priv); | 664 | ret = unicast_send_skb(skb, bat_priv); |
648 | if (ret != 0) | 665 | if (ret != 0) |
649 | goto dropped_freed; | 666 | goto dropped_freed; |
@@ -662,8 +679,6 @@ end: | |||
662 | softif_neigh_free_ref(curr_softif_neigh); | 679 | softif_neigh_free_ref(curr_softif_neigh); |
663 | if (primary_if) | 680 | if (primary_if) |
664 | hardif_free_ref(primary_if); | 681 | hardif_free_ref(primary_if); |
665 | if (orig_node) | ||
666 | orig_node_free_ref(orig_node); | ||
667 | return NETDEV_TX_OK; | 682 | return NETDEV_TX_OK; |
668 | } | 683 | } |
669 | 684 | ||