aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/routing.c
diff options
context:
space:
mode:
authorAntonio Quartulli <antonio@open-mesh.com>2013-06-04 06:11:39 -0400
committerAntonio Quartulli <antonio@meshcoding.com>2013-10-19 09:11:21 -0400
commitc018ad3de61a1dc4194879a53e5559e094aa7b1a (patch)
tree4edb9c156b618dae46d38249a5c817e0d1f1e2b0 /net/batman-adv/routing.c
parentbc58eeef744df93e141678ef44452f0869cd563d (diff)
batman-adv: add the VLAN ID attribute to the TT entry
To make the translation table code VLAN-aware, each entry must carry the VLAN ID which it belongs to. This patch adds such attribute to the related TT structures. Signed-off-by: Antonio Quartulli <antonio@open-mesh.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r--net/batman-adv/routing.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 3281a504c20a..149ef57e78c3 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -30,6 +30,8 @@
30#include "network-coding.h" 30#include "network-coding.h"
31#include "fragmentation.h" 31#include "fragmentation.h"
32 32
33#include <linux/if_vlan.h>
34
33static int batadv_route_unicast_packet(struct sk_buff *skb, 35static int batadv_route_unicast_packet(struct sk_buff *skb,
34 struct batadv_hard_iface *recv_if); 36 struct batadv_hard_iface *recv_if);
35 37
@@ -724,6 +726,7 @@ out:
724 * @bat_priv: the bat priv with all the soft interface information 726 * @bat_priv: the bat priv with all the soft interface information
725 * @unicast_packet: the unicast header to be updated 727 * @unicast_packet: the unicast header to be updated
726 * @dst_addr: the payload destination 728 * @dst_addr: the payload destination
729 * @vid: VLAN identifier
727 * 730 *
728 * Search the translation table for dst_addr and update the unicast header with 731 * Search the translation table for dst_addr and update the unicast header with
729 * the new corresponding information (originator address where the destination 732 * the new corresponding information (originator address where the destination
@@ -734,21 +737,22 @@ out:
734static bool 737static bool
735batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, 738batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
736 struct batadv_unicast_packet *unicast_packet, 739 struct batadv_unicast_packet *unicast_packet,
737 uint8_t *dst_addr) 740 uint8_t *dst_addr, unsigned short vid)
738{ 741{
739 struct batadv_orig_node *orig_node = NULL; 742 struct batadv_orig_node *orig_node = NULL;
740 struct batadv_hard_iface *primary_if = NULL; 743 struct batadv_hard_iface *primary_if = NULL;
741 bool ret = false; 744 bool ret = false;
742 uint8_t *orig_addr, orig_ttvn; 745 uint8_t *orig_addr, orig_ttvn;
743 746
744 if (batadv_is_my_client(bat_priv, dst_addr)) { 747 if (batadv_is_my_client(bat_priv, dst_addr, vid)) {
745 primary_if = batadv_primary_if_get_selected(bat_priv); 748 primary_if = batadv_primary_if_get_selected(bat_priv);
746 if (!primary_if) 749 if (!primary_if)
747 goto out; 750 goto out;
748 orig_addr = primary_if->net_dev->dev_addr; 751 orig_addr = primary_if->net_dev->dev_addr;
749 orig_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); 752 orig_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn);
750 } else { 753 } else {
751 orig_node = batadv_transtable_search(bat_priv, NULL, dst_addr); 754 orig_node = batadv_transtable_search(bat_priv, NULL, dst_addr,
755 vid);
752 if (!orig_node) 756 if (!orig_node)
753 goto out; 757 goto out;
754 758
@@ -775,11 +779,12 @@ out:
775 779
776static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, 780static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
777 struct sk_buff *skb, int hdr_len) { 781 struct sk_buff *skb, int hdr_len) {
778 uint8_t curr_ttvn, old_ttvn; 782 struct batadv_unicast_packet *unicast_packet;
783 struct batadv_hard_iface *primary_if;
779 struct batadv_orig_node *orig_node; 784 struct batadv_orig_node *orig_node;
785 uint8_t curr_ttvn, old_ttvn;
780 struct ethhdr *ethhdr; 786 struct ethhdr *ethhdr;
781 struct batadv_hard_iface *primary_if; 787 unsigned short vid;
782 struct batadv_unicast_packet *unicast_packet;
783 int is_old_ttvn; 788 int is_old_ttvn;
784 789
785 /* check if there is enough data before accessing it */ 790 /* check if there is enough data before accessing it */
@@ -791,6 +796,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
791 return 0; 796 return 0;
792 797
793 unicast_packet = (struct batadv_unicast_packet *)skb->data; 798 unicast_packet = (struct batadv_unicast_packet *)skb->data;
799 vid = batadv_get_vid(skb, hdr_len);
794 ethhdr = (struct ethhdr *)(skb->data + hdr_len); 800 ethhdr = (struct ethhdr *)(skb->data + hdr_len);
795 801
796 /* check if the destination client was served by this node and it is now 802 /* check if the destination client was served by this node and it is now
@@ -798,9 +804,9 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
798 * message and that it knows the new destination in the mesh to re-route 804 * message and that it knows the new destination in the mesh to re-route
799 * the packet to 805 * the packet to
800 */ 806 */
801 if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest)) { 807 if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
802 if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, 808 if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
803 ethhdr->h_dest)) 809 ethhdr->h_dest, vid))
804 net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, 810 net_ratelimited_function(batadv_dbg, BATADV_DBG_TT,
805 bat_priv, 811 bat_priv,
806 "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n", 812 "Rerouting unicast packet to %pM (dst=%pM): Local Roaming\n",
@@ -846,7 +852,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
846 * target host 852 * target host
847 */ 853 */
848 if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, 854 if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
849 ethhdr->h_dest)) { 855 ethhdr->h_dest, vid)) {
850 net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv, 856 net_ratelimited_function(batadv_dbg, BATADV_DBG_TT, bat_priv,
851 "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", 857 "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
852 unicast_packet->dest, ethhdr->h_dest, 858 unicast_packet->dest, ethhdr->h_dest,
@@ -858,7 +864,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
858 * currently served by this node or there is no destination at all and 864 * currently served by this node or there is no destination at all and
859 * it is possible to drop the packet 865 * it is possible to drop the packet
860 */ 866 */
861 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest)) 867 if (!batadv_is_my_client(bat_priv, ethhdr->h_dest, vid))
862 return 0; 868 return 0;
863 869
864 /* update the header in order to let the packet be delivered to this 870 /* update the header in order to let the packet be delivered to this