| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | | -/* Copyright (C) 2012-2018 B.A.T.M.A.N. contributors: |
|---|
| 2 | +/* Copyright (C) 2012-2020 B.A.T.M.A.N. contributors: |
|---|
| 3 | 3 | * |
|---|
| 4 | 4 | * Martin Hundebøll, Jeppe Ledet-Pedersen |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or |
|---|
| 7 | | - * modify it under the terms of version 2 of the GNU General Public |
|---|
| 8 | | - * License as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | | - * General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 5 | */ |
|---|
| 18 | 6 | |
|---|
| 19 | 7 | #include "network-coding.h" |
|---|
| .. | .. |
|---|
| 38 | 26 | #include <linux/lockdep.h> |
|---|
| 39 | 27 | #include <linux/net.h> |
|---|
| 40 | 28 | #include <linux/netdevice.h> |
|---|
| 29 | +#include <linux/prandom.h> |
|---|
| 41 | 30 | #include <linux/printk.h> |
|---|
| 42 | | -#include <linux/random.h> |
|---|
| 43 | 31 | #include <linux/rculist.h> |
|---|
| 44 | 32 | #include <linux/rcupdate.h> |
|---|
| 45 | 33 | #include <linux/seq_file.h> |
|---|
| .. | .. |
|---|
| 146 | 134 | } |
|---|
| 147 | 135 | |
|---|
| 148 | 136 | /** |
|---|
| 149 | | - * batadv_nc_mesh_init() - initialise coding hash table and start house keeping |
|---|
| 137 | + * batadv_nc_mesh_init() - initialise coding hash table and start housekeeping |
|---|
| 150 | 138 | * @bat_priv: the bat priv with all the soft interface information |
|---|
| 151 | 139 | * |
|---|
| 152 | 140 | * Return: 0 on success or negative error number in case of failure |
|---|
| .. | .. |
|---|
| 234 | 222 | */ |
|---|
| 235 | 223 | static void batadv_nc_node_put(struct batadv_nc_node *nc_node) |
|---|
| 236 | 224 | { |
|---|
| 225 | + if (!nc_node) |
|---|
| 226 | + return; |
|---|
| 227 | + |
|---|
| 237 | 228 | kref_put(&nc_node->refcount, batadv_nc_node_release); |
|---|
| 238 | 229 | } |
|---|
| 239 | 230 | |
|---|
| .. | .. |
|---|
| 258 | 249 | */ |
|---|
| 259 | 250 | static void batadv_nc_path_put(struct batadv_nc_path *nc_path) |
|---|
| 260 | 251 | { |
|---|
| 252 | + if (!nc_path) |
|---|
| 253 | + return; |
|---|
| 254 | + |
|---|
| 261 | 255 | kref_put(&nc_path->refcount, batadv_nc_path_release); |
|---|
| 262 | 256 | } |
|---|
| 263 | 257 | |
|---|
| 264 | 258 | /** |
|---|
| 265 | 259 | * batadv_nc_packet_free() - frees nc packet |
|---|
| 266 | 260 | * @nc_packet: the nc packet to free |
|---|
| 267 | | - * @dropped: whether the packet is freed because is is dropped |
|---|
| 261 | + * @dropped: whether the packet is freed because is dropped |
|---|
| 268 | 262 | */ |
|---|
| 269 | 263 | static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet, |
|---|
| 270 | 264 | bool dropped) |
|---|
| .. | .. |
|---|
| 714 | 708 | } |
|---|
| 715 | 709 | |
|---|
| 716 | 710 | /** |
|---|
| 717 | | - * batadv_nc_worker() - periodic task for house keeping related to network |
|---|
| 711 | + * batadv_nc_worker() - periodic task for housekeeping related to network |
|---|
| 718 | 712 | * coding |
|---|
| 719 | 713 | * @work: kernel work struct |
|---|
| 720 | 714 | */ |
|---|
| .. | .. |
|---|
| 1330 | 1324 | } |
|---|
| 1331 | 1325 | |
|---|
| 1332 | 1326 | /** |
|---|
| 1333 | | - * batadv_nc_skb_src_search() - Loops through the list of neighoring nodes of |
|---|
| 1327 | + * batadv_nc_skb_src_search() - Loops through the list of neighboring nodes of |
|---|
| 1334 | 1328 | * the skb's sender (may be equal to the originator). |
|---|
| 1335 | 1329 | * @bat_priv: the bat priv with all the soft interface information |
|---|
| 1336 | 1330 | * @skb: data skb to forward |
|---|
| .. | .. |
|---|
| 1416 | 1410 | * @neigh_node: next hop to forward packet to |
|---|
| 1417 | 1411 | * @ethhdr: pointer to the ethernet header inside the skb |
|---|
| 1418 | 1412 | * |
|---|
| 1419 | | - * Loops through list of neighboring nodes the next hop has a good connection to |
|---|
| 1420 | | - * (receives OGMs with a sufficient quality). We need to find a neighbor of our |
|---|
| 1421 | | - * next hop that potentially sent a packet which our next hop also received |
|---|
| 1422 | | - * (overheard) and has stored for later decoding. |
|---|
| 1413 | + * Loops through the list of neighboring nodes the next hop has a good |
|---|
| 1414 | + * connection to (receives OGMs with a sufficient quality). We need to find a |
|---|
| 1415 | + * neighbor of our next hop that potentially sent a packet which our next hop |
|---|
| 1416 | + * also received (overheard) and has stored for later decoding. |
|---|
| 1423 | 1417 | * |
|---|
| 1424 | 1418 | * Return: true if the skb was consumed (encoded packet sent) or false otherwise |
|---|
| 1425 | 1419 | */ |
|---|
| .. | .. |
|---|
| 1958 | 1952 | /** |
|---|
| 1959 | 1953 | * batadv_nc_init_debugfs() - create nc folder and related files in debugfs |
|---|
| 1960 | 1954 | * @bat_priv: the bat priv with all the soft interface information |
|---|
| 1961 | | - * |
|---|
| 1962 | | - * Return: 0 on success or negative error number in case of failure |
|---|
| 1963 | 1955 | */ |
|---|
| 1964 | | -int batadv_nc_init_debugfs(struct batadv_priv *bat_priv) |
|---|
| 1956 | +void batadv_nc_init_debugfs(struct batadv_priv *bat_priv) |
|---|
| 1965 | 1957 | { |
|---|
| 1966 | | - struct dentry *nc_dir, *file; |
|---|
| 1958 | + struct dentry *nc_dir; |
|---|
| 1967 | 1959 | |
|---|
| 1968 | 1960 | nc_dir = debugfs_create_dir("nc", bat_priv->debug_dir); |
|---|
| 1969 | | - if (!nc_dir) |
|---|
| 1970 | | - goto out; |
|---|
| 1971 | 1961 | |
|---|
| 1972 | | - file = debugfs_create_u8("min_tq", 0644, nc_dir, &bat_priv->nc.min_tq); |
|---|
| 1973 | | - if (!file) |
|---|
| 1974 | | - goto out; |
|---|
| 1962 | + debugfs_create_u8("min_tq", 0644, nc_dir, &bat_priv->nc.min_tq); |
|---|
| 1975 | 1963 | |
|---|
| 1976 | | - file = debugfs_create_u32("max_fwd_delay", 0644, nc_dir, |
|---|
| 1977 | | - &bat_priv->nc.max_fwd_delay); |
|---|
| 1978 | | - if (!file) |
|---|
| 1979 | | - goto out; |
|---|
| 1964 | + debugfs_create_u32("max_fwd_delay", 0644, nc_dir, |
|---|
| 1965 | + &bat_priv->nc.max_fwd_delay); |
|---|
| 1980 | 1966 | |
|---|
| 1981 | | - file = debugfs_create_u32("max_buffer_time", 0644, nc_dir, |
|---|
| 1982 | | - &bat_priv->nc.max_buffer_time); |
|---|
| 1983 | | - if (!file) |
|---|
| 1984 | | - goto out; |
|---|
| 1985 | | - |
|---|
| 1986 | | - return 0; |
|---|
| 1987 | | - |
|---|
| 1988 | | -out: |
|---|
| 1989 | | - return -ENOMEM; |
|---|
| 1967 | + debugfs_create_u32("max_buffer_time", 0644, nc_dir, |
|---|
| 1968 | + &bat_priv->nc.max_buffer_time); |
|---|
| 1990 | 1969 | } |
|---|
| 1991 | 1970 | #endif |
|---|