[PATCH v3] qrtr: add MODULE_ALIAS macro to smd

2018-02-24 Thread Ramon Fried
Added MODULE_ALIAS("rpmsg:IPCRTR") to ensure qrtr-smd and qrtr will load
when IPCRTR channel is detected.

Signed-off-by: Ramon Fried 

---
V2: Corrected subject line, this is not a part of a patchset.
V3: Placed the changelog under the ---.

 net/qrtr/smd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/qrtr/smd.c b/net/qrtr/smd.c
index 50615d5efac1..9cf089b9754e 100644
--- a/net/qrtr/smd.c
+++ b/net/qrtr/smd.c
@@ -114,5 +114,6 @@ static struct rpmsg_driver qcom_smd_qrtr_driver = {
 
 module_rpmsg_driver(qcom_smd_qrtr_driver);
 
+MODULE_ALIAS("rpmsg:IPCRTR");
 MODULE_DESCRIPTION("Qualcomm IPC-Router SMD interface driver");
 MODULE_LICENSE("GPL v2");
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH v2] qrtr: add MODULE_ALIAS macro to smd

2018-02-24 Thread Kalle Valo
Ramon Fried  writes:

> Added MODULE_ALIAS("rpmsg:IPCRTR") to ensure qrtr-smd and qrtr will load
> when IPCRTR channel is detected.
>
> Signed-off-by: Ramon Fried 
>
> V2: Corrected subject line, this is not a part of a patchset.
> ---
>  net/qrtr/smd.c | 1 +
>  1 file changed, 1 insertion(+)

The change log should be after "---" line so that git-am can discard it
automatically. Now the changelog would be part of git commit log and we
don't want that.

So please submit v3.

-- 
Kalle Valo


[PATCH v2] qrtr: add MODULE_ALIAS macro to smd

2018-02-24 Thread Ramon Fried
Added MODULE_ALIAS("rpmsg:IPCRTR") to ensure qrtr-smd and qrtr will load
when IPCRTR channel is detected.

Signed-off-by: Ramon Fried 

V2: Corrected subject line, this is not a part of a patchset.
---
 net/qrtr/smd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/qrtr/smd.c b/net/qrtr/smd.c
