@@ -839,12 +839,16 @@ void term_lockless_list(lockless_list *l, u_int8_t free_memory)
839
839
/* ********************************** */
840
840
841
841
pf_ring_net * netns_lookup (struct net * net ) {
842
- pf_ring_net * pf_net = net_generic (net , pf_ring_net_id );
842
+ pf_ring_net * netns = net_generic (net , pf_ring_net_id );
843
843
844
- if (pf_net == NULL )
845
- printk ("[PF_RING] Namespace lookup failure\n" );
844
+ if (netns == NULL ) {
845
+ printk ("[PF_RING] Namespace lookup failure (not found)\n" );
846
+ } else if (netns -> magic != RING_MAGIC_VALUE ) {
847
+ printk ("[PF_RING] Namespace lookup failure (corruption detected)\n" );
848
+ netns = NULL ;
849
+ }
846
850
847
- return pf_net ;
851
+ return netns ;
848
852
}
849
853
850
854
/* ********************************** */
@@ -859,6 +863,9 @@ static inline int device_net_eq(pf_ring_device *dev_ptr, struct net *net) {
859
863
pf_ring_net * netns_add (struct net * net ) {
860
864
pf_ring_net * netns = net_generic (net , pf_ring_net_id );
861
865
866
+ memset (netns , 0 , sizeof (pf_ring_net ));
867
+ netns -> magic = RING_MAGIC_VALUE ;
868
+
862
869
netns -> net = net ;
863
870
ring_proc_init (netns );
864
871
@@ -9152,7 +9159,7 @@ static struct notifier_block ring_netdev_notifier = {
9152
9159
9153
9160
static int __net_init ring_net_init (struct net * net )
9154
9161
{
9155
- debug_printk (1 , "init network namespace [net=%pK ]\n" , net );
9162
+ debug_printk (1 , "init network namespace [net=%p ]\n" , net );
9156
9163
netns_add (net );
9157
9164
return 0 ;
9158
9165
}
@@ -9161,7 +9168,7 @@ static int __net_init ring_net_init(struct net *net)
9161
9168
9162
9169
static void __net_exit ring_net_exit (struct net * net )
9163
9170
{
9164
- debug_printk (1 , "exit network namespace [net=%pK ]\n" , net );
9171
+ debug_printk (1 , "exit network namespace [net=%p ]\n" , net );
9165
9172
netns_remove (net );
9166
9173
}
9167
9174
0 commit comments