diff options
author | David S. Miller <davem@davemloft.net> | 2011-11-26 14:26:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-26 14:26:24 -0500 |
commit | d6f03f29f7cdf064289f941bf0b838348e996e65 (patch) | |
tree | f8e75089e5690d27c271ca382f25a3386db76f14 /net | |
parent | 6f39da2c5eab64921f92a9ff4a48f3d14a8db24c (diff) | |
parent | 76e8d7b0d1b0091929e8cd18551a87b6bb6ef2c1 (diff) |
Merge branch 'for_david' of git://git.open-mesh.org/linux-merge
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/bat_sysfs.c | 4 | ||||
-rw-r--r-- | net/batman-adv/bitarray.c | 2 | ||||
-rw-r--r-- | net/batman-adv/gateway_client.c | 153 | ||||
-rw-r--r-- | net/batman-adv/gateway_client.h | 5 | ||||
-rw-r--r-- | net/batman-adv/gateway_common.c | 4 | ||||
-rw-r--r-- | net/batman-adv/hash.c | 4 | ||||
-rw-r--r-- | net/batman-adv/hash.h | 13 | ||||
-rw-r--r-- | net/batman-adv/main.h | 2 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 13 | ||||
-rw-r--r-- | net/batman-adv/originator.h | 2 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 22 | ||||
-rw-r--r-- | net/batman-adv/soft-interface.c | 43 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 100 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 17 |
14 files changed, 202 insertions, 182 deletions
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c index b8a7414c3571..c25492f7d665 100644 --- a/net/batman-adv/bat_sysfs.c +++ b/net/batman-adv/bat_sysfs.c | |||
@@ -174,7 +174,7 @@ static int store_uint_attr(const char *buff, size_t count, | |||
174 | unsigned long uint_val; | 174 | unsigned long uint_val; |
175 | int ret; | 175 | int ret; |
176 | 176 | ||
177 | ret = strict_strtoul(buff, 10, &uint_val); | 177 | ret = kstrtoul(buff, 10, &uint_val); |
178 | if (ret) { | 178 | if (ret) { |
179 | bat_info(net_dev, | 179 | bat_info(net_dev, |
180 | "%s: Invalid parameter received: %s\n", | 180 | "%s: Invalid parameter received: %s\n", |
@@ -239,7 +239,7 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, | |||
239 | unsigned long val; | 239 | unsigned long val; |
240 | int ret, vis_mode_tmp = -1; | 240 | int ret, vis_mode_tmp = -1; |
241 | 241 | ||
242 | ret = strict_strtoul(buff, 10, &val); | 242 | ret = kstrtoul(buff, 10, &val); |
243 | 243 | ||
244 | if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || | 244 | if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || |
245 | (strncmp(buff, "client", 6) == 0) || | 245 | (strncmp(buff, "client", 6) == 0) || |
diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c index 0be9ff346fa0..9bc63b209b3f 100644 --- a/net/batman-adv/bitarray.c +++ b/net/batman-adv/bitarray.c | |||
@@ -155,7 +155,7 @@ int bit_get_packet(void *priv, unsigned long *seq_bits, | |||
155 | /* sequence number is much newer, probably missed a lot of packets */ | 155 | /* sequence number is much newer, probably missed a lot of packets */ |
156 | 156 | ||
157 | if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) | 157 | if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) |
158 | || (seq_num_diff < EXPECTED_SEQNO_RANGE)) { | 158 | && (seq_num_diff < EXPECTED_SEQNO_RANGE)) { |
159 | bat_dbg(DBG_BATMAN, bat_priv, | 159 | bat_dbg(DBG_BATMAN, bat_priv, |
160 | "We missed a lot of packets (%i) !\n", | 160 | "We missed a lot of packets (%i) !\n", |
161 | seq_num_diff - 1); | 161 | seq_num_diff - 1); |
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 619fb73b3b76..9373a143c6d4 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "gateway_common.h" | 25 | #include "gateway_common.h" |
26 | #include "hard-interface.h" | 26 | #include "hard-interface.h" |
27 | #include "originator.h" | 27 | #include "originator.h" |
28 | #include "translation-table.h" | ||
28 | #include "routing.h" | 29 | #include "routing.h" |
29 | #include <linux/ip.h> | 30 | #include <linux/ip.h> |
30 | #include <linux/ipv6.h> | 31 | #include <linux/ipv6.h> |
@@ -572,108 +573,142 @@ out: | |||
572 | return ret; | 573 | return ret; |
573 | } | 574 | } |
574 | 575 | ||
575 | int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb, | 576 | bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) |
576 | struct orig_node *old_gw) | ||
577 | { | 577 | { |
578 | struct ethhdr *ethhdr; | 578 | struct ethhdr *ethhdr; |
579 | struct iphdr *iphdr; | 579 | struct iphdr *iphdr; |
580 | struct ipv6hdr *ipv6hdr; | 580 | struct ipv6hdr *ipv6hdr; |
581 | struct udphdr *udphdr; | 581 | struct udphdr *udphdr; |
582 | struct gw_node *curr_gw; | ||
583 | struct neigh_node *neigh_curr = NULL, *neigh_old = NULL; | ||
584 | unsigned int header_len = 0; | ||
585 | int ret = 1; | ||
586 | |||
587 | if (atomic_read(&bat_priv->gw_mode) == GW_MODE_OFF) | ||
588 | return 0; | ||
589 | 582 | ||
590 | /* check for ethernet header */ | 583 | /* check for ethernet header */ |
591 | if (!pskb_may_pull(skb, header_len + ETH_HLEN)) | 584 | if (!pskb_may_pull(skb, *header_len + ETH_HLEN)) |
592 | return 0; | 585 | return false; |
593 | ethhdr = (struct ethhdr *)skb->data; | 586 | ethhdr = (struct ethhdr *)skb->data; |
594 | header_len += ETH_HLEN; | 587 | *header_len += ETH_HLEN; |
595 | 588 | ||
596 | /* check for initial vlan header */ | 589 | /* check for initial vlan header */ |
597 | if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { | 590 | if (ntohs(ethhdr->h_proto) == ETH_P_8021Q) { |
598 | if (!pskb_may_pull(skb, header_len + VLAN_HLEN)) | 591 | if (!pskb_may_pull(skb, *header_len + VLAN_HLEN)) |
599 | return 0; | 592 | return false; |
600 | ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN); | 593 | ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN); |
601 | header_len += VLAN_HLEN; | 594 | *header_len += VLAN_HLEN; |
602 | } | 595 | } |
603 | 596 | ||
604 | /* check for ip header */ | 597 | /* check for ip header */ |
605 | switch (ntohs(ethhdr->h_proto)) { | 598 | switch (ntohs(ethhdr->h_proto)) { |
606 | case ETH_P_IP: | 599 | case ETH_P_IP: |
607 | if (!pskb_may_pull(skb, header_len + sizeof(*iphdr))) | 600 | if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr))) |
608 | return 0; | 601 | return false; |
609 | iphdr = (struct iphdr *)(skb->data + header_len); | 602 | iphdr = (struct iphdr *)(skb->data + *header_len); |
610 | header_len += iphdr->ihl * 4; | 603 | *header_len += iphdr->ihl * 4; |
611 | 604 | ||
612 | /* check for udp header */ | 605 | /* check for udp header */ |
613 | if (iphdr->protocol != IPPROTO_UDP) | 606 | if (iphdr->protocol != IPPROTO_UDP) |
614 | return 0; | 607 | return false; |
615 | 608 | ||
616 | break; | 609 | break; |
617 | case ETH_P_IPV6: | 610 | case ETH_P_IPV6: |
618 | if (!pskb_may_pull(skb, header_len + sizeof(*ipv6hdr))) | 611 | if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr))) |
619 | return 0; | 612 | return false; |
620 | ipv6hdr = (struct ipv6hdr *)(skb->data + header_len); | 613 | ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len); |
621 | header_len += sizeof(*ipv6hdr); | 614 | *header_len += sizeof(*ipv6hdr); |
622 | 615 | ||
623 | /* check for udp header */ | 616 | /* check for udp header */ |
624 | if (ipv6hdr->nexthdr != IPPROTO_UDP) | 617 | if (ipv6hdr->nexthdr != IPPROTO_UDP) |
625 | return 0; | 618 | return false; |
626 | 619 | ||
627 | break; | 620 | break; |
628 | default: | 621 | default: |
629 | return 0; | 622 | return false; |
630 | } | 623 | } |
631 | 624 | ||
632 | if (!pskb_may_pull(skb, header_len + sizeof(*udphdr))) | 625 | if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr))) |
633 | return 0; | 626 | return false; |
634 | udphdr = (struct udphdr *)(skb->data + header_len); | 627 | udphdr = (struct udphdr *)(skb->data + *header_len); |
635 | header_len += sizeof(*udphdr); | 628 | *header_len += sizeof(*udphdr); |
636 | 629 | ||
637 | /* check for bootp port */ | 630 | /* check for bootp port */ |
638 | if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && | 631 | if ((ntohs(ethhdr->h_proto) == ETH_P_IP) && |
639 | (ntohs(udphdr->dest) != 67)) | 632 | (ntohs(udphdr->dest) != 67)) |
640 | return 0; | 633 | return false; |
641 | 634 | ||
642 | if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) && | 635 | if ((ntohs(ethhdr->h_proto) == ETH_P_IPV6) && |
643 | (ntohs(udphdr->dest) != 547)) | 636 | (ntohs(udphdr->dest) != 547)) |
644 | return 0; | 637 | return false; |
645 | 638 | ||
646 | if (atomic_read(&bat_priv->gw_mode) == GW_MODE_SERVER) | 639 | return true; |
647 | return -1; | 640 | } |
648 | 641 | ||
649 | curr_gw = gw_get_selected_gw_node(bat_priv); | 642 | bool gw_out_of_range(struct bat_priv *bat_priv, |
650 | if (!curr_gw) | 643 | struct sk_buff *skb, struct ethhdr *ethhdr) |
651 | return 0; | 644 | { |
652 | 645 | struct neigh_node *neigh_curr = NULL, *neigh_old = NULL; | |
653 | /* If old_gw != NULL then this packet is unicast. | 646 | struct orig_node *orig_dst_node = NULL; |
654 | * So, at this point we have to check the message type: if it is a | 647 | struct gw_node *curr_gw = NULL; |
655 | * DHCPREQUEST we have to decide whether to drop it or not */ | 648 | bool ret, out_of_range = false; |
656 | if (old_gw && curr_gw->orig_node != old_gw) { | 649 | unsigned int header_len = 0; |
657 | if (is_type_dhcprequest(skb, header_len)) { | 650 | uint8_t curr_tq_avg; |
658 | /* If the dhcp packet has been sent to a different gw, | 651 | |
659 | * we have to evaluate whether the old gw is still | 652 | ret = gw_is_dhcp_target(skb, &header_len); |
660 | * reliable enough */ | 653 | if (!ret) |
661 | neigh_curr = find_router(bat_priv, curr_gw->orig_node, | 654 | goto out; |
662 | NULL); | 655 | |
663 | neigh_old = find_router(bat_priv, old_gw, NULL); | 656 | orig_dst_node = transtable_search(bat_priv, ethhdr->h_source, |
664 | if (!neigh_curr || !neigh_old) | 657 | ethhdr->h_dest); |
665 | goto free_neigh; | 658 | if (!orig_dst_node) |
666 | if (neigh_curr->tq_avg - neigh_old->tq_avg < | 659 | goto out; |
667 | GW_THRESHOLD) | 660 | |
668 | ret = -1; | 661 | if (!orig_dst_node->gw_flags) |
669 | } | 662 | goto out; |
663 | |||
664 | ret = is_type_dhcprequest(skb, header_len); | ||
665 | if (!ret) | ||
666 | goto out; | ||
667 | |||
668 | switch (atomic_read(&bat_priv->gw_mode)) { | ||
669 | case GW_MODE_SERVER: | ||
670 | /* If we are a GW then we are our best GW. We can artificially | ||
671 | * set the tq towards ourself as the maximum value */ | ||
672 | curr_tq_avg = TQ_MAX_VALUE; | ||
673 | break; | ||
674 | case GW_MODE_CLIENT: | ||
675 | curr_gw = gw_get_selected_gw_node(bat_priv); | ||
676 | if (!curr_gw) | ||
677 | goto out; | ||
678 | |||
679 | /* packet is going to our gateway */ | ||
680 | if (curr_gw->orig_node == orig_dst_node) | ||
681 | goto out; | ||
682 | |||
683 | /* If the dhcp packet has been sent to a different gw, | ||
684 | * we have to evaluate whether the old gw is still | ||
685 | * reliable enough */ | ||
686 | neigh_curr = find_router(bat_priv, curr_gw->orig_node, NULL); | ||
687 | if (!neigh_curr) | ||
688 | goto out; | ||
689 | |||
690 | curr_tq_avg = neigh_curr->tq_avg; | ||
691 | break; | ||
692 | case GW_MODE_OFF: | ||
693 | default: | ||
694 | goto out; | ||
670 | } | 695 | } |
671 | free_neigh: | 696 | |
697 | neigh_old = find_router(bat_priv, orig_dst_node, NULL); | ||
698 | if (!!neigh_old) | ||
699 | goto out; | ||
700 | |||
701 | if (curr_tq_avg - neigh_old->tq_avg > GW_THRESHOLD) | ||
702 | out_of_range = true; | ||
703 | |||
704 | out: | ||
705 | if (orig_dst_node) | ||
706 | orig_node_free_ref(orig_dst_node); | ||
707 | if (curr_gw) | ||
708 | gw_node_free_ref(curr_gw); | ||
672 | if (neigh_old) | 709 | if (neigh_old) |
673 | neigh_node_free_ref(neigh_old); | 710 | neigh_node_free_ref(neigh_old); |
674 | if (neigh_curr) | 711 | if (neigh_curr) |
675 | neigh_node_free_ref(neigh_curr); | 712 | neigh_node_free_ref(neigh_curr); |
676 | if (curr_gw) | 713 | return out_of_range; |
677 | gw_node_free_ref(curr_gw); | ||
678 | return ret; | ||
679 | } | 714 | } |
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index b9b983c07feb..e1edba08eb1d 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h | |||
@@ -31,7 +31,8 @@ void gw_node_update(struct bat_priv *bat_priv, | |||
31 | void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node); | 31 | void gw_node_delete(struct bat_priv *bat_priv, struct orig_node *orig_node); |
32 | void gw_node_purge(struct bat_priv *bat_priv); | 32 | void gw_node_purge(struct bat_priv *bat_priv); |
33 | int gw_client_seq_print_text(struct seq_file *seq, void *offset); | 33 | int gw_client_seq_print_text(struct seq_file *seq, void *offset); |
34 | int gw_is_target(struct bat_priv *bat_priv, struct sk_buff *skb, | 34 | bool gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len); |
35 | struct orig_node *old_gw); | 35 | bool gw_out_of_range(struct bat_priv *bat_priv, |
36 | struct sk_buff *skb, struct ethhdr *ethhdr); | ||
36 | 37 | ||
37 | #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ | 38 | #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ |
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c index 18661af0bc3b..c4ac7b0a2a63 100644 --- a/net/batman-adv/gateway_common.c +++ b/net/batman-adv/gateway_common.c | |||
@@ -97,7 +97,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, | |||
97 | *tmp_ptr = '\0'; | 97 | *tmp_ptr = '\0'; |
98 | } | 98 | } |
99 | 99 | ||
100 | ret = strict_strtol(buff, 10, &ldown); | 100 | ret = kstrtol(buff, 10, &ldown); |
101 | if (ret) { | 101 | if (ret) { |
102 | bat_err(net_dev, | 102 | bat_err(net_dev, |
103 | "Download speed of gateway mode invalid: %s\n", | 103 | "Download speed of gateway mode invalid: %s\n", |
@@ -122,7 +122,7 @@ static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff, | |||
122 | *tmp_ptr = '\0'; | 122 | *tmp_ptr = '\0'; |
123 | } | 123 | } |
124 | 124 | ||
125 | ret = strict_strtol(slash_ptr + 1, 10, &lup); | 125 | ret = kstrtol(slash_ptr + 1, 10, &lup); |
126 | if (ret) { | 126 | if (ret) { |
127 | bat_err(net_dev, | 127 | bat_err(net_dev, |
128 | "Upload speed of gateway mode invalid: " | 128 | "Upload speed of gateway mode invalid: " |
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c index 2a172505f513..d1da29da333b 100644 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c | |||
@@ -25,7 +25,7 @@ | |||
25 | /* clears the hash */ | 25 | /* clears the hash */ |
26 | static void hash_init(struct hashtable_t *hash) | 26 | static void hash_init(struct hashtable_t *hash) |
27 | { | 27 | { |
28 | int i; | 28 | uint32_t i; |
29 | 29 | ||
30 | for (i = 0 ; i < hash->size; i++) { | 30 | for (i = 0 ; i < hash->size; i++) { |
31 | INIT_HLIST_HEAD(&hash->table[i]); | 31 | INIT_HLIST_HEAD(&hash->table[i]); |
@@ -42,7 +42,7 @@ void hash_destroy(struct hashtable_t *hash) | |||
42 | } | 42 | } |
43 | 43 | ||
44 | /* allocates and clears the hash */ | 44 | /* allocates and clears the hash */ |
45 | struct hashtable_t *hash_new(int size) | 45 | struct hashtable_t *hash_new(uint32_t size) |
46 | { | 46 | { |
47 | struct hashtable_t *hash; | 47 | struct hashtable_t *hash; |
48 | 48 | ||
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h index d20aa71ba1e8..4768717f07f9 100644 --- a/net/batman-adv/hash.h +++ b/net/batman-adv/hash.h | |||
@@ -33,17 +33,17 @@ typedef int (*hashdata_compare_cb)(const struct hlist_node *, const void *); | |||
33 | /* the hashfunction, should return an index | 33 | /* the hashfunction, should return an index |
34 | * based on the key in the data of the first | 34 | * based on the key in the data of the first |
35 | * argument and the size the second */ | 35 | * argument and the size the second */ |
36 | typedef int (*hashdata_choose_cb)(const void *, int); | 36 | typedef uint32_t (*hashdata_choose_cb)(const void *, uint32_t); |
37 | typedef void (*hashdata_free_cb)(struct hlist_node *, void *); | 37 | typedef void (*hashdata_free_cb)(struct hlist_node *, void *); |
38 | 38 | ||
39 | struct hashtable_t { | 39 | struct hashtable_t { |
40 | struct hlist_head *table; /* the hashtable itself with the buckets */ | 40 | struct hlist_head *table; /* the hashtable itself with the buckets */ |
41 | spinlock_t *list_locks; /* spinlock for each hash list entry */ | 41 | spinlock_t *list_locks; /* spinlock for each hash list entry */ |
42 | int size; /* size of hashtable */ | 42 | uint32_t size; /* size of hashtable */ |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* allocates and clears the hash */ | 45 | /* allocates and clears the hash */ |
46 | struct hashtable_t *hash_new(int size); | 46 | struct hashtable_t *hash_new(uint32_t size); |
47 | 47 | ||
48 | /* free only the hashtable and the hash itself. */ | 48 | /* free only the hashtable and the hash itself. */ |
49 | void hash_destroy(struct hashtable_t *hash); | 49 | void hash_destroy(struct hashtable_t *hash); |
@@ -57,7 +57,7 @@ static inline void hash_delete(struct hashtable_t *hash, | |||
57 | struct hlist_head *head; | 57 | struct hlist_head *head; |
58 | struct hlist_node *node, *node_tmp; | 58 | struct hlist_node *node, *node_tmp; |
59 | spinlock_t *list_lock; /* spinlock to protect write access */ | 59 | spinlock_t *list_lock; /* spinlock to protect write access */ |
60 | int i; | 60 | uint32_t i; |
61 | 61 | ||
62 | for (i = 0; i < hash->size; i++) { | 62 | for (i = 0; i < hash->size; i++) { |
63 | head = &hash->table[i]; | 63 | head = &hash->table[i]; |
@@ -93,7 +93,8 @@ static inline int hash_add(struct hashtable_t *hash, | |||
93 | hashdata_choose_cb choose, | 93 | hashdata_choose_cb choose, |
94 | const void *data, struct hlist_node *data_node) | 94 | const void *data, struct hlist_node *data_node) |
95 | { | 95 | { |
96 | int index, ret = -1; | 96 | uint32_t index; |
97 | int ret = -1; | ||
97 | struct hlist_head *head; | 98 | struct hlist_head *head; |
98 | struct hlist_node *node; | 99 | struct hlist_node *node; |
99 | spinlock_t *list_lock; /* spinlock to protect write access */ | 100 | spinlock_t *list_lock; /* spinlock to protect write access */ |
@@ -137,7 +138,7 @@ static inline void *hash_remove(struct hashtable_t *hash, | |||
137 | hashdata_compare_cb compare, | 138 | hashdata_compare_cb compare, |
138 | hashdata_choose_cb choose, void *data) | 139 | hashdata_choose_cb choose, void *data) |
139 | { | 140 | { |
140 | size_t index; | 141 | uint32_t index; |
141 | struct hlist_node *node; | 142 | struct hlist_node *node; |
142 | struct hlist_head *head; | 143 | struct hlist_head *head; |
143 | void *data_save = NULL; | 144 | void *data_save = NULL; |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 964ad4d8ba33..86354e06eb48 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #define DRIVER_DEVICE "batman-adv" | 28 | #define DRIVER_DEVICE "batman-adv" |
29 | 29 | ||
30 | #ifndef SOURCE_VERSION | 30 | #ifndef SOURCE_VERSION |
31 | #define SOURCE_VERSION "2011.4.0" | 31 | #define SOURCE_VERSION "2012.0.0" |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | /* B.A.T.M.A.N. parameters */ | 34 | /* B.A.T.M.A.N. parameters */ |
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 0e5b77255d99..0bc2045a2f2e 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -164,7 +164,7 @@ void originator_free(struct bat_priv *bat_priv) | |||
164 | struct hlist_head *head; | 164 | struct hlist_head *head; |
165 | spinlock_t *list_lock; /* spinlock to protect write access */ | 165 | spinlock_t *list_lock; /* spinlock to protect write access */ |
166 | struct orig_node *orig_node; | 166 | struct orig_node *orig_node; |
167 | int i; | 167 | uint32_t i; |
168 | 168 | ||
169 | if (!hash) | 169 | if (!hash) |
170 | return; | 170 | return; |
@@ -350,7 +350,7 @@ static void _purge_orig(struct bat_priv *bat_priv) | |||
350 | struct hlist_head *head; | 350 | struct hlist_head *head; |
351 | spinlock_t *list_lock; /* spinlock to protect write access */ | 351 | spinlock_t *list_lock; /* spinlock to protect write access */ |
352 | struct orig_node *orig_node; | 352 | struct orig_node *orig_node; |
353 | int i; | 353 | uint32_t i; |
354 | 354 | ||
355 | if (!hash) | 355 | if (!hash) |
356 | return; | 356 | return; |
@@ -413,7 +413,8 @@ int orig_seq_print_text(struct seq_file *seq, void *offset) | |||
413 | int batman_count = 0; | 413 | int batman_count = 0; |
414 | int last_seen_secs; | 414 | int last_seen_secs; |
415 | int last_seen_msecs; | 415 | int last_seen_msecs; |
416 | int i, ret = 0; | 416 | uint32_t i; |
417 | int ret = 0; | ||
417 | 418 | ||
418 | primary_if = primary_if_get_selected(bat_priv); | 419 | primary_if = primary_if_get_selected(bat_priv); |
419 | 420 | ||
@@ -519,7 +520,8 @@ int orig_hash_add_if(struct hard_iface *hard_iface, int max_if_num) | |||
519 | struct hlist_node *node; | 520 | struct hlist_node *node; |
520 | struct hlist_head *head; | 521 | struct hlist_head *head; |
521 | struct orig_node *orig_node; | 522 | struct orig_node *orig_node; |
522 | int i, ret; | 523 | uint32_t i; |
524 | int ret; | ||
523 | 525 | ||
524 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on | 526 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on |
525 | * if_num */ | 527 | * if_num */ |
@@ -601,7 +603,8 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num) | |||
601 | struct hlist_head *head; | 603 | struct hlist_head *head; |
602 | struct hard_iface *hard_iface_tmp; | 604 | struct hard_iface *hard_iface_tmp; |
603 | struct orig_node *orig_node; | 605 | struct orig_node *orig_node; |
604 | int i, ret; | 606 | uint32_t i; |
607 | int ret; | ||
605 | 608 | ||
606 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on | 609 | /* resize all orig nodes because orig_node->bcast_own(_sum) depend on |
607 | * if_num */ | 610 | * if_num */ |
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h index cfc1f60a96a1..67765ffef731 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h | |||
@@ -42,7 +42,7 @@ int orig_hash_del_if(struct hard_iface *hard_iface, int max_if_num); | |||
42 | 42 | ||
43 | /* hashfunction to choose an entry in a hash table of given size */ | 43 | /* hashfunction to choose an entry in a hash table of given size */ |
44 | /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ | 44 | /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ |
45 | static inline int choose_orig(const void *data, int32_t size) | 45 | static inline uint32_t choose_orig(const void *data, uint32_t size) |
46 | { | 46 | { |
47 | const unsigned char *key = data; | 47 | const unsigned char *key = data; |
48 | uint32_t hash = 0; | 48 | uint32_t hash = 0; |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index f961cc5eade5..ef24a7205f65 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -39,7 +39,7 @@ void slide_own_bcast_window(struct hard_iface *hard_iface) | |||
39 | struct hlist_head *head; | 39 | struct hlist_head *head; |
40 | struct orig_node *orig_node; | 40 | struct orig_node *orig_node; |
41 | unsigned long *word; | 41 | unsigned long *word; |
42 | int i; | 42 | uint32_t i; |
43 | size_t word_index; | 43 | size_t word_index; |
44 | 44 | ||
45 | for (i = 0; i < hash->size; i++) { | 45 | for (i = 0; i < hash->size; i++) { |
@@ -578,6 +578,7 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) | |||
578 | { | 578 | { |
579 | struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); | 579 | struct bat_priv *bat_priv = netdev_priv(recv_if->soft_iface); |
580 | struct tt_query_packet *tt_query; | 580 | struct tt_query_packet *tt_query; |
581 | uint16_t tt_len; | ||
581 | struct ethhdr *ethhdr; | 582 | struct ethhdr *ethhdr; |
582 | 583 | ||
583 | /* drop packet if it has not necessary minimum size */ | 584 | /* drop packet if it has not necessary minimum size */ |
@@ -616,13 +617,22 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if) | |||
616 | } | 617 | } |
617 | break; | 618 | break; |
618 | case TT_RESPONSE: | 619 | case TT_RESPONSE: |
619 | /* packet needs to be linearized to access the TT changes */ | 620 | if (is_my_mac(tt_query->dst)) { |
620 | if (skb_linearize(skb) < 0) | 621 | /* packet needs to be linearized to access the TT |
621 | goto out; | 622 | * changes */ |
623 | if (skb_linearize(skb) < 0) | ||
624 | goto out; | ||
625 | |||
626 | tt_len = tt_query->tt_data * sizeof(struct tt_change); | ||
627 | |||
628 | /* Ensure we have all the claimed data */ | ||
629 | if (unlikely(skb_headlen(skb) < | ||
630 | sizeof(struct tt_query_packet) + | ||
631 | tt_len)) | ||
632 | goto out; | ||
622 | 633 | ||
623 | if (is_my_mac(tt_query->dst)) | ||
624 | handle_tt_response(bat_priv, tt_query); | 634 | handle_tt_response(bat_priv, tt_query); |
625 | else { | 635 | } else { |
626 | bat_dbg(DBG_TT, bat_priv, | 636 | bat_dbg(DBG_TT, bat_priv, |
627 | "Routing TT_RESPONSE to %pM [%c]\n", | 637 | "Routing TT_RESPONSE to %pM [%c]\n", |
628 | tt_query->dst, | 638 | tt_query->dst, |
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 | ||
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index c7aafc7c5ed4..78b9528bfc2a 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -67,7 +67,7 @@ static struct tt_local_entry *tt_local_hash_find(struct bat_priv *bat_priv, | |||
67 | struct hlist_head *head; | 67 | struct hlist_head *head; |
68 | struct hlist_node *node; | 68 | struct hlist_node *node; |
69 | struct tt_local_entry *tt_local_entry, *tt_local_entry_tmp = NULL; | 69 | struct tt_local_entry *tt_local_entry, *tt_local_entry_tmp = NULL; |
70 | int index; | 70 | uint32_t index; |
71 | 71 | ||
72 | if (!hash) | 72 | if (!hash) |
73 | return NULL; | 73 | return NULL; |
@@ -99,7 +99,7 @@ static struct tt_global_entry *tt_global_hash_find(struct bat_priv *bat_priv, | |||
99 | struct hlist_node *node; | 99 | struct hlist_node *node; |
100 | struct tt_global_entry *tt_global_entry; | 100 | struct tt_global_entry *tt_global_entry; |
101 | struct tt_global_entry *tt_global_entry_tmp = NULL; | 101 | struct tt_global_entry *tt_global_entry_tmp = NULL; |
102 | int index; | 102 | uint32_t index; |
103 | 103 | ||
104 | if (!hash) | 104 | if (!hash) |
105 | return NULL; | 105 | return NULL; |
@@ -314,9 +314,8 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
314 | struct hard_iface *primary_if; | 314 | struct hard_iface *primary_if; |
315 | struct hlist_node *node; | 315 | struct hlist_node *node; |
316 | struct hlist_head *head; | 316 | struct hlist_head *head; |
317 | size_t buf_size, pos; | 317 | uint32_t i; |
318 | char *buff; | 318 | int ret = 0; |
319 | int i, ret = 0; | ||
320 | 319 | ||
321 | primary_if = primary_if_get_selected(bat_priv); | 320 | primary_if = primary_if_get_selected(bat_priv); |
322 | if (!primary_if) { | 321 | if (!primary_if) { |
@@ -337,34 +336,13 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
337 | "announced via TT (TTVN: %u):\n", | 336 | "announced via TT (TTVN: %u):\n", |
338 | net_dev->name, (uint8_t)atomic_read(&bat_priv->ttvn)); | 337 | net_dev->name, (uint8_t)atomic_read(&bat_priv->ttvn)); |
339 | 338 | ||
340 | buf_size = 1; | ||
341 | /* Estimate length for: " * xx:xx:xx:xx:xx:xx\n" */ | ||
342 | for (i = 0; i < hash->size; i++) { | ||
343 | head = &hash->table[i]; | ||
344 | |||
345 | rcu_read_lock(); | ||
346 | __hlist_for_each_rcu(node, head) | ||
347 | buf_size += 29; | ||
348 | rcu_read_unlock(); | ||
349 | } | ||
350 | |||
351 | buff = kmalloc(buf_size, GFP_ATOMIC); | ||
352 | if (!buff) { | ||
353 | ret = -ENOMEM; | ||
354 | goto out; | ||
355 | } | ||
356 | |||
357 | buff[0] = '\0'; | ||
358 | pos = 0; | ||
359 | |||
360 | for (i = 0; i < hash->size; i++) { | 339 | for (i = 0; i < hash->size; i++) { |
361 | head = &hash->table[i]; | 340 | head = &hash->table[i]; |
362 | 341 | ||
363 | rcu_read_lock(); | 342 | rcu_read_lock(); |
364 | hlist_for_each_entry_rcu(tt_local_entry, node, | 343 | hlist_for_each_entry_rcu(tt_local_entry, node, |
365 | head, hash_entry) { | 344 | head, hash_entry) { |
366 | pos += snprintf(buff + pos, 30, " * %pM " | 345 | seq_printf(seq, " * %pM [%c%c%c%c%c]\n", |
367 | "[%c%c%c%c%c]\n", | ||
368 | tt_local_entry->addr, | 346 | tt_local_entry->addr, |
369 | (tt_local_entry->flags & | 347 | (tt_local_entry->flags & |
370 | TT_CLIENT_ROAM ? 'R' : '.'), | 348 | TT_CLIENT_ROAM ? 'R' : '.'), |
@@ -379,9 +357,6 @@ int tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
379 | } | 357 | } |
380 | rcu_read_unlock(); | 358 | rcu_read_unlock(); |
381 | } | 359 | } |
382 | |||
383 | seq_printf(seq, "%s", buff); | ||
384 | kfree(buff); | ||
385 | out: | 360 | out: |
386 | if (primary_if) | 361 | if (primary_if) |
387 | hardif_free_ref(primary_if); | 362 | hardif_free_ref(primary_if); |
@@ -427,7 +402,7 @@ static void tt_local_purge(struct bat_priv *bat_priv) | |||
427 | struct hlist_node *node, *node_tmp; | 402 | struct hlist_node *node, *node_tmp; |
428 | struct hlist_head *head; | 403 | struct hlist_head *head; |
429 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 404 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
430 | int i; | 405 | uint32_t i; |
431 | 406 | ||
432 | for (i = 0; i < hash->size; i++) { | 407 | for (i = 0; i < hash->size; i++) { |
433 | head = &hash->table[i]; | 408 | head = &hash->table[i]; |
@@ -465,7 +440,7 @@ static void tt_local_table_free(struct bat_priv *bat_priv) | |||
465 | struct tt_local_entry *tt_local_entry; | 440 | struct tt_local_entry *tt_local_entry; |
466 | struct hlist_node *node, *node_tmp; | 441 | struct hlist_node *node, *node_tmp; |
467 | struct hlist_head *head; | 442 | struct hlist_head *head; |
468 | int i; | 443 | uint32_t i; |
469 | 444 | ||
470 | if (!bat_priv->tt_local_hash) | 445 | if (!bat_priv->tt_local_hash) |
471 | return; | 446 | return; |
@@ -590,9 +565,8 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
590 | struct hard_iface *primary_if; | 565 | struct hard_iface *primary_if; |
591 | struct hlist_node *node; | 566 | struct hlist_node *node; |
592 | struct hlist_head *head; | 567 | struct hlist_head *head; |
593 | size_t buf_size, pos; | 568 | uint32_t i; |
594 | char *buff; | 569 | int ret = 0; |
595 | int i, ret = 0; | ||
596 | 570 | ||
597 | primary_if = primary_if_get_selected(bat_priv); | 571 | primary_if = primary_if_get_selected(bat_priv); |
598 | if (!primary_if) { | 572 | if (!primary_if) { |
@@ -615,35 +589,13 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
615 | seq_printf(seq, " %-13s %s %-15s %s %s\n", | 589 | seq_printf(seq, " %-13s %s %-15s %s %s\n", |
616 | "Client", "(TTVN)", "Originator", "(Curr TTVN)", "Flags"); | 590 | "Client", "(TTVN)", "Originator", "(Curr TTVN)", "Flags"); |
617 | 591 | ||
618 | buf_size = 1; | ||
619 | /* Estimate length for: " * xx:xx:xx:xx:xx:xx (ttvn) via | ||
620 | * xx:xx:xx:xx:xx:xx (cur_ttvn)\n"*/ | ||
621 | for (i = 0; i < hash->size; i++) { | ||
622 | head = &hash->table[i]; | ||
623 | |||
624 | rcu_read_lock(); | ||
625 | __hlist_for_each_rcu(node, head) | ||
626 | buf_size += 67; | ||
627 | rcu_read_unlock(); | ||
628 | } | ||
629 | |||
630 | buff = kmalloc(buf_size, GFP_ATOMIC); | ||
631 | if (!buff) { | ||
632 | ret = -ENOMEM; | ||
633 | goto out; | ||
634 | } | ||
635 | |||
636 | buff[0] = '\0'; | ||
637 | pos = 0; | ||
638 | |||
639 | for (i = 0; i < hash->size; i++) { | 592 | for (i = 0; i < hash->size; i++) { |
640 | head = &hash->table[i]; | 593 | head = &hash->table[i]; |
641 | 594 | ||
642 | rcu_read_lock(); | 595 | rcu_read_lock(); |
643 | hlist_for_each_entry_rcu(tt_global_entry, node, | 596 | hlist_for_each_entry_rcu(tt_global_entry, node, |
644 | head, hash_entry) { | 597 | head, hash_entry) { |
645 | pos += snprintf(buff + pos, 69, | 598 | seq_printf(seq, " * %pM (%3u) via %pM (%3u) " |
646 | " * %pM (%3u) via %pM (%3u) " | ||
647 | "[%c%c%c]\n", tt_global_entry->addr, | 599 | "[%c%c%c]\n", tt_global_entry->addr, |
648 | tt_global_entry->ttvn, | 600 | tt_global_entry->ttvn, |
649 | tt_global_entry->orig_node->orig, | 601 | tt_global_entry->orig_node->orig, |
@@ -659,9 +611,6 @@ int tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
659 | } | 611 | } |
660 | rcu_read_unlock(); | 612 | rcu_read_unlock(); |
661 | } | 613 | } |
662 | |||
663 | seq_printf(seq, "%s", buff); | ||
664 | kfree(buff); | ||
665 | out: | 614 | out: |
666 | if (primary_if) | 615 | if (primary_if) |
667 | hardif_free_ref(primary_if); | 616 | hardif_free_ref(primary_if); |
@@ -716,7 +665,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, | |||
716 | struct orig_node *orig_node, const char *message) | 665 | struct orig_node *orig_node, const char *message) |
717 | { | 666 | { |
718 | struct tt_global_entry *tt_global_entry; | 667 | struct tt_global_entry *tt_global_entry; |
719 | int i; | 668 | uint32_t i; |
720 | struct hashtable_t *hash = bat_priv->tt_global_hash; | 669 | struct hashtable_t *hash = bat_priv->tt_global_hash; |
721 | struct hlist_node *node, *safe; | 670 | struct hlist_node *node, *safe; |
722 | struct hlist_head *head; | 671 | struct hlist_head *head; |
@@ -735,9 +684,10 @@ void tt_global_del_orig(struct bat_priv *bat_priv, | |||
735 | if (tt_global_entry->orig_node == orig_node) { | 684 | if (tt_global_entry->orig_node == orig_node) { |
736 | bat_dbg(DBG_TT, bat_priv, | 685 | bat_dbg(DBG_TT, bat_priv, |
737 | "Deleting global tt entry %pM " | 686 | "Deleting global tt entry %pM " |
738 | "(via %pM): originator time out\n", | 687 | "(via %pM): %s\n", |
739 | tt_global_entry->addr, | 688 | tt_global_entry->addr, |
740 | tt_global_entry->orig_node->orig); | 689 | tt_global_entry->orig_node->orig, |
690 | message); | ||
741 | hlist_del_rcu(node); | 691 | hlist_del_rcu(node); |
742 | tt_global_entry_free_ref(tt_global_entry); | 692 | tt_global_entry_free_ref(tt_global_entry); |
743 | } | 693 | } |
@@ -754,7 +704,7 @@ static void tt_global_roam_purge(struct bat_priv *bat_priv) | |||
754 | struct hlist_node *node, *node_tmp; | 704 | struct hlist_node *node, *node_tmp; |
755 | struct hlist_head *head; | 705 | struct hlist_head *head; |
756 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 706 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
757 | int i; | 707 | uint32_t i; |
758 | 708 | ||
759 | for (i = 0; i < hash->size; i++) { | 709 | for (i = 0; i < hash->size; i++) { |
760 | head = &hash->table[i]; | 710 | head = &hash->table[i]; |
@@ -788,7 +738,7 @@ static void tt_global_table_free(struct bat_priv *bat_priv) | |||
788 | struct tt_global_entry *tt_global_entry; | 738 | struct tt_global_entry *tt_global_entry; |
789 | struct hlist_node *node, *node_tmp; | 739 | struct hlist_node *node, *node_tmp; |
790 | struct hlist_head *head; | 740 | struct hlist_head *head; |
791 | int i; | 741 | uint32_t i; |
792 | 742 | ||
793 | if (!bat_priv->tt_global_hash) | 743 | if (!bat_priv->tt_global_hash) |
794 | return; | 744 | return; |
@@ -874,7 +824,8 @@ uint16_t tt_global_crc(struct bat_priv *bat_priv, struct orig_node *orig_node) | |||
874 | struct tt_global_entry *tt_global_entry; | 824 | struct tt_global_entry *tt_global_entry; |
875 | struct hlist_node *node; | 825 | struct hlist_node *node; |
876 | struct hlist_head *head; | 826 | struct hlist_head *head; |
877 | int i, j; | 827 | uint32_t i; |
828 | int j; | ||
878 | 829 | ||
879 | for (i = 0; i < hash->size; i++) { | 830 | for (i = 0; i < hash->size; i++) { |
880 | head = &hash->table[i]; | 831 | head = &hash->table[i]; |
@@ -911,7 +862,8 @@ uint16_t tt_local_crc(struct bat_priv *bat_priv) | |||
911 | struct tt_local_entry *tt_local_entry; | 862 | struct tt_local_entry *tt_local_entry; |
912 | struct hlist_node *node; | 863 | struct hlist_node *node; |
913 | struct hlist_head *head; | 864 | struct hlist_head *head; |
914 | int i, j; | 865 | uint32_t i; |
866 | int j; | ||
915 | 867 | ||
916 | for (i = 0; i < hash->size; i++) { | 868 | for (i = 0; i < hash->size; i++) { |
917 | head = &hash->table[i]; | 869 | head = &hash->table[i]; |
@@ -1048,7 +1000,7 @@ static struct sk_buff *tt_response_fill_table(uint16_t tt_len, uint8_t ttvn, | |||
1048 | struct sk_buff *skb = NULL; | 1000 | struct sk_buff *skb = NULL; |
1049 | uint16_t tt_tot, tt_count; | 1001 | uint16_t tt_tot, tt_count; |
1050 | ssize_t tt_query_size = sizeof(struct tt_query_packet); | 1002 | ssize_t tt_query_size = sizeof(struct tt_query_packet); |
1051 | int i; | 1003 | uint32_t i; |
1052 | 1004 | ||
1053 | if (tt_query_size + tt_len > primary_if->soft_iface->mtu) { | 1005 | if (tt_query_size + tt_len > primary_if->soft_iface->mtu) { |
1054 | tt_len = primary_if->soft_iface->mtu - tt_query_size; | 1006 | tt_len = primary_if->soft_iface->mtu - tt_query_size; |
@@ -1187,11 +1139,11 @@ static bool send_other_tt_response(struct bat_priv *bat_priv, | |||
1187 | (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); | 1139 | (tt_request->flags & TT_FULL_TABLE ? 'F' : '.')); |
1188 | 1140 | ||
1189 | /* Let's get the orig node of the REAL destination */ | 1141 | /* Let's get the orig node of the REAL destination */ |
1190 | req_dst_orig_node = get_orig_node(bat_priv, tt_request->dst); | 1142 | req_dst_orig_node = orig_hash_find(bat_priv, tt_request->dst); |
1191 | if (!req_dst_orig_node) | 1143 | if (!req_dst_orig_node) |
1192 | goto out; | 1144 | goto out; |
1193 | 1145 | ||
1194 | res_dst_orig_node = get_orig_node(bat_priv, tt_request->src); | 1146 | res_dst_orig_node = orig_hash_find(bat_priv, tt_request->src); |
1195 | if (!res_dst_orig_node) | 1147 | if (!res_dst_orig_node) |
1196 | goto out; | 1148 | goto out; |
1197 | 1149 | ||
@@ -1317,7 +1269,7 @@ static bool send_my_tt_response(struct bat_priv *bat_priv, | |||
1317 | my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); | 1269 | my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); |
1318 | req_ttvn = tt_request->ttvn; | 1270 | req_ttvn = tt_request->ttvn; |
1319 | 1271 | ||
1320 | orig_node = get_orig_node(bat_priv, tt_request->src); | 1272 | orig_node = orig_hash_find(bat_priv, tt_request->src); |
1321 | if (!orig_node) | 1273 | if (!orig_node) |
1322 | goto out; | 1274 | goto out; |
1323 | 1275 | ||
@@ -1725,7 +1677,7 @@ void tt_free(struct bat_priv *bat_priv) | |||
1725 | * entry */ | 1677 | * entry */ |
1726 | static void tt_local_reset_flags(struct bat_priv *bat_priv, uint16_t flags) | 1678 | static void tt_local_reset_flags(struct bat_priv *bat_priv, uint16_t flags) |
1727 | { | 1679 | { |
1728 | int i; | 1680 | uint32_t i; |
1729 | struct hashtable_t *hash = bat_priv->tt_local_hash; | 1681 | struct hashtable_t *hash = bat_priv->tt_local_hash; |
1730 | struct hlist_head *head; | 1682 | struct hlist_head *head; |
1731 | struct hlist_node *node; | 1683 | struct hlist_node *node; |
@@ -1758,7 +1710,7 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv) | |||
1758 | struct hlist_node *node, *node_tmp; | 1710 | struct hlist_node *node, *node_tmp; |
1759 | struct hlist_head *head; | 1711 | struct hlist_head *head; |
1760 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1712 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
1761 | int i; | 1713 | uint32_t i; |
1762 | 1714 | ||
1763 | if (!hash) | 1715 | if (!hash) |
1764 | return; | 1716 | return; |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index f81a6b668b0c..7445413253ca 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -66,7 +66,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2) | |||
66 | 66 | ||
67 | /* hash function to choose an entry in a hash table of given size */ | 67 | /* hash function to choose an entry in a hash table of given size */ |
68 | /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ | 68 | /* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ |
69 | static int vis_info_choose(const void *data, int size) | 69 | static uint32_t vis_info_choose(const void *data, uint32_t size) |
70 | { | 70 | { |
71 | const struct vis_info *vis_info = data; | 71 | const struct vis_info *vis_info = data; |
72 | const struct vis_packet *packet; | 72 | const struct vis_packet *packet; |
@@ -96,7 +96,7 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, | |||
96 | struct hlist_head *head; | 96 | struct hlist_head *head; |
97 | struct hlist_node *node; | 97 | struct hlist_node *node; |
98 | struct vis_info *vis_info, *vis_info_tmp = NULL; | 98 | struct vis_info *vis_info, *vis_info_tmp = NULL; |
99 | int index; | 99 | uint32_t index; |
100 | 100 | ||
101 | if (!hash) | 101 | if (!hash) |
102 | return NULL; | 102 | return NULL; |
@@ -202,7 +202,8 @@ int vis_seq_print_text(struct seq_file *seq, void *offset) | |||
202 | HLIST_HEAD(vis_if_list); | 202 | HLIST_HEAD(vis_if_list); |
203 | struct if_list_entry *entry; | 203 | struct if_list_entry *entry; |
204 | struct hlist_node *pos, *n; | 204 | struct hlist_node *pos, *n; |
205 | int i, j, ret = 0; | 205 | uint32_t i; |
206 | int j, ret = 0; | ||
206 | int vis_server = atomic_read(&bat_priv->vis_mode); | 207 | int vis_server = atomic_read(&bat_priv->vis_mode); |
207 | size_t buff_pos, buf_size; | 208 | size_t buff_pos, buf_size; |
208 | char *buff; | 209 | char *buff; |
@@ -556,7 +557,8 @@ static int find_best_vis_server(struct bat_priv *bat_priv, | |||
556 | struct hlist_head *head; | 557 | struct hlist_head *head; |
557 | struct orig_node *orig_node; | 558 | struct orig_node *orig_node; |
558 | struct vis_packet *packet; | 559 | struct vis_packet *packet; |
559 | int best_tq = -1, i; | 560 | int best_tq = -1; |
561 | uint32_t i; | ||
560 | 562 | ||
561 | packet = (struct vis_packet *)info->skb_packet->data; | 563 | packet = (struct vis_packet *)info->skb_packet->data; |
562 | 564 | ||
@@ -608,7 +610,8 @@ static int generate_vis_packet(struct bat_priv *bat_priv) | |||
608 | struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; | 610 | struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; |
609 | struct vis_info_entry *entry; | 611 | struct vis_info_entry *entry; |
610 | struct tt_local_entry *tt_local_entry; | 612 | struct tt_local_entry *tt_local_entry; |
611 | int best_tq = -1, i; | 613 | int best_tq = -1; |
614 | uint32_t i; | ||
612 | 615 | ||
613 | info->first_seen = jiffies; | 616 | info->first_seen = jiffies; |
614 | packet->vis_type = atomic_read(&bat_priv->vis_mode); | 617 | packet->vis_type = atomic_read(&bat_priv->vis_mode); |
@@ -696,7 +699,7 @@ unlock: | |||
696 | * held */ | 699 | * held */ |
697 | static void purge_vis_packets(struct bat_priv *bat_priv) | 700 | static void purge_vis_packets(struct bat_priv *bat_priv) |
698 | { | 701 | { |
699 | int i; | 702 | uint32_t i; |
700 | struct hashtable_t *hash = bat_priv->vis_hash; | 703 | struct hashtable_t *hash = bat_priv->vis_hash; |
701 | struct hlist_node *node, *node_tmp; | 704 | struct hlist_node *node, *node_tmp; |
702 | struct hlist_head *head; | 705 | struct hlist_head *head; |
@@ -733,7 +736,7 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv, | |||
733 | struct sk_buff *skb; | 736 | struct sk_buff *skb; |
734 | struct hard_iface *hard_iface; | 737 | struct hard_iface *hard_iface; |
735 | uint8_t dstaddr[ETH_ALEN]; | 738 | uint8_t dstaddr[ETH_ALEN]; |
736 | int i; | 739 | uint32_t i; |
737 | 740 | ||
738 | 741 | ||
739 | packet = (struct vis_packet *)info->skb_packet->data; | 742 | packet = (struct vis_packet *)info->skb_packet->data; |