index 50615d5efac1..9cf089b9754e 100644
--- a/net/qrtr/smd.c
+++ b/net/qrtr/smd.c
@@ -114,5 +114,6 @@ static struct rpmsg_driver qcom_smd_qrtr_driver = {
 
 module_rpmsg_driver(qcom_smd_qrtr_driver);
 
+MODULE_ALIAS("rpmsg:IPCRTR");
 MODULE_DESCRIPTION("Qualcomm IPC-Router SMD interface driver");
 MODULE_LICENSE("GPL v2");
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[net] ba4f5b62a2: kernel_BUG_at_net/socket.c

2018-02-24 Thread kernel test robot
FYI, we noticed the following commit (built with gcc-7):

commit: ba4f5b62a2565718cf1b85e736df12da68bbb114 ("net: mark slab's used by ss 
as UAPI")
url: 
https://github.com/0day-ci/linux/commits/Stephen-Hemminger/mark-some-slabs-as-visible-not-mergeable/20180225-084344


in testcase: trinity
with following parameters:

runtime: 300s

test-description: Trinity is a linux system call fuzz tester.
test-url: http://codemonkey.org.uk/projects/trinity/


on test machine: qemu-system-x86_64 -enable-kvm -m 512M

caused below changes (please refer to attached dmesg/kmsg for entire 
log/backtrace):


+--+++
|  | 679d6c9b78 | ba4f5b62a2 |
+--+++
| boot_successes   | 37 | 0  |
| boot_failures| 0  | 6  |
| kernel_BUG_at_net/socket.c   | 0  | 6  |
| invalid_opcode:#[##] | 0  | 6  |
| RIP:sock_init| 0  | 6  |
| Kernel_panic-not_syncing:Fatal_exception | 0  | 6  |
+--+++



[0.054820] kernel BUG at net/socket.c:293!
[0.055261] invalid opcode:  [#1] PREEMPT
[0.055574] CPU: 0 PID: 1 Comm: swapper Not tainted 
4.16.0-rc2-00147-gba4f5b6 #1
[0.056094] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.10.2-1 04/01/2014
[0.056681] RIP: 0010:sock_init+0xc7/0x1a9
[0.056979] RSP: :c900be58 EFLAGS: 00010293
[0.057351] RAX:  RBX: cbc1095dc7d516bb RCX: 88001f66e040
[0.057903] RDX:  RSI: 833e9787 RDI: 82df9208
[0.058401] RBP: c900be70 R08: c900bf48 R09: 
[0.058902] R10: 0002 R11: 0100 R12: 0003
[0.059401] R13:  R14: 833e96c0 R15: 9feaf2bde0204734
[0.059909] FS:  () GS:82a42000() 
knlGS:
[0.06] CS:  0010 DS:  ES:  CR0: 80050033
[0.06] CR2:  CR3: 02a1c000 CR4: 06f0
[0.06] DR0:  DR1:  DR2: 
[0.06] DR3:  DR6: fffe0ff0 DR7: 0400
[0.06] Call Trace:
[0.06]  do_one_initcall+0x110/0x30e
[0.06]  ? do_early_param+0x1d9/0x1d9
[0.06]  kernel_init_freeable+0x191/0x2ff
[0.06]  ? rest_init+0x10d/0x10d
[0.06]  kernel_init+0x14/0x1ca
[0.06]  ? rest_init+0x10d/0x10d
[0.06]  ret_from_fork+0x24/0x30
[0.06] Code: df 82 31 c9 31 d2 44 89 e6 49 83 c4 02 48 89 05 c0 8a f2 
ff e8 16 e2 dc fd 4a ff 04 e5 c8 09 24 83 4d 85 ed 75 07 e8 14 71 d9 fd <0f> 0b 
48 b8 66 15 13 7e 02 01 3f 70 48 01 c3 e8 00 71 d9 fd 48 
[0.06] RIP: sock_init+0xc7/0x1a9 RSP: c900be58
[0.060043] ---[ end trace 7952a3ce7af68811 ]---


To reproduce:

git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k  job-script  # job-script is attached in this 
email



Thanks,
lkp
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 4.16.0-rc2 Kernel Configuration
#
CONFIG_64BIT=y
CONFIG_X86_64=y
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_MMU=y
CONFIG_ARCH_MMAP_RND_BITS_MIN=28
CONFIG_ARCH_MMAP_RND_BITS_MAX=32
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=8
CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_ARCH_HAS_CPU_RELAX=y
CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
CONFIG_HAVE_SETUP_PER_CPU_AREA=y
CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
CONFIG_ZONE_DMA32=y
CONFIG_AUDIT_ARCH=y
CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=4
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_EXTABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y

#
# General setup
#
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y

[PATCH 1/6] qrtr: add MODULE_ALIAS macro to smd

2018-02-24 Thread Ramon Fried
Added MODULE_ALIAS("rpmsg:IPCRTR") to ensure qrtr-smd and qrtr will load
when IPCRTR channel is detected.

Signed-off-by: Ramon Fried 
---
 net/qrtr/smd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/qrtr/smd.c b/net/qrtr/smd.c
index 50615d5efac1..9cf089b9754e 100644
--- a/net/qrtr/smd.c
+++ b/net/qrtr/smd.c
@@ -114,5 +114,6 @@ static struct rpmsg_driver qcom_smd_qrtr_driver = {
 
 module_rpmsg_driver(qcom_smd_qrtr_driver);
 
+MODULE_ALIAS("rpmsg:IPCRTR");
 MODULE_DESCRIPTION("Qualcomm IPC-Router SMD interface driver");
 MODULE_LICENSE("GPL v2");
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH net-next 3/5] ipv6: fib6_rules: support for match on sport, dport and ip proto

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

support to match on src port, dst port and ip protocol.

Signed-off-by: Roopa Prabhu 
---
 net/ipv6/fib6_rules.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 95a2c9e..678d664 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -223,6 +223,15 @@ static int fib6_rule_match(struct fib_rule *rule, struct 
flowi *fl, int flags)
if (r->tclass && r->tclass != ip6_tclass(fl6->flowlabel))
return 0;
 
+   if (rule->ip_proto && (rule->ip_proto != fl6->flowi4_proto))
+   return 0;
+
+   if (!fib_rule_port_inrange(>sport_range, fl6->fl4_sport))
+   return 0;
+
+   if (!fib_rule_port_inrange(>dport_range, fl6->fl4_dport))
+   return 0;
+
return 1;
 }
 
-- 
2.1.4



[PATCH net-next 5/5] ipv6: route: dissect flow in input path if fib rules need it

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

Dissect flow in fwd path if fib rules require it. Controlled by
a flag to avoid penatly for the common case. Flag is set when fib
rules with sport, dport and proto match that require flow dissect
are installed. Also passes the dissected hash keys to the multipath
hash function when applicable to avoid dissecting the flow again.
icmp packets will continue to use inner header for hash
calculations.

Signed-off-by: Roopa Prabhu 
---
 include/net/ip6_route.h  |  3 ++-
 include/net/netns/ipv6.h |  1 +
 net/ipv6/fib6_rules.c|  5 +
 net/ipv6/icmp.c  |  2 +-
 net/ipv6/route.c | 45 -
 5 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 27d23a6..218f89c 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -127,7 +127,8 @@ static inline int ip6_route_get_saddr(struct net *net, 
struct rt6_info *rt,
 
 struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr,
const struct in6_addr *saddr, int oif, int flags);
-u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb);
+u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb,
+  struct flow_keys *hkeys);
 
 struct dst_entry *icmp6_dst_alloc(struct net_device *dev, struct flowi6 *fl6);
 
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index 987cc45..7aca00e 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -72,6 +72,7 @@ struct netns_ipv6 {
unsigned longip6_rt_last_gc;
 #ifdef CONFIG_IPV6_MULTIPLE_TABLES
bool fib6_has_custom_rules;
+   bool fib6_rules_require_fldissect;
struct rt6_info *ip6_prohibit_entry;
struct rt6_info *ip6_blk_hole_entry;
struct fib6_table   *fib6_local_tbl;
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 678d664..e3a7861 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -267,6 +267,11 @@ static int fib6_rule_configure(struct fib_rule *rule, 
struct sk_buff *skb,
rule6->dst.plen = frh->dst_len;
rule6->tclass = frh->tos;
 
+   if (rule->ip_proto ||
+   fib_rule_port_range_valid(>sport_range) ||
+   fib_rule_port_range_valid(>dport_range))
+   net->ipv6.fib6_rules_require_fldissect = true;
+
net->ipv6.fib6_has_custom_rules = true;
err = 0;
 errout:
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 4fa4f1b..b0778d3 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -522,7 +522,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 
code, __u32 info,
fl6.fl6_icmp_type = type;
fl6.fl6_icmp_code = code;
fl6.flowi6_uid = sock_net_uid(net, NULL);
-   fl6.mp_hash = rt6_multipath_hash(, skb);
+   fl6.mp_hash = rt6_multipath_hash(, skb, NULL);
security_skb_classify_flow(skb, flowi6_to_flowi());
 
sk = icmpv6_xmit_lock(net);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index aa709b6..778212b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -460,7 +460,7 @@ static struct rt6_info *rt6_multipath_select(struct 
rt6_info *match,
 * case it will always be non-zero. Otherwise now is the time to do it.
 */
if (!fl6->mp_hash)
-   fl6->mp_hash = rt6_multipath_hash(fl6, NULL);
+   fl6->mp_hash = rt6_multipath_hash(fl6, NULL, NULL);
 
if (fl6->mp_hash <= atomic_read(>rt6i_nh_upper_bound))
return match;
@@ -1786,10 +1786,12 @@ struct dst_entry *ip6_route_input_lookup(struct net 
*net,
 EXPORT_SYMBOL_GPL(ip6_route_input_lookup);
 
 static void ip6_multipath_l3_keys(const struct sk_buff *skb,
- struct flow_keys *keys)
+ struct flow_keys *keys,
+ struct flow_keys *flkeys)
 {
const struct ipv6hdr *outer_iph = ipv6_hdr(skb);
const struct ipv6hdr *key_iph = outer_iph;
+   struct flow_keys *_flkeys = flkeys;
const struct ipv6hdr *inner_iph;
const struct icmp6hdr *icmph;
struct ipv6hdr _inner_iph;
@@ -1811,22 +1813,31 @@ static void ip6_multipath_l3_keys(const struct sk_buff 
*skb,
goto out;
 
key_iph = inner_iph;
+   _flkeys = NULL;
 out:
memset(keys, 0, sizeof(*keys));
keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
-   keys->addrs.v6addrs.src = key_iph->saddr;
-   keys->addrs.v6addrs.dst = key_iph->daddr;
-   keys->tags.flow_label = ip6_flowinfo(key_iph);
-   keys->basic.ip_proto = key_iph->nexthdr;
+   if (_flkeys) {
+   keys->addrs.v6addrs.src = _flkeys->addrs.v6addrs.src;
+   keys->addrs.v6addrs.dst = _flkeys->addrs.v6addrs.dst;

[PATCH net-next 4/5] ipv4: route: dissect flow in input path if fib rules need it

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

Dissect flow in fwd path if fib rules require it. Controlled by
a flag to avoid penatly for the common case. Flag is set when fib
rules with sport, dport and proto match that require flow dissect
are installed. Also passes the dissected hash keys to the multipath
hash function when applicable to avoid dissecting the flow again.
icmp packets will continue to use inner header for hash
calculations (Thanks to Nikolay Aleksandrov for some review here).

Signed-off-by: Roopa Prabhu 
---
 include/net/ip_fib.h |  2 +-
 include/net/netns/ipv4.h |  1 +
 net/ipv4/fib_rules.c |  6 ++
 net/ipv4/fib_semantics.c |  2 +-
 net/ipv4/route.c | 52 +++-
 5 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index f805243..5ada772 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -371,7 +371,7 @@ int fib_sync_up(struct net_device *dev, unsigned int 
nh_flags);
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
-  const struct sk_buff *skb);
+  const struct sk_buff *skb, struct flow_keys *flkeys);
 #endif
 void fib_select_multipath(struct fib_result *res, int hash);
 void fib_select_path(struct net *net, struct fib_result *res,
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 44668c2..87b8fdc 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -52,6 +52,7 @@ struct netns_ipv4 {
 #ifdef CONFIG_IP_MULTIPLE_TABLES
struct fib_rules_ops*rules_ops;
boolfib_has_custom_rules;
+   boolfib_rules_require_fldissect;
struct fib_table __rcu  *fib_main;
struct fib_table __rcu  *fib_default;
 #endif
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 9d55c90..83aa786 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -253,6 +253,11 @@ static int fib4_rule_configure(struct fib_rule *rule, 
struct sk_buff *skb,
}
 #endif
 
+   if (rule->ip_proto ||
+   fib_rule_port_range_valid(>sport_range) ||
+   fib_rule_port_range_valid(>dport_range))
+   net->ipv4.fib_rules_require_fldissect = true;
+
rule4->src_len = frh->src_len;
rule4->srcmask = inet_make_mask(rule4->src_len);
rule4->dst_len = frh->dst_len;
@@ -398,6 +403,7 @@ int __net_init fib4_rules_init(struct net *net)
goto fail;
net->ipv4.rules_ops = ops;
net->ipv4.fib_has_custom_rules = false;
+   net->ipv4.fib_rules_require_fldissect = false;
return 0;
 
 fail:
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index cd46d76..b0c398a 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1770,7 +1770,7 @@ void fib_select_path(struct net *net, struct fib_result 
*res,
 
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
if (res->fi->fib_nhs > 1) {
-   int h = fib_multipath_hash(res->fi, fl4, skb);
+   int h = fib_multipath_hash(res->fi, fl4, skb, NULL);
 
fib_select_multipath(res, h);
}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 26eefa2..72dd6c6 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1783,7 +1783,7 @@ static void ip_multipath_l3_keys(const struct sk_buff 
*skb,
 
 /* if skb is set it will be used and fl4 can be NULL */
 int fib_multipath_hash(const struct fib_info *fi, const struct flowi4 *fl4,
-  const struct sk_buff *skb)
+  const struct sk_buff *skb, struct flow_keys *flkeys)
 {
struct net *net = fi->fib_net;
struct flow_keys hash_keys;
@@ -1810,14 +1810,23 @@ int fib_multipath_hash(const struct fib_info *fi, const 
struct flowi4 *fl4,
if (skb->l4_hash)
return skb_get_hash_raw(skb) >> 1;
memset(_keys, 0, sizeof(hash_keys));
-   skb_flow_dissect_flow_keys(skb, , flag);
 
-   hash_keys.control.addr_type = 
FLOW_DISSECTOR_KEY_IPV4_ADDRS;
-   hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src;
-   hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst;
-   hash_keys.ports.src = keys.ports.src;
-   hash_keys.ports.dst = keys.ports.dst;
-   hash_keys.basic.ip_proto = keys.basic.ip_proto;
+   if (flkeys) {
+   hash_keys.control.addr_type = 
FLOW_DISSECTOR_KEY_IPV4_ADDRS;
+   hash_keys.addrs.v4addrs.src = 
flkeys->addrs.v4addrs.src;
+   hash_keys.addrs.v4addrs.dst = 
flkeys->addrs.v4addrs.dst;
+   hash_keys.ports.src = flkeys->ports.src;
+   

[PATCH net-next 2/5] ipv4: fib_rules: support match on sport, dport and ip proto

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

support to match on src port, dst port and ip protocol.

Signed-off-by: Roopa Prabhu 
---
 net/ipv4/fib_rules.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 35d646a..9d55c90 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -182,6 +182,15 @@ static int fib4_rule_match(struct fib_rule *rule, struct 
flowi *fl, int flags)
if (r->tos && (r->tos != fl4->flowi4_tos))
return 0;
 
+   if (rule->ip_proto && (rule->ip_proto != fl4->flowi4_proto))
+   return 0;
+
+   if (!fib_rule_port_inrange(>sport_range, fl4->fl4_sport))
+   return 0;
+
+   if (!fib_rule_port_inrange(>dport_range, fl4->fl4_dport))
+   return 0;
+
return 1;
 }
 
-- 
2.1.4



[PATCH net-next 0/5] fib_rules: support sport, dport and ip proto match

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

This series extends fib rule match support to include sport, dport
and ip proto match (to complete the 5-tuple match support).
Common use-cases of Policy based routing in the data center require
5-tuple match. The last 2 patches in the series add a call to flow dissect
in the fwd path if required by the installed fib rules (controlled by a flag).

v1:
  - Fix errors reported by kbuild and feedback on RFC series
  - extend port match uapi to accomodate port ranges

Roopa Prabhu (5):
  net: fib_rules: support for match on ip_proto, sport and dport
  ipv4: fib_rules: support match on sport, dport and ip proto
  ipv6: fib6_rules: support for match on sport, dport and ip proto
  ipv4: route: dissect flow in input path if fib rules need it
  ipv6: route: dissect flow in input path if fib rules need it

 include/net/fib_rules.h| 31 +-
 include/net/ip6_route.h|  3 +-
 include/net/ip_fib.h   |  2 +-
 include/net/netns/ipv4.h   |  1 +
 include/net/netns/ipv6.h   |  1 +
 include/uapi/linux/fib_rules.h |  8 
 net/core/fib_rules.c   | 95 +-
 net/ipv4/fib_rules.c   | 15 +++
 net/ipv4/fib_semantics.c   |  2 +-
 net/ipv4/route.c   | 52 ---
 net/ipv6/fib6_rules.c  | 14 +++
 net/ipv6/icmp.c|  2 +-
 net/ipv6/route.c   | 45 
 13 files changed, 241 insertions(+), 30 deletions(-)

-- 
2.1.4



[PATCH net-next 1/5] net: fib_rules: support for match on ip_proto, sport and dport

2018-02-24 Thread Roopa Prabhu
From: Roopa Prabhu 

uapi for ip_proto, sport and dport range match
in fib rules.

Signed-off-by: Roopa Prabhu 
---
 include/net/fib_rules.h| 31 +-
 include/uapi/linux/fib_rules.h |  8 
 net/core/fib_rules.c   | 94 +-
 3 files changed, 130 insertions(+), 3 deletions(-)

diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index b3d2162..6d99202 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -11,6 +11,11 @@
 #include 
 #include 
 
+struct fib_port_range {
+   __u16 start;
+   __u16 end;
+};
+
 struct fib_kuid_range {
kuid_t start;
kuid_t end;
@@ -27,7 +32,7 @@ struct fib_rule {
u8  action;
u8  l3mdev;
u8  proto;
-   /* 1 byte hole, try to use */
+   u8  ip_proto;
u32 target;
__be64  tun_id;
struct fib_rule __rcu   *ctarget;
@@ -40,6 +45,8 @@ struct fib_rule {
chariifname[IFNAMSIZ];
charoifname[IFNAMSIZ];
struct fib_kuid_range   uid_range;
+   struct fib_port_range   sport_range;
+   struct fib_port_range   dport_range;
struct rcu_head rcu;
 };
 
@@ -144,6 +151,28 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, 
struct nlattr **nla)
return frh->table;
 }
 
+static inline bool fib_rule_port_inrange(struct fib_port_range *a,
+__be16 port)
+{
+   if (!a->start)
+   return true;
+   return ntohs(port) >= a->start &&
+   ntohs(port) <= a->end;
+}
+
+static inline bool fib_rule_port_range_valid(const struct fib_port_range *a)
+{
+   return a->start > 0 && a->end < 0x &&
+   a->start <= a->end;
+}
+
+static inline bool fib_rule_port_range_compare(struct fib_port_range *a,
+  struct fib_port_range *b)
+{
+   return a->start == b->start &&
+   a->end == b->end;
+}
+
 struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *,
 struct net *);
 void fib_rules_unregister(struct fib_rules_ops *);
diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h
index 77d90ae..232df14 100644
--- a/include/uapi/linux/fib_rules.h
+++ b/include/uapi/linux/fib_rules.h
@@ -35,6 +35,11 @@ struct fib_rule_uid_range {
__u32   end;
 };
 
+struct fib_rule_port_range {
+   __u16   start;
+   __u16   end;
+};
+
 enum {
FRA_UNSPEC,
FRA_DST,/* destination address */
@@ -59,6 +64,9 @@ enum {
FRA_L3MDEV, /* iif or oif is l3mdev goto its table */
FRA_UID_RANGE,  /* UID range */
FRA_PROTOCOL,   /* Originator of the rule */
+   FRA_IP_PROTO,   /* ip proto */
+   FRA_SPORT_RANGE, /* sport */
+   FRA_DPORT_RANGE, /* dport */
__FRA_MAX
 };
 
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index a6aea80..5008235 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -33,6 +33,10 @@ bool fib_rule_matchall(const struct fib_rule *rule)
if (!uid_eq(rule->uid_range.start, fib_kuid_range_unset.start) ||
!uid_eq(rule->uid_range.end, fib_kuid_range_unset.end))
return false;
+   if (fib_rule_port_range_valid(>sport_range))
+   return false;
+   if (fib_rule_port_range_valid(>dport_range))
+   return false;
return true;
 }
 EXPORT_SYMBOL_GPL(fib_rule_matchall);
@@ -221,6 +225,12 @@ static int nla_put_uid_range(struct sk_buff *skb, struct 
fib_kuid_range *range)
return nla_put(skb, FRA_UID_RANGE, sizeof(out), );
 }
 
+static int nla_put_port_range(struct sk_buff *skb, int attrtype,
+ struct fib_port_range *range)
+{
+   return nla_put(skb, attrtype, sizeof(*range), range);
+}
+
 static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
  struct flowi *fl, int flags,
  struct fib_lookup_arg *arg)
@@ -425,6 +435,17 @@ static int rule_exists(struct fib_rules_ops *ops, struct 
fib_rule_hdr *frh,
!uid_eq(r->uid_range.end, rule->uid_range.end))
continue;
 
+   if (r->ip_proto != rule->ip_proto)
+   continue;
+
+   if (!fib_rule_port_range_compare(>sport_range,
+>sport_range))
+   continue;
+
+   if (!fib_rule_port_range_compare(>dport_range,
+>dport_range))
+   continue;
+
if (!ops->compare(r, frh, tb))

Re: [PATCH 2/2] net: mark slab's used by ss as UAPI

2018-02-24 Thread kbuild test robot
Hi Stephen,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[also build test WARNING on v4.16-rc2 next-20180223]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stephen-Hemminger/mark-some-slabs-as-visible-not-mergeable/20180225-084344
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/init.h:134:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/init.h:135:5: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/init.h:268:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/init.h:269:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/printk.h:200:6: sparse: attribute 'indirect_branch': unknown 
attribute
   arch/x86/include/asm/mem_encrypt.h:32:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:34:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:37:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:38:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:40:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:42:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:43:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:45:5: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:46:5: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:49:6: sparse: attribute 
'indirect_branch': unknown attribute
   arch/x86/include/asm/qspinlock.h:53:32: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/workqueue.h:646:5: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/workqueue.h:647:5: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/memory_hotplug.h:221:13: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/numa.h:34:12: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/numa.h:35:13: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/numa.h:62:13: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/vmalloc.h:64:13: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/vmalloc.h:173:8: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/vmalloc.h:174:8: sparse: attribute 'indirect_branch': unknown 
attribute
   arch/x86/include/asm/fixmap.h:174:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/fixmap.h:176:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/fixmap.h:178:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/fixmap.h:180:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/apic.h:254:13: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/apic.h:430:13: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/io_apic.h:184:13: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/mmzone.h:1292:15: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/smp.h:113:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/smp.h:125:13: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/smp.h:126:13: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/percpu.h:110:33: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/percpu.h:112:13: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/percpu.h:114:12: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/percpu.h:118:12: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/percpu.h:126:12: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/kmemleak.h:29:33: sparse: attribute 'indirect_branch': unknown 
attribute
   arch/x86/include/asm/kasan.h:29:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/kasan.h:30:6: sparse: attribute 'indirect_branch': 
unknown attribute
   arch/x86/include/asm/pgtable.h:28:5: sparse: attribute 'indirect_branch': 
unknown attribute
   include/linux/slab.h:141:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/slab.h:722:6: sparse: attribute 'indirect_branch': unknown 
attribute
   include/linux/hrtimer.h:497:13: sparse: attribute 

Re: [PATCH] DT: net: renesas,ravb: document R8A77980 bindings

2018-02-24 Thread David Miller
From: Sergei Shtylyov 
Date: Sat, 24 Feb 2018 21:01:15 +0300

> On 02/01/2018 11:13 PM, Sergei Shtylyov wrote:
> 
>> Renesas R-Car V3H (R8A77980) SoC has the R-Car gen3 compatible EtherAVB
>> device, so document the SoC specific bindings.
>> 
>> Signed-off-by: Sergei Shtylyov 
>> 
>> ---
>> The patch is against DaveM's 'net-next.git' repo but I wouldn't mind if it's
>> applied to 'net.git' instead. :-)
> 
>David, I see this patch was marked as "not applicable" in patchwork. Why, 
> because
> it was posted during the merge window?

No because I thought the relevant architecture tree would take a mere
DT update.


Re: ss issue on arm not showing UDP listening ports

2018-02-24 Thread Jesse Cooper
Thank you all for your help. This has been very educational. I will change the 
settings on my build and create a new image.

On February 23, 2018 7:58:31 AM CST, Guillaume Nault  
wrote:
>On Thu, Feb 22, 2018 at 12:08:19PM -0500, jesse_coo...@codeholics.com
>wrote:
>> 
>> Quoting Guillaume Nault :
>> 
>> > On Wed, Feb 21, 2018 at 07:59:24PM -0600, Jesse Cooper wrote:
>> > > Thank you for the suggestions. This is on a raspberry pi 3 not
>sure if
>> > > that fact matters. I will notify Raspbian of the issue.
>> > > 
>> > Does your kernel have CONFIG_INET_UDP_DIAG?
>> 
>> grep CONFIG_INET_UDP_DIAG kernel.config
>> # CONFIG_INET_UDP_DIAG is not set
>> 
>> sudo modprobe udp_diag
>> modprobe: FATAL: Module udp_diag not found in directory
>> /lib/modules/4.9.59-v7+
>> 
>> Can this module be loaded after the fact? If so what is the easiest
>way to
>> get the proper .ko file?
>> 
>Just recompile with CONFIG_INET_UDP_DIAG=m (or ask your distribution to
>do so). That should be enough to fix the problem.

-- 
Jesse Cooper


[PATCH net 3/4] net/sonic: Clean up and modernize log messages

2018-02-24 Thread Finn Thain
Add missing printk severity levels by adopting pr_foo() calls for the
platform_driver and dev_foo() calls for the nubus_driver.
Avoid KERN_CONT usage as per advice from checkpatch.
Avoid #ifdef around printk calls.
Don't log driver probe messages after calling register_netdev().

Cc: Thomas Bogendoerfer 
Cc: Chris Zankel 
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
Only the macsonic.c changes have been tested. The other changes
are similar but untested.
---
 drivers/net/ethernet/natsemi/jazzsonic.c | 13 -
 drivers/net/ethernet/natsemi/macsonic.c  | 49 ++--
 drivers/net/ethernet/natsemi/xtsonic.c   | 11 +++
 3 files changed, 33 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c 
b/drivers/net/ethernet/natsemi/jazzsonic.c
index d5b28884e21e..58495316d318 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -142,17 +142,14 @@ static int sonic_probe1(struct net_device *dev)
i++;
 
if (known_revisions[i] == 0x) {
-   printk("SONIC ethernet controller not found (0x%4x)\n",
-  silicon_revision);
+   pr_info("SONIC ethernet controller not found (0x%4x)\n",
+   silicon_revision);
goto out;
}
 
if (sonic_debug  &&  version_printed++ == 0)
printk(version);
 
-   printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ",
-  dev_name(lp->device), dev->base_addr);
-
/*
 * Put the sonic into software reset, then
 * retrieve and print the ethernet address.
@@ -245,12 +242,14 @@ static int jazz_sonic_probe(struct platform_device *pdev)
err = sonic_probe1(dev);
if (err)
goto out;
+
+   pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
+   dev->base_addr, dev->dev_addr, dev->irq);
+
err = register_netdev(dev);
if (err)
goto out1;
 
-   printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
-
return 0;
 
 out1:
diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index f6745a893c82..dc690f287a6d 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -311,8 +311,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
int sr;
bool commslot = macintosh_config->expansion_type == MAC_EXP_PDS_COMM;
 
-   printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
-
/* Bogus probing, on the models which may or may not have
   Ethernet (BTW, the Ethernet *is* always at the same
   address, and nothing else lives there, at least if Apple's
@@ -322,13 +320,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
 
card_present = hwreg_present((void*)ONBOARD_SONIC_REGISTERS);
if (!card_present) {
-   printk("none.\n");
+   pr_info("Onboard/comm-slot SONIC not found\n");
return -ENODEV;
}
}
 
-   printk("yes\n");
-
/* Danger!  My arms are flailing wildly!  You *must* set lp->reg_offset
 * and dev->base_addr before using SONIC_READ() or SONIC_WRITE() */
dev->base_addr = ONBOARD_SONIC_REGISTERS;
@@ -341,14 +337,11 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
printk(KERN_INFO "%s", version);
sonic_version_printed = 1;
}
-   printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n",
-  dev_name(lp->device), dev->base_addr);
 
/* The PowerBook's SONIC is 16 bit always. */
if (macintosh_config->ident == MAC_MODEL_PB520) {
lp->reg_offset = 0;
lp->dma_bitmode = SONIC_BITMODE16;
-   sr = SONIC_READ(SONIC_SR);
} else if (commslot) {
/* Some of the comm-slot cards are 16 bit.  But some
   of them are not.  The 32-bit cards use offset 2 and
@@ -365,22 +358,21 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else {
lp->dma_bitmode = SONIC_BITMODE16;
lp->reg_offset = 0;
-   sr = SONIC_READ(SONIC_SR);
}
} else {
/* All onboard cards are at offset 2 with 32 bit DMA. */
lp->reg_offset = 2;
lp->dma_bitmode = SONIC_BITMODE32;
-   sr = SONIC_READ(SONIC_SR);
}
-   printk(KERN_INFO
-  "%s: revision 0x%04x, using %d bit DMA and register offset %d\n",
-  dev_name(lp->device), sr, lp->dma_bitmode?32:16, lp->reg_offset);
 
-#if 0 /* This is sometimes useful to find 

[PATCH net 4/4] net/sonic: Replace custom debug logging with netif_* calls

2018-02-24 Thread Finn Thain
Eliminate duplicated debug code by moving it into the core driver.
Don't log the only valid silicon revision number (it's in the source).

Cc: Thomas Bogendoerfer 
Cc: Chris Zankel 
Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
Only the sonic.[ch] and macsonic.c changes have been tested. The other
changes are similar but untested.
---
 drivers/net/ethernet/natsemi/jazzsonic.c | 19 +-
 drivers/net/ethernet/natsemi/macsonic.c  | 25 ++--
 drivers/net/ethernet/natsemi/sonic.c | 99 
 drivers/net/ethernet/natsemi/sonic.h |  2 +
 drivers/net/ethernet/natsemi/xtsonic.c   | 19 +-
 5 files changed, 61 insertions(+), 103 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c 
b/drivers/net/ethernet/natsemi/jazzsonic.c
index 58495316d318..51fa82b429a3 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -60,14 +60,6 @@ do { 
\
*((volatile unsigned int *)dev->base_addr+(reg)) = (val);   
\
 } while (0)
 
-
-/* use 0 for production, 1 for verification, >1 for debug */
-#ifdef SONIC_DEBUG
-static unsigned int sonic_debug = SONIC_DEBUG;
-#else
-static unsigned int sonic_debug = 1;
-#endif
-
 /*
  * We cannot use station (ethernet) address prefixes to detect the
  * sonic controller since these are board manufacturer depended.
@@ -117,7 +109,6 @@ static const struct net_device_ops sonic_netdev_ops = {
 
 static int sonic_probe1(struct net_device *dev)
 {
-   static unsigned version_printed;
unsigned int silicon_revision;
unsigned int val;
struct sonic_local *lp = netdev_priv(dev);
@@ -133,9 +124,6 @@ static int sonic_probe1(struct net_device *dev)
 * the expected location.
 */
silicon_revision = SONIC_READ(SONIC_SR);
-   if (sonic_debug > 1)
-   printk("SONIC Silicon Revision = 0x%04x\n",silicon_revision);
-
i = 0;
while (known_revisions[i] != 0x &&
   known_revisions[i] != silicon_revision)
@@ -147,9 +135,6 @@ static int sonic_probe1(struct net_device *dev)
goto out;
}
 
