fragmentation.c (4f2c0a4acffbec01079c28f839422e64ddeff004) | fragmentation.c (07afe1ba288c04280622fa002ed385f1ac0b6fe6) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (C) B.A.T.M.A.N. contributors: 3 * 4 * Martin Hundebøll <martin@hundeboll.net> 5 */ 6 7#include "fragmentation.h" 8#include "main.h" --- 11 unchanged lines hidden (view full) --- 20#include <linux/skbuff.h> 21#include <linux/slab.h> 22#include <linux/spinlock.h> 23#include <linux/string.h> 24#include <uapi/linux/batadv_packet.h> 25 26#include "hard-interface.h" 27#include "originator.h" | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (C) B.A.T.M.A.N. contributors: 3 * 4 * Martin Hundebøll <martin@hundeboll.net> 5 */ 6 7#include "fragmentation.h" 8#include "main.h" --- 11 unchanged lines hidden (view full) --- 20#include <linux/skbuff.h> 21#include <linux/slab.h> 22#include <linux/spinlock.h> 23#include <linux/string.h> 24#include <uapi/linux/batadv_packet.h> 25 26#include "hard-interface.h" 27#include "originator.h" |
28#include "routing.h" | |
29#include "send.h" 30 31/** 32 * batadv_frag_clear_chain() - delete entries in the fragment buffer chain 33 * @head: head of chain with entries. 34 * @dropped: whether the chain is cleared because all fragments are dropped 35 * 36 * Free fragments in the passed hlist. Should be called with appropriate lock. --- 309 unchanged lines hidden (view full) --- 346 * 347 * Return: true if the fragment is consumed/forwarded, false otherwise. 348 */ 349bool batadv_frag_skb_fwd(struct sk_buff *skb, 350 struct batadv_hard_iface *recv_if, 351 struct batadv_orig_node *orig_node_src) 352{ 353 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); | 28#include "send.h" 29 30/** 31 * batadv_frag_clear_chain() - delete entries in the fragment buffer chain 32 * @head: head of chain with entries. 33 * @dropped: whether the chain is cleared because all fragments are dropped 34 * 35 * Free fragments in the passed hlist. Should be called with appropriate lock. --- 309 unchanged lines hidden (view full) --- 345 * 346 * Return: true if the fragment is consumed/forwarded, false otherwise. 347 */ 348bool batadv_frag_skb_fwd(struct sk_buff *skb, 349 struct batadv_hard_iface *recv_if, 350 struct batadv_orig_node *orig_node_src) 351{ 352 struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface); |
354 struct batadv_orig_node *orig_node_dst; | |
355 struct batadv_neigh_node *neigh_node = NULL; 356 struct batadv_frag_packet *packet; 357 u16 total_size; 358 bool ret = false; 359 360 packet = (struct batadv_frag_packet *)skb->data; | 353 struct batadv_neigh_node *neigh_node = NULL; 354 struct batadv_frag_packet *packet; 355 u16 total_size; 356 bool ret = false; 357 358 packet = (struct batadv_frag_packet *)skb->data; |
361 orig_node_dst = batadv_orig_hash_find(bat_priv, packet->dest); 362 if (!orig_node_dst) 363 goto out; | |
364 | 359 |
365 neigh_node = batadv_find_router(bat_priv, orig_node_dst, recv_if); | 360 neigh_node = batadv_orig_to_router(bat_priv, packet->dest, recv_if); |
366 if (!neigh_node) 367 goto out; 368 369 /* Forward the fragment, if the merged packet would be too big to 370 * be assembled. 371 */ 372 total_size = ntohs(packet->total_size); 373 if (total_size > neigh_node->if_incoming->net_dev->mtu) { 374 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_FWD); 375 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES, 376 skb->len + ETH_HLEN); 377 378 packet->ttl--; 379 batadv_send_unicast_skb(skb, neigh_node); 380 ret = true; 381 } 382 383out: | 361 if (!neigh_node) 362 goto out; 363 364 /* Forward the fragment, if the merged packet would be too big to 365 * be assembled. 366 */ 367 total_size = ntohs(packet->total_size); 368 if (total_size > neigh_node->if_incoming->net_dev->mtu) { 369 batadv_inc_counter(bat_priv, BATADV_CNT_FRAG_FWD); 370 batadv_add_counter(bat_priv, BATADV_CNT_FRAG_FWD_BYTES, 371 skb->len + ETH_HLEN); 372 373 packet->ttl--; 374 batadv_send_unicast_skb(skb, neigh_node); 375 ret = true; 376 } 377 378out: |
384 batadv_orig_node_put(orig_node_dst); | |
385 batadv_neigh_node_put(neigh_node); 386 return ret; 387} 388 389/** 390 * batadv_frag_create() - create a fragment from skb 391 * @net_dev: outgoing device for fragment 392 * @skb: skb to create fragment from --- 170 unchanged lines hidden --- | 379 batadv_neigh_node_put(neigh_node); 380 return ret; 381} 382 383/** 384 * batadv_frag_create() - create a fragment from skb 385 * @net_dev: outgoing device for fragment 386 * @skb: skb to create fragment from --- 170 unchanged lines hidden --- |