routing.c (e23c34bb41da65f354fb7eee04300c56ee48f60c) routing.c (a40d9b075c21f06872de3f05cc2eb3d06665e2ff)
1/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 294 unchanged lines hidden (view full) ---

303 if (skb_cow(skb, ETH_HLEN) < 0)
304 goto out;
305
306 icmph = (struct batadv_icmp_header *)skb->data;
307
308 memcpy(icmph->dst, icmph->orig, ETH_ALEN);
309 memcpy(icmph->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
310 icmph->msg_type = BATADV_ECHO_REPLY;
1/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public
7 * License as published by the Free Software Foundation.
8 *

--- 294 unchanged lines hidden (view full) ---

303 if (skb_cow(skb, ETH_HLEN) < 0)
304 goto out;
305
306 icmph = (struct batadv_icmp_header *)skb->data;
307
308 memcpy(icmph->dst, icmph->orig, ETH_ALEN);
309 memcpy(icmph->orig, primary_if->net_dev->dev_addr, ETH_ALEN);
310 icmph->msg_type = BATADV_ECHO_REPLY;
311 icmph->header.ttl = BATADV_TTL;
311 icmph->ttl = BATADV_TTL;
312
313 res = batadv_send_skb_to_orig(skb, orig_node, NULL);
314 if (res != NET_XMIT_DROP)
315 ret = NET_RX_SUCCESS;
316
317 break;
318 default:
319 /* drop unknown type */

--- 38 unchanged lines hidden (view full) ---

358 goto out;
359
360 icmp_packet = (struct batadv_icmp_packet *)skb->data;
361
362 memcpy(icmp_packet->icmph.dst, icmp_packet->icmph.orig, ETH_ALEN);
363 memcpy(icmp_packet->icmph.orig, primary_if->net_dev->dev_addr,
364 ETH_ALEN);
365 icmp_packet->icmph.msg_type = BATADV_TTL_EXCEEDED;
312
313 res = batadv_send_skb_to_orig(skb, orig_node, NULL);
314 if (res != NET_XMIT_DROP)
315 ret = NET_RX_SUCCESS;
316
317 break;
318 default:
319 /* drop unknown type */

--- 38 unchanged lines hidden (view full) ---

358 goto out;
359
360 icmp_packet = (struct batadv_icmp_packet *)skb->data;
361
362 memcpy(icmp_packet->icmph.dst, icmp_packet->icmph.orig, ETH_ALEN);
363 memcpy(icmp_packet->icmph.orig, primary_if->net_dev->dev_addr,
364 ETH_ALEN);
365 icmp_packet->icmph.msg_type = BATADV_TTL_EXCEEDED;
366 icmp_packet->icmph.header.ttl = BATADV_TTL;
366 icmp_packet->icmph.ttl = BATADV_TTL;
367
368 if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
369 ret = NET_RX_SUCCESS;
370
371out:
372 if (primary_if)
373 batadv_hardif_free_ref(primary_if);
374 if (orig_node)

--- 54 unchanged lines hidden (view full) ---

429 icmp_packet_rr->rr_cur++;
430 }
431
432 /* packet for me */
433 if (batadv_is_my_mac(bat_priv, icmph->dst))
434 return batadv_recv_my_icmp_packet(bat_priv, skb);
435
436 /* TTL exceeded */
367
368 if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
369 ret = NET_RX_SUCCESS;
370
371out:
372 if (primary_if)
373 batadv_hardif_free_ref(primary_if);
374 if (orig_node)

--- 54 unchanged lines hidden (view full) ---

429 icmp_packet_rr->rr_cur++;
430 }
431
432 /* packet for me */
433 if (batadv_is_my_mac(bat_priv, icmph->dst))
434 return batadv_recv_my_icmp_packet(bat_priv, skb);
435
436 /* TTL exceeded */
437 if (icmph->header.ttl < 2)
437 if (icmph->ttl < 2)
438 return batadv_recv_icmp_ttl_exceeded(bat_priv, skb);
439
440 /* get routing information */
441 orig_node = batadv_orig_hash_find(bat_priv, icmph->dst);
442 if (!orig_node)
443 goto out;
444
445 /* create a copy of the skb, if needed, to modify it. */
446 if (skb_cow(skb, ETH_HLEN) < 0)
447 goto out;
448
449 icmph = (struct batadv_icmp_header *)skb->data;
450
451 /* decrement ttl */
438 return batadv_recv_icmp_ttl_exceeded(bat_priv, skb);
439
440 /* get routing information */
441 orig_node = batadv_orig_hash_find(bat_priv, icmph->dst);
442 if (!orig_node)
443 goto out;
444
445 /* create a copy of the skb, if needed, to modify it. */
446 if (skb_cow(skb, ETH_HLEN) < 0)
447 goto out;
448
449 icmph = (struct batadv_icmp_header *)skb->data;
450
451 /* decrement ttl */
452 icmph->header.ttl--;
452 icmph->ttl--;
453
454 /* route it */
455 if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP)
456 ret = NET_RX_SUCCESS;
457
458out:
459 if (orig_node)
460 batadv_orig_node_free_ref(orig_node);

--- 243 unchanged lines hidden (view full) ---