-   if (sonic_debug  &&  version_printed++ == 0)
-   printk(version);
-
/*
 * Put the sonic into software reset, then
 * retrieve and print the ethernet address.
@@ -246,6 +231,8 @@ static int jazz_sonic_probe(struct platform_device *pdev)
pr_info("SONIC ethernet @%08lx, MAC %pM, IRQ %d\n",
dev->base_addr, dev->dev_addr, dev->irq);
 
+   sonic_msg_init(dev);
+
err = register_netdev(dev);
if (err)
goto out1;
@@ -261,8 +248,6 @@ static int jazz_sonic_probe(struct platform_device *pdev)
 }
 
 MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
-module_param(sonic_debug, int, 0);
-MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
 MODULE_ALIAS("platform:jazzsonic");
 
 #include "sonic.c"
diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index dc690f287a6d..0937fc2a928e 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -70,15 +70,6 @@
 #define SONIC_WRITE(reg,val) (nubus_writew(val, dev->base_addr + (reg * 4) \
  + lp->reg_offset))
 
-/* use 0 for production, 1 for verification, >1 for debug */
-#ifdef SONIC_DEBUG
-static unsigned int sonic_debug = SONIC_DEBUG;
-#else
-static unsigned int sonic_debug = 1;
-#endif
-
-static int sonic_version_printed;
-
 /* For onboard SONIC */
 #define ONBOARD_SONIC_REGISTERS0x50F0A000
 #define ONBOARD_SONIC_PROM_BASE0x50f08000
@@ -333,11 +324,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
else
dev->irq = IRQ_NUBUS_9;
 
