* [PATCH 6/27] cw1200: queue: Use setup_timer
From: Julia Lawall @ 2014-12-26 14:35 UTC (permalink / raw)
To: Solomon Peachy
Cc: kernel-janitors, Kalle Valo, linux-wireless, netdev, linux-kernel
In-Reply-To: <1419604558-29743-1-git-send-email-Julia.Lawall@lip6.fr>
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.
A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression t,f,d;
@@
-init_timer(&t);
+setup_timer(&t,f,d);
-t.data = d;
-t.function = f;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/wireless/cw1200/queue.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/wireless/cw1200/queue.c b/drivers/net/wireless/cw1200/queue.c
index 9c3925f..0ba5ef9 100644
--- a/drivers/net/wireless/cw1200/queue.c
+++ b/drivers/net/wireless/cw1200/queue.c
@@ -179,9 +179,7 @@ int cw1200_queue_init(struct cw1200_queue *queue,
INIT_LIST_HEAD(&queue->pending);
INIT_LIST_HEAD(&queue->free_pool);
spin_lock_init(&queue->lock);
- init_timer(&queue->gc);
- queue->gc.data = (unsigned long)queue;
- queue->gc.function = cw1200_queue_gc;
+ setup_timer(&queue->gc, cw1200_queue_gc, (unsigned long)queue);
queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity,
GFP_KERNEL);
^ permalink raw reply related
* [PATCH 7/27] cw1200: main: Use setup_timer
From: Julia Lawall @ 2014-12-26 14:35 UTC (permalink / raw)
To: Solomon Peachy
Cc: kernel-janitors, Kalle Valo, linux-wireless, netdev, linux-kernel
In-Reply-To: <1419604558-29743-1-git-send-email-Julia.Lawall@lip6.fr>
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.
A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression t,f,d;
@@
-init_timer(&t);
+setup_timer(&t,f,d);
-t.data = d;
-t.function = f;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/wireless/cw1200/main.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/cw1200/main.c b/drivers/net/wireless/cw1200/main.c
index 3e78cc3..fa965ee 100644
--- a/drivers/net/wireless/cw1200/main.c
+++ b/drivers/net/wireless/cw1200/main.c
@@ -374,9 +374,8 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr,
INIT_WORK(&priv->update_filtering_work, cw1200_update_filtering_work);
INIT_WORK(&priv->set_beacon_wakeup_period_work,
cw1200_set_beacon_wakeup_period_work);
- init_timer(&priv->mcast_timeout);
- priv->mcast_timeout.data = (unsigned long)priv;
- priv->mcast_timeout.function = cw1200_mcast_timeout;
+ setup_timer(&priv->mcast_timeout, cw1200_mcast_timeout,
+ (unsigned long)priv);
if (cw1200_queue_stats_init(&priv->tx_queue_stats,
CW1200_LINK_ID_MAX,
^ permalink raw reply related
* [PATCH 8/27] wireless: cw1200: Use setup_timer
From: Julia Lawall @ 2014-12-26 14:35 UTC (permalink / raw)
To: Solomon Peachy
Cc: kernel-janitors, Kalle Valo, linux-wireless, netdev, linux-kernel
In-Reply-To: <1419604558-29743-1-git-send-email-Julia.Lawall@lip6.fr>
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.
A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression t,f,d;
@@
-init_timer(&t);
+setup_timer(&t,f,d);
-t.data = d;
-t.function = f;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/wireless/cw1200/pm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/cw1200/pm.c b/drivers/net/wireless/cw1200/pm.c
index 6907c8f..d2202ae 100644
--- a/drivers/net/wireless/cw1200/pm.c
+++ b/drivers/net/wireless/cw1200/pm.c
@@ -101,9 +101,8 @@ int cw1200_pm_init(struct cw1200_pm_state *pm,
{
spin_lock_init(&pm->lock);
- init_timer(&pm->stay_awake);
- pm->stay_awake.data = (unsigned long)pm;
- pm->stay_awake.function = cw1200_pm_stay_awake_tmo;
+ setup_timer(&pm->stay_awake, cw1200_pm_stay_awake_tmo,
+ (unsigned long)pm);
return 0;
}
^ permalink raw reply related
* [PATCH 3/27] atl1e: Use setup_timer
From: Julia Lawall @ 2014-12-26 14:35 UTC (permalink / raw)
To: Jay Cliburn; +Cc: kernel-janitors, Chris Snook, netdev, linux-kernel
In-Reply-To: <1419604558-29743-1-git-send-email-Julia.Lawall@lip6.fr>
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.
A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression t,f,d;
@@
-init_timer(&t);
+setup_timer(&t,f,d);
-t.function = f;
-t.data = d;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 2326579..c88abf5 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -2373,9 +2373,8 @@ static int atl1e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netif_napi_add(netdev, &adapter->napi, atl1e_clean, 64);
- init_timer(&adapter->phy_config_timer);
- adapter->phy_config_timer.function = atl1e_phy_config;
- adapter->phy_config_timer.data = (unsigned long) adapter;
+ setup_timer(&adapter->phy_config_timer, atl1e_phy_config,
+ (unsigned long)adapter);
/* get user settings */
atl1e_check_options(adapter);
^ permalink raw reply related
* [PATCH 0/27] Use setup_timer
From: Julia Lawall @ 2014-12-26 14:35 UTC (permalink / raw)
To: wil6210
Cc: kernel-janitors, linux-wireless, netdev, linux-kernel,
linux-media, linux-usb
These patches group a call to init_timer and initialization of the function
and data fields into a call to setup_timer. Is there is no initialization
of the data field before add_timer is called, the the data value is set to
0UL. If the data value has a cast to something other than unsigned long,
it is changes to a cast to unsigned long, which is the type of the data
field.
The semantic patch that performs this change is shown below
(http://coccinelle.lip6.fr/). This semantic patch is fairly restrictive on
what appears between the init_timer call and the two field initializations,
to ensure that the there is no code that the initializations depend on.
// <smpl>
@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@
(
-t.data = d;
|
-t.function = f;
|
-init_timer(&t);
+setup_timer(&t,f,d);
|
-init_timer_on_stack(&t);
+setup_timer_on_stack(&t,f,d);
)
<... when != S1
t.x1 = e1;
...>
(
-t.data = d;
|
-t.function = f;
|
-init_timer(&t);
+setup_timer(&t,f,d);
|
-init_timer_on_stack(&t);
+setup_timer_on_stack(&t,f,d);
)
<... when != S2
t.x2 = e2;
...>
(
-t.data = d;
|
-t.function = f;
|
-init_timer(&t);
+setup_timer(&t,f,d);
|
-init_timer_on_stack(&t);
+setup_timer_on_stack(&t,f,d);
)
// ----------------------
@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@
(
-t->data = d;
|
-t->function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
<... when != S1
t->x1 = e1;
...>
(
-t->data = d;
|
-t->function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
<... when != S2
t->x2 = e2;
...>
(
-t->data = d;
|
-t->function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
// ---------------------------------------------------------------------
// no initialization of data field
@@
expression t,d1,d2,f;
@@
(
-init_timer(&t);
+setup_timer(&t,f,0UL);
|
-init_timer_on_stack(&t);
+setup_timer_on_stack(&t,f,0UL);
)
... when != t.data = d1;
-t.function = f;
... when != t.data = d2;
add_timer(&t);
@@
expression t,d,f,fn;
type T;
@@
-t.function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(&t);
+setup_timer(&t,f,d);
|
-init_timer_on_stack(&t);
+setup_timer_on_stack(&t,f,0UL);
)
... when != t.data = d;
add_timer(&t);
// ----------------------
@@
expression t,d1,d2,f;
@@
(
-init_timer(t);
+setup_timer(t,f,0UL);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t->data = d1;
-t->function = f;
... when != t->data = d2;
add_timer(t);
@@
expression t,d,f,fn;
type T;
@@
-t->function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t->data = d;
add_timer(t);
// ---------------------------------------------------------------------
// change data field type
@@
expression d;
type T;
@@
(
setup_timer
|
setup_timer_on_stack
)
(...,
(
(unsigned long)d
|
- (T)
+ (unsigned long)
d
)
)
// </smpl>
^ permalink raw reply
* pull-request: wireless-drivers 2014-12-26
From: Kalle Valo @ 2014-12-26 12:09 UTC (permalink / raw)
To: David Miller; +Cc: linux-wireless, netdev, linux-kernel
Hi Dave,
here's my first wireless-drivers pull request after John's "retirement".
I'll start this with few fixes for 3.19, changelog below.
I used a signed tag to create this pull request, I hope that's ok.
Please let me know if there are any problems.
Kalle
The following changes since commit 02d6a746c3f0cdd6f8aad0afd0b32d4646d6525e:
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth (2014-12-19 15:47:32 -0500)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git tags/wireless-drivers-for-davem-2014-12-26
for you to fetch changes up to 8975842bed0840f314281c9fbf021a1d29537cf0:
brcmfmac: Do not crash if platform data is not populated (2014-12-24 15:26:46 +0200)
----------------------------------------------------------------
o Paul made a Kconfig dependency fix to ipw2200, it was not possible to
enable that driver because Wireless Extensions is now disabled by default.
o Mika fixed brcmfmac not to crash when platform data is not populated
o Emmanuel provided few fixes to iwlwifi, he says:
"I have here new device IDs and a fix for double free bug I
introduced. I also fix an issue with the RFKILL interrupt - the HW
needs us to ACK the interrupt again after we reset it. Liad fixes an
issue with the firmware debugging infrastructure. While working on
torture scenarios of firmware restarts, Eliad found an issue which
he fixed."
----------------------------------------------------------------
Eliad Peller (1):
iwlwifi: mvm: clear IN_HW_RESTART flag on stop()
Emmanuel Grumbach (3):
iwlwifi: pcie: re-ACK all interrupts after device reset
iwlwifi: don't double free a pointer if no FW was found
iwlwifi: add new device IDs for 3165
Kalle Valo (1):
Merge tag 'iwlwifi-fixes-for-kalle-2014-12-18' of git://git.kernel.org/.../iwlwifi/iwlwifi-fixes
Liad Kaufman (1):
iwlwifi: pcie: limit fw chunk sizes given to fh
Mika Westerberg (1):
brcmfmac: Do not crash if platform data is not populated
Paul Bolle (1):
ipw2200: select CFG80211_WEXT
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 4 ++--
drivers/net/wireless/ipw2x00/Kconfig | 3 ++-
drivers/net/wireless/iwlwifi/iwl-drv.c | 2 +-
drivers/net/wireless/iwlwifi/iwl-fh.h | 1 +
drivers/net/wireless/iwlwifi/mvm/mac80211.c | 15 +++++++++++++--
drivers/net/wireless/iwlwifi/pcie/drv.c | 4 ++++
drivers/net/wireless/iwlwifi/pcie/trans.c | 17 +++++++++++------
7 files changed, 34 insertions(+), 12 deletions(-)
--
Kalle Valo
^ permalink raw reply
* Re: [PATCH net-next 1/2] socket: Allow external sockets to use socket syscalls
From: Jason Wang @ 2014-12-26 9:45 UTC (permalink / raw)
To: Alex Gartrell, davem, herbert; +Cc: netdev, linux-kernel, kernel-team
In-Reply-To: <1419576624-8999-2-git-send-email-agartrell@fb.com>
On 12/26/2014 02:50 PM, Alex Gartrell wrote:
> Currently the "is-socket" test for a file compares the ops table pointer,
> which is static and local to the socket.c. Instead, this adds a flag for
> private_data_is_socket. This is an exceptionally long commit message for a
> two-line patch.
>
> Signed-off-by: Alex Gartrell <agartrell@fb.com>
> ---
> include/linux/fs.h | 2 +-
> net/socket.c | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index bb29b02..d162476 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -809,7 +809,7 @@ struct file {
> #endif
> /* needed for tty driver, and maybe others */
> void *private_data;
> -
> + bool private_data_is_socket : 1;
> #ifdef CONFIG_EPOLL
> /* Used by fs/eventpoll.c to link all the hooks to this file */
> struct list_head f_ep_links;
> diff --git a/net/socket.c b/net/socket.c
> index 8809afc..cd853be 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -388,6 +388,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
> sock->file = file;
> file->f_flags = O_RDWR | (flags & O_NONBLOCK);
> file->private_data = sock;
> + file->private_data_is_socket = true;
This is only safe if all user of sock_alloc_file() have full support for
each method in proto_ops.
> return file;
> }
> EXPORT_SYMBOL(sock_alloc_file);
> @@ -411,7 +412,7 @@ static int sock_map_fd(struct socket *sock, int flags)
>
> struct socket *sock_from_file(struct file *file, int *err)
> {
> - if (file->f_op == &socket_file_ops)
> + if (file->private_data_is_socket)
> return file->private_data; /* set in sock_map_fd */
>
> *err = -ENOTSOCK;
Not sure it's the best method, how about a dedicated f_op to do this?
^ permalink raw reply
* Re: [PATCH net-next 2/2] tun: enable socket system calls
From: Jason Wang @ 2014-12-26 9:43 UTC (permalink / raw)
To: Alex Gartrell, davem, herbert; +Cc: netdev, linux-kernel, kernel-team
In-Reply-To: <1419576624-8999-3-git-send-email-agartrell@fb.com>
On 12/26/2014 02:50 PM, Alex Gartrell wrote:
> By setting private_data to a socket and private_data_is_socket to true, we
> can use the socket syscalls. We also can't just blindly use private_data
> anymore, so there's a __tun_file_get function that returns the container_of
> private_data appropriately.
So this in fact expose other socket syscalls to userspace. But some of
proto_ops was not supported. E.g consider what happens if a bind() was
called for tun socket?
> Signed-off-by: Alex Gartrell <agartrell@fb.com>
> ---
> drivers/net/tun.c | 34 ++++++++++++++++++++++------------
> 1 file changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index a5cbf67..b16ddc5 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -547,9 +547,18 @@ static void tun_detach_all(struct net_device *dev)
> module_put(THIS_MODULE);
> }
>
> +static struct tun_file *tun_file_from_file(struct file *file)
> +{
> + struct socket *s = (struct socket *)file->private_data;
> +
> + if (!s)
Can s be NULL here? If yes, why tun_get() didn't check for NULL?
> + return NULL;
> + return container_of(s, struct tun_file, socket);
> +}
> +
> static int tun_attach(struct tun_struct *tun, struct file *file, bool skip_filter)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> int err;
>
> err = security_tun_dev_attach(tfile->socket.sk, tun->security);
> @@ -612,7 +621,7 @@ static struct tun_struct *__tun_get(struct tun_file *tfile)
>
> static struct tun_struct *tun_get(struct file *file)
> {
> - return __tun_get(file->private_data);
> + return __tun_get(tun_file_from_file(file));
> }
>
> static void tun_put(struct tun_struct *tun)
> @@ -973,7 +982,7 @@ static void tun_net_init(struct net_device *dev)
> /* Poll */
> static unsigned int tun_chr_poll(struct file *file, poll_table *wait)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct tun_struct *tun = __tun_get(tfile);
> struct sock *sk;
> unsigned int mask = 0;
> @@ -1235,7 +1244,7 @@ static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from)
> {
> struct file *file = iocb->ki_filp;
> struct tun_struct *tun = tun_get(file);
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> ssize_t result;
>
> if (!tun)
> @@ -1392,7 +1401,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
> static ssize_t tun_chr_read_iter(struct kiocb *iocb, struct iov_iter *to)
> {
> struct file *file = iocb->ki_filp;
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct tun_struct *tun = __tun_get(tfile);
> ssize_t len = iov_iter_count(to), ret;
>
> @@ -1567,7 +1576,7 @@ static DEVICE_ATTR(group, 0444, tun_show_group, NULL);
> static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
> {
> struct tun_struct *tun;
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct net_device *dev;
> int err;
>
> @@ -1801,7 +1810,7 @@ static void tun_set_sndbuf(struct tun_struct *tun)
>
> static int tun_set_queue(struct file *file, struct ifreq *ifr)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct tun_struct *tun;
> int ret = 0;
>
> @@ -1834,7 +1843,7 @@ unlock:
> static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg, int ifreq_len)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct tun_struct *tun;
> void __user* argp = (void __user*)arg;
> struct ifreq ifr;
> @@ -2122,7 +2131,7 @@ static long tun_chr_compat_ioctl(struct file *file,
>
> static int tun_chr_fasync(int fd, struct file *file, int on)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> int ret;
>
> if ((ret = fasync_helper(fd, file, on, &tfile->fasync)) < 0)
> @@ -2165,7 +2174,8 @@ static int tun_chr_open(struct inode *inode, struct file * file)
> tfile->sk.sk_write_space = tun_sock_write_space;
> tfile->sk.sk_sndbuf = INT_MAX;
>
> - file->private_data = tfile;
> + file->private_data = &tfile->socket;
> + file->private_data_is_socket = true;
> set_bit(SOCK_EXTERNALLY_ALLOCATED, &tfile->socket.flags);
> INIT_LIST_HEAD(&tfile->next);
>
> @@ -2176,7 +2186,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
>
> static int tun_chr_close(struct inode *inode, struct file *file)
> {
> - struct tun_file *tfile = file->private_data;
> + struct tun_file *tfile = tun_file_from_file(file);
> struct net *net = tfile->net;
>
> tun_detach(tfile, true);
> @@ -2335,7 +2345,7 @@ struct socket *tun_get_socket(struct file *file)
> struct tun_file *tfile;
> if (file->f_op != &tun_fops)
> return ERR_PTR(-EINVAL);
> - tfile = file->private_data;
> + tfile = tun_file_from_file(file);
> if (!tfile)
> return ERR_PTR(-EBADFD);
> return &tfile->socket;
^ permalink raw reply
* [PATCH] net: wireless: rt2x00: use helper to check capability/requirement
From: Fred Chou @ 2014-12-26 8:19 UTC (permalink / raw)
To: sgruszka, helmut.schaa, kvalo, linux-wireless, users, netdev,
linux-kernel
Cc: Fred Chou
From: Fred Chou <fred.chou.nd@gmail.com>
Use rt2x00_has_cap_flag macro to check rt2x00dev->cap_flags.
Signed-off-by: Fred Chou <fred.chou.nd@gmail.com>
---
drivers/net/wireless/rt2x00/rt2x00config.c | 4 ++--
drivers/net/wireless/rt2x00/rt2x00dev.c | 18 +++++++++---------
drivers/net/wireless/rt2x00/rt2x00firmware.c | 2 +-
drivers/net/wireless/rt2x00/rt2x00mac.c | 2 +-
drivers/net/wireless/rt2x00/rt2x00queue.c | 18 +++++++++---------
drivers/net/wireless/rt2x00/rt2x00usb.c | 8 ++++----
6 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 1122dc4..48a2cad 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -240,7 +240,7 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
rt2x00dev->rf_channel = libconf.rf.channel;
}
- if (test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) &&
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_PS_AUTOWAKE) &&
(ieee80211_flags & IEEE80211_CONF_CHANGE_PS))
cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
@@ -257,7 +257,7 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
rt2x00link_reset_tuner(rt2x00dev, false);
if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
- test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) &&
+ rt2x00_has_cap_flag(rt2x00dev, REQUIRE_PS_AUTOWAKE) &&
(ieee80211_flags & IEEE80211_CONF_CHANGE_PS) &&
(conf->flags & IEEE80211_CONF_PS)) {
beacon_diff = (long)jiffies - (long)rt2x00dev->last_beacon;
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 9967a1d..5639ed8 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -351,7 +351,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
/*
* Remove L2 padding which was added during
*/
- if (test_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_L2PAD))
rt2x00queue_remove_l2pad(entry->skb, header_length);
/*
@@ -460,7 +460,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
* send the status report back.
*/
if (!(skbdesc_flags & SKBDESC_NOT_MAC80211)) {
- if (test_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_TASKLET_CONTEXT))
ieee80211_tx_status(rt2x00dev->hw, entry->skb);
else
ieee80211_tx_status_ni(rt2x00dev->hw, entry->skb);
@@ -1056,9 +1056,9 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* Take TX headroom required for alignment into account.
*/
- if (test_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_L2PAD))
rt2x00dev->hw->extra_tx_headroom += RT2X00_L2PAD_SIZE;
- else if (test_bit(REQUIRE_DMA, &rt2x00dev->cap_flags))
+ else if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DMA))
rt2x00dev->hw->extra_tx_headroom += RT2X00_ALIGN_SIZE;
/*
@@ -1069,7 +1069,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* Allocate tx status FIFO for driver use.
*/
- if (test_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags)) {
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_TXSTATUS_FIFO)) {
/*
* Allocate the txstatus fifo. In the worst case the tx
* status fifo has to hold the tx status of all entries
@@ -1131,7 +1131,7 @@ static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
/*
* Stop rfkill polling.
*/
- if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DELAYED_RFKILL))
rt2x00rfkill_unregister(rt2x00dev);
/*
@@ -1173,7 +1173,7 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
/*
* Start rfkill polling.
*/
- if (test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DELAYED_RFKILL))
rt2x00rfkill_register(rt2x00dev);
return 0;
@@ -1389,7 +1389,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
/*
* Start rfkill polling.
*/
- if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+ if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DELAYED_RFKILL))
rt2x00rfkill_register(rt2x00dev);
return 0;
@@ -1408,7 +1408,7 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
/*
* Stop rfkill polling.
*/
- if (!test_bit(REQUIRE_DELAYED_RFKILL, &rt2x00dev->cap_flags))
+ if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DELAYED_RFKILL))
rt2x00rfkill_unregister(rt2x00dev);
/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index fbae279..5813300 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -96,7 +96,7 @@ int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
{
int retval;
- if (!test_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags))
+ if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_FIRMWARE))
return 0;
if (!rt2x00dev->fw) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index cb40245..300876d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -119,7 +119,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw,
* Use the ATIM queue if appropriate and present.
*/
if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
- test_bit(REQUIRE_ATIM_QUEUE, &rt2x00dev->cap_flags))
+ rt2x00_has_cap_flag(rt2x00dev, REQUIRE_ATIM_QUEUE))
qid = QID_ATIM;
queue = rt2x00queue_get_tx_queue(rt2x00dev, qid);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 66ff364..68b620b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -85,7 +85,7 @@ struct sk_buff *rt2x00queue_alloc_rxskb(struct queue_entry *entry, gfp_t gfp)
memset(skbdesc, 0, sizeof(*skbdesc));
skbdesc->entry = entry;
- if (test_bit(REQUIRE_DMA, &rt2x00dev->cap_flags)) {
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DMA)) {
dma_addr_t skb_dma;
skb_dma = dma_map_single(rt2x00dev->dev, skb->data, skb->len,
@@ -198,7 +198,7 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
__set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags);
- if (!test_bit(REQUIRE_SW_SEQNO, &rt2x00dev->cap_flags)) {
+ if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_SW_SEQNO)) {
/*
* rt2800 has a H/W (or F/W) bug, device incorrectly increase
* seqno on retransmited data (non-QOS) frames. To workaround
@@ -484,7 +484,7 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
rt2x00crypto_create_tx_descriptor(rt2x00dev, skb, txdesc);
rt2x00queue_create_tx_descriptor_seq(rt2x00dev, skb, txdesc);
- if (test_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_HT_TX_DESC))
rt2x00queue_create_tx_descriptor_ht(rt2x00dev, skb, txdesc,
sta, hwrate);
else
@@ -526,7 +526,7 @@ static int rt2x00queue_write_tx_data(struct queue_entry *entry,
/*
* Map the skb to DMA.
*/
- if (test_bit(REQUIRE_DMA, &rt2x00dev->cap_flags) &&
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_DMA) &&
rt2x00queue_map_txskb(entry))
return -ENOMEM;
@@ -646,7 +646,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
*/
if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc.flags) &&
!test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc.flags)) {
- if (test_bit(REQUIRE_COPY_IV, &queue->rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_COPY_IV))
rt2x00crypto_tx_copy_iv(skb, &txdesc);
else
rt2x00crypto_tx_remove_iv(skb, &txdesc);
@@ -660,9 +660,9 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
* PCI and USB devices, while header alignment only is valid
* for PCI devices.
*/
- if (test_bit(REQUIRE_L2PAD, &queue->rt2x00dev->cap_flags))
+ if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_L2PAD))
rt2x00queue_insert_l2pad(skb, txdesc.header_length);
- else if (test_bit(REQUIRE_DMA, &queue->rt2x00dev->cap_flags))
+ else if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_DMA))
rt2x00queue_align_frame(skb);
/*
@@ -1178,7 +1178,7 @@ int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev)
if (status)
goto exit;
- if (test_bit(REQUIRE_ATIM_QUEUE, &rt2x00dev->cap_flags)) {
+ if (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_ATIM_QUEUE)) {
status = rt2x00queue_alloc_entries(rt2x00dev->atim);
if (status)
goto exit;
@@ -1234,7 +1234,7 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev)
struct data_queue *queue;
enum data_queue_qid qid;
unsigned int req_atim =
- !!test_bit(REQUIRE_ATIM_QUEUE, &rt2x00dev->cap_flags);
+ rt2x00_has_cap_flag(rt2x00dev, REQUIRE_ATIM_QUEUE);
/*
* We need the following queues:
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 892270d..7627af6 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -274,7 +274,7 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
* Schedule the delayed work for reading the TX status
* from the device.
*/
- if (!test_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags) ||
+ if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_TXSTATUS_FIFO) ||
!kfifo_is_empty(&rt2x00dev->txstatus_fifo))
queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
}
@@ -456,7 +456,7 @@ static bool rt2x00usb_flush_entry(struct queue_entry *entry, void *data)
* Kill guardian urb (if required by driver).
*/
if ((entry->queue->qid == QID_BEACON) &&
- (test_bit(REQUIRE_BEACON_GUARD, &rt2x00dev->cap_flags)))
+ (rt2x00_has_cap_flag(rt2x00dev, REQUIRE_BEACON_GUARD)))
usb_kill_urb(bcn_priv->guardian_urb);
return false;
@@ -655,7 +655,7 @@ static int rt2x00usb_alloc_entries(struct data_queue *queue)
* then we are done.
*/
if (queue->qid != QID_BEACON ||
- !test_bit(REQUIRE_BEACON_GUARD, &rt2x00dev->cap_flags))
+ !rt2x00_has_cap_flag(rt2x00dev, REQUIRE_BEACON_GUARD))
return 0;
for (i = 0; i < queue->limit; i++) {
@@ -690,7 +690,7 @@ static void rt2x00usb_free_entries(struct data_queue *queue)
* then we are done.
*/
if (queue->qid != QID_BEACON ||
- !test_bit(REQUIRE_BEACON_GUARD, &rt2x00dev->cap_flags))
+ !rt2x00_has_cap_flag(rt2x00dev, REQUIRE_BEACON_GUARD))
return;
for (i = 0; i < queue->limit; i++) {
--
1.9.1
^ permalink raw reply related
* [PATCH net-next] tun: return proper error code from tun_do_read
From: Alex Gartrell @ 2014-12-26 7:22 UTC (permalink / raw)
To: davem, herbert; +Cc: netdev, linux-kernel, kernel-team, Alex Gartrell
Instead of -1 with EAGAIN, read on a O_NONBLOCK tun fd will return 0. This
fixes this by properly returning the error code from __skb_recv_datagram.
Signed-off-by: Alex Gartrell <agartrell@fb.com>
---
drivers/net/tun.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a5cbf67..2f65d6c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1378,7 +1378,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
&peeked, &off, &err);
if (!skb)
- return 0;
+ return err;
ret = tun_put_user(tun, tfile, skb, to);
if (unlikely(ret < 0))
--
Alex Gartrell <agartrell@fb.com>
^ permalink raw reply related
* [PATCH net-next] tun: Fixed unsigned/signed comparison
From: Alex Gartrell @ 2014-12-26 7:05 UTC (permalink / raw)
To: davem, herbert; +Cc: netdev, linux-kernel, kernel-team, Alex Gartrell
Validated that this was actually using the unsigned comparison with gdb.
Signed-off-by: Alex Gartrell <agartrell@fb.com>
---
drivers/net/tun.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a5cbf67..6c63e21 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1499,7 +1499,7 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
goto out;
}
ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT);
- if (ret > total_len) {
+ if (ret > (ssize_t)total_len) {
m->msg_flags |= MSG_TRUNC;
ret = flags & MSG_TRUNC ? ret : total_len;
}
--
Alex Gartrell <agartrell@fb.com>
^ permalink raw reply related
* [PATCH net-next 2/2] tun: enable socket system calls
From: Alex Gartrell @ 2014-12-26 6:50 UTC (permalink / raw)
To: davem, herbert; +Cc: netdev, linux-kernel, kernel-team, Alex Gartrell
In-Reply-To: <1419576624-8999-1-git-send-email-agartrell@fb.com>
By setting private_data to a socket and private_data_is_socket to true, we
can use the socket syscalls. We also can't just blindly use private_data
anymore, so there's a __tun_file_get function that returns the container_of
private_data appropriately.
Signed-off-by: Alex Gartrell <agartrell@fb.com>
---
drivers/net/tun.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a5cbf67..b16ddc5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -547,9 +547,18 @@ static void tun_detach_all(struct net_device *dev)
module_put(THIS_MODULE);
}
+static struct tun_file *tun_file_from_file(struct file *file)
+{
+ struct socket *s = (struct socket *)file->private_data;
+
+ if (!s)
+ return NULL;
+ return container_of(s, struct tun_file, socket);
+}
+
static int tun_attach(struct tun_struct *tun, struct file *file, bool skip_filter)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
int err;
err = security_tun_dev_attach(tfile->socket.sk, tun->security);
@@ -612,7 +621,7 @@ static struct tun_struct *__tun_get(struct tun_file *tfile)
static struct tun_struct *tun_get(struct file *file)
{
- return __tun_get(file->private_data);
+ return __tun_get(tun_file_from_file(file));
}
static void tun_put(struct tun_struct *tun)
@@ -973,7 +982,7 @@ static void tun_net_init(struct net_device *dev)
/* Poll */
static unsigned int tun_chr_poll(struct file *file, poll_table *wait)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct tun_struct *tun = __tun_get(tfile);
struct sock *sk;
unsigned int mask = 0;
@@ -1235,7 +1244,7 @@ static ssize_t tun_chr_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct tun_struct *tun = tun_get(file);
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
ssize_t result;
if (!tun)
@@ -1392,7 +1401,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
static ssize_t tun_chr_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *file = iocb->ki_filp;
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct tun_struct *tun = __tun_get(tfile);
ssize_t len = iov_iter_count(to), ret;
@@ -1567,7 +1576,7 @@ static DEVICE_ATTR(group, 0444, tun_show_group, NULL);
static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
{
struct tun_struct *tun;
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct net_device *dev;
int err;
@@ -1801,7 +1810,7 @@ static void tun_set_sndbuf(struct tun_struct *tun)
static int tun_set_queue(struct file *file, struct ifreq *ifr)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct tun_struct *tun;
int ret = 0;
@@ -1834,7 +1843,7 @@ unlock:
static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
unsigned long arg, int ifreq_len)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct tun_struct *tun;
void __user* argp = (void __user*)arg;
struct ifreq ifr;
@@ -2122,7 +2131,7 @@ static long tun_chr_compat_ioctl(struct file *file,
static int tun_chr_fasync(int fd, struct file *file, int on)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
int ret;
if ((ret = fasync_helper(fd, file, on, &tfile->fasync)) < 0)
@@ -2165,7 +2174,8 @@ static int tun_chr_open(struct inode *inode, struct file * file)
tfile->sk.sk_write_space = tun_sock_write_space;
tfile->sk.sk_sndbuf = INT_MAX;
- file->private_data = tfile;
+ file->private_data = &tfile->socket;
+ file->private_data_is_socket = true;
set_bit(SOCK_EXTERNALLY_ALLOCATED, &tfile->socket.flags);
INIT_LIST_HEAD(&tfile->next);
@@ -2176,7 +2186,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
static int tun_chr_close(struct inode *inode, struct file *file)
{
- struct tun_file *tfile = file->private_data;
+ struct tun_file *tfile = tun_file_from_file(file);
struct net *net = tfile->net;
tun_detach(tfile, true);
@@ -2335,7 +2345,7 @@ struct socket *tun_get_socket(struct file *file)
struct tun_file *tfile;
if (file->f_op != &tun_fops)
return ERR_PTR(-EINVAL);
- tfile = file->private_data;
+ tfile = tun_file_from_file(file);
if (!tfile)
return ERR_PTR(-EBADFD);
return &tfile->socket;
--
Alex Gartrell <agartrell@fb.com>
^ permalink raw reply related
* [PATCH net-next 1/2] socket: Allow external sockets to use socket syscalls
From: Alex Gartrell @ 2014-12-26 6:50 UTC (permalink / raw)
To: davem, herbert; +Cc: netdev, linux-kernel, kernel-team, Alex Gartrell
In-Reply-To: <1419576624-8999-1-git-send-email-agartrell@fb.com>
Currently the "is-socket" test for a file compares the ops table pointer,
which is static and local to the socket.c. Instead, this adds a flag for
private_data_is_socket. This is an exceptionally long commit message for a
two-line patch.
Signed-off-by: Alex Gartrell <agartrell@fb.com>
---
include/linux/fs.h | 2 +-
net/socket.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index bb29b02..d162476 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -809,7 +809,7 @@ struct file {
#endif
/* needed for tty driver, and maybe others */
void *private_data;
-
+ bool private_data_is_socket : 1;
#ifdef CONFIG_EPOLL
/* Used by fs/eventpoll.c to link all the hooks to this file */
struct list_head f_ep_links;
diff --git a/net/socket.c b/net/socket.c
index 8809afc..cd853be 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -388,6 +388,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
sock->file = file;
file->f_flags = O_RDWR | (flags & O_NONBLOCK);
file->private_data = sock;
+ file->private_data_is_socket = true;
return file;
}
EXPORT_SYMBOL(sock_alloc_file);
@@ -411,7 +412,7 @@ static int sock_map_fd(struct socket *sock, int flags)
struct socket *sock_from_file(struct file *file, int *err)
{
- if (file->f_op == &socket_file_ops)
+ if (file->private_data_is_socket)
return file->private_data; /* set in sock_map_fd */
*err = -ENOTSOCK;
--
Alex Gartrell <agartrell@fb.com>
^ permalink raw reply related
* [PATCH net-next 0/2] tun: support socket system calls
From: Alex Gartrell @ 2014-12-26 6:50 UTC (permalink / raw)
To: davem, herbert; +Cc: netdev, linux-kernel, kernel-team, Alex Gartrell
There is an underlying socket object in struct tun that isn't accessible,
so if you try to do a recvmmsg on a tun file descriptor you'll get an
error. This small patchset allows external file objects to claim socket
status and enables it for tun_files.
Alex Gartrell (2):
socket: Allow external sockets to use socket syscalls
tun: enable socket system calls
drivers/net/tun.c | 34 ++++++++++++++++++++++------------
include/linux/fs.h | 2 +-
net/socket.c | 3 ++-
3 files changed, 25 insertions(+), 14 deletions(-)
--
Alex Gartrell <agartrell@fb.com>
^ permalink raw reply
* [PATCH iproute2] man ip-link: Small example of 'ip link show master'
From: Vadim Kochan @ 2014-12-26 2:46 UTC (permalink / raw)
To: netdev; +Cc: Vadim Kochan
From: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
man/man8/ip-link.8.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 5134e28..1209b55 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -739,6 +739,11 @@ ip link show type vlan
Shows the vlan devices.
.RE
.PP
+ip link show master br0
+.RS 4
+Shows devices enslaved by br0
+.RE
+.PP
ip link set dev ppp0 mtu 1400
.RS 4
Change the MTU the ppp0 device.
--
2.1.3
^ permalink raw reply related
* [PATCH iproute2] ss: Use rtnl_dump_filter for inet_show_netlink
From: Vadim Kochan @ 2014-12-26 2:26 UTC (permalink / raw)
To: netdev; +Cc: Vadim Kochan
From: Vadim Kochan <vadim4j@gmail.com>
Just another refactoring for ss to use rtnl API from lib
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
It would be good to make better testing with opened different
kind of sockets to test if ss behaves correctly and does not
shows any errors.
include/libnetlink.h | 1 +
lib/libnetlink.c | 17 +++++--
misc/ss.c | 139 ++++++++++++++-------------------------------------
3 files changed, 50 insertions(+), 107 deletions(-)
diff --git a/include/libnetlink.h b/include/libnetlink.h
index 3794ef1..db04969 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -19,6 +19,7 @@ struct rtnl_handle
__u32 seq;
__u32 dump;
int proto;
+ FILE *dump_fp;
};
extern int rcvbuf;
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index e3b7862..45ff90a 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -220,12 +220,15 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
return -1;
}
+ if (rth->dump_fp)
+ fwrite(buf, 1, NLMSG_ALIGN(status), rth->dump_fp);
+
for (a = arg; a->filter; a++) {
struct nlmsghdr *h = (struct nlmsghdr*)buf;
msglen = status;
while (NLMSG_OK(h, msglen)) {
- int err;
+ int err = 0;
if (nladdr.nl_pid != 0 ||
h->nlmsg_pid != rth->local.nl_pid ||
@@ -247,16 +250,20 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
} else {
errno = -err->error;
if (rth->proto == NETLINK_SOCK_DIAG &&
- errno == ENOENT)
+ (errno == ENOENT ||
+ errno == EOPNOTSUPP))
return -1;
perror("RTNETLINK answers");
}
return -1;
}
- err = a->filter(&nladdr, h, a->arg1);
- if (err < 0)
- return err;
+
+ if (!rth->dump_fp) {
+ err = a->filter(&nladdr, h, a->arg1);
+ if (err < 0)
+ return err;
+ }
skip_it:
h = NLMSG_NEXT(h, msglen);
diff --git a/misc/ss.c b/misc/ss.c
index 706b5ba..f0c7b34 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1871,122 +1871,57 @@ static int sockdiag_send(int family, int fd, int protocol, struct filter *f)
return 0;
}
-static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
-{
- int fd, family;
- struct sockaddr_nl nladdr;
- struct msghdr msg;
- char buf[16384];
- struct iovec iov[3];
-
- if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
- return -1;
-
- family = PF_INET;
-again:
- if (sockdiag_send(family, fd, protocol, f))
- return -1;
-
- memset(&nladdr, 0, sizeof(nladdr));
- nladdr.nl_family = AF_NETLINK;
-
- iov[0] = (struct iovec){
- .iov_base = buf,
- .iov_len = sizeof(buf)
- };
-
- while (1) {
- int status;
- struct nlmsghdr *h;
-
- msg = (struct msghdr) {
- (void*)&nladdr, sizeof(nladdr),
- iov, 1,
- NULL, 0,
- 0
- };
-
- status = recvmsg(fd, &msg, 0);
-
- if (status < 0) {
- if (errno == EINTR)
- continue;
- perror("OVERRUN");
- continue;
- }
- if (status == 0) {
- fprintf(stderr, "EOF on netlink\n");
- close(fd);
- return 0;
- }
-
- if (dump_fp)
- fwrite(buf, 1, NLMSG_ALIGN(status), dump_fp);
+struct inet_diag_arg {
+ struct filter *f;
+ int protocol;
+};
- h = (struct nlmsghdr*)buf;
- while (NLMSG_OK(h, status)) {
- int err;
- struct inet_diag_msg *r = NLMSG_DATA(h);
+static int show_one_inet_sock(const struct sockaddr_nl *addr,
+ struct nlmsghdr *h, void *arg)
+{
+ int err;
+ struct inet_diag_arg *diag_arg = arg;
+ struct inet_diag_msg *r = NLMSG_DATA(h);
- if (/*h->nlmsg_pid != rth->local.nl_pid ||*/
- h->nlmsg_seq != MAGIC_SEQ)
- goto skip_it;
+ if (!(diag_arg->f->families & (1 << r->idiag_family)))
+ return 0;
+ if ((err = inet_show_sock(h, NULL, diag_arg->protocol)) < 0)
+ return err;
- if (h->nlmsg_type == NLMSG_DONE)
- goto done;
+ return 0;
+}
- if (h->nlmsg_type == NLMSG_ERROR) {
- struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
- if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
- fprintf(stderr, "ERROR truncated\n");
- } else {
- if (family != PF_UNSPEC) {
- family = PF_UNSPEC;
- goto again;
- }
+static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
+{
+ int err = 0;
+ struct rtnl_handle rth;
+ int family = PF_INET;
+ struct inet_diag_arg arg = { .f = f, .protocol = protocol };
- errno = -err->error;
- if (errno == EOPNOTSUPP) {
- close(fd);
- return -1;
- }
- perror("TCPDIAG answers");
- }
+ if (rtnl_open_byproto(&rth, 0, NETLINK_SOCK_DIAG))
+ return -1;
+ rth.dump = MAGIC_SEQ;
+ rth.dump_fp = dump_fp;
- goto done;
- }
- if (!dump_fp) {
- if (!(f->families & (1<<r->idiag_family))) {
- h = NLMSG_NEXT(h, status);
- continue;
- }
- err = inet_show_sock(h, NULL, protocol);
- if (err < 0) {
- close(fd);
- return err;
- }
- }
+again:
+ if ((err = sockdiag_send(family, rth.fd, protocol, f)))
+ goto Exit;
-skip_it:
- h = NLMSG_NEXT(h, status);
- }
- if (msg.msg_flags & MSG_TRUNC) {
- fprintf(stderr, "Message truncated\n");
- continue;
- }
- if (status) {
- fprintf(stderr, "!!!Remnant of size %d\n", status);
- exit(1);
+ if ((err = rtnl_dump_filter(&rth, show_one_inet_sock, &arg))) {
+ if (family != PF_UNSPEC) {
+ family = PF_UNSPEC;
+ goto again;
}
+ goto Exit;
}
-done:
if (family == PF_INET) {
family = PF_INET6;
goto again;
}
- close(fd);
- return 0;
+Exit:
+ rtnl_close(&rth);
+ return err;
}
static int tcp_show_netlink_file(struct filter *f)
--
2.1.3
^ permalink raw reply related
* Re: [PATCH 1/1 net-next] tipc: replace 0 by NULL for pointers
From: Ying Xue @ 2014-12-26 1:02 UTC (permalink / raw)
To: Fabian Frederick, linux-kernel
Cc: Jon Maloy, Allan Stephens, David S. Miller, netdev,
tipc-discussion
In-Reply-To: <1419505550-17336-1-git-send-email-fabf@skynet.be>
On 12/25/2014 07:05 PM, Fabian Frederick wrote:
> Fix sparse warning:
> net/tipc/link.c:1924:40: warning: Using plain integer as NULL pointer
>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
Acked-by: Ying Xue <ying.xue@windriver.com>
> net/tipc/link.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/tipc/link.c b/net/tipc/link.c
> index 23bcc11..082c3b5 100644
> --- a/net/tipc/link.c
> +++ b/net/tipc/link.c
> @@ -1921,7 +1921,7 @@ static struct tipc_node *tipc_link_find_owner(const char *link_name,
> {
> struct tipc_link *l_ptr;
> struct tipc_node *n_ptr;
> - struct tipc_node *found_node = 0;
> + struct tipc_node *found_node = NULL;
> int i;
>
> *bearer_id = 0;
>
^ permalink raw reply
* [PATCH iproute2] tc class: Show classes as ASCII graph
From: Vadim Kochan @ 2014-12-26 0:10 UTC (permalink / raw)
To: netdev; +Cc: Vadim Kochan
From: Vadim Kochan <vadim4j@gmail.com>
Added new '-g[raph]' option which shows classes in the graph view.
Meanwhile only generic stats info output is supported.
e.g.:
$ tc/tc -g class show dev tap0
+---(1:2) htb rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| +---(1:40) htb prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| +---(1:50) htb rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| | +---(1:51) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
| |
| +---(1:60) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
|
+---(1:1) htb rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
+---(1:10) htb prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
+---(1:20) htb prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
+---(1:30) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
$ tc/tc -g -s class show dev tap0
+---(1:2) htb rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---(1:40) htb prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---(1:50) htb rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| | | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | | rate 0bit 0pps backlog 0b 0p requeues 0
| | |
| | +---(1:51) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
| | Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| | rate 0bit 0pps backlog 0b 0p requeues 0
| |
| +---(1:60) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---(1:1) htb rate 6Mbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---(1:10) htb prio 0 rate 5Mbit ceil 5Mbit burst 15Kb cburst 1600b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---(1:20) htb prio 0 rate 3Mbit ceil 6Mbit burst 15Kb cburst 1599b
| Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
| rate 0bit 0pps backlog 0b 0p requeues 0
|
+---(1:30) htb prio 0 rate 1Kbit ceil 6Mbit burst 15Kb cburst 1599b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
tc/tc.c | 5 +-
tc/tc_class.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
tc/tc_common.h | 2 +
3 files changed, 171 insertions(+), 3 deletions(-)
diff --git a/tc/tc.c b/tc/tc.c
index 9b50e74..25a1c68 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -34,8 +34,9 @@ int show_stats = 0;
int show_details = 0;
int show_raw = 0;
int show_pretty = 0;
-int batch_mode = 0;
+int show_graph = 0;
+int batch_mode = 0;
int resolve_hosts = 0;
int use_iec = 0;
int force = 0;
@@ -278,6 +279,8 @@ int main(int argc, char **argv)
++show_raw;
} else if (matches(argv[1], "-pretty") == 0) {
++show_pretty;
+ } else if (matches(argv[1], "-graph") == 0) {
+ show_graph = 1;
} else if (matches(argv[1], "-Version") == 0) {
printf("tc utility, iproute2-ss%s\n", SNAPSHOT);
return 0;
diff --git a/tc/tc_class.c b/tc/tc_class.c
index ba7869b..877048a 100644
--- a/tc/tc_class.c
+++ b/tc/tc_class.c
@@ -24,6 +24,21 @@
#include "utils.h"
#include "tc_util.h"
#include "tc_common.h"
+#include "hlist.h"
+
+struct graph_node {
+ struct hlist_node hlist;
+ __u32 id;
+ __u32 parent_id;
+ struct graph_node *parent_node;
+ struct graph_node *right_node;
+ void *data;
+ int data_len;
+ int nodes_count;
+};
+
+static struct hlist_head cls_list = {};
+static struct hlist_head root_cls_list = {};
static void usage(void);
@@ -148,13 +163,152 @@ int filter_ifindex;
__u32 filter_qdisc;
__u32 filter_classid;
+static void graph_node_add(__u32 parent_id, __u32 id, void *data,
+ int len)
+{
+ struct graph_node *node = malloc(sizeof(struct graph_node));
+
+ memset(node, 0, sizeof(*node));
+ node->id = id;
+ node->parent_id = parent_id;
+
+ if (data && len) {
+ node->data = malloc(len);
+ node->data_len = len;
+ memcpy(node->data, data, len);
+ }
+
+ if (parent_id == TC_H_ROOT)
+ hlist_add_head(&node->hlist, &root_cls_list);
+ else
+ hlist_add_head(&node->hlist, &cls_list);
+}
+
+static void graph_indent(char *buf, struct graph_node *node, int is_newline,
+ int add_spaces)
+{
+ char spaces[100] = {0};
+
+ while (node && node->parent_node) {
+ node->parent_node->right_node = node;
+ node = node->parent_node;
+ }
+ while (node && node->right_node) {
+ if (node->hlist.next)
+ strcat(buf, "| ");
+ else
+ strcat(buf, " ");
+
+ node = node->right_node;
+ }
+
+ if (is_newline) {
+ if (node->hlist.next && node->nodes_count)
+ strcat(buf, "| |");
+ else if (node->hlist.next)
+ strcat(buf, "| ");
+ else if (node->nodes_count)
+ strcat(buf, " |");
+ else if (!node->hlist.next)
+ strcat(buf, " ");
+ }
+ if (add_spaces > 0) {
+ sprintf(spaces, "%-*s", add_spaces, "");
+ strcat(buf, spaces);
+ }
+}
+
+static void graph_cls_show(FILE *fp, char *buf, struct hlist_head *root_list,
+ int level)
+{
+ struct hlist_node *n, *tmp_cls;
+ char cls_id_str[256] = {};
+ struct rtattr *tb[TCA_MAX + 1] = {};
+ struct qdisc_util *q;
+ char str[100] = {};
+
+ hlist_for_each_safe(n, tmp_cls, root_list) {
+ struct hlist_node *c, *tmp_chld;
+ struct hlist_head children = {};
+ struct graph_node *cls = container_of(n, struct graph_node,
+ hlist);
+
+ hlist_for_each_safe(c, tmp_chld, &cls_list) {
+ struct graph_node *child = container_of(c,
+ struct graph_node, hlist);
+
+ if (cls->id == child->parent_id) {
+ hlist_del(c);
+ hlist_add_head(c, &children);
+ cls->nodes_count++;
+ child->parent_node = cls;
+ }
+ }
+
+ graph_indent(buf, cls, 0, 0);
+
+ print_tc_classid(cls_id_str, sizeof(cls_id_str), cls->id);
+ sprintf(str, "+---(%s)", cls_id_str);
+ strcat(buf, str);
+
+ parse_rtattr(tb, TCA_MAX, (struct rtattr *)cls->data,
+ cls->data_len);
+
+ if (tb[TCA_KIND] == NULL) {
+ strcat(buf, " [unknown qdisc kind] ");
+ } else {
+ const char *kind = rta_getattr_str(tb[TCA_KIND]);
+
+ sprintf(str, " %s ", kind);
+ strcat(buf, str);
+ fprintf(fp, "%s", buf);
+ buf[0] = '\0';
+
+ q = get_qdisc_kind(kind);
+ if (q && q->print_copt) {
+ q->print_copt(q, fp, tb[TCA_OPTIONS]);
+ }
+ if (q && show_stats) {
+ int cls_indent = strlen(q->id) - 2 +
+ strlen(cls_id_str);
+ struct rtattr *stats = NULL;
+
+ graph_indent(buf, cls, 1, cls_indent);
+
+ if (tb[TCA_STATS] || tb[TCA_STATS2]) {
+ fprintf(fp, "\n");
+ print_tcstats_attr(fp, tb, buf, &stats);
+ buf[0] = '\0';
+ }
+ if (cls->hlist.next || cls->nodes_count) {
+ strcat(buf, "\n");
+ graph_indent(buf, cls, 1, 0);
+ }
+ }
+ }
+ free(cls->data);
+ fprintf(fp, "%s\n", buf);
+ buf[0] = '\0';
+
+ graph_cls_show(fp, buf, &children, level + 1);
+ if (!cls->hlist.next) {
+ graph_indent(buf, cls, 0, 0);
+ strcat(buf, "\n");
+ }
+
+ fprintf(fp, "%s", buf);
+ buf[0] = '\0';
+ free(cls);
+ }
+}
+
int print_class(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
{
FILE *fp = (FILE*)arg;
struct tcmsg *t = NLMSG_DATA(n);
int len = n->nlmsg_len;
- struct rtattr * tb[TCA_MAX+1];
+ struct rtattr *tb[TCA_MAX + 1] = {};
struct qdisc_util *q;
char abuf[256];
@@ -167,13 +321,18 @@ int print_class(const struct sockaddr_nl *who,
fprintf(stderr, "Wrong len %d\n", len);
return -1;
}
+
+ if (show_graph) {
+ graph_node_add(t->tcm_parent, t->tcm_handle, TCA_RTA(t), len);
+ return 0;
+ }
+
if (filter_qdisc && TC_H_MAJ(t->tcm_handle^filter_qdisc))
return 0;
if (filter_classid && t->tcm_handle != filter_classid)
return 0;
- memset(tb, 0, sizeof(tb));
parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
if (tb[TCA_KIND] == NULL) {
@@ -236,6 +395,7 @@ static int tc_class_list(int argc, char **argv)
{
struct tcmsg t;
char d[16];
+ char buf[1024] = {0};
memset(&t, 0, sizeof(t));
t.tcm_family = AF_UNSPEC;
@@ -306,6 +466,9 @@ static int tc_class_list(int argc, char **argv)
return 1;
}
+ if (show_graph)
+ graph_cls_show(stdout, &buf[0], &root_cls_list, 0);
+
return 0;
}
diff --git a/tc/tc_common.h b/tc/tc_common.h
index 4f88856..ea16f7f 100644
--- a/tc/tc_common.h
+++ b/tc/tc_common.h
@@ -19,3 +19,5 @@ extern int parse_estimator(int *p_argc, char ***p_argv, struct tc_estimator *est
struct tc_sizespec;
extern int parse_size_table(int *p_argc, char ***p_argv, struct tc_sizespec *s);
extern int check_size_table_opts(struct tc_sizespec *s);
+
+extern int show_graph;
--
2.1.3
^ permalink raw reply related
* Re: [PATCH v3] ne2k-pci: Add pci_disable_device in error handling
From: David Miller @ 2014-12-25 23:30 UTC (permalink / raw)
To: baijiaju1990; +Cc: bhelgaas, benoit.taine, netdev
In-Reply-To: <1419305343-29032-1-git-send-email-baijiaju1990@163.com>
From: Jia-Ju Bai <baijiaju1990@163.com>
Date: Tue, 23 Dec 2014 11:29:03 +0800
> For linux-3.18.0
> The driver lacks pci_disable_device in error handling code of
> ne2k_pci_init_one, so the device enabled by pci_enable_device is not
> disabled when errors occur.
> This patch fixes this problem.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH] bonding: change error message to debug message in __bond_release_one()
From: David Miller @ 2014-12-25 23:29 UTC (permalink / raw)
To: wen.gang.wang; +Cc: netdev, gospo, dingtianhong
In-Reply-To: <1419297876-1412-1-git-send-email-wen.gang.wang@oracle.com>
From: Wengang Wang <wen.gang.wang@oracle.com>
Date: Tue, 23 Dec 2014 09:24:36 +0800
> In __bond_release_one(), when the interface is not a slave or not a slave of
> "this" master, it log error message.
>
> The message actually should be a debug message matching what bond_enslave()
> does.
>
> Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 0/5] netlink/genetlink cleanups & multicast improvements
From: David Miller @ 2014-12-25 23:26 UTC (permalink / raw)
To: johannes; +Cc: netdev
In-Reply-To: <1419270999-22165-1-git-send-email-johannes@sipsolutions.net>
From: Johannes Berg <johannes@sipsolutions.net>
Date: Mon, 22 Dec 2014 18:56:34 +0100
> I'm looking at using the multicast group functionality in a way that would
> benefit from knowing when there are subscribers to avoid collecting the
> required data when there aren't any. During this I noticed that the unbind
> for multicast groups doesn't actually work - it's never called when sockets
> are closed. Luckily, nobody actually uses the functionality.
>
> While looking at the code trying to find why it's not called and where the
> multicast listeners are actually removed, I found the potential cleanup in
> patch 3. Patch 2 also has a cleanup for a generic netlink API in this area.
Series applied, using v2 of patch #5.
^ permalink raw reply
* [PATCH] ipnetns: fix exec for netns not in NETNS_RUN_DIR
From: Shahar Lev @ 2014-12-25 22:15 UTC (permalink / raw)
To: netdev; +Cc: Shahar Lev
Enabling "ip netns exec" to be run with a net namespace
specified by a file path rather than a filename under /var/run/nets.
Signed-off-by: Shahar Lev <shahar@stratoscale.com>
---
ip/ipnetns.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 1c8aa02..5310d0c 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -66,7 +66,7 @@ static int usage(void)
exit(-1);
}
-int get_netns_fd(const char *name)
+static int get_netns_fd_flags(const char *name, int flags)
{
char pathbuf[MAXPATHLEN];
const char *path, *ptr;
@@ -78,7 +78,12 @@ int get_netns_fd(const char *name)
NETNS_RUN_DIR, name );
path = pathbuf;
}
- return open(path, O_RDONLY);
+ return open(path, flags);
+}
+
+int get_netns_fd(const char *name)
+{
+ return get_netns_fd_flags(name, O_RDONLY);
}
static int netns_list(int argc, char **argv)
@@ -135,7 +140,6 @@ static int netns_exec(int argc, char **argv)
* aware, and execute a program in that environment.
*/
const char *name, *cmd;
- char net_path[MAXPATHLEN];
int netns;
if (argc < 1) {
@@ -149,8 +153,7 @@ static int netns_exec(int argc, char **argv)
name = argv[0];
cmd = argv[1];
- snprintf(net_path, sizeof(net_path), "%s/%s", NETNS_RUN_DIR, name);
- netns = open(net_path, O_RDONLY | O_CLOEXEC);
+ netns = get_netns_fd_flags(name, O_RDONLY | O_CLOEXEC);
if (netns < 0) {
fprintf(stderr, "Cannot open network namespace \"%s\": %s\n",
name, strerror(errno));
--
1.8.3.1
^ permalink raw reply related
* Re: Marvell Kirkwood - MV643XX: near 100% UDP RX packet loss
From: Rick Jones @ 2014-12-25 21:54 UTC (permalink / raw)
To: Bruno Prémont, Sebastian Hesselbarth; +Cc: netdev
In-Reply-To: <20141224001844.15e13db8@neptune.home>
> Why are so many packets being discarded?
You should also check the netstat statistics, particularly UDP on the
receiving side. Look before and after the test and see how they change,
if at all.
rick jones
^ permalink raw reply
* [PATCH v2 2/2] vhost: relax used address alignment
From: Michael S. Tsirkin @ 2014-12-25 15:05 UTC (permalink / raw)
To: linux-kernel; +Cc: netdev, kvm, virtualization
In-Reply-To: <1419517332-12291-1-git-send-email-mst@redhat.com>
virtio 1.0 only requires used address to be 4 byte aligned,
vhost required 8 bytes (size of vring_used_elem).
Fix up vhost to match that.
Additionally, while vhost correctly requires 8 byte
alignment for log, it's unconnected to used ring:
it's a consequence that log has u64 entries.
Tweak code to make that clearer.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/vhost/vhost.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ed71b53..cb807d0 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -713,9 +713,13 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
r = -EFAULT;
break;
}
- if ((a.avail_user_addr & (sizeof *vq->avail->ring - 1)) ||
- (a.used_user_addr & (sizeof *vq->used->ring - 1)) ||
- (a.log_guest_addr & (sizeof *vq->used->ring - 1))) {
+
+ /* Make sure it's safe to cast pointers to vring types. */
+ BUILD_BUG_ON(__alignof__ *vq->avail > VRING_AVAIL_ALIGN_SIZE);
+ BUILD_BUG_ON(__alignof__ *vq->used > VRING_USED_ALIGN_SIZE);
+ if ((a.avail_user_addr & (VRING_AVAIL_ALIGN_SIZE - 1)) ||
+ (a.used_user_addr & (VRING_USED_ALIGN_SIZE - 1)) ||
+ (a.log_guest_addr & (sizeof(u64) - 1))) {
r = -EINVAL;
break;
}
--
MST
^ permalink raw reply related
* Re: [Nios2-dev] [PATCH] Altera TSE: Add missing phydev
From: Tobias Klauser @ 2014-12-25 14:55 UTC (permalink / raw)
To: Kostya Belezko; +Cc: Nios2-dev, Vince Bridgers, netdev
In-Reply-To: <20141225125239.GP16916@distanz.ch>
On 2014-12-25 at 13:52:39 +0100, Tobias Klauser <tklauser@distanz.ch> wrote:
> On 2014-12-22 at 23:37:19 +0100, Kostya Belezko <bkostya@hotmail.com> wrote:
> > Altera network device doesn't come up after
> >
> > ifconfig eth0 down
> > ifconfig eth0 up
> >
> > The reason behind is clearing priv->phydev during tse_shutdown().
> > The phydev is not restored back at tse_open().
> >
> > Signed-off-by: Kostya Belezko <bkostya@hotmail.com>
>
> Please Cc: netdev@vger.kernel.org for network driver patches.
>
> > ---
> > drivers/net/ethernet/altera/altera_tse_main.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
> > index 4efc435..361bf35 100644
> > --- a/drivers/net/ethernet/altera/altera_tse_main.c
> > +++ b/drivers/net/ethernet/altera/altera_tse_main.c
> > @@ -1150,6 +1150,9 @@ static int tse_open(struct net_device *dev)
> >
> > spin_unlock_irqrestore(&priv->rxdma_irq_lock, flags);
> >
> > + if (!priv->phydev)
> > + init_phy(dev);
>
> That way the PHY will be initialized twice on first start.
It actually won't. Sorry, I didn't read careful enough.
Still, the solution suggested below is preferable IMO and this is also
what other ethernet drivers are doing (at least those I checked).
> IMO the proper solution would be to disconnect and NULL the phydev in
> altera_tse_remove, not in tse_shutdown. There, only phy_stop should be
> called.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox