7575static void tun_default_link_ksettings (struct net_device * dev ,
7676 struct ethtool_link_ksettings * cmd );
7777
78- /* Uncomment to enable debugging */
79- /* #define TUN_DEBUG 1 */
80-
81- #ifdef TUN_DEBUG
82- static int debug ;
83-
84- #define tun_debug (level , tun , fmt , args ...) \
85- do { \
86- if (tun->debug) \
87- netdev_printk(level, tun->dev, fmt, ##args); \
88- } while (0)
89- #define DBG1 (level , fmt , args ...) \
90- do { \
91- if (debug == 2) \
92- printk(level fmt, ##args); \
93- } while (0)
94- #else
95- #define tun_debug (level , tun , fmt , args ...) \
96- do { \
97- if (0) \
98- netdev_printk(level, tun->dev, fmt, ##args); \
99- } while (0)
100- #define DBG1 (level , fmt , args ...) \
101- do { \
102- if (0) \
103- printk(level fmt, ##args); \
104- } while (0)
105- #endif
106-
10778#define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD)
10879
10980/* TUN device flags */
@@ -225,9 +196,7 @@ struct tun_struct {
225196 struct sock_fprog fprog ;
226197 /* protected by rtnl lock */
227198 bool filter_attached ;
228- #ifdef TUN_DEBUG
229- int debug ;
230- #endif
199+ u32 msg_enable ;
231200 spinlock_t lock ;
232201 struct hlist_head flows [TUN_NUM_FLOW_ENTRIES ];
233202 struct timer_list flow_gc_timer ;
@@ -423,8 +392,9 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
423392 struct tun_flow_entry * e = kmalloc (sizeof (* e ), GFP_ATOMIC );
424393
425394 if (e ) {
426- tun_debug (KERN_INFO , tun , "create flow: hash %u index %u\n" ,
427- rxhash , queue_index );
395+ netif_info (tun , tx_queued , tun -> dev ,
396+ "create flow: hash %u index %u\n" ,
397+ rxhash , queue_index );
428398 e -> updated = jiffies ;
429399 e -> rxhash = rxhash ;
430400 e -> rps_rxhash = 0 ;
@@ -438,8 +408,8 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
438408
439409static void tun_flow_delete (struct tun_struct * tun , struct tun_flow_entry * e )
440410{
441- tun_debug ( KERN_INFO , tun , "delete flow: hash %u index %u\n" ,
442- e -> rxhash , e -> queue_index );
411+ netif_info ( tun , tx_queued , tun -> dev , "delete flow: hash %u index %u\n" ,
412+ e -> rxhash , e -> queue_index );
443413 hlist_del_rcu (& e -> hash_link );
444414 kfree_rcu (e , rcu );
445415 -- tun -> flow_count ;
@@ -485,8 +455,6 @@ static void tun_flow_cleanup(struct timer_list *t)
485455 unsigned long count = 0 ;
486456 int i ;
487457
488- tun_debug (KERN_INFO , tun , "tun_flow_cleanup\n" );
489-
490458 spin_lock (& tun -> lock );
491459 for (i = 0 ; i < TUN_NUM_FLOW_ENTRIES ; i ++ ) {
492460 struct tun_flow_entry * e ;
@@ -546,8 +514,7 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
546514 rcu_read_unlock ();
547515}
548516
549- /**
550- * Save the hash received in the stack receive path and update the
517+ /* Save the hash received in the stack receive path and update the
551518 * flow_hash table accordingly.
552519 */
553520static inline void tun_flow_save_rps_rxhash (struct tun_flow_entry * e , u32 hash )
@@ -1076,7 +1043,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
10761043 if (!rcu_dereference (tun -> steering_prog ))
10771044 tun_automq_xmit (tun , skb );
10781045
1079- tun_debug ( KERN_INFO , tun , "tun_net_xmit %d\n" , skb -> len );
1046+ netif_info ( tun , tx_queued , tun -> dev , "%s %d\n" , __func__ , skb -> len );
10801047
10811048 /* Drop if the filter does not like it.
10821049 * This is a noop if the filter is disabled.
@@ -1433,8 +1400,6 @@ static __poll_t tun_chr_poll(struct file *file, poll_table *wait)
14331400
14341401 sk = tfile -> socket .sk ;
14351402
1436- tun_debug (KERN_INFO , tun , "tun_chr_poll\n" );
1437-
14381403 poll_wait (file , sk_sleep (sk ), wait );
14391404
14401405 if (!ptr_ring_empty (& tfile -> tx_ring ))
@@ -2205,8 +2170,6 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
22052170 ssize_t ret ;
22062171 int err ;
22072172
2208- tun_debug (KERN_INFO , tun , "tun_do_read\n" );
2209-
22102173 if (!iov_iter_count (to )) {
22112174 tun_ptr_free (ptr );
22122175 return 0 ;
@@ -2851,8 +2814,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
28512814
28522815 netif_carrier_on (tun -> dev );
28532816
2854- tun_debug (KERN_INFO , tun , "tun_set_iff\n" );
2855-
28562817 /* Make sure persistent devices do not get stuck in
28572818 * xoff state.
28582819 */
@@ -2883,8 +2844,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
28832844
28842845static void tun_get_iff (struct tun_struct * tun , struct ifreq * ifr )
28852846{
2886- tun_debug (KERN_INFO , tun , "tun_get_iff\n" );
2887-
28882847 strcpy (ifr -> ifr_name , tun -> dev -> name );
28892848
28902849 ifr -> ifr_flags = tun_flags (tun );
@@ -3108,7 +3067,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
31083067 if (!tun )
31093068 goto unlock ;
31103069
3111- tun_debug ( KERN_INFO , tun , "tun_chr_ioctl cmd %u\n" , cmd );
3070+ netif_info ( tun , drv , tun -> dev , "tun_chr_ioctl cmd %u\n" , cmd );
31123071
31133072 net = dev_net (tun -> dev );
31143073 ret = 0 ;
@@ -3129,8 +3088,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
31293088 /* Disable/Enable checksum */
31303089
31313090 /* [unimplemented] */
3132- tun_debug ( KERN_INFO , tun , "ignored: set checksum %s\n" ,
3133- arg ? "disabled" : "enabled" );
3091+ netif_info ( tun , drv , tun -> dev , "ignored: set checksum %s\n" ,
3092+ arg ? "disabled" : "enabled" );
31343093 break ;
31353094
31363095 case TUNSETPERSIST :
@@ -3148,8 +3107,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
31483107 do_notify = true;
31493108 }
31503109
3151- tun_debug ( KERN_INFO , tun , "persist %s\n" ,
3152- arg ? "enabled" : "disabled" );
3110+ netif_info ( tun , drv , tun -> dev , "persist %s\n" ,
3111+ arg ? "enabled" : "disabled" );
31533112 break ;
31543113
31553114 case TUNSETOWNER :
@@ -3161,8 +3120,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
31613120 }
31623121 tun -> owner = owner ;
31633122 do_notify = true;
3164- tun_debug ( KERN_INFO , tun , "owner set to %u\n" ,
3165- from_kuid (& init_user_ns , tun -> owner ));
3123+ netif_info ( tun , drv , tun -> dev , "owner set to %u\n" ,
3124+ from_kuid (& init_user_ns , tun -> owner ));
31663125 break ;
31673126
31683127 case TUNSETGROUP :
@@ -3174,29 +3133,28 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
31743133 }
31753134 tun -> group = group ;
31763135 do_notify = true;
3177- tun_debug ( KERN_INFO , tun , "group set to %u\n" ,
3178- from_kgid (& init_user_ns , tun -> group ));
3136+ netif_info ( tun , drv , tun -> dev , "group set to %u\n" ,
3137+ from_kgid (& init_user_ns , tun -> group ));
31793138 break ;
31803139
31813140 case TUNSETLINK :
31823141 /* Only allow setting the type when the interface is down */
31833142 if (tun -> dev -> flags & IFF_UP ) {
3184- tun_debug ( KERN_INFO , tun ,
3185- "Linktype set failed because interface is up\n" );
3143+ netif_info ( tun , drv , tun -> dev ,
3144+ "Linktype set failed because interface is up\n" );
31863145 ret = - EBUSY ;
31873146 } else {
31883147 tun -> dev -> type = (int ) arg ;
3189- tun_debug ( KERN_INFO , tun , "linktype set to %d\n" ,
3190- tun -> dev -> type );
3148+ netif_info ( tun , drv , tun -> dev , "linktype set to %d\n" ,
3149+ tun -> dev -> type );
31913150 ret = 0 ;
31923151 }
31933152 break ;
31943153
3195- #ifdef TUN_DEBUG
31963154 case TUNSETDEBUG :
3197- tun -> debug = arg ;
3155+ tun -> msg_enable = ( u32 ) arg ;
31983156 break ;
3199- #endif
3157+
32003158 case TUNSETOFFLOAD :
32013159 ret = set_offload (tun , arg );
32023160 break ;
@@ -3219,9 +3177,6 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
32193177
32203178 case SIOCSIFHWADDR :
32213179 /* Set hw address */
3222- tun_debug (KERN_DEBUG , tun , "set hw address: %pM\n" ,
3223- ifr .ifr_hwaddr .sa_data );
3224-
32253180 ret = dev_set_mac_address (tun -> dev , & ifr .ifr_hwaddr , NULL );
32263181 break ;
32273182
@@ -3416,8 +3371,6 @@ static int tun_chr_open(struct inode *inode, struct file * file)
34163371 struct net * net = current -> nsproxy -> net_ns ;
34173372 struct tun_file * tfile ;
34183373
3419- DBG1 (KERN_INFO , "tunX: tun_chr_open\n" );
3420-
34213374 tfile = (struct tun_file * )sk_alloc (net , AF_UNSPEC , GFP_KERNEL ,
34223375 & tun_proto , 0 );
34233376 if (!tfile )
@@ -3557,20 +3510,16 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
35573510
35583511static u32 tun_get_msglevel (struct net_device * dev )
35593512{
3560- #ifdef TUN_DEBUG
35613513 struct tun_struct * tun = netdev_priv (dev );
3562- return tun -> debug ;
3563- #else
3564- return - EOPNOTSUPP ;
3565- #endif
3514+
3515+ return tun -> msg_enable ;
35663516}
35673517
35683518static void tun_set_msglevel (struct net_device * dev , u32 value )
35693519{
3570- #ifdef TUN_DEBUG
35713520 struct tun_struct * tun = netdev_priv (dev );
3572- tun -> debug = value ;
3573- #endif
3521+
3522+ tun -> msg_enable = value ;
35743523}
35753524
35763525static int tun_get_coalesce (struct net_device * dev ,
0 commit comments