-   if (!sonic_version_printed) {
-   printk(KERN_INFO "%s", version);
-   sonic_version_printed = 1;
-   }
-
/* The PowerBook's SONIC is 16 bit always. */
if (macintosh_config->ident == MAC_MODEL_PB520) {
lp->reg_offset = 0;
@@ -499,11 +485,6 @@ static int mac_sonic_nubus_probe_board(struct nubus_board 
*board, int id,
lp->dma_bitmode = dma_bitmode;
dev->irq = SLOT2IRQ(board->slot);
 
-   if (!sonic_version_printed) {
-   printk(KERN_INFO "%s", version);
-   sonic_version_printed = 1;
-   }
-
dev_info(>dev, "%s, revision 0x%04x, %d bit DMA, register offset 
%d\n",
 board->name, SONIC_READ(SONIC_SR),
 lp->dma_bitmode ? 32 : 16, lp->reg_offset);
@@ -555,6 +536,8 @@ static int mac_sonic_platform_probe(struct platform_device 
*pdev)
if (err)
goto out;
 
+   sonic_msg_init(dev);
+
err = register_netdev(dev);
if (err)

[PATCH net 0/4] Fixes, cleanup and modernization for SONIC ethernet drivers

2018-02-24 Thread Finn Thain
Changes since v4 of combined patch series:
- Removed redundant and non-portable MACH_IS_MAC tests.
- Omitted patches unrelated to SONIC drivers.
- Dropped changes to the 'version_printed' logic and debug message text.


Finn Thain (4):
  net/macsonic: Convert to nubus_driver
  net/macsonic: Drop redundant MACH_IS_MAC test
  net/sonic: Clean up and modernize log messages
  net/sonic: Replace custom debug logging with netif_* calls

 drivers/net/ethernet/natsemi/jazzsonic.c |  32 +---
 drivers/net/ethernet/natsemi/macsonic.c  | 244 ++-
 drivers/net/ethernet/natsemi/sonic.c |  99 +++--
 drivers/net/ethernet/natsemi/sonic.h |   2 +
 drivers/net/ethernet/natsemi/xtsonic.c   |  30 +---
 5 files changed, 210 insertions(+), 197 deletions(-)

-- 
2.16.1



[PATCH net 1/4] net/macsonic: Convert to nubus_driver

2018-02-24 Thread Finn Thain
This resolves an old issue preventing any NuBus SONIC NICs from
working in a Mac with an on-board SONIC device.

Tested-by: Stan Johnson 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/natsemi/macsonic.c | 173 ++--
 1 file changed, 119 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index b922ab5cedea..c744912f55a9 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -60,8 +60,6 @@
 #include 
 #include 
 
-static char mac_sonic_string[] = "macsonic";
-
 #include "sonic.h"
 
 /* These should basically be bus-size and endian independent (since
@@ -410,7 +408,7 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
return macsonic_init(dev);
 }
 
-static int mac_nubus_sonic_ethernet_addr(struct net_device *dev,
+static int mac_sonic_nubus_ethernet_addr(struct net_device *dev,
 unsigned long prom_addr, int id)
 {
int i;
@@ -449,70 +447,49 @@ static int macsonic_ident(struct nubus_rsrc *fres)
return -1;
 }
 
-static int mac_nubus_sonic_probe(struct net_device *dev)
+static int mac_sonic_nubus_probe_board(struct nubus_board *board, int id,
+  struct net_device *dev)
 {
-   static int slots;
-   struct nubus_rsrc *ndev = NULL;
struct sonic_local* lp = netdev_priv(dev);
unsigned long base_addr, prom_addr;
u16 sonic_dcr;
-   int id = -1;
int reg_offset, dma_bitmode;
 
-   /* Find the first SONIC that hasn't been initialized already */
-   for_each_func_rsrc(ndev) {
-   if (ndev->category != NUBUS_CAT_NETWORK ||
-   ndev->type != NUBUS_TYPE_ETHERNET)
-   continue;
-
-   /* Have we seen it already? */
-   if (slots & (1slot))
-   continue;
-   slots |= 1slot;
-
-   /* Is it one of ours? */
-   if ((id = macsonic_ident(ndev)) != -1)
-   break;
-   }
-
-   if (ndev == NULL)
-   return -ENODEV;
-
switch (id) {
case MACSONIC_DUODOCK:
-   base_addr = ndev->board->slot_addr + DUODOCK_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DUODOCK_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + DUODOCK_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DUODOCK_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT0 | SONIC_DCR_RFT1 |
SONIC_DCR_TFT0;
reg_offset = 2;
dma_bitmode = SONIC_BITMODE32;
break;
case MACSONIC_APPLE:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_BMS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE32;
break;
case MACSONIC_APPLE16:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + APPLE_SONIC_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + APPLE_SONIC_PROM_BASE;
sonic_dcr = SONIC_DCR_EXBUS | SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE16;
break;
case MACSONIC_DAYNALINK:
-   base_addr = ndev->board->slot_addr + APPLE_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DAYNALINK_PROM_BASE;
+   base_addr = board->slot_addr + APPLE_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DAYNALINK_PROM_BASE;
sonic_dcr = SONIC_DCR_RFT1 | SONIC_DCR_TFT0 |
SONIC_DCR_PO1 | SONIC_DCR_BMS;
reg_offset = 0;
dma_bitmode = SONIC_BITMODE16;
break;
case MACSONIC_DAYNA:
-   base_addr = ndev->board->slot_addr + DAYNA_SONIC_REGISTERS;
-   prom_addr = ndev->board->slot_addr + DAYNA_SONIC_MAC_ADDR;
+   base_addr = board->slot_addr + DAYNA_SONIC_REGISTERS;
+   prom_addr = board->slot_addr + DAYNA_SONIC_MAC_ADDR;
sonic_dcr = SONIC_DCR_BMS |
SONIC_DCR_RFT1 | SONIC_DCR_TFT0 | SONIC_DCR_PO1;
reg_offset = 0;
@@ -528,14 +505,14 @@ static int mac_nubus_sonic_probe(struct net_device 

[PATCH net 2/4] net/macsonic: Drop redundant MACH_IS_MAC test

2018-02-24 Thread Finn Thain
The MACH_IS_MAC test is redundant here because the platform device
won't get registered unless MACH_IS_MAC.

Cc: Geert Uytterhoeven 
Signed-off-by: Finn Thain 
---
 drivers/net/ethernet/natsemi/macsonic.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/macsonic.c 
b/drivers/net/ethernet/natsemi/macsonic.c
index c744912f55a9..f6745a893c82 100644
--- a/drivers/net/ethernet/natsemi/macsonic.c
+++ b/drivers/net/ethernet/natsemi/macsonic.c
@@ -311,9 +311,6 @@ static int mac_onboard_sonic_probe(struct net_device *dev)
int sr;
bool commslot = macintosh_config->expansion_type == MAC_EXP_PDS_COMM;
 
-   if (!MACH_IS_MAC)
-   return -ENODEV;
-
printk(KERN_INFO "Checking for internal Macintosh ethernet (SONIC).. ");
 
/* Bogus probing, on the models which may or may not have
-- 
2.16.1



[PATCH] netdev: carrier detect ok, don't turn off negotiation

2018-02-24 Thread Denis Du
Sometimes when physical lines have a just good noise to make the protocol
handshaking fail, but the carrier detect still good. Then after remove of
the noise, nobody will trigger this protocol to be start again to cause
the link to never come back. The fix is when the carrier is still on, not
terminate the protocol handshaking.

Signed-off-by: Denis Du 
---
 drivers/net/wan/hdlc_ppp.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index afeca6b..ab8b3cb 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -574,7 +574,10 @@ static void ppp_timer(struct timer_list *t)
ppp_cp_event(proto->dev, proto->pid, TO_GOOD, 0, 0,
 0, NULL);
proto->restart_counter--;
-   } else
+   } else if (netif_carrier_ok(proto->dev))
+   ppp_cp_event(proto->dev, proto->pid, TO_GOOD, 0, 0,
+0, NULL);
+   else
ppp_cp_event(proto->dev, proto->pid, TO_BAD, 0, 0,
 0, NULL);
break;
-- 
2.1.4



Re: ppp/pppoe, still panic 4.15.3 in ppp_push

2018-02-24 Thread Denys Fedoryshchenko

On 2018-02-23 12:07, Guillaume Nault wrote:

On Fri, Feb 23, 2018 at 11:41:43AM +0200, Denys Fedoryshchenko wrote:

On 2018-02-23 11:38, Guillaume Nault wrote:
> On Thu, Feb 22, 2018 at 08:51:19PM +0200, Denys Fedoryshchenko wrote:
> > I'm using accel-ppp that has unit-cache option, i guess for
> > "reusing" ppp
> > interfaces (because creating a lot of interfaces on BRAS with 8k
> > users quite
> > expensive).
> > Maybe it is somehow related and can be that scenario causing this bug?
> >
> Indeed, it'd be interesting to know if unit-cache is part of the
> equation (if it's workable for you to disable it).
Already did that and testing, unfortunately i had to disable KASAN and 
full
refcount, as performance hit is too heavy for me. I will try to enable 
KASAN

alone tomorrow.

Don't hesitate to post the result even if you can't afford enabling 
KASAN.

Very likely unit-cache is major contributor to this reboots.
After disabling it, it is almost 48h and no reboots yet.


Re: [PATCH 0/2] mark some slabs as visible not mergeable

2018-02-24 Thread Matthew Wilcox
On Sat, Feb 24, 2018 at 11:04:52AM -0800, Stephen Hemminger wrote:
> This fixes an old bug in iproute2's ss command because it was
> reading slabinfo to get statistics. There isn't a better API
> to do this, and one can argue that /proc is a UAPI that must
> not change.
> 
> Therefore this patch set adds a flag to slab to give another
> reason to prevent merging, and then uses it in network code.

This is exactly the solution I would have suggested.  Note that SLUB
has always had slab merging, so this tool has been broken since 2.6.22
on any kernel with CONFIG_SLUB.

Reviewed-by: Matthew Wilcox 


[PATCH net-next] sh_eth: fix TSU init on SH7734/R8A7740

2018-02-24 Thread Sergei Shtylyov
It appears that the single port Ether controllers having TSU (like SH7734/
R8A7740) need the same kind of treating in sh_eth_tsu_init() as R7S72100
currently has -- they also don't have the TSU registers related e.g. to
passing the frames between ports. Add the 'sh_eth_cpu_data::dual_port'
flag and use it as a new criterion for taking a "short path" in the TSU
init sequence in order to avoid writing to the non-existant registers...

Fixes: f0e81fecd4f8 ("net: sh_eth: Add support SH7734")
Fixes: 73a0d907301e ("net: sh_eth: add support R8A7740")
Signed-off-by: Sergei Shtylyov 

---
David, I'm submitting this patch against the 'net-next.git' repo since nothing
seems to explode when writing to the non-existing TSU registers. Whether to
apply this to 'net.git' instead is up to you...

 drivers/net/ethernet/renesas/sh_eth.c |6 +-
 drivers/net/ethernet/renesas/sh_eth.h |1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -752,6 +752,7 @@ static struct sh_eth_cpu_data sh7757_dat
.rpadir = 1,
.rpadir_value   = 2 << 16,
.rtrate = 1,
+   .dual_port  = 1,
 };
 
 #define SH_GIGA_ETH_BASE   0xfee0UL
@@ -830,6 +831,7 @@ static struct sh_eth_cpu_data sh7757_dat
.no_trimd   = 1,
.no_ade = 1,
.tsu= 1,
+   .dual_port  = 1,
 };
 
 /* SH7734 */
@@ -900,6 +902,7 @@ static struct sh_eth_cpu_data sh7763_dat
.tsu= 1,
.irq_flags  = IRQF_SHARED,
.magic  = 1,
+   .dual_port  = 1,
 };
 
 static struct sh_eth_cpu_data sh7619_data = {
@@ -932,6 +935,7 @@ static struct sh_eth_cpu_data sh771x_dat
  EESIPR_RRFIP | EESIPR_RTLFIP | EESIPR_RTSFIP |
  EESIPR_PREIP | EESIPR_CERFIP,
.tsu= 1,
+   .dual_port  = 1,
 };
 
 static void sh_eth_set_default_cpu_data(struct sh_eth_cpu_data *cd)
@@ -2915,7 +2919,7 @@ static int sh_eth_vlan_rx_kill_vid(struc
 /* SuperH's TSU register init function */
 static void sh_eth_tsu_init(struct sh_eth_private *mdp)
 {
-   if (sh_eth_is_rz_fast_ether(mdp)) {
+   if (!mdp->cd->dual_port) {
sh_eth_tsu_write(mdp, 0, TSU_TEN); /* Disable all CAM entry */
sh_eth_tsu_write(mdp, TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL,
 TSU_FWSLC);/* Enable POST registers */
Index: net-next/drivers/net/ethernet/renesas/sh_eth.h
===
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.h
+++ net-next/drivers/net/ethernet/renesas/sh_eth.h
@@ -509,6 +509,7 @@ struct sh_eth_cpu_data {
unsigned rmiimode:1;/* EtherC has RMIIMODE register */
unsigned rtrate:1;  /* EtherC has RTRATE register */
unsigned magic:1;   /* EtherC has ECMR.MPDE and ECSR.MPD */
+   unsigned dual_port:1;   /* Dual EtherC/E-DMAC */
 };
 
 struct sh_eth_private {


[PATCH iproute2 3/3] ss: update slabinfo names and sum IPv4 and IPv6

2018-02-24 Thread Stephen Hemminger
For a long time the name of slabs for TCP sockets have changed.
And ss summary was missing them. Also it never handled IPv6.
Change the code to sum values from both protocols.

Also, print error if slabinfo can not be opened.
Typically this is attempt to run 'ss -s' as non-root user
and /proc/slabinfo is now protected.

Reported-by: Igor Komyagin 
Signed-off-by: Stephen Hemminger 
---
 misc/ss.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index 4c7057198eb2..f98acdba6e24 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -686,15 +686,14 @@ static int get_slabstat(struct slabstat *s)
 {
char buf[256];
FILE *fp;
-   int cnt;
static bool slabstat_valid;
static const char * const slabstat_ids[] = {
-   "sock",
+   "sock_inode_cache",
"tcp_bind_bucket",
-   "tcp_tw_bucket",
-   "tcp_open_request",
+   "tw_sock_TCP",
+   "request_sock_TCP",
};
-   unsigned int *vals = (unsigned int *) s;
+   unsigned int *slabstat_vals = (unsigned int *) s;
 
if (slabstat_valid)
return 0;
@@ -702,27 +701,29 @@ static int get_slabstat(struct slabstat *s)
memset(s, 0, sizeof(*s));
 
fp = slabinfo_open();
-   if (!fp)
+   if (!fp) {
+   fprintf(stderr, "slabinfo unavailable: %s\n",
+   strerror(errno));
return -1;
-
-   cnt = sizeof(*s)/sizeof(int);
+   }
 
if (!fgets(buf, sizeof(buf), fp)) {
fclose(fp);
return -1;
}
+
while (fgets(buf, sizeof(buf), fp) != NULL) {
int i;
 
for (i = 0; i < ARRAY_SIZE(slabstat_ids); i++) {
-   if (memcmp(buf, slabstat_ids[i], 
strlen(slabstat_ids[i])) == 0) {
-   sscanf(buf, "%*s%u", vals + i);
-   cnt--;
-   break;
-   }
+   unsigned long val;
+
+   if (memcmp(buf, slabstat_ids[i], 
strlen(slabstat_ids[i])))
+   continue;
+
+   if (sscanf(buf, "%*s%lu", ))
+   slabstat_vals[i] += val;
}
-   if (cnt <= 0)
-   break;
}
 
slabstat_valid = true;
-- 
2.16.1



[PATCH iproute2 2/3] ss: convert socket statistics to unsigned

2018-02-24 Thread Stephen Hemminger
The kernel keeps these values as unsigned not signed integer.

Signed-off-by: Stephen Hemminger 
---
 misc/ss.c | 96 +++
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index fefe5c813c44..4c7057198eb2 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -674,10 +674,10 @@ next:
 /* Get stats from slab */
 
 struct slabstat {
-   int socks;
-   int tcp_ports;
-   int tcp_tws;
-   int tcp_syns;
+   unsigned int socks;
+   unsigned int tcp_ports;
+   unsigned int tcp_tws;
+   unsigned int tcp_syns;
 };
 
 static struct slabstat slabstat;
@@ -687,13 +687,14 @@ static int get_slabstat(struct slabstat *s)
char buf[256];
FILE *fp;
int cnt;
-   static int slabstat_valid;
+   static bool slabstat_valid;
static const char * const slabstat_ids[] = {
"sock",
"tcp_bind_bucket",
"tcp_tw_bucket",
"tcp_open_request",
};
+   unsigned int *vals = (unsigned int *) s;
 
if (slabstat_valid)
return 0;
@@ -715,7 +716,7 @@ static int get_slabstat(struct slabstat *s)
 
for (i = 0; i < ARRAY_SIZE(slabstat_ids); i++) {
if (memcmp(buf, slabstat_ids[i], 
strlen(slabstat_ids[i])) == 0) {
-   sscanf(buf, "%*s%d", ((int *)s) + i);
+   sscanf(buf, "%*s%u", vals + i);
cnt--;
break;
}
@@ -724,7 +725,7 @@ static int get_slabstat(struct slabstat *s)
break;
}
 
-   slabstat_valid = 1;
+   slabstat_valid = true;
 
fclose(fp);
return 0;
@@ -3287,8 +3288,7 @@ static int tcp_show(struct filter *f)
 */
if (1) {
get_slabstat();
-
-   int guess = slabstat.socks+slabstat.tcp_syns;
+   unsigned int guess = slabstat.socks + slabstat.tcp_syns;
 
if (f->states&(1<socks);
+   sscanf(rem, "%*s%u", >socks);
else if (strcmp(id, "UDP:") == 0)
-   sscanf(rem, "%*s%d", >udp4);
+   sscanf(rem, "%*s%u", >udp4);
else if (strcmp(id, "UDP6:") == 0)
-   sscanf(rem, "%*s%d", >udp6);
+   sscanf(rem, "%*s%u", >udp6);
else if (strcmp(id, "RAW:") == 0)
-   sscanf(rem, "%*s%d", >raw4);
+   sscanf(rem, "%*s%u", >raw4);
else if (strcmp(id, "RAW6:") == 0)
-   sscanf(rem, "%*s%d", >raw6);
+   sscanf(rem, "%*s%u", >raw6);
else if (strcmp(id, "TCP6:") == 0)
-   sscanf(rem, "%*s%d", >tcp6_hashed);
+   sscanf(rem, "%*s%u", >tcp6_hashed);
else if (strcmp(id, "FRAG:") == 0)
-   sscanf(rem, "%*s%d%*s%d", >frag4, >frag4_mem);
+   sscanf(rem, "%*s%u%*s%u", >frag4, >frag4_mem);
  

[PATCH iproute2 0/3] ss: fix slab statistics

2018-02-24 Thread Stephen Hemminger
The ss -s command has been broken in several places since the
2.6.13 kernel. The slab values it is looking for have changed
names and kernel started merging the values (see kernel patch
for fixing that).

Stephen Hemminger (3):
  ss: drop unused slabstat for skb's
  ss: convert socket statistics to unsigned
  ss: update slabinfo names and sum IPv4 and IPv6

 misc/ss.c | 125 +++---
 1 file changed, 62 insertions(+), 63 deletions(-)

-- 
2.16.1



[PATCH iproute2 1/3] ss: drop unused slabstat for skb's

2018-02-24 Thread Stephen Hemminger
This value is not used anywhere in current code.

Signed-off-by: Stephen Hemminger 
---
 misc/ss.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index e047f9c04582..fefe5c813c44 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -678,7 +678,6 @@ struct slabstat {
int tcp_ports;
int tcp_tws;
int tcp_syns;
-   int skbs;
 };
 
 static struct slabstat slabstat;
@@ -694,7 +693,6 @@ static int get_slabstat(struct slabstat *s)
"tcp_bind_bucket",
"tcp_tw_bucket",
"tcp_open_request",
-   "skbuff_head_cache",
};
 
if (slabstat_valid)
-- 
2.16.1



[PATCH 2/2] net: mark slab's used by ss as UAPI

2018-02-24 Thread Stephen Hemminger
The iproute2 ss command reads /proc/slabinfo as way to get estimates
for number of open sockets etc. This has been broken since slab
merging went in 3.17.

Mark those kmem caches's as non mergeable with new flag.
The TCP caches's are already not mergeable because of the RCU
flags, but someone might change that and cause surprise later.

Reported-by: Igor Komyagin 
Signed-off-by: Stephen Hemminger 
---
 net/ipv4/tcp.c  | 3 ++-
 net/ipv4/tcp_ipv4.c | 2 +-
 net/ipv6/tcp_ipv6.c | 2 +-
 net/socket.c| 6 +++---
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 48636aee23c3..8c0d4cdc601d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3617,7 +3617,8 @@ void __init tcp_init(void)
tcp_hashinfo.bind_bucket_cachep =
kmem_cache_create("tcp_bind_bucket",
  sizeof(struct inet_bind_bucket), 0,
- SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
+ 
SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_VISIBLE_UAPI,
+ NULL);
 
/* Size and allocate the main established and bind bucket
 * hash tables.
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f8ad397e285e..4442f91fab93 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2434,7 +2434,7 @@ struct proto tcp_prot = {
.sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_tcp_rmem),
.max_header = MAX_TCP_HEADER,
.obj_size   = sizeof(struct tcp_sock),
-   .slab_flags = SLAB_TYPESAFE_BY_RCU,
+   .slab_flags = SLAB_TYPESAFE_BY_RCU | SLAB_VISIBLE_UAPI,
.twsk_prot  = _timewait_sock_ops,
.rsk_prot   = _request_sock_ops,
.h.hashinfo = _hashinfo,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 412139f4eccd..d6df3b3f401c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1944,7 +1944,7 @@ struct proto tcpv6_prot = {
.sysctl_rmem_offset = offsetof(struct net, ipv4.sysctl_tcp_rmem),
.max_header = MAX_TCP_HEADER,
.obj_size   = sizeof(struct tcp6_sock),
-   .slab_flags = SLAB_TYPESAFE_BY_RCU,
+   .slab_flags = SLAB_TYPESAFE_BY_RCU | SLAB_VISIBLE_UAPI,
.twsk_prot  = _timewait_sock_ops,
.rsk_prot   = _request_sock_ops,
.h.hashinfo = _hashinfo,
diff --git a/net/socket.c b/net/socket.c
index a93c99b518ca..f76ae11af8c7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -286,9 +286,9 @@ static void init_inodecache(void)
sock_inode_cachep = kmem_cache_create("sock_inode_cache",
  sizeof(struct socket_alloc),
  0,
- (SLAB_HWCACHE_ALIGN |
-  SLAB_RECLAIM_ACCOUNT |
-  SLAB_MEM_SPREAD | SLAB_ACCOUNT),
+ SLAB_HWCACHE_ALIGN | 
SLAB_VISIBLE_UAPI |
+ SLAB_RECLAIM_ACCOUNT |
+ SLAB_MEM_SPREAD | SLAB_ACCOUNT,
  init_once);
BUG_ON(sock_inode_cachep == NULL);
 }
-- 
2.16.1



[PATCH 1/2] slab: add flag to block merging of UAPI elements

2018-02-24 Thread Stephen Hemminger
The iproute2 program ss reads /proc/slabinfo to get TCP socket
statistics; therefore those kmem cache's can not be merged.
This patch adds a new flag to block merging in these kind
of cases.

Signed-off-by: Stephen Hemminger 
---
 include/linux/slab.h | 6 ++
 mm/slab_common.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 231abc8976c5..867acc2ddcbc 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -108,6 +108,12 @@
 #define SLAB_KASAN 0
 #endif
 
+/*
+ * Some old applications may want to read/write particular slab cache
+ * by name and therefore this can not be merged.
+ */
+#define SLAB_VISIBLE_UAPI  0x1000UL
+
 /* The following flags affect the page allocator grouping pages by mobility */
 /* Objects are reclaimable */
 #define SLAB_RECLAIM_ACCOUNT   ((slab_flags_t __force)0x0002U)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 10f127b2de7c..71eb5fc63cf8 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -49,7 +49,7 @@ static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
  */
 #define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
SLAB_TRACE | SLAB_TYPESAFE_BY_RCU | SLAB_NOLEAKTRACE | \
-   SLAB_FAILSLAB | SLAB_KASAN)
+   SLAB_FAILSLAB | SLAB_KASAN | SLAB_VISIBLE_UAPI)
 
 #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \
 SLAB_ACCOUNT)
-- 
2.16.1



[PATCH 0/2] mark some slabs as visible not mergeable

2018-02-24 Thread Stephen Hemminger
This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.

Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.

The patches are against davem's linux-net tree and should also
goto stable as well.

Stephen Hemminger (2):
  slab: add flag to block merging of UAPI elements
  net: mark slab's used by ss as UAPI

 include/linux/slab.h | 6 ++
 mm/slab_common.c | 2 +-
 net/ipv4/tcp.c   | 3 ++-
 net/ipv4/tcp_ipv4.c  | 2 +-
 net/ipv6/tcp_ipv6.c  | 2 +-
 net/socket.c | 6 +++---
 6 files changed, 14 insertions(+), 7 deletions(-)

-- 
2.16.1



Re: tcp_bind_bucket is missing from slabinfo

2018-02-24 Thread Stephen Hemminger
On Sat, 24 Feb 2018 06:35:20 -0800
Matthew Wilcox  wrote:

> On Fri, Feb 23, 2018 at 10:50:30PM -0800, Stephen Hemminger wrote:
> > Somewhere back around 3.17 the kmem cache "tcp_bind_bucket" dropped out
> > of /proc/slabinfo. It turns out the ss command was dumpster diving
> > in slabinfo to determine the number of bound sockets and now it always
> > reports 0.
> > 
> > Not sure why, the cache is still created but it doesn't
> > show in slabinfo. Could it be some part of making slab/slub common code
> > (or network namespaces). The cache is created in tcp_init but not visible.
> > 
> > Any ideas?  
> 
> Try booting with slab_nomerge=1

Yes, thats it. 


[PATCH] xfrm: mark kmem_caches as __ro_after_init

2018-02-24 Thread Alexey Dobriyan
Kmem caches aren't relocated once set up.

Signed-off-by: Alexey Dobriyan 
---

 net/xfrm/xfrm_input.c  |3 ++-
 net/xfrm/xfrm_policy.c |2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -9,6 +9,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,7 +32,7 @@ struct xfrm_trans_cb {
 
 #define XFRM_TRANS_SKB_CB(__skb) ((struct xfrm_trans_cb *)&((__skb)->cb[0]))
 
-static struct kmem_cache *secpath_cachep __read_mostly;
+static struct kmem_cache *secpath_cachep __ro_after_init;
 
 static DEFINE_SPINLOCK(xfrm_input_afinfo_lock);
 static struct xfrm_input_afinfo const __rcu *xfrm_input_afinfo[AF_INET6 + 1];
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -51,7 +51,7 @@ static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
 static struct xfrm_policy_afinfo const __rcu *xfrm_policy_afinfo[AF_INET6 + 1]
__read_mostly;
 
-static struct kmem_cache *xfrm_dst_cache __read_mostly;
+static struct kmem_cache *xfrm_dst_cache __ro_after_init;
 static __read_mostly seqcount_t xfrm_policy_hash_generation;
 
 static void xfrm_init_pmtu(struct xfrm_dst **bundle, int nr);


[PATCH] net: make kmem caches as __ro_after_init

2018-02-24 Thread Alexey Dobriyan
All kmem caches aren't reallocated once set up.

Signed-off-by: Alexey Dobriyan 
---

 net/core/net_namespace.c |2 +-
 net/core/skbuff.c|4 ++--
 net/ipv4/fib_trie.c  |5 +++--
 net/ipv4/inetpeer.c  |3 ++-
 net/ipv4/ipmr.c  |3 ++-
 net/socket.c |2 +-
 6 files changed, 11 insertions(+), 8 deletions(-)

--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -362,7 +362,7 @@ static void dec_net_namespaces(struct ucounts *ucounts)
dec_ucount(ucounts, UCOUNT_NET_NAMESPACES);
 }
 
-static struct kmem_cache *net_cachep;
+static struct kmem_cache *net_cachep __ro_after_init;
 static struct workqueue_struct *netns_wq;
 
 static struct net *net_alloc(void)
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -77,8 +77,8 @@
 #include 
 #include 
 
-struct kmem_cache *skbuff_head_cache __read_mostly;
-static struct kmem_cache *skbuff_fclone_cache __read_mostly;
+struct kmem_cache *skbuff_head_cache __ro_after_init;
+static struct kmem_cache *skbuff_fclone_cache __ro_after_init;
 int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
 EXPORT_SYMBOL(sysctl_max_skb_frags);
 
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -50,6 +50,7 @@
 
 #define VERSION "0.409"
 
+#include 
 #include 
 #include 
 #include 
@@ -191,8 +192,8 @@ static size_t tnode_free_size;
  */
 static const int sync_pages = 128;
 
-static struct kmem_cache *fn_alias_kmem __read_mostly;
-static struct kmem_cache *trie_leaf_kmem __read_mostly;
+static struct kmem_cache *fn_alias_kmem __ro_after_init;
+static struct kmem_cache *trie_leaf_kmem __ro_after_init;
 
 static inline struct tnode *tn_info(struct key_vector *kv)
 {
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -6,6 +6,7 @@
  *  Authors:   Andrey V. Savochkin 
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -51,7 +52,7 @@
  * daddr: unchangeable
  */
 
-static struct kmem_cache *peer_cachep __read_mostly;
+static struct kmem_cache *peer_cachep __ro_after_init;
 
 void inet_peer_base_init(struct inet_peer_base *bp)
 {
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -96,7 +97,7 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
  * In this case data path is free of exclusive locks at all.
  */
 
-static struct kmem_cache *mrt_cachep __read_mostly;
+static struct kmem_cache *mrt_cachep __ro_after_init;
 
 static struct mr_table *ipmr_new_table(struct net *net, u32 id);
 static void ipmr_free_table(struct mr_table *mrt);
--- a/net/socket.c
+++ b/net/socket.c
@@ -233,7 +233,7 @@ static int move_addr_to_user(struct sockaddr_storage 
*kaddr, int klen,
return __put_user(klen, ulen);
 }
 
-static struct kmem_cache *sock_inode_cachep __read_mostly;
+static struct kmem_cache *sock_inode_cachep __ro_after_init;
 
 static struct inode *sock_alloc_inode(struct super_block *sb)
 {


Re: [PATCH] DT: net: renesas,ravb: document R8A77980 bindings

2018-02-24 Thread Sergei Shtylyov
On 02/01/2018 11:13 PM, Sergei Shtylyov wrote:

> Renesas R-Car V3H (R8A77980) SoC has the R-Car gen3 compatible EtherAVB
> device, so document the SoC specific bindings.
> 
> Signed-off-by: Sergei Shtylyov 
> 
> ---
> The patch is against DaveM's 'net-next.git' repo but I wouldn't mind if it's
> applied to 'net.git' instead. :-)

   David, I see this patch was marked as "not applicable" in patchwork. Why, 
because
it was posted during the merge window?

MNBR, Sergei


[PATCH net-next] sh_eth: TSU_QTAG0/1 registers the same as TSU_QTAGM0/1

2018-02-24 Thread Sergei Shtylyov
The TSU_QTAG0/1 registers found in the Gigabit Ether controllers actually
have the same long name  as the TSU_QTAGM0/1 registers in the early Ether
controllers:  Qtag Addition/Deletion Set Register (Port 0/1 to 1/0); thus
there's no need to make a difference in sh_eth_tsu_init() between those
controllers. Unfortunately, we can't just remove TSU_QTAG0/1 from the
register *enum* because that would break the ethtool register dump...

Fixes: b0ca2a21f769 ("sh_eth: Add support of SH7763 to sh_eth")
Signed-off-by: Sergei Shtylyov 

---
 drivers/net/ethernet/renesas/sh_eth.c |   15 ---
 drivers/net/ethernet/renesas/sh_eth.h |4 ++--
 2 files changed, 6 insertions(+), 13 deletions(-)

Index: net-next/drivers/net/ethernet/renesas/sh_eth.c
===
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net-next/drivers/net/ethernet/renesas/sh_eth.c
@@ -123,8 +123,8 @@ static const u16 sh_eth_offset_gigabit[S
[TSU_FWSL0] = 0x0030,
[TSU_FWSL1] = 0x0034,
[TSU_FWSLC] = 0x0038,
-   [TSU_QTAG0] = 0x0040,
-   [TSU_QTAG1] = 0x0044,
+   [TSU_QTAGM0]= 0x0040,
+   [TSU_QTAGM1]= 0x0044,
[TSU_FWSR]  = 0x0050,
[TSU_FWINMK]= 0x0054,
[TSU_ADQT0] = 0x0048,
@@ -2097,8 +2097,6 @@ static size_t __sh_eth_get_regs(struct n
add_tsu_reg(TSU_FWSL0);
add_tsu_reg(TSU_FWSL1);
add_tsu_reg(TSU_FWSLC);
-   add_tsu_reg(TSU_QTAG0);
-   add_tsu_reg(TSU_QTAG1);
add_tsu_reg(TSU_QTAGM0);
add_tsu_reg(TSU_QTAGM1);
add_tsu_reg(TSU_FWSR);
@@ -2934,13 +2932,8 @@ static void sh_eth_tsu_init(struct sh_et
sh_eth_tsu_write(mdp, 0, TSU_FWSL0);
sh_eth_tsu_write(mdp, 0, TSU_FWSL1);
sh_eth_tsu_write(mdp, TSU_FWSLC_POSTENU | TSU_FWSLC_POSTENL, TSU_FWSLC);
-   if (sh_eth_is_gether(mdp)) {
-   sh_eth_tsu_write(mdp, 0, TSU_QTAG0);/* Disable QTAG(0->1) */
-   sh_eth_tsu_write(mdp, 0, TSU_QTAG1);/* Disable QTAG(1->0) */
-   } else {
-   sh_eth_tsu_write(mdp, 0, TSU_QTAGM0);   /* Disable QTAG(0->1) */
-   sh_eth_tsu_write(mdp, 0, TSU_QTAGM1);   /* Disable QTAG(1->0) */
-   }
+   sh_eth_tsu_write(mdp, 0, TSU_QTAGM0);   /* Disable QTAG(0->1) */
+   sh_eth_tsu_write(mdp, 0, TSU_QTAGM1);   /* Disable QTAG(1->0) */
sh_eth_tsu_write(mdp, 0, TSU_FWSR); /* all interrupt status clear */
sh_eth_tsu_write(mdp, 0, TSU_FWINMK);   /* Disable all interrupt */
sh_eth_tsu_write(mdp, 0, TSU_TEN);  /* Disable all CAM entry */
Index: net-next/drivers/net/ethernet/renesas/sh_eth.h
===
--- net-next.orig/drivers/net/ethernet/renesas/sh_eth.h
+++ net-next/drivers/net/ethernet/renesas/sh_eth.h
@@ -118,8 +118,8 @@ enum {
TSU_FWSL0,
TSU_FWSL1,
TSU_FWSLC,
-   TSU_QTAG0,
-   TSU_QTAG1,
+   TSU_QTAG0,  /* Same as TSU_QTAGM0 */
+   TSU_QTAG1,  /* Same as TSU_QTAGM1 */
TSU_QTAGM0,
TSU_QTAGM1,
TSU_FWSR,


[PATCH V8 2/4] sctp: Add ip option support

2018-02-24 Thread Richard Haines
Add ip option support to allow LSM security modules to utilise CIPSO/IPv4
and CALIPSO/IPv6 services.

Signed-off-by: Richard Haines 
---
All SCTP lksctp-tools/src/func_tests run correctly in enforcing mode.
All "./sctp-tests run" obtained from: https://github.com/sctp/sctp-tests
pass.

V7 Changes:
1) Log when copy ip options fail for IPv4 and IPv6
2) Correct sctp_setsockopt_maxseg() function. Note that the lksctp-tools
func_tests do not test with struct sctp_assoc_value. Just used simple test
and okay.
3) Move calculation of overheads to sctp_packet_config().
NOTE: Initially in sctp_packet_reset() I set packet->size and
packet->overhead to zero (as it is a reset). This was okay for all the
lksctp-tools function tests, however when running "sctp-tests" ndatshched
tests it causes these to fail with an st_s.log entry of:
sid: 3, expected: 3
sid: 3, expected: 3
unexpected sid packet !!!
sid: 1, expected: 3

I then found sctp_packet_transmit() relies on setting
"packet->size = packet->overhead;" to reset size to the current overhead
after sending packets, hence the comment in sctp_packet_reset()

V8 Change:
Fix sparse warning:
net/sctp/protocol.c:269:28: sparse: dereference of noderef expression
highlighted in [1] for sctp_v4_ip_options_len() function.

[1] https://lists.01.org/pipermail/kbuild-all/2018-February/043695.html

 include/net/sctp/sctp.h|  4 +++-
 include/net/sctp/structs.h |  2 ++
 net/sctp/chunk.c   | 10 +++---
 net/sctp/ipv6.c| 45 ++---
 net/sctp/output.c  | 34 +-
 net/sctp/protocol.c| 43 +++
 net/sctp/socket.c  | 11 ---
 7 files changed, 122 insertions(+), 27 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index f7ae6b0..25c5c87 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -441,9 +441,11 @@ static inline int sctp_list_single_entry(struct list_head 
*head)
 static inline int sctp_frag_point(const struct sctp_association *asoc, int 
pmtu)
 {
struct sctp_sock *sp = sctp_sk(asoc->base.sk);
+   struct sctp_af *af = sp->pf->af;
int frag = pmtu;
 
-   frag -= sp->pf->af->net_header_len;
+   frag -= af->ip_options_len(asoc->base.sk);
+   frag -= af->net_header_len;
frag -= sizeof(struct sctphdr) + sctp_datachk_len(>stream);
 
if (asoc->user_frag)
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 03e92dd..ead5fce 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -491,6 +491,7 @@ struct sctp_af {
void(*ecn_capable)(struct sock *sk);
__u16   net_header_len;
int sockaddr_len;
+   int (*ip_options_len)(struct sock *sk);
sa_family_t sa_family;
struct list_head list;
 };
@@ -515,6 +516,7 @@ struct sctp_pf {
int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr);
void (*to_sk_saddr)(union sctp_addr *, struct sock *sk);
void (*to_sk_daddr)(union sctp_addr *, struct sock *sk);
+   void (*copy_ip_options)(struct sock *sk, struct sock *newsk);
struct sctp_af *af;
 };
 
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 991a530..d726d21 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -171,6 +171,8 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct 
sctp_association *asoc,
struct list_head *pos, *temp;
struct sctp_chunk *chunk;
struct sctp_datamsg *msg;
+   struct sctp_sock *sp;
+   struct sctp_af *af;
int err;
 
msg = sctp_datamsg_new(GFP_KERNEL);
@@ -189,9 +191,11 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct 
sctp_association *asoc,
/* This is the biggest possible DATA chunk that can fit into
 * the packet
 */
-   max_data = asoc->pathmtu -
-  sctp_sk(asoc->base.sk)->pf->af->net_header_len -
-  sizeof(struct sctphdr) - sctp_datachk_len(>stream);
+   sp = sctp_sk(asoc->base.sk);
+   af = sp->pf->af;
+   max_data = asoc->pathmtu - af->net_header_len -
+  sizeof(struct sctphdr) - sctp_datachk_len(>stream) -
+  af->ip_options_len(asoc->base.sk);
max_data = SCTP_TRUNC4(max_data);
 
/* If the the peer requested that we authenticate DATA chunks
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index e35d4f7..30a05a8 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -427,6 +427,41 @@ static void sctp_v6_copy_addrlist(struct list_head 
*addrlist,
rcu_read_unlock();
 }
 
+/* Copy over any ip options */
+static void sctp_v6_copy_ip_options(struct sock *sk, struct sock *newsk)
+{
+   struct ipv6_pinfo *newnp, *np = inet6_sk(sk);
+   struct ipv6_txoptions *opt;
+
+   newnp = inet6_sk(newsk);
+
+  

[PATCH net-next v2] r8169: improve interrupt handling

2018-02-24 Thread Heiner Kallweit
This patch improves few aspects of interrupt handling:
- update to current interrupt allocation API
  (use pci_alloc_irq_vectors() instead of deprecated pci_enable_msi())
- this implicitly will allocate a MSI-X interrupt if available
- get rid of flag RTL_FEATURE_MSI
- remove some dead code, intentionally disabling (unreliable) MSI
  being partially available on old PCI chips.

The patch works fine on a RTL8168evl (chip version 34) and on a
RTL8169SB (chip version 04).

Signed-off-by: Heiner Kallweit 
---
v2:
- disable MSI on old PCI chips even if they partially support it
- improve error handling
---
 drivers/net/ethernet/realtek/r8169.c | 48 
 1 file changed, 21 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c 
b/drivers/net/ethernet/realtek/r8169.c
index 96db3283e..cc51286ee 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -736,8 +736,7 @@ struct ring_info {
 };
 
 enum features {
-   RTL_FEATURE_MSI = (1 << 0),
-   RTL_FEATURE_GMII= (1 << 1),
+   RTL_FEATURE_GMII= (1 << 0),
 };
 
 struct rtl8169_counters {
@@ -7847,7 +7846,7 @@ static int rtl8169_close(struct net_device *dev)
 
cancel_work_sync(>wk.work);
 
-   free_irq(pdev->irq, dev);
+   pci_free_irq(pdev, 0, dev);
 
dma_free_coherent(>dev, R8169_RX_RING_BYTES, tp->RxDescArray,
  tp->RxPhyAddr);
@@ -7903,9 +7902,8 @@ static int rtl_open(struct net_device *dev)
 
rtl_request_firmware(tp);
 
-   retval = request_irq(pdev->irq, rtl8169_interrupt,
-(tp->features & RTL_FEATURE_MSI) ? 0 : IRQF_SHARED,
-dev->name, dev);
+   retval = pci_request_irq(pdev, 0, rtl8169_interrupt, NULL, dev,
+dev->name);
if (retval < 0)
goto err_release_fw_2;
 
@@ -8253,7 +8251,7 @@ static const struct rtl_cfg_info {
.region = 2,
.align  = 8,
.event_slow = SYSErr | LinkChg | RxOverflow,
-   .features   = RTL_FEATURE_GMII | RTL_FEATURE_MSI,
+   .features   = RTL_FEATURE_GMII,
.coalesce_info  = rtl_coalesce_info_8168_8136,
.default_ver= RTL_GIGA_MAC_VER_11,
},
@@ -8263,32 +8261,26 @@ static const struct rtl_cfg_info {
.align  = 8,
.event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver |
  PCSTimeout,
-   .features   = RTL_FEATURE_MSI,
.coalesce_info  = rtl_coalesce_info_8168_8136,
.default_ver= RTL_GIGA_MAC_VER_13,
}
 };
 
-/* Cfg9346_Unlock assumed. */
-static unsigned rtl_try_msi(struct rtl8169_private *tp,
-   const struct rtl_cfg_info *cfg)
+static int rtl_alloc_irq(struct rtl8169_private *tp)
 {
void __iomem *ioaddr = tp->mmio_addr;
-   unsigned msi = 0;
-   u8 cfg2;
+   unsigned int flags;
 
-   cfg2 = RTL_R8(Config2) & ~MSIEnable;
-   if (cfg->features & RTL_FEATURE_MSI) {
-   if (pci_enable_msi(tp->pci_dev)) {
-   netif_info(tp, hw, tp->dev, "no MSI. Back to INTx.\n");
-   } else {
-   cfg2 |= MSIEnable;
-   msi = RTL_FEATURE_MSI;
-   }
+   if (tp->mac_version <= RTL_GIGA_MAC_VER_06) {
+   RTL_W8(Cfg9346, Cfg9346_Unlock);
+   RTL_W8(Config2, RTL_R8(Config2) & ~MSIEnable);
+   RTL_W8(Cfg9346, Cfg9346_Lock);
+   flags = PCI_IRQ_LEGACY;
+   } else {
+   flags = PCI_IRQ_ALL_TYPES;
}
-   if (tp->mac_version <= RTL_GIGA_MAC_VER_06)
-   RTL_W8(Config2, cfg2);
-   return msi;
+
+   return pci_alloc_irq_vectors(tp->pci_dev, 1, 1, flags);
 }
 
 DECLARE_RTL_COND(rtl_link_list_ready_cond)
@@ -8497,9 +8489,11 @@ static int rtl_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
chipset = tp->mac_version;
tp->txd_version = rtl_chip_infos[chipset].txd_version;
 
-   RTL_W8(Cfg9346, Cfg9346_Unlock);
-   tp->features |= rtl_try_msi(tp, cfg);
-   RTL_W8(Cfg9346, Cfg9346_Lock);
+   rc = rtl_alloc_irq(tp);
+   if (rc < 0) {
+   netif_err(tp, probe, dev, "Can't allocate interrupt\n");
+   return rc;
+   }
 
/* override BIOS settings, use userspace tools to enable WOL */
__rtl8169_set_wol(tp, 0);
-- 
2.16.2



Re: [PATCH net-next] r8169: improve interrupt handling

2018-02-24 Thread Heiner Kallweit
Am 24.02.2018 um 02:35 schrieb Francois Romieu:
> Heiner Kallweit  :
> [...]
>> Last but not least it enables a feature which was (I presume accidently)
>> disabled before. There are members of the RTL8169 family supporting MSI
>> (e.g. RTL8169SB), however MSI never got enabled because RTL_CFG_0 was
>> missing flag RTL_FEATURE_MSI.
>> An indicator for "accidently" is that statement "cfg2 |= MSIEnable;"
> 
> The reality is more simple: it could had been removed.
> 
>> in rtl_try_msi() is dead code. cfg2 is used for chip versions <= 06
>> only and for all these chip versions RTL_FEATURE_MSI isn't set.
> 
> On purpose:
> 1. mostly untested
> 2. MSI without MSI-X does not buy much
> 3. wrt 2., ok, it kills (yucky) plain old shared PCI irq (remember those ?)
>but I didn't end feeling that good about realtek MSI support on older
>chipsets to enable it any further
> 
Good to know, thanks for the feedback.
Then I'll change the patch to leave MSI disabled on old PCI chips.
Plus addressing your last comment.


> [...]
>> diff --git a/drivers/net/ethernet/realtek/r8169.c 
>> b/drivers/net/ethernet/realtek/r8169.c
>> index 96db3283e..4730db990 100644
>> --- a/drivers/net/ethernet/realtek/r8169.c
>> +++ b/drivers/net/ethernet/realtek/r8169.c
> [...]
>> -static unsigned rtl_try_msi(struct rtl8169_private *tp,
>> -const struct rtl_cfg_info *cfg)
>> +static void rtl_alloc_irq(struct rtl8169_private *tp)
>>  {
> [...]
>> +ret = pci_alloc_irq_vectors(tp->pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
>> +if (ret < 0) {
>> +netif_err(tp, drv, tp->dev, "failed to allocate irq!\n");
>> +return;
> [...]
>> @@ -8497,9 +8495,7 @@ static int rtl_init_one(struct pci_dev *pdev, const 
>> struct pci_device_id *ent)
>>  chipset = tp->mac_version;
>>  tp->txd_version = rtl_chip_infos[chipset].txd_version;
>>  
>> -RTL_W8(Cfg9346, Cfg9346_Unlock);
>> -tp->features |= rtl_try_msi(tp, cfg);
>> -RTL_W8(Cfg9346, Cfg9346_Lock);
>> +rtl_alloc_irq(tp);
> 
> Happily proceeding after error. :o/
> 



Re: tcp_bind_bucket is missing from slabinfo

2018-02-24 Thread Matthew Wilcox
On Fri, Feb 23, 2018 at 10:50:30PM -0800, Stephen Hemminger wrote:
> Somewhere back around 3.17 the kmem cache "tcp_bind_bucket" dropped out
> of /proc/slabinfo. It turns out the ss command was dumpster diving
> in slabinfo to determine the number of bound sockets and now it always
> reports 0.
> 
> Not sure why, the cache is still created but it doesn't
> show in slabinfo. Could it be some part of making slab/slub common code
> (or network namespaces). The cache is created in tcp_init but not visible.
> 
> Any ideas?

Try booting with slab_nomerge=1


[no subject]

2018-02-24 Thread Roxana Guerrero Nunez
Herzlichen Glückwunsch, Sie haben € 650.000,00 bei den monatlichen 
Gewinnspielen von Euro Millions / Google Promo am  Februar 2018 gewonnen. 
Kontaktieren Sie unseren Schadenversicherer E-Mail: eurosilli...@gmail.com

 1. Vollständiger Name:
 2. Adresse:
 3. Sex:
 4. Alter:
 5. Beruf:
 6. Telefon:


RE: [Crypto v7 03/12] tls: support for inline tls

2018-02-24 Thread Atul Gupta


-Original Message-
From: Dave Watson [mailto:davejwat...@fb.com] 
Sent: Friday, February 23, 2018 11:03 PM
To: Atul Gupta 
Cc: da...@davemloft.net; herb...@gondor.apana.org.au; s...@queasysnail.net; 
linux-cry...@vger.kernel.org; netdev@vger.kernel.org; Ganesh GR 

Subject: Re: [Crypto v7 03/12] tls: support for inline tls

On 02/23/18 04:58 PM, Atul Gupta wrote:
> > On 02/22/18 11:21 PM, Atul Gupta wrote:
> > > @@ -403,6 +431,15 @@ static int do_tls_setsockopt_tx(struct sock *sk, 
> > > char __user *optval,
> > >   goto err_crypto_info;
> > >   }
> > >  
> > > + rc = tls_offload_dev_absent(sk);
> > > + if (rc == -EINVAL) {
> > > + goto out;
> > > + } else if (rc == -EEXIST) {
> > > + /* Retain HW unhash for cleanup and move to SW Tx */
> > > + sk->sk_prot[TLS_BASE_TX].unhash =
> > > + sk->sk_prot[TLS_FULL_HW].unhash;
> > 
> > I'm still confused by this, it lookes like it is modifying the global 
> > tls_prots without taking a lock?  And modifying it for all sockets, not 
> > just this one?  One way to fix might be to always set an unhash in 
> > TLS_BASE_TX, and then have a function pointer unhash in ctx.
> 
> code enters do_tls_setsockopt_tx only for those offload capable dev which 
> does not define FULL_HW setsockopt as done by chtls, unhash prot update is 
> required for cleanup/revert of setup done in tls_hw_hash. This update does 
> not impact SW or other Inline HW path. 

I still don't follow.  If it doesn't impact SW, then what is it doing?
According to the comment, we're moving to SW tx, where sk_prot will be 
_prot[TLS_SW_TX], and the unhash function you set here in TLS_BASE_TX won't 
be called.

some of the scenarios I originally thought:
- tls_init finds the Inline offload dev and sets the TLS_FULL_HW but setsockopt 
remains do_tls_setsockopt_tx, In the above path we continue in TLS_SW_TX mode 
with updated unhash. Since, sw_tx prot is borrowed from base_tx we modified the 
base_tx prot unhash for cleanup.
- tls_offload_dev_absent finds no device i.e rc=0. Continue in TLS_SW_TX mode. 
No change required.
- Inline tls device is added after tls_init is called, do_tls_setsockopt_tx 
will see tls_offload_dev_absent return EEXIST and will modify unhash but only 
if tx_conf = TLS_FULL_HW [missing now] and you rightly pointed that it ends up 
modifying base prot for all sk which is not we want. My worry was losing hw 
specific unhash.
I see calling tls_offload_dev_absent in do_tls_setsockopt_tx an overkill, the 
sk here perhaps require no update to continue in SW_TX, the HW unhash is still 
assigned to tls_init 'sk' for cleanup in the close path, better to remove 
tls_offload_dev_absent altogether and simplify.



NETDEV WATCHDOG: eth0 (tg3): transmit queue 0 timed out

2018-02-24 Thread Borislav Petkov
Hi,

this didn't happen before but after 4.16-rc1 my tg3 nic stops for
whatever reason and the connection to the machine is dead. It didn't show
anything in dmesg until today.

The IO pagefaults look like it is trying to access something it
shouldn't and maybe that's why it times out.

It triggers pretty quickly so I'd call it a reliable reproducer and thus
I can test patches... :-)

Thx.

...
[   15.916840] random: crng init done
[   44.792699] tg3 :01:00.0 eth0: Link is up at 100 Mbps, full duplex
[   44.793024] tg3 :01:00.0 eth0: Flow control is on for TX and on for RX
[   44.793315] tg3 :01:00.0 eth0: EEE is disabled
[   44.793395] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   58.216474] tg3 :01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT 
domain=0x0001 address=0x0001f0c0 flags=0x]
[   58.216943] tg3 :01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT 
domain=0x0001 address=0x0001f100 flags=0x]
[   58.217395] tg3 :01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT 
domain=0x0001 address=0x0001f140 flags=0x]
[   58.217844] tg3 :01:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT 
domain=0x0001 address=0x0001f180 flags=0x]
[   64.992145] [ cut here ]
[   64.992406] NETDEV WATCHDOG: eth0 (tg3): transmit queue 0 timed out
[   64.992742] WARNING: CPU: 1 PID: 0 at net/sched/sch_generic.c:464 
dev_watchdog+0x1fe/0x210
[   64.992744] Modules linked in: arc4 iwlmvm mac80211 amdgpu kvm_amd kvm 
iwlwifi irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel 
snd_hda_codec_conexant snd_hda_codec_hdmi snd_hda_codec_generic aesni_intel 
sha256_generic aes_x86_64 crypto_simd snd_hda_intel cryptd glue_helper tg3 
snd_hda_codec pcspkr snd_hwdep cfg80211 joydev psmouse ptp snd_hda_core hp_wmi 
pps_core snd_pcm ehci_pci chash tpm_infineon rfkill libphy i2c_piix4 snd_timer 
fam15h_power xhci_pci ehci_hcd snd sg gpu_sched k10temp soundcore xhci_hcd 
tpm_tis tpm_tis_core video tpm battery button ac acpi_cpufreq evdev input_leds 
serio_raw sd_mod thermal pinctrl_amd
[   64.993216] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.16.0-rc1+ #2
[   64.993222] Hardware name: HP HP EliteBook 745 G3/807E, BIOS N73 Ver. 01.08 
01/28/2016
[   64.996048] RIP: 0010:dev_watchdog+0x1fe/0x210
[   64.996050] RSP: 0018:88043dc83e88 EFLAGS: 00010282
[   64.996052] RAX:  RBX:  RCX: 0103
[   64.996054] RDX: 8103 RSI: 0086 RDI: 
[   64.996055] RBP: 88042b86e39c R08: 81c0a400 R09: 0001
[   64.996057] R10: 035a R11:  R12: 88042b86e3b0
[   64.996058] R13: 88042b86e000 R14: 0005 R15: 88042a0ced80
[   64.996061] FS:  () GS:88043dc8() 
knlGS:
[   64.996063] CS:  0010 DS:  ES:  CR0: 80050033
[   64.996065] CR2: 7f98ed87eb00 CR3: 000428ea CR4: 001406e0
[   64.996068] Call Trace:
[   64.996074]  
[   64.996082]  ? qdisc_reset+0xe0/0xe0
[   64.996085]  ? qdisc_reset+0xe0/0xe0
[   64.996092]  call_timer_fn+0x2b/0x150
[   64.996097]  run_timer_softirq+0x415/0x460
[   64.996101]  ? tick_sched_timer+0x42/0x90
[   64.996106]  ? _raw_spin_lock_irq+0x1a/0x40
[   64.996110]  ? __hrtimer_run_queues+0x113/0x2d0
[   64.996114]  __do_softirq+0xeb/0x2d5
[   64.996121]  irq_exit+0xaa/0xb0
[   64.996125]  smp_apic_timer_interrupt+0x73/0x150
[   64.996128]  apic_timer_interrupt+0x7d/0x90
[   64.996131]  
[   64.996136] RIP: 0010:cpuidle_enter_state+0xa3/0x2f0
[   64.996138] RSP: 0018:c900019c3ea8 EFLAGS: 0246 ORIG_RAX: 
ff12
[   64.996141] RAX: 88043dc8 RBX: 000f21d4b954 RCX: 001f
[   64.996142] RDX: 000f21d4b954 RSI: 81da4ca1 RDI: 81db2a9e
[   64.996144] RBP: 88042a39a200 R08: 0005a0b5 R09: 000585fa
[   64.996145] R10: 0018 R11: 00049370 R12: 0002
[   64.996146] R13: 82095db8 R14:  R15: 000f0b23994e
[   64.996157]  ? cpuidle_enter_state+0x93/0x2f0
[   65.003171]  do_idle+0x19a/0x1f0
[   65.003176]  cpu_startup_entry+0x6f/0x80
[   65.003181]  start_secondary+0x1a5/0x200
[   65.003185]  secondary_startup_64+0xa5/0xb0
[   65.003189] Code: 00 49 63 4c 24 f0 eb 93 4c 89 ef c6 05 5b 10 af 00 01 e8 
b6 67 fd ff 89 d9 48 89 c2 4c 89 ee 48 c7 c7 20 f6 df 81 e8 e2 8d a7 ff <0f> ff 
eb be 0f 1f 40 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 
[   65.003234] ---[ end trace b191673f18a75f41 ]---
[   65.003243] tg3 :01:00.0 eth0: transmit timed out, resetting
[   67.679695] tg3 :01:00.0 eth0: 0x: 0x168714e4, 0x10100406, 
0x0210, 0x
[   67.680053] tg3 :01:00.0 eth0: 0x0010: 0xd082000c, 0x, 
0xd081000c, 0x
[   67.680406] tg3 :01:00.0 eth0: 0x0020: 0xd08c, 0x, 
0x, 0x807e103c
[   67.680419] tg3 :01:00.0 eth0: 0x0030: 0x, 

Re: [for-next 7/7] IB/mlx5: Implement fragmented completion queue (CQ)

2018-02-24 Thread Majd Dibbiny

> On Feb 23, 2018, at 9:13 PM, Saeed Mahameed  wrote:
> 
>> On Thu, 2018-02-22 at 16:04 -0800, Santosh Shilimkar wrote:
>> Hi Saeed
>> 
>>> On 2/21/2018 12:13 PM, Saeed Mahameed wrote:
>>> From: Yonatan Cohen 
>>> 
>>> The current implementation of create CQ requires contiguous
>>> memory, such requirement is problematic once the memory is
>>> fragmented or the system is low in memory, it causes for
>>> failures in dma_zalloc_coherent().
>>> 
>>> This patch implements new scheme of fragmented CQ to overcome
>>> this issue by introducing new type: 'struct mlx5_frag_buf_ctrl'
>>> to allocate fragmented buffers, rather than contiguous ones.
>>> 
>>> Base the Completion Queues (CQs) on this new fragmented buffer.
>>> 
>>> It fixes following crashes:
>>> kworker/29:0: page allocation failure: order:6, mode:0x80d0
>>> CPU: 29 PID: 8374 Comm: kworker/29:0 Tainted: G OE 3.10.0
>>> Workqueue: ib_cm cm_work_handler [ib_cm]
>>> Call Trace:
>>> [<>] dump_stack+0x19/0x1b
>>> [<>] warn_alloc_failed+0x110/0x180
>>> [<>] __alloc_pages_slowpath+0x6b7/0x725
>>> [<>] __alloc_pages_nodemask+0x405/0x420
>>> [<>] dma_generic_alloc_coherent+0x8f/0x140
>>> [<>] x86_swiotlb_alloc_coherent+0x21/0x50
>>> [<>] mlx5_dma_zalloc_coherent_node+0xad/0x110 [mlx5_core]
>>> [<>] ? mlx5_db_alloc_node+0x69/0x1b0 [mlx5_core]
>>> [<>] mlx5_buf_alloc_node+0x3e/0xa0 [mlx5_core]
>>> [<>] mlx5_buf_alloc+0x14/0x20 [mlx5_core]
>>> [<>] create_cq_kernel+0x90/0x1f0 [mlx5_ib]
>>> [<>] mlx5_ib_create_cq+0x3b0/0x4e0 [mlx5_ib]
>>> 
>>> Signed-off-by: Yonatan Cohen 
>>> Reviewed-by: Tariq Toukan 
>>> Signed-off-by: Leon Romanovsky 
>>> Signed-off-by: Saeed Mahameed 
>>> ---
>> 
>> Jason mentioned about this patch to me off-list. We were
>> seeing similar issue with SRQs & QPs. So wondering whether
>> you have any plans to do similar change for other resouces
>> too so that they don't rely on higher order page allocation
>> for icm tables.
>> 
> 
> Hi Santosh,
> 
> Adding Majd,
> 
> Which ULP is in question ? how big are the QPs/SRQs you create that
> lead to this problem ?
> 
> For icm tables we already allocate only order 0 pages:
> see alloc_system_page() in
> drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
> 
> But for kernel RDMA SRQ and QP buffers there is a place for
> improvement.
> 
> Majd, do you know if we have any near future plans for this.

It’s in our plans to move all the buffers to use 0-order pages.

Santosh,

Is this RDS? Do you have persistent failure with some configuration? Can you 
please share more information?

Thanks
> 
>> Regards,
>> Santosh