hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/batman-adv/network-coding.c
....@@ -1,19 +1,7 @@
11 // 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:
33 *
44 * 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/>.
175 */
186
197 #include "network-coding.h"
....@@ -38,8 +26,8 @@
3826 #include <linux/lockdep.h>
3927 #include <linux/net.h>
4028 #include <linux/netdevice.h>
29
+#include <linux/prandom.h>
4130 #include <linux/printk.h>
42
-#include <linux/random.h>
4331 #include <linux/rculist.h>
4432 #include <linux/rcupdate.h>
4533 #include <linux/seq_file.h>
....@@ -146,7 +134,7 @@
146134 }
147135
148136 /**
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
150138 * @bat_priv: the bat priv with all the soft interface information
151139 *
152140 * Return: 0 on success or negative error number in case of failure
....@@ -234,6 +222,9 @@
234222 */
235223 static void batadv_nc_node_put(struct batadv_nc_node *nc_node)
236224 {
225
+ if (!nc_node)
226
+ return;
227
+
237228 kref_put(&nc_node->refcount, batadv_nc_node_release);
238229 }
239230
....@@ -258,13 +249,16 @@
258249 */
259250 static void batadv_nc_path_put(struct batadv_nc_path *nc_path)
260251 {
252
+ if (!nc_path)
253
+ return;
254
+
261255 kref_put(&nc_path->refcount, batadv_nc_path_release);
262256 }
263257
264258 /**
265259 * batadv_nc_packet_free() - frees nc packet
266260 * @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
268262 */
269263 static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet,
270264 bool dropped)
....@@ -714,7 +708,7 @@
714708 }
715709
716710 /**
717
- * batadv_nc_worker() - periodic task for house keeping related to network
711
+ * batadv_nc_worker() - periodic task for housekeeping related to network
718712 * coding
719713 * @work: kernel work struct
720714 */
....@@ -1330,7 +1324,7 @@
13301324 }
13311325
13321326 /**
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
13341328 * the skb's sender (may be equal to the originator).
13351329 * @bat_priv: the bat priv with all the soft interface information
13361330 * @skb: data skb to forward
....@@ -1416,10 +1410,10 @@
14161410 * @neigh_node: next hop to forward packet to
14171411 * @ethhdr: pointer to the ethernet header inside the skb
14181412 *
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.
14231417 *
14241418 * Return: true if the skb was consumed (encoded packet sent) or false otherwise
14251419 */
....@@ -1958,34 +1952,19 @@
19581952 /**
19591953 * batadv_nc_init_debugfs() - create nc folder and related files in debugfs
19601954 * @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
19631955 */
1964
-int batadv_nc_init_debugfs(struct batadv_priv *bat_priv)
1956
+void batadv_nc_init_debugfs(struct batadv_priv *bat_priv)
19651957 {
1966
- struct dentry *nc_dir, *file;
1958
+ struct dentry *nc_dir;
19671959
19681960 nc_dir = debugfs_create_dir("nc", bat_priv->debug_dir);
1969
- if (!nc_dir)
1970
- goto out;
19711961
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);
19751963
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);
19801966
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);
19901969 }
19911970 #endif