translation-table.c (91c2b1a9f680ff105369d49abc7e19ca7efb33e1) translation-table.c (a30e22ca8464c2dc573e0144a972221c2f06c2cd)
1/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich, Antonio Quartulli
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 *

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

1970 unsigned short vid)
1971{
1972 struct batadv_hashtable *hash = bat_priv->tt.global_hash;
1973 struct batadv_tt_common_entry *tt_common;
1974 struct batadv_tt_global_entry *tt_global;
1975 struct hlist_head *head;
1976 uint32_t i, crc_tmp, crc = 0;
1977 uint8_t flags;
1/* Copyright (C) 2007-2014 B.A.T.M.A.N. contributors:
2 *
3 * Marek Lindner, Simon Wunderlich, Antonio Quartulli
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 *

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

1970 unsigned short vid)
1971{
1972 struct batadv_hashtable *hash = bat_priv->tt.global_hash;
1973 struct batadv_tt_common_entry *tt_common;
1974 struct batadv_tt_global_entry *tt_global;
1975 struct hlist_head *head;
1976 uint32_t i, crc_tmp, crc = 0;
1977 uint8_t flags;
1978 __be16 tmp_vid;
1978
1979 for (i = 0; i < hash->size; i++) {
1980 head = &hash->table[i];
1981
1982 rcu_read_lock();
1983 hlist_for_each_entry_rcu(tt_common, head, hash_entry) {
1984 tt_global = container_of(tt_common,
1985 struct batadv_tt_global_entry,

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

2006
2007 /* find out if this global entry is announced by this
2008 * originator
2009 */
2010 if (!batadv_tt_global_entry_has_orig(tt_global,
2011 orig_node))
2012 continue;
2013
1979
1980 for (i = 0; i < hash->size; i++) {
1981 head = &hash->table[i];
1982
1983 rcu_read_lock();
1984 hlist_for_each_entry_rcu(tt_common, head, hash_entry) {
1985 tt_global = container_of(tt_common,
1986 struct batadv_tt_global_entry,

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

2007
2008 /* find out if this global entry is announced by this
2009 * originator
2010 */
2011 if (!batadv_tt_global_entry_has_orig(tt_global,
2012 orig_node))
2013 continue;
2014
2014 crc_tmp = crc32c(0, &tt_common->vid,
2015 sizeof(tt_common->vid));
2015 /* use network order to read the VID: this ensures that
2016 * every node reads the bytes in the same order.
2017 */
2018 tmp_vid = htons(tt_common->vid);
2019 crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
2016
2017 /* compute the CRC on flags that have to be kept in sync
2018 * among nodes
2019 */
2020 flags = tt_common->flags & BATADV_TT_SYNC_MASK;
2021 crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
2022
2023 crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);

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

2041static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
2042 unsigned short vid)
2043{
2044 struct batadv_hashtable *hash = bat_priv->tt.local_hash;
2045 struct batadv_tt_common_entry *tt_common;
2046 struct hlist_head *head;
2047 uint32_t i, crc_tmp, crc = 0;
2048 uint8_t flags;
2020
2021 /* compute the CRC on flags that have to be kept in sync
2022 * among nodes
2023 */
2024 flags = tt_common->flags & BATADV_TT_SYNC_MASK;
2025 crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
2026
2027 crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);

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

2045static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
2046 unsigned short vid)
2047{
2048 struct batadv_hashtable *hash = bat_priv->tt.local_hash;
2049 struct batadv_tt_common_entry *tt_common;
2050 struct hlist_head *head;
2051 uint32_t i, crc_tmp, crc = 0;
2052 uint8_t flags;
2053 __be16 tmp_vid;
2049
2050 for (i = 0; i < hash->size; i++) {
2051 head = &hash->table[i];
2052
2053 rcu_read_lock();
2054 hlist_for_each_entry_rcu(tt_common, head, hash_entry) {
2055 /* compute the CRC only for entries belonging to the
2056 * VLAN identified by vid
2057 */
2058 if (tt_common->vid != vid)
2059 continue;
2060
2061 /* not yet committed clients have not to be taken into
2062 * account while computing the CRC
2063 */
2064 if (tt_common->flags & BATADV_TT_CLIENT_NEW)
2065 continue;
2066
2054
2055 for (i = 0; i < hash->size; i++) {
2056 head = &hash->table[i];
2057
2058 rcu_read_lock();
2059 hlist_for_each_entry_rcu(tt_common, head, hash_entry) {
2060 /* compute the CRC only for entries belonging to the
2061 * VLAN identified by vid
2062 */
2063 if (tt_common->vid != vid)
2064 continue;
2065
2066 /* not yet committed clients have not to be taken into
2067 * account while computing the CRC
2068 */
2069 if (tt_common->flags & BATADV_TT_CLIENT_NEW)
2070 continue;
2071
2067 crc_tmp = crc32c(0, &tt_common->vid,
2068 sizeof(tt_common->vid));
2072 /* use network order to read the VID: this ensures that
2073 * every node reads the bytes in the same order.
2074 */
2075 tmp_vid = htons(tt_common->vid);
2076 crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
2069
2070 /* compute the CRC on flags that have to be kept in sync
2071 * among nodes
2072 */
2073 flags = tt_common->flags & BATADV_TT_SYNC_MASK;
2074 crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
2075
2076 crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);

--- 1536 unchanged lines hidden ---
2077
2078 /* compute the CRC on flags that have to be kept in sync
2079 * among nodes
2080 */
2081 flags = tt_common->flags & BATADV_TT_SYNC_MASK;
2082 crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
2083
2084 crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);

--- 1536 unchanged lines hidden ---