Staging: batman-adv: Unify sysfs file names with their bat_priv atomics
[firefly-linux-kernel-4.4.55.git] / drivers / staging / batman-adv / routing.c
index 1e101113b6ff4a81193e60803f445cb2fab080bd..1b35486349040199d8abe7d9ab1de47ed1863b2f 100644 (file)
@@ -1019,7 +1019,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
        /* without bonding, the first node should
         * always choose the default router. */
 
-       bonding_enabled = atomic_read(&bat_priv->bonding_enabled);
+       bonding_enabled = atomic_read(&bat_priv->bonding);
 
        if ((!recv_if) && (!bonding_enabled))
                return orig_node->router;
@@ -1117,8 +1117,8 @@ static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
        return 0;
 }
 
-static int route_unicast_packet(struct sk_buff *skb,
-                               struct batman_if *recv_if, int hdr_size)
+int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,
+                        int hdr_size)
 {
        struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface);
        struct orig_node *orig_node;
@@ -1128,6 +1128,8 @@ static int route_unicast_packet(struct sk_buff *skb,
        unsigned long flags;
        struct unicast_packet *unicast_packet;
        struct ethhdr *ethhdr = (struct ethhdr *)skb_mac_header(skb);
+       int ret;
+       struct sk_buff *new_skb;
 
        unicast_packet = (struct unicast_packet *)skb->data;
 
@@ -1166,11 +1168,27 @@ static int route_unicast_packet(struct sk_buff *skb,
        unicast_packet = (struct unicast_packet *)skb->data;
 
        if (unicast_packet->packet_type == BAT_UNICAST &&
-           atomic_read(&bat_priv->frag_enabled) &&
+           atomic_read(&bat_priv->fragmentation) &&
            skb->len > batman_if->net_dev->mtu)
                return frag_send_skb(skb, bat_priv, batman_if,
                                     dstaddr);
 
+       if (unicast_packet->packet_type == BAT_UNICAST_FRAG &&
+           2 * skb->len - hdr_size <= batman_if->net_dev->mtu) {
+
+               ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
+
+               if (ret == NET_RX_DROP)
+                       return NET_RX_DROP;
+
+               /* packet was buffered for late merge */
+               if (!new_skb)
+                       return NET_RX_SUCCESS;
+
+               skb = new_skb;
+               unicast_packet = (struct unicast_packet *)skb->data;
+       }
+
        /* decrement ttl */
        unicast_packet->ttl--;
 
@@ -1192,7 +1210,7 @@ int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if)
 
        /* packet for me */
        if (is_my_mac(unicast_packet->dest)) {
-               interface_rx(recv_if->soft_iface, skb, hdr_size);
+               interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size);
                return NET_RX_SUCCESS;
        }
 
@@ -1224,7 +1242,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if)
                if (!new_skb)
                        return NET_RX_SUCCESS;
 
-               interface_rx(recv_if->soft_iface, new_skb, hdr_size);
+               interface_rx(recv_if->soft_iface, new_skb, recv_if,
+                            sizeof(struct unicast_packet));
                return NET_RX_SUCCESS;
        }
 
@@ -1305,7 +1324,7 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)
        add_bcast_packet_to_list(bat_priv, skb);
 
        /* broadcast for me */
-       interface_rx(recv_if->soft_iface, skb, hdr_size);
+       interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size);
 
        return NET_RX_SUCCESS;
 }