aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/hard-interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r--net/batman-adv/hard-interface.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index dfbfccc9fe4..db7aacf1e09 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -46,7 +46,7 @@ void hardif_free_rcu(struct rcu_head *rcu)
46 kfree(hard_iface); 46 kfree(hard_iface);
47} 47}
48 48
49struct hard_iface *hardif_get_by_netdev(struct net_device *net_dev) 49struct hard_iface *hardif_get_by_netdev(const struct net_device *net_dev)
50{ 50{
51 struct hard_iface *hard_iface; 51 struct hard_iface *hard_iface;
52 52
@@ -64,7 +64,7 @@ out:
64 return hard_iface; 64 return hard_iface;
65} 65}
66 66
67static int is_valid_iface(struct net_device *net_dev) 67static int is_valid_iface(const struct net_device *net_dev)
68{ 68{
69 if (net_dev->flags & IFF_LOOPBACK) 69 if (net_dev->flags & IFF_LOOPBACK)
70 return 0; 70 return 0;
@@ -86,7 +86,7 @@ static int is_valid_iface(struct net_device *net_dev)
86 return 1; 86 return 1;
87} 87}
88 88
89static struct hard_iface *hardif_get_active(struct net_device *soft_iface) 89static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
90{ 90{
91 struct hard_iface *hard_iface; 91 struct hard_iface *hard_iface;
92 92
@@ -138,7 +138,7 @@ static void primary_if_select(struct bat_priv *bat_priv,
138 if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount)) 138 if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
139 new_hard_iface = NULL; 139 new_hard_iface = NULL;
140 140
141 curr_hard_iface = bat_priv->primary_if; 141 curr_hard_iface = rcu_dereference_protected(bat_priv->primary_if, 1);
142 rcu_assign_pointer(bat_priv->primary_if, new_hard_iface); 142 rcu_assign_pointer(bat_priv->primary_if, new_hard_iface);
143 143
144 if (curr_hard_iface) 144 if (curr_hard_iface)
@@ -152,15 +152,9 @@ static void primary_if_select(struct bat_priv *bat_priv,
152 batman_packet->ttl = TTL; 152 batman_packet->ttl = TTL;
153 153
154 primary_if_update_addr(bat_priv); 154 primary_if_update_addr(bat_priv);
155
156 /***
157 * hacky trick to make sure that we send the TT information via
158 * our new primary interface
159 */
160 atomic_set(&bat_priv->tt_local_changed, 1);
161} 155}
162 156
163static bool hardif_is_iface_up(struct hard_iface *hard_iface) 157static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
164{ 158{
165 if (hard_iface->net_dev->flags & IFF_UP) 159 if (hard_iface->net_dev->flags & IFF_UP)
166 return true; 160 return true;
@@ -176,9 +170,9 @@ static void update_mac_addresses(struct hard_iface *hard_iface)
176 hard_iface->net_dev->dev_addr, ETH_ALEN); 170 hard_iface->net_dev->dev_addr, ETH_ALEN);
177} 171}
178 172
179static void check_known_mac_addr(struct net_device *net_dev) 173static void check_known_mac_addr(const struct net_device *net_dev)
180{ 174{
181 struct hard_iface *hard_iface; 175 const struct hard_iface *hard_iface;
182 176
183 rcu_read_lock(); 177 rcu_read_lock();
184 list_for_each_entry_rcu(hard_iface, &hardif_list, list) { 178 list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
@@ -204,8 +198,8 @@ static void check_known_mac_addr(struct net_device *net_dev)
204 198
205int hardif_min_mtu(struct net_device *soft_iface) 199int hardif_min_mtu(struct net_device *soft_iface)
206{ 200{
207 struct bat_priv *bat_priv = netdev_priv(soft_iface); 201 const struct bat_priv *bat_priv = netdev_priv(soft_iface);
208 struct hard_iface *hard_iface; 202 const struct hard_iface *hard_iface;
209 /* allow big frames if all devices are capable to do so 203 /* allow big frames if all devices are capable to do so
210 * (have MTU > 1500 + BAT_HEADER_LEN) */ 204 * (have MTU > 1500 + BAT_HEADER_LEN) */
211 int min_mtu = ETH_DATA_LEN; 205 int min_mtu = ETH_DATA_LEN;
@@ -285,7 +279,8 @@ static void hardif_deactivate_interface(struct hard_iface *hard_iface)
285 update_min_mtu(hard_iface->soft_iface); 279 update_min_mtu(hard_iface->soft_iface);
286} 280}
287 281
288int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name) 282int hardif_enable_interface(struct hard_iface *hard_iface,
283 const char *iface_name)
289{ 284{
290 struct bat_priv *bat_priv; 285 struct bat_priv *bat_priv;
291 struct batman_packet *batman_packet; 286 struct batman_packet *batman_packet;
@@ -336,10 +331,11 @@ int hardif_enable_interface(struct hard_iface *hard_iface, char *iface_name)
336 batman_packet = (struct batman_packet *)(hard_iface->packet_buff); 331 batman_packet = (struct batman_packet *)(hard_iface->packet_buff);
337 batman_packet->packet_type = BAT_PACKET; 332 batman_packet->packet_type = BAT_PACKET;
338 batman_packet->version = COMPAT_VERSION; 333 batman_packet->version = COMPAT_VERSION;
339 batman_packet->flags = 0; 334 batman_packet->flags = NO_FLAGS;
340 batman_packet->ttl = 2; 335 batman_packet->ttl = 2;
341 batman_packet->tq = TQ_MAX_VALUE; 336 batman_packet->tq = TQ_MAX_VALUE;
342 batman_packet->num_tt = 0; 337 batman_packet->tt_num_changes = 0;
338 batman_packet->ttvn = 0;
343 339
344 hard_iface->if_num = bat_priv->num_ifaces; 340 hard_iface->if_num = bat_priv->num_ifaces;
345 bat_priv->num_ifaces++; 341 bat_priv->num_ifaces++;
@@ -458,7 +454,7 @@ static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
458 454
459 dev_hold(net_dev); 455 dev_hold(net_dev);
460 456
461 hard_iface = kmalloc(sizeof(struct hard_iface), GFP_ATOMIC); 457 hard_iface = kmalloc(sizeof(*hard_iface), GFP_ATOMIC);
462 if (!hard_iface) { 458 if (!hard_iface) {
463 pr_err("Can't add interface (%s): out of memory\n", 459 pr_err("Can't add interface (%s): out of memory\n",
464 net_dev->name); 460 net_dev->name);
@@ -522,7 +518,7 @@ void hardif_remove_interfaces(void)
522static int hard_if_event(struct notifier_block *this, 518static int hard_if_event(struct notifier_block *this,
523 unsigned long event, void *ptr) 519 unsigned long event, void *ptr)
524{ 520{
525 struct net_device *net_dev = (struct net_device *)ptr; 521 struct net_device *net_dev = ptr;
526 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); 522 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
527 struct hard_iface *primary_if = NULL; 523 struct hard_iface *primary_if = NULL;
528 struct bat_priv *bat_priv; 524 struct bat_priv *bat_priv;
@@ -567,7 +563,7 @@ static int hard_if_event(struct notifier_block *this,
567 break; 563 break;
568 default: 564 default:
569 break; 565 break;
570 }; 566 }
571 567
572hardif_put: 568hardif_put:
573 hardif_free_ref(hard_iface); 569 hardif_free_ref(hard_iface);
@@ -658,6 +654,14 @@ static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
658 case BAT_VIS: 654 case BAT_VIS:
659 ret = recv_vis_packet(skb, hard_iface); 655 ret = recv_vis_packet(skb, hard_iface);
660 break; 656 break;
657 /* Translation table query (request or response) */
658 case BAT_TT_QUERY:
659 ret = recv_tt_query(skb, hard_iface);
660 break;
661 /* Roaming advertisement */
662 case BAT_ROAM_ADV:
663 ret = recv_roam_adv(skb, hard_iface);
664 break;
661 default: 665 default:
662 ret = NET_RX_DROP; 666 ret = NET_RX_DROP;
663 } 667 }