Commit 3424170f authored by Michal Kubecek's avatar Michal Kubecek Committed by David S. Miller

tun: replace tun_debug() by netif_info()

The tun driver uses custom macro tun_debug() which is only available if
TUN_DEBUG is set. Replace it by standard netif_ifinfo(). For that purpose,
rename tun_struct::debug to msg_enable and make it u32 and always present.
Finally, make tun_get_msglevel(), tun_set_msglevel() and TUNSETDEBUG ioctl
independent of TUN_DEBUG.
Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 18209434
...@@ -81,7 +81,7 @@ static void tun_default_link_ksettings(struct net_device *dev, ...@@ -81,7 +81,7 @@ static void tun_default_link_ksettings(struct net_device *dev,
#ifdef TUN_DEBUG #ifdef TUN_DEBUG
#define tun_debug(level, tun, fmt, args...) \ #define tun_debug(level, tun, fmt, args...) \
do { \ do { \
if (tun->debug) \ if (tun->msg_enable) \
netdev_printk(level, tun->dev, fmt, ##args); \ netdev_printk(level, tun->dev, fmt, ##args); \
} while (0) } while (0)
#else #else
...@@ -213,9 +213,7 @@ struct tun_struct { ...@@ -213,9 +213,7 @@ struct tun_struct {
struct sock_fprog fprog; struct sock_fprog fprog;
/* protected by rtnl lock */ /* protected by rtnl lock */
bool filter_attached; bool filter_attached;
#ifdef TUN_DEBUG u32 msg_enable;
int debug;
#endif
spinlock_t lock; spinlock_t lock;
struct hlist_head flows[TUN_NUM_FLOW_ENTRIES]; struct hlist_head flows[TUN_NUM_FLOW_ENTRIES];
struct timer_list flow_gc_timer; struct timer_list flow_gc_timer;
...@@ -411,8 +409,9 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun, ...@@ -411,8 +409,9 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
struct tun_flow_entry *e = kmalloc(sizeof(*e), GFP_ATOMIC); struct tun_flow_entry *e = kmalloc(sizeof(*e), GFP_ATOMIC);
if (e) { if (e) {
tun_debug(KERN_INFO, tun, "create flow: hash %u index %u\n", netif_info(tun, tx_queued, tun->dev,
rxhash, queue_index); "create flow: hash %u index %u\n",
rxhash, queue_index);
e->updated = jiffies; e->updated = jiffies;
e->rxhash = rxhash; e->rxhash = rxhash;
e->rps_rxhash = 0; e->rps_rxhash = 0;
...@@ -426,8 +425,8 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun, ...@@ -426,8 +425,8 @@ static struct tun_flow_entry *tun_flow_create(struct tun_struct *tun,
static void tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e) static void tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e)
{ {
tun_debug(KERN_INFO, tun, "delete flow: hash %u index %u\n", netif_info(tun, tx_queued, tun->dev, "delete flow: hash %u index %u\n",
e->rxhash, e->queue_index); e->rxhash, e->queue_index);
hlist_del_rcu(&e->hash_link); hlist_del_rcu(&e->hash_link);
kfree_rcu(e, rcu); kfree_rcu(e, rcu);
--tun->flow_count; --tun->flow_count;
...@@ -1061,7 +1060,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1061,7 +1060,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
if (!rcu_dereference(tun->steering_prog)) if (!rcu_dereference(tun->steering_prog))
tun_automq_xmit(tun, skb); tun_automq_xmit(tun, skb);
tun_debug(KERN_INFO, tun, "tun_net_xmit %d\n", skb->len); netif_info(tun, tx_queued, tun->dev, "%s %d\n", __func__, skb->len);
/* Drop if the filter does not like it. /* Drop if the filter does not like it.
* This is a noop if the filter is disabled. * This is a noop if the filter is disabled.
...@@ -3085,7 +3084,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, ...@@ -3085,7 +3084,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
if (!tun) if (!tun)
goto unlock; goto unlock;
tun_debug(KERN_INFO, tun, "tun_chr_ioctl cmd %u\n", cmd); netif_info(tun, drv, tun->dev, "tun_chr_ioctl cmd %u\n", cmd);
net = dev_net(tun->dev); net = dev_net(tun->dev);
ret = 0; ret = 0;
...@@ -3106,8 +3105,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, ...@@ -3106,8 +3105,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
/* Disable/Enable checksum */ /* Disable/Enable checksum */
/* [unimplemented] */ /* [unimplemented] */
tun_debug(KERN_INFO, tun, "ignored: set checksum %s\n", netif_info(tun, drv, tun->dev, "ignored: set checksum %s\n",
arg ? "disabled" : "enabled"); arg ? "disabled" : "enabled");
break; break;
case TUNSETPERSIST: case TUNSETPERSIST:
...@@ -3125,8 +3124,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, ...@@ -3125,8 +3124,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
do_notify = true; do_notify = true;
} }
tun_debug(KERN_INFO, tun, "persist %s\n", netif_info(tun, drv, tun->dev, "persist %s\n",
arg ? "enabled" : "disabled"); arg ? "enabled" : "disabled");
break; break;
case TUNSETOWNER: case TUNSETOWNER:
...@@ -3138,8 +3137,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, ...@@ -3138,8 +3137,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
} }
tun->owner = owner; tun->owner = owner;
do_notify = true; do_notify = true;
tun_debug(KERN_INFO, tun, "owner set to %u\n", netif_info(tun, drv, tun->dev, "owner set to %u\n",
from_kuid(&init_user_ns, tun->owner)); from_kuid(&init_user_ns, tun->owner));
break; break;
case TUNSETGROUP: case TUNSETGROUP:
...@@ -3151,29 +3150,28 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, ...@@ -3151,29 +3150,28 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
} }
tun->group = group; tun->group = group;
do_notify = true; do_notify = true;
tun_debug(KERN_INFO, tun, "group set to %u\n", netif_info(tun, drv, tun->dev, "group set to %u\n",
from_kgid(&init_user_ns, tun->group)); from_kgid(&init_user_ns, tun->group));
break; break;
case TUNSETLINK: case TUNSETLINK:
/* Only allow setting the type when the interface is down */ /* Only allow setting the type when the interface is down */
if (tun->dev->flags & IFF_UP) { if (tun->dev->flags & IFF_UP) {
tun_debug(KERN_INFO, tun, netif_info(tun, drv, tun->dev,
"Linktype set failed because interface is up\n"); "Linktype set failed because interface is up\n");
ret = -EBUSY; ret = -EBUSY;
} else { } else {
tun->dev->type = (int) arg; tun->dev->type = (int) arg;
tun_debug(KERN_INFO, tun, "linktype set to %d\n", netif_info(tun, drv, tun->dev, "linktype set to %d\n",
tun->dev->type); tun->dev->type);
ret = 0; ret = 0;
} }
break; break;
#ifdef TUN_DEBUG
case TUNSETDEBUG: case TUNSETDEBUG:
tun->debug = arg; tun->msg_enable = (u32)arg;
break; break;
#endif
case TUNSETOFFLOAD: case TUNSETOFFLOAD:
ret = set_offload(tun, arg); ret = set_offload(tun, arg);
break; break;
...@@ -3529,20 +3527,16 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info ...@@ -3529,20 +3527,16 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
static u32 tun_get_msglevel(struct net_device *dev) static u32 tun_get_msglevel(struct net_device *dev)
{ {
#ifdef TUN_DEBUG
struct tun_struct *tun = netdev_priv(dev); struct tun_struct *tun = netdev_priv(dev);
return tun->debug;
#else return tun->msg_enable;
return -EOPNOTSUPP;
#endif
} }
static void tun_set_msglevel(struct net_device *dev, u32 value) static void tun_set_msglevel(struct net_device *dev, u32 value)
{ {
#ifdef TUN_DEBUG
struct tun_struct *tun = netdev_priv(dev); struct tun_struct *tun = netdev_priv(dev);
tun->debug = value;
#endif tun->msg_enable = value;
} }
static int tun_get_coalesce(struct net_device *dev, static int tun_get_coalesce(struct net_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment