* [PATCH net 1/2] igmp: fix incorrect unsolicit report count when join group
From: Hangbin Liu @ 2018-08-29 10:06 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Hangbin Liu
In-Reply-To: <1535537171-24533-1-git-send-email-liuhangbin@gmail.com>
We should not start timer if im->unsolicit_count equal to 0 after decrease.
Or we will send one more unsolicit report message. i.e. 3 instead of 2 by
default.
Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/ipv4/igmp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index cf75f89..deb1f82 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -820,10 +820,9 @@ static void igmp_timer_expire(struct timer_list *t)
spin_lock(&im->lock);
im->tm_running = 0;
- if (im->unsolicit_count) {
- im->unsolicit_count--;
+ if (im->unsolicit_count && --im->unsolicit_count)
igmp_start_timer(im, unsolicited_report_interval(in_dev));
- }
+
im->reporter = 1;
spin_unlock(&im->lock);
--
2.5.5
^ permalink raw reply related
* [PATCH net 1/2] igmp: fix incorrect unsolicit report count when join group
From: Hangbin Liu @ 2018-08-29 10:06 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Hangbin Liu
In-Reply-To: <1535537171-24533-1-git-send-email-liuhangbin@gmail.com>
We should not start timer if im->unsolicit_count equal to 0 after decrease.
Or we will send one more unsolicit report message. i.e. 3 instead of 2 by
default.
Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/ipv4/igmp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index cf75f89..deb1f82 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -820,10 +820,9 @@ static void igmp_timer_expire(struct timer_list *t)
spin_lock(&im->lock);
im->tm_running = 0;
- if (im->unsolicit_count) {
- im->unsolicit_count--;
+ if (im->unsolicit_count && --im->unsolicit_count)
igmp_start_timer(im, unsolicited_report_interval(in_dev));
- }
+
im->reporter = 1;
spin_unlock(&im->lock);
--
2.5.5
^ permalink raw reply related
* [PATCH net 2/2] igmp: fix incorrect unsolicit report count after link down and up
From: Hangbin Liu @ 2018-08-29 10:06 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Hangbin Liu
In-Reply-To: <1535537171-24533-1-git-send-email-liuhangbin@gmail.com>
After link down and up, i.e. when call ip_mc_up(), we doesn't init
im->unsolicit_count. So after igmp_timer_expire(), we will not start
timer again and only send one unsolicit report at last.
Fix it by initializing im->unsolicit_count in igmp_group_added(), so
we can respect igmp robustness value.
Fixes: 24803f38a5c0b ("igmp: do not remove igmp souce list info when set link down")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/ipv4/igmp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index deb1f82..4da3944 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1307,6 +1307,8 @@ static void igmp_group_added(struct ip_mc_list *im)
if (in_dev->dead)
return;
+
+ im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) {
spin_lock_bh(&im->lock);
igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY);
@@ -1390,9 +1392,6 @@ static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
unsigned int mode)
{
struct ip_mc_list *im;
-#ifdef CONFIG_IP_MULTICAST
- struct net *net = dev_net(in_dev->dev);
-#endif
ASSERT_RTNL();
@@ -1419,7 +1418,6 @@ static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
spin_lock_init(&im->lock);
#ifdef CONFIG_IP_MULTICAST
timer_setup(&im->timer, igmp_timer_expire, 0);
- im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
#endif
im->next_rcu = in_dev->mc_list;
--
2.5.5
^ permalink raw reply related
* [PATCH net 2/2] igmp: fix incorrect unsolicit report count after link down and up
From: Hangbin Liu @ 2018-08-29 10:06 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Hangbin Liu
In-Reply-To: <1535537171-24533-1-git-send-email-liuhangbin@gmail.com>
After link down and up, i.e. when call ip_mc_up(), we doesn't init
im->unsolicit_count. So after igmp_timer_expire(), we will not start
timer again and only send one unsolicit report at last.
Fix it by initializing im->unsolicit_count in igmp_group_added(), so
we can respect igmp robustness value.
Fixes: 24803f38a5c0b ("igmp: do not remove igmp souce list info when set link down")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/ipv4/igmp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index deb1f82..4da3944 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1307,6 +1307,8 @@ static void igmp_group_added(struct ip_mc_list *im)
if (in_dev->dead)
return;
+
+ im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) {
spin_lock_bh(&im->lock);
igmp_start_timer(im, IGMP_INITIAL_REPORT_DELAY);
@@ -1390,9 +1392,6 @@ static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
unsigned int mode)
{
struct ip_mc_list *im;
-#ifdef CONFIG_IP_MULTICAST
- struct net *net = dev_net(in_dev->dev);
-#endif
ASSERT_RTNL();
@@ -1419,7 +1418,6 @@ static void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
spin_lock_init(&im->lock);
#ifdef CONFIG_IP_MULTICAST
timer_setup(&im->timer, igmp_timer_expire, 0);
- im->unsolicit_count = net->ipv4.sysctl_igmp_qrv;
#endif
im->next_rcu = in_dev->mc_list;
--
2.5.5
^ permalink raw reply related
* [PATCH net-next 1/5] pppoe: fix PPPOEIOCSFWD compat handling
From: Arnd Bergmann @ 2018-08-29 14:03 UTC (permalink / raw)
To: paulus, linux-ppp, netdev
Cc: mitch, mostrows, jchapman, xeb, davem, viro, y2038, linux-kernel,
Arnd Bergmann
Support for handling the PPPOEIOCSFWD ioctl in compat mode was added in
linux-2.5.69 along with hundreds of other commands, but was always broken
sincen only the structure is compatible, but the command number is not,
due to the size being sizeof(size_t), or at first sizeof(sizeof((struct
sockaddr_pppox)), which is different on 64-bit architectures.
Fix it by defining a separate command code that matches the 32-bit
version, and marking that one as compatible.
This should apply to all stable kernels.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ppp/pppoe.c | 4 ++++
fs/compat_ioctl.c | 2 +-
include/linux/if_pppox.h | 2 ++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index ce61231e96ea..d1c3f9292c54 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -57,6 +57,7 @@
*
*/
+#include <linux/compat.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -780,6 +781,9 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
err = 0;
break;
+#ifdef CONFIG_COMPAT
+ case PPPOEIOCSFWD32:
+#endif
case PPPOEIOCSFWD:
{
struct pppox_sock *relay_po;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a9b00942e87d..a8bb193fdfd5 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -895,7 +895,7 @@ COMPATIBLE_IOCTL(PPPIOCATTCHAN)
COMPATIBLE_IOCTL(PPPIOCGCHAN)
COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS)
/* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD)
+COMPATIBLE_IOCTL(PPPOEIOCSFWD32)
COMPATIBLE_IOCTL(PPPOEIOCDFWD)
/* Big A */
/* sparc only */
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
index ba7a9b0c7c57..d221f1465f41 100644
--- a/include/linux/if_pppox.h
+++ b/include/linux/if_pppox.h
@@ -85,6 +85,8 @@ extern void unregister_pppox_proto(int proto_num);
extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
+#define PPPOEIOCSFWD32 _IOW(0xB1 ,0, compat_size_t)
+
/* PPPoX socket states */
enum {
PPPOX_NONE = 0, /* initial state */
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 2/5] ppp: move simple ioctl compat handling out of fs_compat_ioctl.c
From: Arnd Bergmann @ 2018-08-29 14:03 UTC (permalink / raw)
To: paulus, linux-ppp, netdev
Cc: mitch, mostrows, jchapman, xeb, davem, viro, y2038, linux-kernel,
Arnd Bergmann, Guillaume Nault
In-Reply-To: <20180829140409.833488-1-arnd@arndb.de>
There are multiple implementations of the PPP ioctl interface in the
kernel:
- drivers/net/ppp/ppp_generic.c implements a generic interface
for the /dev/ppp chardev used by some subdrivers.
- drivers/net/ppp/pppox.c implements a socket based interface
for pppoe, pptp and l2tp.
- drivers/isdn/i4l/isdn_ppp.c is for the i4l ISDN stack
All ioctl commands in the respective functions are compatible between
32-bit and 64-bit kernels, so we can simply mark the handlers themselves
as compatible and stop listing the commands individually.
Four commands (PPPIOCSCOMPRESS, PPPIOCSPASS, PPPIOCSACTIVE, and
PPPIOCGIDLE) are incompatible on the user level but have a translation
handler to make them compatible. I'm simplifying that compat handling
in separate patches.
The PPPIOCGUNIT and PPPIOCGCHAN ioctl commands are special, they are
implemented on various other file descriptors, so we have to keep them
listed as COMPATIBLE_IOCTL().
For the isdn_ppp code, additional ioctl commands are needed that have
never had working compat handling, so I'm leaving that part out: If
they are remaining users of i4l's ippp, they are not using compat
mode today, and are highly unlikely in the future before the last
ISDN network gets shut down. I4L has been deprecated since 2002.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ppp/ppp_generic.c | 1 +
drivers/net/ppp/pppoe.c | 3 +++
drivers/net/ppp/pptp.c | 3 +++
fs/compat_ioctl.c | 31 -------------------------------
net/l2tp/l2tp_ppp.c | 3 +++
5 files changed, 10 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 02ad03a2fab7..41a6e9851a4a 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -899,6 +899,7 @@ static const struct file_operations ppp_device_fops = {
.write = ppp_write,
.poll = ppp_poll,
.unlocked_ioctl = ppp_ioctl,
+ .compat_ioctl = ppp_ioctl,
.open = ppp_open,
.release = ppp_release,
.llseek = noop_llseek,
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index d1c3f9292c54..25174fa7a470 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1120,6 +1120,9 @@ static const struct proto_ops pppoe_ops = {
.recvmsg = pppoe_recvmsg,
.mmap = sock_no_mmap,
.ioctl = pppox_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = pppox_ioctl,
+#endif
};
static const struct pppox_proto pppoe_proto = {
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 67ffe74747a1..3b5ab3f6745c 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -632,6 +632,9 @@ static const struct proto_ops pptp_ops = {
.recvmsg = sock_no_recvmsg,
.mmap = sock_no_mmap,
.ioctl = pppox_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = pppox_ioctl,
+#endif
};
static const struct pppox_proto pppox_pptp_proto = {
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a8bb193fdfd5..142ca673b9cc 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -864,39 +864,8 @@ COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
#endif
/* PPP stuff */
-COMPATIBLE_IOCTL(PPPIOCGFLAGS)
-COMPATIBLE_IOCTL(PPPIOCSFLAGS)
-COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
COMPATIBLE_IOCTL(PPPIOCGUNIT)
-COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCGMRU)
-COMPATIBLE_IOCTL(PPPIOCSMRU)
-COMPATIBLE_IOCTL(PPPIOCSMAXCID)
-COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
-COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
-/* PPPIOCSCOMPRESS is translated */
-COMPATIBLE_IOCTL(PPPIOCGNPMODE)
-COMPATIBLE_IOCTL(PPPIOCSNPMODE)
-COMPATIBLE_IOCTL(PPPIOCGDEBUG)
-COMPATIBLE_IOCTL(PPPIOCSDEBUG)
-/* PPPIOCSPASS is translated */
-/* PPPIOCSACTIVE is translated */
-/* PPPIOCGIDLE is translated */
-COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
-COMPATIBLE_IOCTL(PPPIOCATTACH)
-COMPATIBLE_IOCTL(PPPIOCDETACH)
-COMPATIBLE_IOCTL(PPPIOCSMRRU)
-COMPATIBLE_IOCTL(PPPIOCCONNECT)
-COMPATIBLE_IOCTL(PPPIOCDISCONN)
-COMPATIBLE_IOCTL(PPPIOCATTCHAN)
COMPATIBLE_IOCTL(PPPIOCGCHAN)
-COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS)
-/* PPPOX */
-COMPATIBLE_IOCTL(PPPOEIOCSFWD32)
-COMPATIBLE_IOCTL(PPPOEIOCDFWD)
/* Big A */
/* sparc only */
/* Big Q for sound/OSS */
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 04d9946dcdba..8ef66513fbe0 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1686,6 +1686,9 @@ static const struct proto_ops pppol2tp_ops = {
.recvmsg = pppol2tp_recvmsg,
.mmap = sock_no_mmap,
.ioctl = pppox_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = pppox_ioctl,
+#endif
};
static const struct pppox_proto pppol2tp_proto = {
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 3/5] ppp: move PPPIOCSCOMPRESS32 to ppp-generic.c
From: Arnd Bergmann @ 2018-08-29 14:03 UTC (permalink / raw)
To: paulus, linux-ppp, netdev
Cc: mitch, mostrows, jchapman, xeb, davem, viro, y2038, linux-kernel,
Arnd Bergmann, Guillaume Nault, Kirill Tkhai
In-Reply-To: <20180829140409.833488-1-arnd@arndb.de>
PPPIOCSCOMPRESS is only implemented in ppp_generic, so it's best to move
the compat handling there. My first approach was to keep it in a new
ppp_compat_ioctl() function, but it turned out to be much simpler to do
it in the regular ioctl handler, by allowing both structure layouts to
be handled directly there.
Aside from moving the code to the right place, this also avoids
a round-trip through compat_alloc_user_space() allocated memory.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ppp/ppp_generic.c | 40 ++++++++++++++++++++++++++++++-----
fs/compat_ioctl.c | 32 ----------------------------
2 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 41a6e9851a4a..8dfe8d47df95 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -274,7 +274,7 @@ static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb);
static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp);
static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb);
#endif /* CONFIG_PPP_MULTILINK */
-static int ppp_set_compress(struct ppp *ppp, unsigned long arg);
+static int ppp_set_compress(struct ppp *ppp, unsigned long arg, bool compat);
static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound);
static void ppp_ccp_closed(struct ppp *ppp);
static struct compressor *find_compressor(int type);
@@ -557,6 +557,15 @@ static __poll_t ppp_poll(struct file *file, poll_table *wait)
return mask;
}
+#ifdef CONFIG_COMPAT
+struct ppp_option_data32 {
+ compat_caddr_t ptr;
+ u32 length;
+ compat_int_t transmit;
+};
+#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
+#endif
+
#ifdef CONFIG_PPP_FILTER
static int get_filter(void __user *arg, struct sock_filter **p)
{
@@ -683,8 +692,14 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
break;
case PPPIOCSCOMPRESS:
- err = ppp_set_compress(ppp, arg);
+ err = ppp_set_compress(ppp, arg, false);
+ break;
+
+#ifdef CONFIG_COMPAT
+ case PPPIOCSCOMPRESS32:
+ err = ppp_set_compress(ppp, arg, true);
break;
+#endif
case PPPIOCGUNIT:
if (put_user(ppp->file.index, p))
@@ -2691,7 +2706,7 @@ ppp_output_wakeup(struct ppp_channel *chan)
/* Process the PPPIOCSCOMPRESS ioctl. */
static int
-ppp_set_compress(struct ppp *ppp, unsigned long arg)
+ppp_set_compress(struct ppp *ppp, unsigned long arg, bool compat)
{
int err;
struct compressor *cp, *ocomp;
@@ -2700,8 +2715,23 @@ ppp_set_compress(struct ppp *ppp, unsigned long arg)
unsigned char ccp_option[CCP_MAX_OPTION_LENGTH];
err = -EFAULT;
- if (copy_from_user(&data, (void __user *) arg, sizeof(data)))
- goto out;
+#ifdef CONFIG_COMPAT
+ if (compat) {
+ struct ppp_option_data32 data32;
+
+ if (copy_from_user(&data32, (void __user *) arg,
+ sizeof(data32)))
+ goto out;
+
+ data.ptr = compat_ptr(data32.ptr);
+ data.length = data32.length;
+ data.transmit = data32.transmit;
+ } else
+#endif
+ {
+ if (copy_from_user(&data, (void __user *) arg, sizeof(data)))
+ goto out;
+ }
if (data.length > CCP_MAX_OPTION_LENGTH)
goto out;
if (copy_from_user(ccp_option, (void __user *) data.ptr, data.length))
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 142ca673b9cc..f518dc174dc7 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -413,13 +413,6 @@ static int ppp_sock_fprog_ioctl_trans(struct file *file,
return do_ioctl(file, cmd, (unsigned long) u_fprog64);
}
-struct ppp_option_data32 {
- compat_caddr_t ptr;
- u32 length;
- compat_int_t transmit;
-};
-#define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
-
struct ppp_idle32 {
compat_time_t xmit_idle;
compat_time_t recv_idle;
@@ -447,29 +440,6 @@ static int ppp_gidle(struct file *file, unsigned int cmd,
return err;
}
-static int ppp_scompress(struct file *file, unsigned int cmd,
- struct ppp_option_data32 __user *odata32)
-{
- struct ppp_option_data __user *odata;
- __u32 data;
- void __user *datap;
-
- odata = compat_alloc_user_space(sizeof(*odata));
-
- if (get_user(data, &odata32->ptr))
- return -EFAULT;
-
- datap = compat_ptr(data);
- if (put_user(datap, &odata->ptr))
- return -EFAULT;
-
- if (copy_in_user(&odata->length, &odata32->length,
- sizeof(__u32) + sizeof(int)))
- return -EFAULT;
-
- return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata);
-}
-
#ifdef CONFIG_BLOCK
struct mtget32 {
compat_long_t mt_type;
@@ -1248,8 +1218,6 @@ static long do_ioctl_trans(unsigned int cmd,
switch (cmd) {
case PPPIOCGIDLE32:
return ppp_gidle(file, cmd, argp);
- case PPPIOCSCOMPRESS32:
- return ppp_scompress(file, cmd, argp);
case PPPIOCSPASS32:
case PPPIOCSACTIVE32:
return ppp_sock_fprog_ioctl_trans(file, cmd, argp);
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 4/5] ppp: move PPPIOCSPASS32/PPPIOCSACTIVE32 to ppp_generic.c
From: Arnd Bergmann @ 2018-08-29 14:03 UTC (permalink / raw)
To: paulus, linux-ppp, netdev
Cc: mitch, mostrows, jchapman, xeb, davem, viro, y2038, linux-kernel,
Arnd Bergmann, Guillaume Nault
In-Reply-To: <20180829140409.833488-1-arnd@arndb.de>
PPPIOCSPASS and PPPIOCSACTIVE are implemented in ppp_generic and isdn_ppp,
but the latter one doesn't work for compat mode in general, so we can
move these two into the generic code.
Again, the best implementation I could come up with was to merge
the compat handling into the regular ppp_ioctl() function and
treating all ioctl commands as compatible.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ppp/ppp_generic.c | 39 ++++++++++++++++++++++++++++++-----
fs/compat_ioctl.c | 37 ---------------------------------
2 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 8dfe8d47df95..3a7aa2eed415 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -22,6 +22,7 @@
* ==FILEVERSION 20041108==
*/
+#include <linux/compat.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched/signal.h>
@@ -567,14 +568,36 @@ struct ppp_option_data32 {
#endif
#ifdef CONFIG_PPP_FILTER
-static int get_filter(void __user *arg, struct sock_filter **p)
+#ifdef CONFIG_COMPAT
+struct sock_fprog32 {
+ unsigned short len;
+ compat_caddr_t filter;
+};
+#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
+#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
+#endif
+
+static int get_filter(void __user *arg, struct sock_filter **p, bool compat)
{
struct sock_fprog uprog;
struct sock_filter *code = NULL;
int len;
- if (copy_from_user(&uprog, arg, sizeof(uprog)))
- return -EFAULT;
+#ifdef CONFIG_COMPAT
+ if (compat) {
+ struct sock_fprog32 uprog32;
+
+ if (copy_from_user(&uprog32, arg, sizeof(uprog32)))
+ return -EFAULT;
+
+ uprog.len = uprog32.len;
+ uprog.filter = compat_ptr(uprog32.filter);
+ } else
+#endif
+ {
+ if (copy_from_user(&uprog, arg, sizeof(uprog)))
+ return -EFAULT;
+ }
if (!uprog.len) {
*p = NULL;
@@ -772,10 +795,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
#ifdef CONFIG_PPP_FILTER
case PPPIOCSPASS:
+#ifdef CONFIG_COMPAT
+ case PPPIOCSPASS32:
+#endif
{
struct sock_filter *code;
- err = get_filter(argp, &code);
+ err = get_filter(argp, &code, cmd != PPPIOCSPASS);
if (err >= 0) {
struct bpf_prog *pass_filter = NULL;
struct sock_fprog_kern fprog = {
@@ -798,10 +824,13 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
break;
}
case PPPIOCSACTIVE:
+#ifdef CONFIG_COMPAT
+ case PPPIOCSACTIVE32:
+#endif
{
struct sock_filter *code;
- err = get_filter(argp, &code);
+ err = get_filter(argp, &code, cmd != PPPIOCSACTIVE);
if (err >= 0) {
struct bpf_prog *active_filter = NULL;
struct sock_fprog_kern fprog = {
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f518dc174dc7..258c6938e80a 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -379,40 +379,6 @@ static int sg_grt_trans(struct file *file,
}
#endif /* CONFIG_BLOCK */
-struct sock_fprog32 {
- unsigned short len;
- compat_caddr_t filter;
-};
-
-#define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
-#define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
-
-static int ppp_sock_fprog_ioctl_trans(struct file *file,
- unsigned int cmd, struct sock_fprog32 __user *u_fprog32)
-{
- struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
- void __user *fptr64;
- u32 fptr32;
- u16 flen;
-
- if (get_user(flen, &u_fprog32->len) ||
- get_user(fptr32, &u_fprog32->filter))
- return -EFAULT;
-
- fptr64 = compat_ptr(fptr32);
-
- if (put_user(flen, &u_fprog64->len) ||
- put_user(fptr64, &u_fprog64->filter))
- return -EFAULT;
-
- if (cmd == PPPIOCSPASS32)
- cmd = PPPIOCSPASS;
- else
- cmd = PPPIOCSACTIVE;
-
- return do_ioctl(file, cmd, (unsigned long) u_fprog64);
-}
-
struct ppp_idle32 {
compat_time_t xmit_idle;
compat_time_t recv_idle;
@@ -1218,9 +1184,6 @@ static long do_ioctl_trans(unsigned int cmd,
switch (cmd) {
case PPPIOCGIDLE32:
return ppp_gidle(file, cmd, argp);
- case PPPIOCSPASS32:
- case PPPIOCSACTIVE32:
- return ppp_sock_fprog_ioctl_trans(file, cmd, argp);
#ifdef CONFIG_BLOCK
case SG_IO:
return sg_ioctl_trans(file, cmd, argp);
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 5/5] ppp: handle PPPIOCGIDLE for 64-bit time_t
From: Arnd Bergmann @ 2018-08-29 14:03 UTC (permalink / raw)
To: paulus, linux-ppp, netdev
Cc: mitch, mostrows, jchapman, xeb, davem, viro, y2038, linux-kernel,
Arnd Bergmann, Karsten Keil, linux-doc
In-Reply-To: <20180829140409.833488-1-arnd@arndb.de>
The ppp_idle structure is defined in terms of __kernel_time_t, which is
defined as 'long' on all architectures, and this usage is not affected
by the y2038 problem since it transports a time interval rather than an
absolute time.
However, the ppp user space defines the same structure as time_t, which
may be 64-bit wide on new libc versions even on 32-bit architectures.
It's easy enough to just handle both possible structure layouts on
all architectures, to deal with the possibility that a user space ppp
implementation comes with its own ppp_idle structure definition, as well
as to document the fact that the driver is y2038-safe.
Doing this also avoids the need for a special compat mode translation,
since 32-bit and 64-bit kernels now support the same interfaces.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Documentation/networking/ppp_generic.txt | 2 ++
drivers/isdn/i4l/isdn_ppp.c | 14 ++++++++---
drivers/net/ppp/ppp_generic.c | 18 ++++++++++----
fs/compat_ioctl.c | 31 ------------------------
include/uapi/linux/ppp-ioctl.h | 2 ++
include/uapi/linux/ppp_defs.h | 14 +++++++++++
6 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/Documentation/networking/ppp_generic.txt b/Documentation/networking/ppp_generic.txt
index 61daf4b39600..fd563aff5fc9 100644
--- a/Documentation/networking/ppp_generic.txt
+++ b/Documentation/networking/ppp_generic.txt
@@ -378,6 +378,8 @@ an interface unit are:
CONFIG_PPP_FILTER option is enabled, the set of packets which reset
the transmit and receive idle timers is restricted to those which
pass the `active' packet filter.
+ Two versions of this command exist, to deal with user space
+ expecting times as either 32-bit or 64-bit time_t seconds.
* PPPIOCSMAXCID sets the maximum connection-ID parameter (and thus the
number of connection slots) for the TCP header compressor and
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index a7b275ea5de1..1f17126c5fa4 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -543,11 +543,19 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
}
is->pppcfg = val;
break;
- case PPPIOCGIDLE: /* get idle time information */
+ case PPPIOCGIDLE32: /* get idle time information */
if (lp) {
- struct ppp_idle pidle;
+ struct ppp_idle32 pidle;
pidle.xmit_idle = pidle.recv_idle = lp->huptimer;
- if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle))))
+ if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle32))))
+ return r;
+ }
+ break;
+ case PPPIOCGIDLE64: /* get idle time information */
+ if (lp) {
+ struct ppp_idle64 pidle;
+ pidle.xmit_idle = pidle.recv_idle = lp->huptimer;
+ if ((r = set_arg(argp, &pidle, sizeof(struct ppp_idle64))))
return r;
}
break;
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 3a7aa2eed415..c8b8aa071140 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -619,7 +619,8 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct ppp_file *pf;
struct ppp *ppp;
int err = -EFAULT, val, val2, i;
- struct ppp_idle idle;
+ struct ppp_idle32 idle32;
+ struct ppp_idle64 idle64;
struct npioctl npi;
int unit, cflags;
struct slcompress *vj;
@@ -743,10 +744,17 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
err = 0;
break;
- case PPPIOCGIDLE:
- idle.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
- idle.recv_idle = (jiffies - ppp->last_recv) / HZ;
- if (copy_to_user(argp, &idle, sizeof(idle)))
+ case PPPIOCGIDLE32:
+ idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
+ idle32.recv_idle = (jiffies - ppp->last_recv) / HZ;
+ if (copy_to_user(argp, &idle32, sizeof(idle32)))
+ err = 0;
+ break;
+
+ case PPPIOCGIDLE64:
+ idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
+ idle64.recv_idle = (jiffies - ppp->last_recv) / HZ;
+ if (copy_to_user(argp, &idle32, sizeof(idle32)))
break;
err = 0;
break;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 258c6938e80a..208ff51f3ed9 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -377,36 +377,7 @@ static int sg_grt_trans(struct file *file,
}
return err;
}
-#endif /* CONFIG_BLOCK */
-
-struct ppp_idle32 {
- compat_time_t xmit_idle;
- compat_time_t recv_idle;
-};
-#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
-
-static int ppp_gidle(struct file *file, unsigned int cmd,
- struct ppp_idle32 __user *idle32)
-{
- struct ppp_idle __user *idle;
- __kernel_time_t xmit, recv;
- int err;
-
- idle = compat_alloc_user_space(sizeof(*idle));
-
- err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle);
- if (!err) {
- if (get_user(xmit, &idle->xmit_idle) ||
- get_user(recv, &idle->recv_idle) ||
- put_user(xmit, &idle32->xmit_idle) ||
- put_user(recv, &idle32->recv_idle))
- err = -EFAULT;
- }
- return err;
-}
-
-#ifdef CONFIG_BLOCK
struct mtget32 {
compat_long_t mt_type;
compat_long_t mt_resid;
@@ -1182,8 +1153,6 @@ static long do_ioctl_trans(unsigned int cmd,
void __user *argp = compat_ptr(arg);
switch (cmd) {
- case PPPIOCGIDLE32:
- return ppp_gidle(file, cmd, argp);
#ifdef CONFIG_BLOCK
case SG_IO:
return sg_ioctl_trans(file, cmd, argp);
diff --git a/include/uapi/linux/ppp-ioctl.h b/include/uapi/linux/ppp-ioctl.h
index 88b5f9990320..7bd2a5a75348 100644
--- a/include/uapi/linux/ppp-ioctl.h
+++ b/include/uapi/linux/ppp-ioctl.h
@@ -104,6 +104,8 @@ struct pppol2tp_ioc_stats {
#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */
#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */
#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */
+#define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) /* 32-bit times */
+#define PPPIOCGIDLE64 _IOR('t', 63, struct ppp_idle64) /* 64-bit times */
#define PPPIOCNEWUNIT _IOWR('t', 62, int) /* create new ppp unit */
#define PPPIOCATTACH _IOW('t', 61, int) /* attach to ppp unit */
#define PPPIOCDETACH _IOW('t', 60, int) /* obsolete, do not use */
diff --git a/include/uapi/linux/ppp_defs.h b/include/uapi/linux/ppp_defs.h
index fff51b91b409..0039fa39a358 100644
--- a/include/uapi/linux/ppp_defs.h
+++ b/include/uapi/linux/ppp_defs.h
@@ -142,10 +142,24 @@ struct ppp_comp_stats {
/*
* The following structure records the time in seconds since
* the last NP packet was sent or received.
+ *
+ * Linux implements both 32-bit and 64-bit time_t versions
+ * for compatibility with user space that defines ppp_idle
+ * based on the libc time_t.
*/
struct ppp_idle {
__kernel_time_t xmit_idle; /* time since last NP packet sent */
__kernel_time_t recv_idle; /* time since last NP packet received */
};
+struct ppp_idle32 {
+ __s32 xmit_idle; /* time since last NP packet sent */
+ __s32 recv_idle; /* time since last NP packet received */
+};
+
+struct ppp_idle64 {
+ __s64 xmit_idle; /* time since last NP packet sent */
+ __s64 recv_idle; /* time since last NP packet received */
+};
+
#endif /* _UAPI_PPP_DEFS_H_ */
--
2.18.0
^ permalink raw reply related
* [RFC net-next] veth: report NEWLINK event when moving the peer device in a new namespace
From: Lorenzo Bianconi @ 2018-08-29 10:09 UTC (permalink / raw)
To: davem; +Cc: netdev
In-Reply-To: <cover.1535532739.git.lorenzo.bianconi@redhat.com>
When moving a veth device to another namespace, userspace receives a
RTM_DELLINK message indicating the device has been removed from current
netns. However, the other peer does not receive a netlink event
containing new values for IFLA_LINK_NETNSID and IFLA_LINK veth
attributes.
Fix that behaviour sending to userspace a RTM_NEWLINK message in the peer
namespace to report new IFLA_LINK_NETNSID/IFLA_LINK values
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
drivers/net/veth.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8d679c8b7f25..b27d46d8084a 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1242,18 +1242,76 @@ static struct rtnl_link_ops veth_link_ops = {
.get_link_net = veth_get_link_net,
};
+static int veth_notify(struct notifier_block *this,
+ unsigned long event, void *ptr)
+{
+ struct net_device *peer, *dev = netdev_notifier_info_to_dev(ptr);
+ struct net *peer_net, *net = dev_net(dev);
+ int nsid, ret = NOTIFY_DONE;
+ struct veth_priv *priv;
+
+ if (dev->netdev_ops != &veth_netdev_ops)
+ return NOTIFY_DONE;
+
+ if (event != NETDEV_REGISTER)
+ return NOTIFY_DONE;
+
+ priv = netdev_priv(dev);
+
+ rcu_read_lock();
+
+ peer = rcu_dereference(priv->peer);
+ if (!peer)
+ goto out;
+
+ peer_net = dev_net(peer);
+ /* do not forward events if both veth devices
+ * are in the same namespace
+ */
+ if (peer_net == net)
+ goto out;
+
+ /* notify on peer namespace new IFLA_LINK_NETNSID
+ * and IFLA_LINK values
+ */
+ nsid = peernet2id_alloc(peer_net, net);
+ rtmsg_ifinfo_newnet(RTM_NEWLINK, peer, ~0U, GFP_ATOMIC,
+ &nsid, dev->ifindex);
+ ret = NOTIFY_OK;
+
+out:
+ rcu_read_unlock();
+
+ return ret;
+}
+
+static struct notifier_block veth_notifier = {
+ .notifier_call = veth_notify,
+};
+
/*
* init/fini
*/
static __init int veth_init(void)
{
- return rtnl_link_register(&veth_link_ops);
+ int err;
+
+ err = register_netdevice_notifier(&veth_notifier);
+ if (err < 0)
+ return err;
+
+ err = rtnl_link_register(&veth_link_ops);
+ if (err < 0)
+ unregister_netdevice_notifier(&veth_notifier);
+
+ return err;
}
static __exit void veth_exit(void)
{
rtnl_link_unregister(&veth_link_ops);
+ unregister_netdevice_notifier(&veth_notifier);
}
module_init(veth_init);
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 0/2] net/sched: Add hardware specific counters to TC actions
From: Paolo Abeni @ 2018-08-29 10:23 UTC (permalink / raw)
To: Jakub Kicinski, Eelco Chaudron
Cc: David Miller, netdev, jhs, xiyou.wangcong, jiri, simon.horman,
Marcelo Ricardo Leitner, louis.peens
In-Reply-To: <20180823201446.3802e84b@cakuba.netronome.com>
On Thu, 2018-08-23 at 20:14 +0200, Jakub Kicinski wrote:
> I asked Louis to run some tests while I'm travelling, and he reports
> that my worry about reporting the extra stats was unfounded. Update
> function does not show up in traces at all. It seems under stress
> (generated with stress-ng) the thread dumping the stats in userspace
> (in OvS it would be the revalidator) actually consumes less CPU in
> __gnet_stats_copy_basic (0.4% less for ~2.0% total).
>
> Would this match with your results? I'm not sure why dumping would be
> faster with your change..
Wild guess on my side: the relevant patch changes a bit the binary
layout of the 'tc_action' struct, possibly (I still need to check with
pahole) moving the tcf_lock and the stats field on different
cachelines, reducing false sharing that could affect badly such test.
Cheers,
Paolo
^ permalink raw reply
* Re: [PATCH net 0/2] igmp: fix two incorrect unsolicit report count issues
From: Hangbin Liu @ 2018-08-29 11:08 UTC (permalink / raw)
To: netdev; +Cc: David Miller
In-Reply-To: <1535537171-24533-1-git-send-email-liuhangbin@gmail.com>
Opps, sent two duplicate mails by mistake.
Please ignore the duplicate messages. Sorry.
On Wed, Aug 29, 2018 at 06:06:07PM +0800, Hangbin Liu wrote:
> Just like the subject, fix two minor igmp unsolicit report count issues.
>
> Hangbin Liu (2):
> igmp: fix incorrect unsolicit report count when join group
> igmp: fix incorrect unsolicit report count after link down and up
>
> net/ipv4/igmp.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> --
> 2.5.5
>
^ permalink raw reply
* [PATCH] veth: add software timestamping
From: Michael Walle @ 2018-08-29 15:24 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel, David S . Miller, Michael Walle
Provide a software TX timestamp as well as the ethtool query interface
and report the software timestamp capabilities.
Tested with "ethtool -T" and two linuxptp instances each bound to a
tunnel endpoint.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/net/veth.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8d679c8b7f25..bc8faf13a731 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -24,6 +24,7 @@
#include <linux/filter.h>
#include <linux/ptr_ring.h>
#include <linux/bpf_trace.h>
+#include <linux/net_tstamp.h>
#define DRV_NAME "veth"
#define DRV_VERSION "1.0"
@@ -114,6 +115,18 @@ static void veth_get_ethtool_stats(struct net_device *dev,
data[0] = peer ? peer->ifindex : 0;
}
+static int veth_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *info)
+{
+ info->so_timestamping =
+ SOF_TIMESTAMPING_TX_SOFTWARE |
+ SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ info->phc_index = -1;
+
+ return 0;
+}
+
static const struct ethtool_ops veth_ethtool_ops = {
.get_drvinfo = veth_get_drvinfo,
.get_link = ethtool_op_get_link,
@@ -121,6 +134,7 @@ static const struct ethtool_ops veth_ethtool_ops = {
.get_sset_count = veth_get_sset_count,
.get_ethtool_stats = veth_get_ethtool_stats,
.get_link_ksettings = veth_get_link_ksettings,
+ .get_ts_info = veth_get_ts_info,
};
/* general routines */
@@ -201,6 +215,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
skb_record_rx_queue(skb, rxq);
}
+ skb_tx_timestamp(skb);
if (likely(veth_forward_skb(rcv, skb, rq, rcv_xdp) == NET_RX_SUCCESS)) {
struct pcpu_vstats *stats = this_cpu_ptr(dev->vstats);
--
2.11.0
^ permalink raw reply related
* Re: [PATCH net] sctp: hold transport before accessing its asoc in sctp_transport_get_next
From: Neil Horman @ 2018-08-29 11:35 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, linux-sctp, davem, Marcelo Ricardo Leitner
In-Reply-To: <CADvbK_f7+UqMqm-ZzEwSz92Joxx_46a1kBrwNbpAi52Qkk=FuQ@mail.gmail.com>
On Wed, Aug 29, 2018 at 12:08:40AM +0800, Xin Long wrote:
> On Mon, Aug 27, 2018 at 9:08 PM Neil Horman <nhorman@tuxdriver.com> wrote:
> >
> > On Mon, Aug 27, 2018 at 06:38:31PM +0800, Xin Long wrote:
> > > As Marcelo noticed, in sctp_transport_get_next, it is iterating over
> > > transports but then also accessing the association directly, without
> > > checking any refcnts before that, which can cause an use-after-free
> > > Read.
> > >
> > > So fix it by holding transport before accessing the association. With
> > > that, sctp_transport_hold calls can be removed in the later places.
> > >
> > > Fixes: 626d16f50f39 ("sctp: export some apis or variables for sctp_diag and reuse some for proc")
> > > Reported-by: syzbot+fe62a0c9aa6a85c6de16@syzkaller.appspotmail.com
> > > Signed-off-by: Xin Long <lucien.xin@gmail.com>
> > > ---
> > > net/sctp/proc.c | 4 ----
> > > net/sctp/socket.c | 22 +++++++++++++++-------
> > > 2 files changed, 15 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/net/sctp/proc.c b/net/sctp/proc.c
> > > index ef5c9a8..4d6f1c8 100644
> > > --- a/net/sctp/proc.c
> > > +++ b/net/sctp/proc.c
> > > @@ -264,8 +264,6 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
> > > }
> > >
> > > transport = (struct sctp_transport *)v;
> > > - if (!sctp_transport_hold(transport))
> > > - return 0;
> > > assoc = transport->asoc;
> > > epb = &assoc->base;
> > > sk = epb->sk;
> > > @@ -322,8 +320,6 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
> > > }
> > >
> > > transport = (struct sctp_transport *)v;
> > > - if (!sctp_transport_hold(transport))
> > > - return 0;
> > > assoc = transport->asoc;
> > >
> > > list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
> > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> > > index e96b15a..aa76586 100644
> > > --- a/net/sctp/socket.c
> > > +++ b/net/sctp/socket.c
> > > @@ -5005,9 +5005,14 @@ struct sctp_transport *sctp_transport_get_next(struct net *net,
> > > break;
> > > }
> > >
> > > + if (!sctp_transport_hold(t))
> > > + continue;
> > > +
> > > if (net_eq(sock_net(t->asoc->base.sk), net) &&
> > > t->asoc->peer.primary_path == t)
> > > break;
> > > +
> > > + sctp_transport_put(t);
> > > }
> > >
> > > return t;
> > > @@ -5017,13 +5022,18 @@ struct sctp_transport *sctp_transport_get_idx(struct net *net,
> > > struct rhashtable_iter *iter,
> > > int pos)
> > > {
> > > - void *obj = SEQ_START_TOKEN;
> > > + struct sctp_transport *t;
> > >
> > > - while (pos && (obj = sctp_transport_get_next(net, iter)) &&
> > > - !IS_ERR(obj))
> > > - pos--;
> > > + if (!pos)
> > > + return SEQ_START_TOKEN;
> > >
> > > - return obj;
> > > + while ((t = sctp_transport_get_next(net, iter)) && !IS_ERR(t)) {
> > > + if (!--pos)
> > > + break;
> > > + sctp_transport_put(t);
> > > + }
> > > +
> > > + return t;
> > > }
> > >
> > > int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *),
> > > @@ -5082,8 +5092,6 @@ int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
> > >
> > > tsp = sctp_transport_get_idx(net, &hti, *pos + 1);
> > > for (; !IS_ERR_OR_NULL(tsp); tsp = sctp_transport_get_next(net, &hti)) {
> > > - if (!sctp_transport_hold(tsp))
> > > - continue;
> > > ret = cb(tsp, p);
> > > if (ret)
> > > break;
> > > --
> > > 2.1.0
> > >
> > >
> > Acked-by: Neil Horman <nhorman@tuxdriver.com>
> >
> > Additionally, its not germaine to this particular fix, but why are we still
> > using that pos variable in sctp_transport_get_idx? With the conversion to
> > rhashtables, it doesn't seem particularly useful anymore.
> For proc, seems so, hti is saved into seq->private.
> But for diag, "hti" in sctp_for_each_transport() is a local variable.
> do you think where we can save it?
>
Sorry, wasn't suggesting that it had to be removed from sctp_for_each_trasnport,
its clearly used as both an input and output there. All I was sugesting was
that, in sctp_transport_get_idx, the pos variable might no longer be needed
there specifically, as sctp_transprt_get_next should terminate the loop on its
own. Or is there another purpose for that positional variable I am missing
Neil
^ permalink raw reply
* Kernel Panic on high bandwidth transfer over wifi
From: Nathaniel Munk @ 2018-08-29 11:42 UTC (permalink / raw)
To: netdev@vger.kernel.org
Hi all,
I'm running Arch Linux on kernel 4.18.5 (same issue on both arch-provided kernel and mainline built-from-source). There is an issue whereby the kernel crashes when transferring at high bandwidths (approx 6mB/s) over a specific wifi connection. I can only reproduce the issue when using the Personal Hotspot on my iPhone 6S+, but can reproduce it very consistently on that connection.
More often than not, any download reaching this speed will cause a panic, but if the download is immediately terminated at the first error the system can recover (and doing this I have obtained the attached logs). Unfortunately, I have not had access to a second machine to obtain the netconsole printout of the panic.
As above, high-bandwidth transfers on other wifi networks do not cause the issue (nor on ethernet connections).
As you can see from the attached log, the issue appears at tcp_recvmsg+0x579 and net_tx_action+0x1fe. At both these positions (net/ipv4/tcp.c:2000 and net/core/dev.c:4279 in mainline 4.18.5), a member of the skb struct is called.
Thank you for your time (and I apologize if this is spurious or badly worded, this is my first bug report), and please don't hesitate to let me know if there's anything else I can do to help work this out.
Regards,
-------------------
Nathaniel Munk
nathaniel@munk.com.au
^ permalink raw reply
* [PATCH net-next] rds: store socket timestamps as ktime_t
From: Arnd Bergmann @ 2018-08-29 15:47 UTC (permalink / raw)
To: Santosh Shilimkar, David S. Miller
Cc: Arnd Bergmann, Sowmini Varadhan, Willem de Bruijn, Ka-Cheong Poon,
Salvatore Mesoraca, Avinash Repaka, Eric Dumazet, netdev,
linux-rdma, rds-devel, linux-kernel
rds is the last in-kernel user of the old do_gettimeofday()
function. Convert it over to ktime_get_real() to make it
work more like the generic socket timestamps, and to let
us kill off do_gettimeofday().
A follow-up patch will have to change the user space interface
to deal better with 32-bit tasks, which may use an incompatible
layout for 'struct timespec'.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/rds/rds.h | 2 +-
net/rds/recv.c | 14 ++++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/rds/rds.h b/net/rds/rds.h
index c4dcf654d8fe..6bfaf05b63b2 100644
--- a/net/rds/rds.h
+++ b/net/rds/rds.h
@@ -278,7 +278,7 @@ struct rds_incoming {
struct in6_addr i_saddr;
rds_rdma_cookie_t i_rdma_cookie;
- struct timeval i_rx_tstamp;
+ ktime_t i_rx_tstamp;
u64 i_rx_lat_trace[RDS_RX_MAX_TRACES];
};
diff --git a/net/rds/recv.c b/net/rds/recv.c
index 504cd6bcc54c..12719653188a 100644
--- a/net/rds/recv.c
+++ b/net/rds/recv.c
@@ -50,8 +50,7 @@ void rds_inc_init(struct rds_incoming *inc, struct rds_connection *conn,
inc->i_conn = conn;
inc->i_saddr = *saddr;
inc->i_rdma_cookie = 0;
- inc->i_rx_tstamp.tv_sec = 0;
- inc->i_rx_tstamp.tv_usec = 0;
+ inc->i_rx_tstamp = ktime_set(0, 0);
for (i = 0; i < RDS_RX_MAX_TRACES; i++)
inc->i_rx_lat_trace[i] = 0;
@@ -67,8 +66,7 @@ void rds_inc_path_init(struct rds_incoming *inc, struct rds_conn_path *cp,
inc->i_conn_path = cp;
inc->i_saddr = *saddr;
inc->i_rdma_cookie = 0;
- inc->i_rx_tstamp.tv_sec = 0;
- inc->i_rx_tstamp.tv_usec = 0;
+ inc->i_rx_tstamp = ktime_set(0, 0);
}
EXPORT_SYMBOL_GPL(rds_inc_path_init);
@@ -385,7 +383,7 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr,
be32_to_cpu(inc->i_hdr.h_len),
inc->i_hdr.h_dport);
if (sock_flag(sk, SOCK_RCVTSTAMP))
- do_gettimeofday(&inc->i_rx_tstamp);
+ inc->i_rx_tstamp = ktime_get_real();
rds_inc_addref(inc);
inc->i_rx_lat_trace[RDS_MSG_RX_END] = local_clock();
list_add_tail(&inc->i_item, &rs->rs_recv_queue);
@@ -552,11 +550,11 @@ static int rds_cmsg_recv(struct rds_incoming *inc, struct msghdr *msg,
goto out;
}
- if ((inc->i_rx_tstamp.tv_sec != 0) &&
+ if ((inc->i_rx_tstamp != 0) &&
sock_flag(rds_rs_to_sk(rs), SOCK_RCVTSTAMP)) {
+ struct timeval tv = ktime_to_timeval(inc->i_rx_tstamp);
ret = put_cmsg(msg, SOL_SOCKET, SCM_TIMESTAMP,
- sizeof(struct timeval),
- &inc->i_rx_tstamp);
+ sizeof(tv), &tv);
if (ret)
goto out;
}
--
2.18.0
^ permalink raw reply related
* Re: Kernel Panic on high bandwidth transfer over wifi
From: Willy Tarreau @ 2018-08-29 12:09 UTC (permalink / raw)
To: Nathaniel Munk; +Cc: netdev@vger.kernel.org
In-Reply-To: <porA6Oc9uVOmzI_nV2MhBU5RzBhBCq82gffuA1TBkrQxwTToIy03qc44DkN8BmdVKgQAGU6qDyrkCx7sDQI5SbSt9b9-HHf9ufHcIQlT-kg=@munk.com.au>
On Wed, Aug 29, 2018 at 11:42:44AM +0000, Nathaniel Munk wrote:
> As you can see from the attached log
You apparently forgot to attach the log.
Willy
^ permalink raw reply
* Re: Kernel Panic on high bandwidth transfer over wifi
From: Nathaniel Munk @ 2018-08-29 12:12 UTC (permalink / raw)
To: Willy Tarreau, netdev@vger.kernel.org
In-Reply-To: <20180829120928.GA21238@1wt.eu>
[-- Attachment #1: Type: text/plain, Size: 404 bytes --]
Of course I did, sorry.
-------------------
Nathaniel Munk
nathaniel@munk.com.au
0435 726 099
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On August 29, 2018 10:09 PM, Willy Tarreau <w@1wt.eu> wrote:
> On Wed, Aug 29, 2018 at 11:42:44AM +0000, Nathaniel Munk wrote:
>
> > As you can see from the attached log
>
> You apparently forgot to attach the log.
>
> Willy
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dmesg.log --]
[-- Type: text/x-log; name="dmesg.log", Size: 14254 bytes --]
[ 1242.620637] TCP recvmsg seq # bug: copied 93359823, seq 1, rcvnxt 93359D8F, fl 80000000
[ 1242.620700] WARNING: CPU: 0 PID: 10255 at net/ipv4/tcp.c:2003 tcp_recvmsg+0x579/0xc70
[ 1242.620704] Modules linked in: ccm nf_tables_set nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat_ipv6 nft_chain_nat_ipv4 nf_tables ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack libcrc32c ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bpfilter 8021q mrp ipheth btusb btrtl btbcm btintel uvcvideo bluetooth videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev media ecdh_generic joydev mousedev nls_iso8859_1 nls_cp437 vfat fat arc4 snd_hda_codec_hdmi
[ 1242.620797] snd_soc_skl snd_soc_skl_ipc iwlmvm snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core snd_soc_acpi snd_soc_core mei_wdt mac80211 snd_hda_codec_realtek snd_compress iTCO_wdt ac97_bus snd_hda_codec_generic snd_pcm_dmaengine iTCO_vendor_support intel_rapl snd_hda_intel x86_pkg_temp_thermal intel_powerclamp snd_hda_codec coretemp kvm_intel snd_hda_core wmi_bmof iwlwifi kvm cfg80211 snd_hwdep input_leds snd_pcm thinkpad_acpi snd_timer psmouse irqbypass nvram mei_me intel_cstate rfkill intel_uncore e1000e intel_rapl_perf mei i2c_i801 snd intel_pch_thermal soundcore ac tpm_tis tpm_tis_core tpm rng_core led_class evdev battery wmi rtc_cmos mac_hid pcc_cpufreq ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto algif_skcipher af_alg dm_crypt dm_mod sd_mod crct10dif_pclmul crc32_pclmul
[ 1242.620885] crc32c_intel ghash_clmulni_intel pcbc serio_raw atkbd libps2 ahci libahci aesni_intel libata aes_x86_64 crypto_simd xhci_pci cryptd glue_helper scsi_mod xhci_hcd i8042 serio hid_generic usbhid usbcore usb_common hid intel_agp i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm intel_gtt agpgart
[ 1242.620933] CPU: 0 PID: 10255 Comm: IOCP Thread 0 Tainted: G U W 4.18.5-arch1-1-ARCH #1
[ 1242.620937] Hardware name: LENOVO 20FN001CAU/20FN001CAU, BIOS R06ET59W (1.33 ) 02/27/2018
[ 1242.620949] RIP: 0010:tcp_recvmsg+0x579/0xc70
[ 1242.620951] Code: fb ff ff 4c 89 e0 41 8b 8d 38 05 00 00 44 8b 44 24 2c 89 de 48 c7 c7 28 f5 6f 9a 4c 89 54 24 08 48 89 44 24 10 e8 11 f8 9f ff <0f> 0b 48 8b 44 24 10 4c 8b 54 24 08 8b 4c 24 3c 39 4c 24 38 0f 8c
[ 1242.621003] RSP: 0018:ffffb0de41223bb0 EFLAGS: 00010282
[ 1242.621007] RAX: 0000000000000000 RBX: 0000000093359823 RCX: 0000000000000001
[ 1242.621010] RDX: 0000000080000001 RSI: ffffffff9a6811ce RDI: 00000000ffffffff
[ 1242.621013] RBP: ffffb0de41223c70 R08: ffffffff99cddf10 R09: 00000000000003c4
[ 1242.621016] R10: 0000000000000008 R11: ffffffff9ae04f2d R12: ffff8a6a70e76a00
[ 1242.621018] R13: ffff8a6a39ea18c0 R14: 0000000000000000 R15: ffff8a6a39ea1dfc
[ 1242.621022] FS: 0000000000000000(0000) GS:ffff8a6a81400000(0063) knlGS:00000000ed455b40
[ 1242.621026] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
[ 1242.621028] CR2: 00000000e9f68000 CR3: 00000002347aa004 CR4: 00000000003606f0
[ 1242.621032] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1242.621035] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1242.621038] Call Trace:
[ 1242.621049] ? update_rq_clock+0x33/0x120
[ 1242.621053] ? compat_import_iovec+0x37/0xcd
[ 1242.621058] ? __switch_to_asm+0x40/0x70
[ 1242.621061] inet_recvmsg+0x5b/0x100
[ 1242.621066] ___sys_recvmsg+0xdd/0x1e0
[ 1242.621070] ? __switch_to_asm+0x34/0x70
[ 1242.621074] ? _raw_spin_unlock_irq+0x1d/0x30
[ 1242.621077] ? finish_task_switch+0x83/0x2c0
[ 1242.621080] ? tcp_keepalive_timer.cold.3+0x19/0x19
[ 1242.621084] ? tcp_poll+0x12e/0x260
[ 1242.621086] ? sock_poll+0x61/0xb0
[ 1242.621091] ? ep_item_poll.isra.1+0x40/0xc0
[ 1242.621095] ? ep_send_events_proc+0x7b/0x1a0
[ 1242.621098] ? __ia32_sys_epoll_ctl+0x20/0x20
[ 1242.621101] ? preempt_count_add+0x68/0xa0
[ 1242.621106] ? _raw_spin_lock_irqsave+0x25/0x50
[ 1242.621112] ? __fget+0x6e/0xa0
[ 1242.621116] __sys_recvmsg+0x54/0xa0
[ 1242.621124] __ia32_compat_sys_socketcall+0x174/0x300
[ 1242.621129] ? do_epoll_wait+0x8b/0xd0
[ 1242.621135] do_fast_syscall_32+0xa7/0x2a0
[ 1242.621139] entry_SYSENTER_compat+0x7f/0x91
[ 1242.621144] ---[ end trace dc996496c7568a8f ]---
[ 1242.621232] BUG: unable to handle kernel paging request at 000000020024cb72
[ 1242.621238] PGD 80000001f9fe0067 P4D 80000001f9fe0067 PUD 0
[ 1242.621244] Oops: 0000 [#1] PREEMPT SMP PTI
[ 1242.621250] CPU: 0 PID: 10255 Comm: IOCP Thread 0 Tainted: G U W 4.18.5-arch1-1-ARCH #1
[ 1242.621252] Hardware name: LENOVO 20FN001CAU/20FN001CAU, BIOS R06ET59W (1.33 ) 02/27/2018
[ 1242.621258] RIP: 0010:tcp_drop+0x17/0x40
[ 1242.621259] Code: 00 e9 5b ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 0f 1f 44 00 00 8b 96 cc 00 00 00 48 8b 8e d0 00 00 00 b8 01 00 00 00 <66> 83 7c 11 06 00 66 0f 45 44 11 06 0f b7 c0 f0 01 87 a8 00 00 00
[ 1242.621299] RSP: 0018:ffffb0de41223b08 EFLAGS: 00010203
[ 1242.621303] RAX: 0000000000000001 RBX: ffff8a6a39ea18c0 RCX: 0000000100254102
[ 1242.621305] RDX: 00000000ffff8a6a RSI: ffff8a6a39ea1988 RDI: ffff8a6a39ea18c0
[ 1242.621306] RBP: ffff8a6a39ea1988 R08: 0000000000000000 R09: ffffffff99e8930e
[ 1242.621308] R10: ffff8a6a743f6310 R11: 0000000000000002 R12: ffff8a6a39ea1988
[ 1242.621310] R13: ffffffff99e92380 R14: 0000000000000000 R15: 00000000fffffff5
[ 1242.621312] FS: 0000000000000000(0000) GS:ffff8a6a81400000(0063) knlGS:00000000ed455b40
[ 1242.621315] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
[ 1242.621316] CR2: 000000020024cb72 CR3: 00000002347aa004 CR4: 00000000003606f0
[ 1242.621319] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1242.621321] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1242.621323] Call Trace:
[ 1242.621332] tcp_rcv_established+0x10a/0x630
[ 1242.621339] tcp_v4_do_rcv+0x11e/0x1c0
[ 1242.621348] __release_sock+0x7c/0xc0
[ 1242.621354] release_sock+0x2b/0x90
[ 1242.621357] tcp_recvmsg+0x4dc/0xc70
[ 1242.621366] ? update_rq_clock+0x33/0x120
[ 1242.621374] ? compat_import_iovec+0x37/0xcd
[ 1242.621381] ? __switch_to_asm+0x40/0x70
[ 1242.621386] inet_recvmsg+0x5b/0x100
[ 1242.621394] ___sys_recvmsg+0xdd/0x1e0
[ 1242.621399] ? __switch_to_asm+0x34/0x70
[ 1242.621403] ? _raw_spin_unlock_irq+0x1d/0x30
[ 1242.621407] ? finish_task_switch+0x83/0x2c0
[ 1242.621412] ? tcp_keepalive_timer.cold.3+0x19/0x19
[ 1242.621420] ? tcp_poll+0x12e/0x260
[ 1242.621423] ? sock_poll+0x61/0xb0
[ 1242.621434] ? ep_item_poll.isra.1+0x40/0xc0
[ 1242.621438] ? ep_send_events_proc+0x7b/0x1a0
[ 1242.621442] ? __ia32_sys_epoll_ctl+0x20/0x20
[ 1242.621445] ? preempt_count_add+0x68/0xa0
[ 1242.621450] ? _raw_spin_lock_irqsave+0x25/0x50
[ 1242.621458] ? __fget+0x6e/0xa0
[ 1242.621462] __sys_recvmsg+0x54/0xa0
[ 1242.621469] __ia32_compat_sys_socketcall+0x174/0x300
[ 1242.621473] ? do_epoll_wait+0x8b/0xd0
[ 1242.621480] do_fast_syscall_32+0xa7/0x2a0
[ 1242.621484] entry_SYSENTER_compat+0x7f/0x91
[ 1242.621490] Modules linked in: ccm nf_tables_set nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat_ipv6 nft_chain_nat_ipv4 nf_tables ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack libcrc32c ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bpfilter 8021q mrp ipheth btusb btrtl btbcm btintel uvcvideo bluetooth videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_common videodev media ecdh_generic joydev mousedev nls_iso8859_1 nls_cp437 vfat fat arc4 snd_hda_codec_hdmi
[ 1242.621570] snd_soc_skl snd_soc_skl_ipc iwlmvm snd_soc_sst_ipc snd_soc_sst_dsp snd_hda_ext_core snd_soc_acpi snd_soc_core mei_wdt mac80211 snd_hda_codec_realtek snd_compress iTCO_wdt ac97_bus snd_hda_codec_generic snd_pcm_dmaengine iTCO_vendor_support intel_rapl snd_hda_intel x86_pkg_temp_thermal intel_powerclamp snd_hda_codec coretemp kvm_intel snd_hda_core wmi_bmof iwlwifi kvm cfg80211 snd_hwdep input_leds snd_pcm thinkpad_acpi snd_timer psmouse irqbypass nvram mei_me intel_cstate rfkill intel_uncore e1000e intel_rapl_perf mei i2c_i801 snd intel_pch_thermal soundcore ac tpm_tis tpm_tis_core tpm rng_core led_class evdev battery wmi rtc_cmos mac_hid pcc_cpufreq ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto algif_skcipher af_alg dm_crypt dm_mod sd_mod crct10dif_pclmul crc32_pclmul
[ 1242.621647] crc32c_intel ghash_clmulni_intel pcbc serio_raw atkbd libps2 ahci libahci aesni_intel libata aes_x86_64 crypto_simd xhci_pci cryptd glue_helper scsi_mod xhci_hcd i8042 serio hid_generic usbhid usbcore usb_common hid intel_agp i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm intel_gtt agpgart
[ 1242.621693] CR2: 000000020024cb72
[ 1242.621698] ---[ end trace dc996496c7568a90 ]---
[ 1242.621709] RIP: 0010:tcp_drop+0x17/0x40
[ 1242.621712] Code: 00 e9 5b ff ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 66 90 0f 1f 44 00 00 8b 96 cc 00 00 00 48 8b 8e d0 00 00 00 b8 01 00 00 00 <66> 83 7c 11 06 00 66 0f 45 44 11 06 0f b7 c0 f0 01 87 a8 00 00 00
[ 1242.621758] RSP: 0018:ffffb0de41223b08 EFLAGS: 00010203
[ 1242.621763] RAX: 0000000000000001 RBX: ffff8a6a39ea18c0 RCX: 0000000100254102
[ 1242.621765] RDX: 00000000ffff8a6a RSI: ffff8a6a39ea1988 RDI: ffff8a6a39ea18c0
[ 1242.621767] RBP: ffff8a6a39ea1988 R08: 0000000000000000 R09: ffffffff99e8930e
[ 1242.621769] R10: ffff8a6a743f6310 R11: 0000000000000002 R12: ffff8a6a39ea1988
[ 1242.621771] R13: ffffffff99e92380 R14: 0000000000000000 R15: 00000000fffffff5
[ 1242.621773] FS: 0000000000000000(0000) GS:ffff8a6a81400000(0063) knlGS:00000000ed455b40
[ 1242.621775] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033
[ 1242.621777] CR2: 000000020024cb72 CR3: 00000002347aa004 CR4: 00000000003606f0
[ 1242.621780] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1242.621782] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- Seperate Boot ---
[ 158.591645] WARNING: CPU: 2 PID: 29 at net/core/dev.c:4279 net_tx_action+0x1fe/0x260
[ 158.591651] Modules linked in: ccm nf_tables_set nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat_ipv6 nft_chain_nat_ipv4 nf_tables ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_raw ip6table_security iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat iptable_mangle iptable_raw iptable_security nf_conntrack libcrc32c arc4 iwlmvm mac80211 ip_set nfnetlink ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter bpfilter btusb snd_soc_skl btrtl btbcm btintel uvcvideo bluetooth ipheth snd_soc_skl_ipc snd_soc_sst_ipc snd_soc_sst_dsp iwlwifi videobuf2_vmalloc snd_hda_ext_core videobuf2_memops videobuf2_v4l2 8021q mrp videobuf2_common
[ 158.591799] snd_soc_acpi intel_rapl snd_soc_core videodev x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel snd_hda_codec_hdmi nls_iso8859_1 media ecdh_generic nls_cp437 snd_compress joydev ac97_bus snd_hda_codec_realtek vfat snd_hda_codec_generic fat snd_pcm_dmaengine mousedev kvm snd_hda_intel cfg80211 snd_hda_codec wmi_bmof mei_wdt snd_hda_core snd_hwdep snd_pcm irqbypass intel_cstate iTCO_wdt tpm_tis iTCO_vendor_support intel_uncore psmouse tpm_tis_core thinkpad_acpi tpm intel_rapl_perf nvram input_leds e1000e snd_timer rfkill rng_core wmi snd mei_me evdev mei battery mac_hid led_class ac intel_pch_thermal rtc_cmos i2c_i801 pcc_cpufreq soundcore ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 fscrypto algif_skcipher af_alg dm_crypt dm_mod sd_mod crct10dif_pclmul crc32_pclmul
[ 158.591959] crc32c_intel ghash_clmulni_intel pcbc serio_raw ahci atkbd libahci libps2 xhci_pci libata aesni_intel aes_x86_64 crypto_simd cryptd glue_helper xhci_hcd scsi_mod i8042 serio hid_generic usbhid usbcore usb_common hid intel_agp i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm intel_gtt agpgart
[ 158.592043] CPU: 2 PID: 29 Comm: ksoftirqd/2 Tainted: G U 4.18.5 #1
[ 158.592047] Hardware name: LENOVO 20FN001CAU/20FN001CAU, BIOS R06ET59W (1.33 ) 02/27/2018
[ 158.592058] RIP: 0010:net_tx_action+0x1fe/0x260
[ 158.592060] Code: 8d bb 04 01 00 00 e8 f1 d5 15 00 e9 2a ff ff ff 5b 4c 89 e7 5d 41 5c 41 5d 41 5e e9 fc 5c 0c 00 0f 1f 44 00 00 e9 76 fe ff ff <0f> 0b e9 5f fe ff ff 65 8b 05 24 6d bf 44 89 c0 48 0f a3 05 2a 38
[ 158.592195] RSP: 0018:ffffb5d4c0d9be50 EFLAGS: 00010286
[ 158.592202] RAX: 00000000c0000000 RBX: ffff945bb4ae3800 RCX: 00000000000000a1
[ 158.592206] RDX: 0000000080000101 RSI: ffffffffbbc81896 RDI: ffffffffbbc898b5
[ 158.592211] RBP: 0000000000000002 R08: 000000694facc758 R09: 0000000000000100
[ 158.592215] R10: 0000000000000000 R11: ffff945bc1520a68 R12: ffff945bc1522f00
[ 158.592219] R13: ffff945bb4ae3900 R14: ffffffffbb4182a0 R15: ffffffffbaea1950
[ 158.592226] FS: 0000000000000000(0000) GS:ffff945bc1500000(0000) knlGS:0000000000000000
[ 158.592231] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 158.592235] CR2: 00007ff03400dad8 CR3: 000000018de0a003 CR4: 00000000003606e0
[ 158.592241] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 158.592245] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 158.592248] Call Trace:
[ 158.592270] __do_softirq+0x10d/0x30d
[ 158.592287] ? sort_range+0x20/0x20
[ 158.592295] run_ksoftirqd+0x32/0x40
[ 158.592306] smpboot_thread_fn+0x198/0x230
[ 158.592319] kthread+0x112/0x130
[ 158.592330] ? kthread_flush_work_fn+0x10/0x10
[ 158.592342] ret_from_fork+0x35/0x40
[ 158.592353] ---[ end trace 88207aade9b579ae ]---
^ permalink raw reply
* Re: [PATCH bpf-next 11/11] samples/bpf: add -c/--copy -z/--zero-copy flags to xdpsock
From: Jesper Dangaard Brouer @ 2018-08-29 12:44 UTC (permalink / raw)
To: Björn Töpel
Cc: magnus.karlsson, magnus.karlsson, alexander.h.duyck,
alexander.duyck, ast, daniel, netdev, jesse.brandeburg,
anjali.singhai, peter.waskiewicz.jr, Björn Töpel,
michael.lundkvist, willemdebruijn.kernel, john.fastabend,
jakub.kicinski, neerav.parikh, mykyta.iziumtsev, francois.ozog,
ilias.apalodimas, brian.brooks, u9012063, pavel, qi.z.zhang,
brouer
In-Reply-To: <20180828124435.30578-12-bjorn.topel@gmail.com>
On Tue, 28 Aug 2018 14:44:35 +0200
Björn Töpel <bjorn.topel@gmail.com> wrote:
> From: Björn Töpel <bjorn.topel@intel.com>
>
> The -c/--copy -z/--zero-copy flags enforces either copy or zero-copy
> mode.
Nice, thanks for adding this. It allows me to quickly test the
difference between normal-copy vs zero-copy modes.
(Kernel bpf-next without RETPOLINE).
AF_XDP RX-drop:
Normal-copy mode: rx 13,070,318 pps - 76.5 ns
Zero-copy mode: rx 26,132,328 pps - 38.3 ns
Compare to XDP_DROP: 34,251,464 pps - 29.2 ns
XDP_DROP + read : 30,756,664 pps - 32.5 ns
The normal-copy mode is surprisingly fast (and it works for every
driver implemeting the regular XDP_REDIRECT action). It is still
faster to do in-kernel XDP_DROP than AF_XDP zero-copy mode dropping,
which was expected given frames travel to a remote CPU before returned
(don't think remote CPU reads payload?). The gap in nanosec is
actually quite small, thus I'm impressed by the SPSC-queue
implementation working across these CPUs.
AF_XDP layer2-fwd:
Normal-copy mode: rx 3,200,885 tx 3,200,892
Zero-copy mode: rx 17,026,300 tx 17,026,269
Compare to XDP_TX: rx 14,529,079 tx 14,529,850 - 68.82 ns
XDP_REDIRECT: rx 13,235,785 tx 13,235,784 - 75.55 ns
The copy-mode is slow because it allocates SKBs internally (I do
wonder if we could speed it up by using ndo_xdp_xmit + disable-BH).
More intersting is that the zero-copy is faster than XDP_TX and
XDP_REDIRECT. I think the speedup comes from avoiding some DMA mapping
calls with ZC.
Side-note: XDP_TX vs. REDIRECT: 75.55 - 68.82 = 6.73 ns. The cost of
going through the xdp_do_redirect_map core is actually quite small :-)
(I have some micro optimizations that should help ~2ns).
AF_XDP TX-only:
Normal-copy mode: tx 2,853,461 pps
Zero-copy mode: tx 22,255,311 pps
(There is not XDP mode that does TX to compare against)
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply
* Re: [PATCH net-next] virtio_net: force_napi_tx module param.
From: Willem de Bruijn @ 2018-08-29 13:01 UTC (permalink / raw)
To: Jason Wang
Cc: Jon Olson (Google Drive), Michael S. Tsirkin, caleb.raitto,
David Miller, Network Development, Caleb Raitto
In-Reply-To: <f7f8a848-6b63-a4c4-469e-9c019a4cfc91@redhat.com>
On Wed, Aug 29, 2018 at 3:56 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
>
> On 2018年08月29日 03:57, Willem de Bruijn wrote:
> > On Mon, Jul 30, 2018 at 2:06 AM Jason Wang <jasowang@redhat.com> wrote:
> >>
> >>
> >> On 2018年07月25日 08:17, Jon Olson wrote:
> >>> On Tue, Jul 24, 2018 at 3:46 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >>>> On Tue, Jul 24, 2018 at 06:31:54PM -0400, Willem de Bruijn wrote:
> >>>>> On Tue, Jul 24, 2018 at 6:23 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >>>>>> On Tue, Jul 24, 2018 at 04:52:53PM -0400, Willem de Bruijn wrote:
> >>>>>>> >From the above linked patch, I understand that there are yet
> >>>>>>> other special cases in production, such as a hard cap on #tx queues to
> >>>>>>> 32 regardless of number of vcpus.
> >>>>>> I don't think upstream kernels have this limit - we can
> >>>>>> now use vmalloc for higher number of queues.
> >>>>> Yes. that patch* mentioned it as a google compute engine imposed
> >>>>> limit. It is exactly such cloud provider imposed rules that I'm
> >>>>> concerned about working around in upstream drivers.
> >>>>>
> >>>>> * for reference, I mean https://patchwork.ozlabs.org/patch/725249/
> >>>> Yea. Why does GCE do it btw?
> >>> There are a few reasons for the limit, some historical, some current.
> >>>
> >>> Historically we did this because of a kernel limit on the number of
> >>> TAP queues (in Montreal I thought this limit was 32). To my chagrin,
> >>> the limit upstream at the time we did it was actually eight. We had
> >>> increased the limit from eight to 32 internally, and it appears in
> >>> upstream it has subsequently increased upstream to 256. We no longer
> >>> use TAP for networking, so that constraint no longer applies for us,
> >>> but when looking at removing/raising the limit we discovered no
> >>> workloads that clearly benefited from lifting it, and it also placed
> >>> more pressure on our virtual networking stack particularly on the Tx
> >>> side. We left it as-is.
> >>>
> >>> In terms of current reasons there are really two. One is memory usage.
> >>> As you know, virtio-net uses rx/tx pairs, so there's an expectation
> >>> that the guest will have an Rx queue for every Tx queue. We run our
> >>> individual virtqueues fairly deep (4096 entries) to give guests a wide
> >>> time window for re-posting Rx buffers and avoiding starvation on
> >>> packet delivery. Filling an Rx vring with max-sized mergeable buffers
> >>> (4096 bytes) is 16MB of GFP_ATOMIC allocations. At 32 queues this can
> >>> be up to 512MB of memory posted for network buffers. Scaling this to
> >>> the largest VM GCE offers today (160 VCPUs -- n1-ultramem-160) keeping
> >>> all of the Rx rings full would (in the large average Rx packet size
> >>> case) consume up to 2.5 GB(!) of guest RAM. Now, those VMs have 3.8T
> >>> of RAM available, but I don't believe we've observed a situation where
> >>> they would have benefited from having 2.5 gigs of buffers posted for
> >>> incoming network traffic :)
> >> We can work to have async txq and rxq instead of paris if there's a
> >> strong requirement.
> >>
> >>> The second reason is interrupt related -- as I mentioned above, we
> >>> have found no workloads that clearly benefit from so many queues, but
> >>> we have found workloads that degrade. In particular workloads that do
> >>> a lot of small packet processing but which aren't extremely latency
> >>> sensitive can achieve higher PPS by taking fewer interrupt across
> >>> fewer VCPUs due to better batching (this also incurs higher latency,
> >>> but at the limit the "busy" cores end up suppressing most interrupts
> >>> and spending most of their cycles farming out work). Memcache is a
> >>> good example here, particularly if the latency targets for request
> >>> completion are in the ~milliseconds range (rather than the
> >>> microseconds we typically strive for with TCP_RR-style workloads).
> >>>
> >>> All of that said, we haven't been forthcoming with data (and
> >>> unfortunately I don't have it handy in a useful form, otherwise I'd
> >>> simply post it here), so I understand the hesitation to simply run
> >>> with napi_tx across the board. As Willem said, this patch seemed like
> >>> the least disruptive way to allow us to continue down the road of
> >>> "universal" NAPI Tx and to hopefully get data across enough workloads
> >>> (with VMs small, large, and absurdly large :) to present a compelling
> >>> argument in one direction or another. As far as I know there aren't
> >>> currently any NAPI related ethtool commands (based on a quick perusal
> >>> of ethtool.h)
> >> As I suggest before, maybe we can (ab)use tx-frames-irq.
> > I forgot to respond to this originally, but I agree.
> >
> > How about something like the snippet below. It would be simpler to
> > reason about if only allow switching while the device is down, but
> > napi does not strictly require that.
> >
> > +static int virtnet_set_coalesce(struct net_device *dev,
> > + struct ethtool_coalesce *ec)
> > +{
> > + const u32 tx_coalesce_napi_mask = (1 << 16);
> > + const struct ethtool_coalesce ec_default = {
> > + .cmd = ETHTOOL_SCOALESCE,
> > + .rx_max_coalesced_frames = 1,
> > + .tx_max_coalesced_frames = 1,
> > + };
> > + struct virtnet_info *vi = netdev_priv(dev);
> > + int napi_weight = 0;
> > + bool running;
> > + int i;
> > +
> > + if (ec->tx_max_coalesced_frames & tx_coalesce_napi_mask) {
> > + ec->tx_max_coalesced_frames &= ~tx_coalesce_napi_mask;
> > + napi_weight = NAPI_POLL_WEIGHT;
> > + }
> > +
> > + /* disallow changes to fields not explicitly tested above */
> > + if (memcmp(ec, &ec_default, sizeof(ec_default)))
> > + return -EINVAL;
> > +
> > + if (napi_weight ^ vi->sq[0].napi.weight) {
> > + running = netif_running(vi->dev);
> > +
> > + for (i = 0; i < vi->max_queue_pairs; i++) {
> > + vi->sq[i].napi.weight = napi_weight;
> > +
> > + if (!running)
> > + continue;
> > +
> > + if (napi_weight)
> > + virtnet_napi_tx_enable(vi, vi->sq[i].vq,
> > + &vi->sq[i].napi);
> > + else
> > + napi_disable(&vi->sq[i].napi);
> > + }
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int virtnet_get_coalesce(struct net_device *dev,
> > + struct ethtool_coalesce *ec)
> > +{
> > + const u32 tx_coalesce_napi_mask = (1 << 16);
> > + const struct ethtool_coalesce ec_default = {
> > + .cmd = ETHTOOL_GCOALESCE,
> > + .rx_max_coalesced_frames = 1,
> > + .tx_max_coalesced_frames = 1,
> > + };
> > + struct virtnet_info *vi = netdev_priv(dev);
> > +
> > + memcpy(ec, &ec_default, sizeof(ec_default));
> > +
> > + if (vi->sq[0].napi.weight)
> > + ec->tx_max_coalesced_frames |= tx_coalesce_napi_mask;
> > +
> > + return 0;
> > +}
>
> Looks good. Just one nit, maybe it's better simply check against zero?
I wanted to avoid making napi and interrupt moderation mutually
exclusive. If the virtio-net driver ever gets true moderation support,
it should be able to work alongside napi.
But I can make no-napi be 0 and napi be 1. That is future proof, in
the sense that napi is enabled if there is any interrupt moderation.
^ permalink raw reply
* Re: [PATCH net-next] rds: store socket timestamps as ktime_t
From: Santosh Shilimkar @ 2018-08-29 17:00 UTC (permalink / raw)
To: Arnd Bergmann, David S. Miller
Cc: Sowmini Varadhan, Willem de Bruijn, Ka-Cheong Poon,
Salvatore Mesoraca, Avinash Repaka, Eric Dumazet, netdev,
linux-rdma, rds-devel, linux-kernel
In-Reply-To: <20180829154732.844217-1-arnd@arndb.de>
On 8/29/2018 8:47 AM, Arnd Bergmann wrote:
> rds is the last in-kernel user of the old do_gettimeofday()
> function. Convert it over to ktime_get_real() to make it
> work more like the generic socket timestamps, and to let
> us kill off do_gettimeofday().
>
> A follow-up patch will have to change the user space interface
> to deal better with 32-bit tasks, which may use an incompatible
> layout for 'struct timespec'.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Thanks Arnd !!
FWIW,
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
^ permalink raw reply
* [PATCH net-next 3/3] net: socket: implement 64-bit timestamps
From: Arnd Bergmann @ 2018-08-29 13:11 UTC (permalink / raw)
To: netdev, David S . Miller
Cc: linux-arch, y2038, linux-alpha, linux-kernel, linux-mips,
linux-sh, viro, tglx, edumazet, Arnd Bergmann
In-Reply-To: <20180829130308.3504560-1-arnd@arndb.de>
The 'timeval' and 'timespec' data structures used for socket timestamps
are going to be redefined in user space based on 64-bit time_t in future
versions of the C library to deal with the y2038 overflow problem,
which breaks the ABI definition.
Unlike many modern ioctl commands, SIOCGSTAMP and SIOCGSTAMPNS do not
use the _IOR() macro to encode the size of the transferred data, so it
remains ambiguous whether the application uses the old or new layout.
The best workaround I could find is rather ugly: we redefine the command
code based on the size of the respective data structure with a ternary
operator. This lets it get evaluated as late as possible, hopefully after
that structure is visible to the caller. We cannot use an #ifdef here,
because inux/sockios.h might have been included before any libc header
that could determine the size of time_t.
The ioctl implementation now interprets the new command codes as always
referring to the 64-bit structure on all architectures, while the old
architecture specific command code still refers to the old architecture
specific layout. The new command number is only used when they are
actually different.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/alpha/include/uapi/asm/sockios.h | 4 ++--
arch/mips/include/uapi/asm/sockios.h | 4 ++--
arch/sh/include/uapi/asm/sockios.h | 5 +++--
arch/xtensa/include/uapi/asm/sockios.h | 4 ++--
include/uapi/asm-generic/sockios.h | 4 ++--
include/uapi/linux/sockios.h | 21 +++++++++++++++++++++
net/socket.c | 22 +++++++++++++++++-----
7 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/arch/alpha/include/uapi/asm/sockios.h b/arch/alpha/include/uapi/asm/sockios.h
index ba287e4b01bf..af92bc27c3be 100644
--- a/arch/alpha/include/uapi/asm/sockios.h
+++ b/arch/alpha/include/uapi/asm/sockios.h
@@ -11,7 +11,7 @@
#define SIOCSPGRP _IOW('s', 8, pid_t)
#define SIOCGPGRP _IOR('s', 9, pid_t)
-#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
-#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
#endif /* _ASM_ALPHA_SOCKIOS_H */
diff --git a/arch/mips/include/uapi/asm/sockios.h b/arch/mips/include/uapi/asm/sockios.h
index 5b40a88593fa..66f60234f290 100644
--- a/arch/mips/include/uapi/asm/sockios.h
+++ b/arch/mips/include/uapi/asm/sockios.h
@@ -21,7 +21,7 @@
#define SIOCSPGRP _IOW('s', 8, pid_t)
#define SIOCGPGRP _IOR('s', 9, pid_t)
-#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
-#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
#endif /* _ASM_SOCKIOS_H */
diff --git a/arch/sh/include/uapi/asm/sockios.h b/arch/sh/include/uapi/asm/sockios.h
index 17313d2c3527..ef18a668456d 100644
--- a/arch/sh/include/uapi/asm/sockios.h
+++ b/arch/sh/include/uapi/asm/sockios.h
@@ -10,6 +10,7 @@
#define SIOCSPGRP _IOW('s', 8, pid_t)
#define SIOCGPGRP _IOR('s', 9, pid_t)
-#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
-#define SIOCGSTAMPNS _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
+#define SIOCGSTAMP_OLD _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
+
#endif /* __ASM_SH_SOCKIOS_H */
diff --git a/arch/xtensa/include/uapi/asm/sockios.h b/arch/xtensa/include/uapi/asm/sockios.h
index fb8ac3607189..1a1f58f4b75a 100644
--- a/arch/xtensa/include/uapi/asm/sockios.h
+++ b/arch/xtensa/include/uapi/asm/sockios.h
@@ -26,7 +26,7 @@
#define SIOCSPGRP _IOW('s', 8, pid_t)
#define SIOCGPGRP _IOR('s', 9, pid_t)
-#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
-#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
#endif /* _XTENSA_SOCKIOS_H */
diff --git a/include/uapi/asm-generic/sockios.h b/include/uapi/asm-generic/sockios.h
index 64f658c7cec2..44fa3ed70483 100644
--- a/include/uapi/asm-generic/sockios.h
+++ b/include/uapi/asm-generic/sockios.h
@@ -8,7 +8,7 @@
#define FIOGETOWN 0x8903
#define SIOCGPGRP 0x8904
#define SIOCATMARK 0x8905
-#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
-#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
+#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
#endif /* __ASM_GENERIC_SOCKIOS_H */
diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
index d393e9ed3964..7d1bccbbef78 100644
--- a/include/uapi/linux/sockios.h
+++ b/include/uapi/linux/sockios.h
@@ -19,6 +19,7 @@
#ifndef _LINUX_SOCKIOS_H
#define _LINUX_SOCKIOS_H
+#include <asm/bitsperlong.h>
#include <asm/sockios.h>
/* Linux-specific socket ioctls */
@@ -27,6 +28,26 @@
#define SOCK_IOC_TYPE 0x89
+/*
+ * the timeval/timespec data structure layout is defined by libc,
+ * so we need to cover both possible versions on 32-bit.
+ */
+/* Get stamp (timeval) */
+#define SIOCGSTAMP_NEW _IOR(SOCK_IOC_TYPE, 0x06, long long[2])
+/* Get stamp (timespec) */
+#define SIOCGSTAMPNS_NEW _IOR(SOCK_IOC_TYPE, 0x07, long long[2])
+
+#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
+/* on 64-bit and x32, avoid the ?: operator */
+#define SIOCGSTAMP SIOCGSTAMP_OLD
+#define SIOCGSTAMPNS SIOCGSTAMPNS_OLD
+#else
+#define SIOCGSTAMP ((sizeof(struct timeval)) == 8 ? \
+ SIOCGSTAMP_OLD : SIOCGSTAMP_NEW)
+#define SIOCGSTAMPNS ((sizeof(struct timespec)) == 8 ? \
+ SIOCGSTAMPNS_OLD : SIOCGSTAMPNS_NEW)
+#endif
+
/* Routing table calls. */
#define SIOCADDRT 0x890B /* add routing table entry */
#define SIOCDELRT 0x890C /* delete routing table entry */
diff --git a/net/socket.c b/net/socket.c
index 6814e8dc8af1..9762e7d5378b 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1069,14 +1069,24 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
err = open_related_ns(&net->ns, get_net_ns);
break;
- case SIOCGSTAMP:
- case SIOCGSTAMPNS:
+ case SIOCGSTAMP_OLD:
+ case SIOCGSTAMPNS_OLD:
if (!sock->ops->gettstamp) {
err = -ENOIOCTLCMD;
break;
}
err = sock->ops->gettstamp(sock, argp,
- cmd == SIOCGSTAMP, false);
+ cmd == SIOCGSTAMP_OLD,
+ !IS_ENABLED(CONFIG_64BIT));
+ case SIOCGSTAMP_NEW:
+ case SIOCGSTAMPNS_NEW:
+ if (!sock->ops->gettstamp) {
+ err = -ENOIOCTLCMD;
+ break;
+ }
+ err = sock->ops->gettstamp(sock, argp,
+ cmd == SIOCGSTAMP_NEW,
+ false);
break;
default:
err = sock_do_ioctl(net, sock, cmd, arg);
@@ -3095,8 +3105,8 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCADDRT:
case SIOCDELRT:
return routing_ioctl(net, sock, cmd, argp);
- case SIOCGSTAMP:
- case SIOCGSTAMPNS:
+ case SIOCGSTAMP_OLD:
+ case SIOCGSTAMPNS_OLD:
if (!sock->ops->gettstamp)
return -ENOIOCTLCMD;
return sock->ops->gettstamp(sock, argp, cmd == SIOCGSTAMP,
@@ -3119,6 +3129,8 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
case SIOCADDDLCI:
case SIOCDELDLCI:
case SIOCGSKNS:
+ case SIOCGSTAMP_NEW:
+ case SIOCGSTAMPNS_NEW:
return sock_ioctl(file, cmd, arg);
case SIOCGIFFLAGS:
--
2.18.0
^ permalink raw reply related
* [PATCH v2 0/6] Ethernet over hdlc
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180828110921.2542-2-david.gounaris@infinera.com>
Here is what has been changed in v2 after the review comments.
v2-0001: Using UCC_MAX_NUM
v2-0002: Unchanged
v2-0003: Changed commit message
v2-0004: Adding fsl,hmask into the dt instead of changing the default value.
v2-0005: Unchanged
v2-0006: Unchanged
Adding robh+dt@kernel.org for comments regarding dt.
Best Regards
David Gounaris
David Gounaris (6):
net/wan/fsl_ucc_hdlc: allow ucc index up to 7
net/wan/fsl_ucc_hdlc: allow PARITY_CRC16_PR0_CCITT parity
net/wan/fsl_ucc_hdlc: Adding ARPHRD_ETHER
net/wan/fsl_ucc_hdlc: hmask
net/wan/fsl_ucc_hdlc: GUMR for non tsa mode
net/wan/fsl_ucc_hdlc: tx timeout handler
.../devicetree/bindings/soc/fsl/cpm_qe/network.txt | 6 +++++
drivers/net/wan/fsl_ucc_hdlc.c | 28 +++++++++++++++++++---
drivers/net/wan/fsl_ucc_hdlc.h | 1 +
3 files changed, 32 insertions(+), 3 deletions(-)
--
2.13.6
^ permalink raw reply
* [PATCH v2 1/6] net/wan/fsl_ucc_hdlc: allow ucc index up to 7
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
There is a need to allow higher indexes to be
able to support MPC83xx platforms. (UCC1-UCC8)
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 33df76405b86..5cf6dcba039c 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1016,7 +1016,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
}
ucc_num = val - 1;
- if ((ucc_num > 3) || (ucc_num < 0)) {
+ if ((ucc_num > UCC_MAX_NUM - 1) || (ucc_num < 0)) {
dev_err(&pdev->dev, ": Invalid UCC num\n");
return -EINVAL;
}
--
2.13.6
^ permalink raw reply related
* [PATCH v2 2/6] net/wan/fsl_ucc_hdlc: allow PARITY_CRC16_PR0_CCITT parity
From: David Gounaris @ 2018-08-29 13:13 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, robh+dt; +Cc: David Gounaris
In-Reply-To: <20180829131328.27901-1-david.gounaris@infinera.com>
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 5cf6dcba039c..c8e526bf1130 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -781,7 +781,8 @@ static int ucc_hdlc_attach(struct net_device *dev, unsigned short encoding,
if (parity != PARITY_NONE &&
parity != PARITY_CRC32_PR1_CCITT &&
- parity != PARITY_CRC16_PR1_CCITT)
+ parity != PARITY_CRC16_PR1_CCITT &&
+ parity != PARITY_CRC16_PR0_CCITT)
return -EINVAL;
priv->encoding = encoding;
--
2.13.6
^ permalink raw reply related
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