704 struct batadv_orig_node *orig_node = NULL;
705 struct batadv_unicast_packet *unicast_packet;
706 struct ethhdr *ethhdr = eth_hdr(skb);
707 int res, hdr_len, ret = NET_RX_DROP;
708
709 unicast_packet = (struct batadv_unicast_packet *)skb->data;
710
711 /* TTL exceeded */
453
454 /* route it */
455 if (batadv_send_skb_to_orig(skb, orig_node, recv_if) != NET_XMIT_DROP)
456 ret = NET_RX_SUCCESS;
457
458out:
459 if (orig_node)
460 batadv_orig_node_free_ref(orig_node);

--- 243 unchanged lines hidden (view full) ---

704 struct batadv_orig_node *orig_node = NULL;
705 struct batadv_unicast_packet *unicast_packet;
706 struct ethhdr *ethhdr = eth_hdr(skb);
707 int res, hdr_len, ret = NET_RX_DROP;
708
709 unicast_packet = (struct batadv_unicast_packet *)skb->data;
710
711 /* TTL exceeded */
712 if (unicast_packet->header.ttl < 2) {
712 if (unicast_packet->ttl < 2) {
713 pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n",
714 ethhdr->h_source, unicast_packet->dest);
715 goto out;
716 }
717
718 /* get routing information */
719 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
720
721 if (!orig_node)
722 goto out;
723
724 /* create a copy of the skb, if needed, to modify it. */
725 if (skb_cow(skb, ETH_HLEN) < 0)
726 goto out;
727
728 /* decrement ttl */
729 unicast_packet = (struct batadv_unicast_packet *)skb->data;
713 pr_debug("Warning - can't forward unicast packet from %pM to %pM: ttl exceeded\n",
714 ethhdr->h_source, unicast_packet->dest);
715 goto out;
716 }
717
718 /* get routing information */
719 orig_node = batadv_orig_hash_find(bat_priv, unicast_packet->dest);
720
721 if (!orig_node)
722 goto out;
723
724 /* create a copy of the skb, if needed, to modify it. */
725 if (skb_cow(skb, ETH_HLEN) < 0)
726 goto out;
727
728 /* decrement ttl */
729 unicast_packet = (struct batadv_unicast_packet *)skb->data;
730 unicast_packet->header.ttl--;
730 unicast_packet->ttl--;
731
731
732 switch (unicast_packet->header.packet_type) {
732 switch (unicast_packet->packet_type) {
733 case BATADV_UNICAST_4ADDR:
734 hdr_len = sizeof(struct batadv_unicast_4addr_packet);
735 break;
736 case BATADV_UNICAST:
737 hdr_len = sizeof(struct batadv_unicast_packet);
738 break;
739 default:
740 /* other packet types not supported - yet */

--- 224 unchanged lines hidden (view full) ---

965 uint8_t *orig_addr;
966 struct batadv_orig_node *orig_node = NULL;
967 int check, hdr_size = sizeof(*unicast_packet);
968 bool is4addr;
969
970 unicast_packet = (struct batadv_unicast_packet *)skb->data;
971 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
972
733 case BATADV_UNICAST_4ADDR:
734 hdr_len = sizeof(struct batadv_unicast_4addr_packet);
735 break;
736 case BATADV_UNICAST:
737 hdr_len = sizeof(struct batadv_unicast_packet);
738 break;
739 default:
740 /* other packet types not supported - yet */

--- 224 unchanged lines hidden (view full) ---

965 uint8_t *orig_addr;
966 struct batadv_orig_node *orig_node = NULL;
967 int check, hdr_size = sizeof(*unicast_packet);
968 bool is4addr;
969
970 unicast_packet = (struct batadv_unicast_packet *)skb->data;
971 unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
972
973 is4addr = unicast_packet->header.packet_type == BATADV_UNICAST_4ADDR;
973 is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
974 /* the caller function should have already pulled 2 bytes */
975 if (is4addr)
976 hdr_size = sizeof(*unicast_4addr_packet);
977
978 /* function returns -EREMOTE for promiscuous packets */
979 check = batadv_check_unicast_packet(bat_priv, skb, hdr_size);
980
981 /* Even though the packet is not for us, we might save it to use for

--- 173 unchanged lines hidden (view full) ---

1155 goto out;
1156
1157 bcast_packet = (struct batadv_bcast_packet *)skb->data;
1158
1159 /* ignore broadcasts originated by myself */
1160 if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
1161 goto out;
1162
974 /* the caller function should have already pulled 2 bytes */
975 if (is4addr)
976 hdr_size = sizeof(*unicast_4addr_packet);
977
978 /* function returns -EREMOTE for promiscuous packets */
979 check = batadv_check_unicast_packet(bat_priv, skb, hdr_size);
980
981 /* Even though the packet is not for us, we might save it to use for

--- 173 unchanged lines hidden (view full) ---

1155 goto out;
1156
1157 bcast_packet = (struct batadv_bcast_packet *)skb->data;
1158
1159 /* ignore broadcasts originated by myself */
1160 if (batadv_is_my_mac(bat_priv, bcast_packet->orig))
1161 goto out;
1162
1163 if (bcast_packet->header.ttl < 2)
1163 if (bcast_packet->ttl < 2)
1164 goto out;
1165
1166 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
1167
1168 if (!orig_node)
1169 goto out;
1170
1171 spin_lock_bh(&orig_node->bcast_seqno_lock);

--- 56 unchanged lines hidden ---
1164 goto out;
1165
1166 orig_node = batadv_orig_hash_find(bat_priv, bcast_packet->orig);
1167
1168 if (!orig_node)
1169 goto out;
1170
1171 spin_lock_bh(&orig_node->bcast_seqno_lock);

--- 56 unchanged lines hidden ---