Merge branch 'tun-debug'
Michal Kubecek says: ==================== tun: debug messages cleanup While testing ethtool output for "strange" devices, I noticed confusing and obviously incorrect message level information for a tun device and sent a quick fix. The result of the upstream discussion was that tun driver would rather deserve a more complex cleanup of the way it handles debug messages. The main problem is that all debugging statements and setting of message level are controlled by TUN_DEBUG macro which is only defined if one edits the source and rebuilds the module, otherwise all DBG1() and tun_debug() statements do nothing. This series drops the TUN_DEBUG switch and replaces custom tun_debug() macro with standard netif_info() so that message level (mask) set and displayed using ethtool works as expected. Some debugging messages are dropped as they only notify about entering a function which can be done easily using ftrace or kprobe. Patch 1 is a trivial fix for compilation warning with W=1. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
425c075dcb
@ -75,35 +75,6 @@
|
|||||||
static void tun_default_link_ksettings(struct net_device *dev,
|
static void tun_default_link_ksettings(struct net_device *dev,
|
||||||
struct ethtool_link_ksettings *cmd);
|
struct ethtool_link_ksettings *cmd);
|
||||||
|
|
||||||
/* Uncomment to enable debugging */
|
|
||||||
/* #define TUN_DEBUG 1 */
|
|
||||||
|
|
||||||
#ifdef TUN_DEBUG
|
|
||||||
static int debug;
|
|
||||||
|
|
||||||
#define tun_debug(level, tun, fmt, args...) \
|
|
||||||
do { \
|
|
||||||
if (tun->debug) \
|
|
||||||
netdev_printk(level, tun->dev, fmt, ##args); \
|
|
||||||
} while (0)
|
|
||||||
#define DBG1(level, fmt, args...) \
|
|
||||||
do { \
|
|
||||||
if (debug == 2) \
|
|
||||||
printk(level fmt, ##args); \
|
|
||||||
} while (0)
|
|
||||||
#else
|
|
||||||
#define tun_debug(level, tun, fmt, args...) \
|
|
||||||
do { \
|
|
||||||
if (0) \
|
|
||||||
netdev_printk(level, tun->dev, fmt, ##args); \
|
|
||||||
} while (0)
|
|
||||||
#define DBG1(level, fmt, args...) \
|
|
||||||
do { \
|
|
||||||
if (0) \
|
|
||||||
printk(level fmt, ##args); \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD)
|
#define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD)
|
||||||
|
|
||||||
/* TUN device flags */
|
/* TUN device flags */
|
||||||
@ -225,9 +196,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;
|
||||||
@ -423,8 +392,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;
|
||||||
@ -438,8 +408,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;
|
||||||
@ -485,8 +455,6 @@ static void tun_flow_cleanup(struct timer_list *t)
|
|||||||
unsigned long count = 0;
|
unsigned long count = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
tun_debug(KERN_INFO, tun, "tun_flow_cleanup\n");
|
|
||||||
|
|
||||||
spin_lock(&tun->lock);
|
spin_lock(&tun->lock);
|
||||||
for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) {
|
for (i = 0; i < TUN_NUM_FLOW_ENTRIES; i++) {
|
||||||
struct tun_flow_entry *e;
|
struct tun_flow_entry *e;
|
||||||
@ -546,8 +514,7 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
|
|||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* Save the hash received in the stack receive path and update the
|
||||||
* Save the hash received in the stack receive path and update the
|
|
||||||
* flow_hash table accordingly.
|
* flow_hash table accordingly.
|
||||||
*/
|
*/
|
||||||
static inline void tun_flow_save_rps_rxhash(struct tun_flow_entry *e, u32 hash)
|
static 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)
|
|||||||
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.
|
||||||
@ -1433,8 +1400,6 @@ static __poll_t tun_chr_poll(struct file *file, poll_table *wait)
|
|||||||
|
|
||||||
sk = tfile->socket.sk;
|
sk = tfile->socket.sk;
|
||||||
|
|
||||||
tun_debug(KERN_INFO, tun, "tun_chr_poll\n");
|
|
||||||
|
|
||||||
poll_wait(file, sk_sleep(sk), wait);
|
poll_wait(file, sk_sleep(sk), wait);
|
||||||
|
|
||||||
if (!ptr_ring_empty(&tfile->tx_ring))
|
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,
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
tun_debug(KERN_INFO, tun, "tun_do_read\n");
|
|
||||||
|
|
||||||
if (!iov_iter_count(to)) {
|
if (!iov_iter_count(to)) {
|
||||||
tun_ptr_free(ptr);
|
tun_ptr_free(ptr);
|
||||||
return 0;
|
return 0;
|
||||||
@ -2851,8 +2814,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
|
|||||||
|
|
||||||
netif_carrier_on(tun->dev);
|
netif_carrier_on(tun->dev);
|
||||||
|
|
||||||
tun_debug(KERN_INFO, tun, "tun_set_iff\n");
|
|
||||||
|
|
||||||
/* Make sure persistent devices do not get stuck in
|
/* Make sure persistent devices do not get stuck in
|
||||||
* xoff state.
|
* xoff state.
|
||||||
*/
|
*/
|
||||||
@ -2883,8 +2844,6 @@ err_free_dev:
|
|||||||
|
|
||||||
static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
|
static void tun_get_iff(struct tun_struct *tun, struct ifreq *ifr)
|
||||||
{
|
{
|
||||||
tun_debug(KERN_INFO, tun, "tun_get_iff\n");
|
|
||||||
|
|
||||||
strcpy(ifr->ifr_name, tun->dev->name);
|
strcpy(ifr->ifr_name, tun->dev->name);
|
||||||
|
|
||||||
ifr->ifr_flags = tun_flags(tun);
|
ifr->ifr_flags = tun_flags(tun);
|
||||||
@ -3108,7 +3067,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;
|
||||||
@ -3129,8 +3088,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:
|
||||||
@ -3148,8 +3107,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:
|
||||||
@ -3161,8 +3120,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:
|
||||||
@ -3174,29 +3133,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;
|
||||||
@ -3219,9 +3177,6 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
|||||||
|
|
||||||
case SIOCSIFHWADDR:
|
case SIOCSIFHWADDR:
|
||||||
/* Set hw address */
|
/* Set hw address */
|
||||||
tun_debug(KERN_DEBUG, tun, "set hw address: %pM\n",
|
|
||||||
ifr.ifr_hwaddr.sa_data);
|
|
||||||
|
|
||||||
ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr, NULL);
|
ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3416,8 +3371,6 @@ static int tun_chr_open(struct inode *inode, struct file * file)
|
|||||||
struct net *net = current->nsproxy->net_ns;
|
struct net *net = current->nsproxy->net_ns;
|
||||||
struct tun_file *tfile;
|
struct tun_file *tfile;
|
||||||
|
|
||||||
DBG1(KERN_INFO, "tunX: tun_chr_open\n");
|
|
||||||
|
|
||||||
tfile = (struct tun_file *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
|
tfile = (struct tun_file *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
|
||||||
&tun_proto, 0);
|
&tun_proto, 0);
|
||||||
if (!tfile)
|
if (!tfile)
|
||||||
@ -3557,20 +3510,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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user