Skip to contentSkip to conversation

can: complete initial namespace support

RFC PATCH In review Oliver Hartkopp 2 participants 2 messages Apr 10, 2017 – Apr 14, 2017

Subsystems (3)
lore
Share & tools
lore

Oliver Hartkopp

author maintainer
#0 lore raw

RFC PATCH v2 1/1 can: complete initial namespace support

The statistics and its proc output was not implemented as per-net in the initial network namespace support by Mario Kicherer (8e8cda6d737d). This patch adds the per-net statistics and fixes a memory leak due to the missing kfree of can_rx_alldev_list in can_pernet_exit().

---
 include/net/netns/can.h |   5 ++
 net/can/af_can.c        |  71 +++++++++++++------------
 net/can/af_can.h        |   9 ----
 net/can/proc.c          | 135 ++++++++++++++++++++++++++----------------------
 4 files changed, 117 insertions(+), 103 deletions(-)
include/net/netns/can.h +5 -0
index e8beba772f1a..574157dbc43a 100644
@@ -8,6 +8,8 @@
 #include <linux/spinlock.h>
 
 struct dev_rcv_lists;
+struct s_stats;
+struct s_pstats;
 
 struct netns_can {
 #if IS_ENABLED(CONFIG_PROC_FS)
@@ -26,6 +28,9 @@ struct netns_can {
 	/* receive filters subscribed for 'all' CAN devices */
 	struct dev_rcv_lists *can_rx_alldev_list;
 	spinlock_t can_rcvlists_lock;
+	struct timer_list can_stattimer;/* timer for statistics update */
+	struct s_stats *can_stats;	/* packet statistics */
+	struct s_pstats *can_pstats;	/* receive list statistics */
 };
 
 #endif /* __NETNS_CAN_H__ */
net/can/af_can.c +39 -32

168 lines not on this page · raw message

net/can/af_can.h +0 -9
index f273c9d9b129..d0ef45bb2a72 100644
@@ -110,18 +110,9 @@ struct s_pstats {
 	unsigned long rcv_entries_max;
 };
 
-/* receive filters subscribed for 'all' CAN devices */
-extern struct dev_rcv_lists can_rx_alldev_list;
-
 /* function prototypes for the CAN networklayer procfs (proc.c) */
 void can_init_proc(struct net *net);
 void can_remove_proc(struct net *net);
 void can_stat_update(unsigned long data);
 
-/* structures and variables from af_can.c needed in proc.c for reading */
-extern struct timer_list can_stattimer;    /* timer for statistics update */
-extern struct s_stats    can_stats;        /* packet statistics */
-extern struct s_pstats   can_pstats;       /* receive list statistics */
-extern struct hlist_head can_rx_dev_list;  /* rx dispatcher structures */
-
 #endif /* AF_CAN_H */
net/can/proc.c +73 -62

233 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw
Quoted 6 lines · Oliver Hartkopp

The statistics and its proc output was not implemented as per-net in the initial network namespace support by Mario Kicherer (8e8cda6d737d). This patch adds the per-net statistics and fixes a memory leak due to the missing kfree of can_rx_alldev_list in can_pernet_exit().

I've split the memleak fix into a seperate patch - added both to can-next.

Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |