Re: [PATCH] Documentation: networking: fix ASCII art in switchdev.txt

2017-09-16 Thread Andrew Lunn
On Sat, Sep 16, 2017 at 01:10:06PM -0700, Randy Dunlap wrote:
> From: Randy Dunlap 
> 
> Fix ASCII art in Documentation/networking/switchdev.txt:
> 
> Change non-ASCII "spaces" to ASCII spaces.
> 
> Change 2 erroneous '+' characters in ASCII art to '-' (at the '*'
> characters below):
> 
> line 32:
>  +--++++-*--++---+  +-+-+
> line 41:
>  +--+---*+
> 
> Signed-off-by: Randy Dunlap 

A much more readable patch. Thanks

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH] Documentation: networking: fix ASCII art in switchdev.txt

2017-09-16 Thread Pavel Machek
On Sat 2017-09-16 13:10:06, Randy Dunlap wrote:
> From: Randy Dunlap 
> 
> Fix ASCII art in Documentation/networking/switchdev.txt:
> 
> Change non-ASCII "spaces" to ASCII spaces.
> 
> Change 2 erroneous '+' characters in ASCII art to '-' (at the '*'
> characters below):
> 
> line 32:
>  +--++++-*--++---+  +-+-+
> line 41:
>  +--+---*+
> 
> Signed-off-by: Randy Dunlap 

Acked-by: Pavel Machek 


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH] Documentation: networking: fix ASCII art in switchdev.txt

2017-09-16 Thread Randy Dunlap
From: Randy Dunlap 

Fix ASCII art in Documentation/networking/switchdev.txt:

Change non-ASCII "spaces" to ASCII spaces.

Change 2 erroneous '+' characters in ASCII art to '-' (at the '*'
characters below):

line 32:
 +--++++-*--++---+  +-+-+
line 41:
 +--+---*+

Signed-off-by: Randy Dunlap 
---
 Documentation/networking/switchdev.txt |   64 +++
 1 file changed, 32 insertions(+), 32 deletions(-)

--- lnx-413.orig/Documentation/networking/switchdev.txt
+++ lnx-413/Documentation/networking/switchdev.txt
@@ -13,42 +13,42 @@ an example setup using a data-center-cla
 with SR-IOV or soft switches, such as OVS, are possible.
 
 
- User-space tools
+ User-space tools
 
-   user space   |
-  +---+
-   kernel   | Netlink
-|
- +--+---+
- | Network stack|
- |   (Linux)|
- |  |
- +--+
+   user space   |
+  +---+
+   kernel   | Netlink
+|
+ +--+---+
+ | Network stack|
+ |   (Linux)|
+ |  |
+ +--+
 
sw1p2 sw1p4 sw1p6
-  sw1p1  +  sw1p3  +  sw1p5  +  eth1
-+|+|+|+
-|||||||
- +--++++-+--++---+  +-+-+
- | Switch driver |  |mgmt   |
- |(this document)|  |   driver  |
- |   |  |   |
- +--++  +---+
-|
-   kernel   | HW bus (eg PCI)
-  +---+
-   hardware |
- +--+---++
- | Switch device (sw1)   |
- |  ++   ++
- |  |v offloaded data path   | mgmt port
- |  ||   |
- +--||++++---+
-||||||
-++++++
-   p1   p2   p3   p4   p5   p6
+  sw1p1  +  sw1p3  +  sw1p5  +  eth1
++|+|+|+
+|||||||
+ +--++++++---+  +-+-+
+ | Switch driver |  |mgmt   |
+ |(this document)|  |   driver  |
+ |   |  |   |
+ +--++  +---+
+|
+   kernel   | HW bus (eg PCI)
+  +---+
+   hardware |
+ +--++
+ | Switch device (sw1)   |
+ |  ++   ++
+ |  |v offloaded data path   | mgmt port
+ |  ||   |
+ +--||++++---+
+||||||
+++++++
+   p1   p2   p3   p4   p5   p6
 
- front-panel ports
+ front-panel ports
 
 
 Fig 1.




Re: [PATCH] Documentation: fix ascii art in networking docs

2017-09-16 Thread Randy Dunlap
On 09/16/17 11:18, Andreas Schwab wrote:
> On Sep 16 2017, Pavel Machek  wrote:
> 
>> diff --git a/Documentation/networking/switchdev.txt 
>> b/Documentation/networking/switchdev.txt
>> index 5e40e1f..6309e90 100644
>> --- a/Documentation/networking/switchdev.txt
>> +++ b/Documentation/networking/switchdev.txt
>> @@ -29,7 +29,7 @@ with SR-IOV or soft switches, such as OVS, are possible.
>>    sw1p1  +  sw1p3  +  sw1p5  +  eth1
>>  +|+|+|+
>>  |||||||
>> - +--++++-+--++---+  +-+-+
>> + +--++++++---+  +-+-+
>>   | Switch driver |  |mgmt   |
>>   |(this document)|  |   driver  |
>>   |   |  |   |
>>
> 
> This is all mis-aligned.  How about replacing all the thin space
> characters by normal spaces?

Yes, there are lots of non-ASCII "spaces" in the ASCII art.  :(

-- 
~Randy


Re: [PATCH] Documentation: fix ascii art in networking docs

2017-09-16 Thread Pavel Machek
On Sat 2017-09-16 20:18:15, Andreas Schwab wrote:
> On Sep 16 2017, Pavel Machek  wrote:
> 
> > diff --git a/Documentation/networking/switchdev.txt 
> > b/Documentation/networking/switchdev.txt
> > index 5e40e1f..6309e90 100644
> > --- a/Documentation/networking/switchdev.txt
> > +++ b/Documentation/networking/switchdev.txt
> > @@ -29,7 +29,7 @@ with SR-IOV or soft switches, such as OVS, are possible.
> >    sw1p1  +  sw1p3  +  sw1p5  +  eth1
> >  +|+|+|+
> >  |||||||
> > - +--++++-+--++---+  +-+-+
> > + +--++++++---+  +-+-+
> >   | Switch driver |  |mgmt   |
> >   |(this document)|  |   driver  |
> >   |   |  |   |
> >
> 
> This is all mis-aligned.  How about replacing all the thin space
> characters by normal spaces?

It looked perfectly ok to me, in emacs. If you see a problem, please
submit followup patch.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: Use after free in __dst_destroy_metrics_generic

2017-09-16 Thread Cong Wang
On Sat, Sep 16, 2017 at 5:40 AM, Julian Anastasov  wrote:
>
> Hello,
>
> On Fri, 15 Sep 2017, Subash Abhinov Kasiviswanathan wrote:
>
>> > May be I'm missing some posting but I don't see if
>> > the patch was tested successfully.
>> >
>> Hi Julian
>>
>> I've had this patch being tested for the last 3-4 days in our regression rack
>> and I haven't seen the same issue being reproduced or even a related crash
>> or leak in dst.
>
> For now I see only its bug-hiding side effects, i.e.
> it does not call kfree. Now if there is no double-free
> there should be a leak, not for dst but for metrics.


You make very good points. I need to take a deeper look.


>
>> The original issue was reported only once to us from the regression rack only
>> so the exact steps to reproduce is unknown.
>
> OK, lets see, may be others can explain what happens.
>

This makes me thinking if it is possible that we no longer have
the guarantee of metrics address aligned to at least 4?
This seems unlikely since kmalloc() should return at least
word-size-aligned address.


Re: [PATCH] Documentation: fix ascii art in networking docs

2017-09-16 Thread Andreas Schwab
On Sep 16 2017, Pavel Machek  wrote:

> diff --git a/Documentation/networking/switchdev.txt 
> b/Documentation/networking/switchdev.txt
> index 5e40e1f..6309e90 100644
> --- a/Documentation/networking/switchdev.txt
> +++ b/Documentation/networking/switchdev.txt
> @@ -29,7 +29,7 @@ with SR-IOV or soft switches, such as OVS, are possible.
>    sw1p1  +  sw1p3  +  sw1p5  +  eth1
>  +|+|+|+
>  |||||||
> - +--++++-+--++---+  +-+-+
> + +--++++++---+  +-+-+
>   | Switch driver |  |mgmt   |
>   |(this document)|  |   driver  |
>   |   |  |   |
>

This is all mis-aligned.  How about replacing all the thin space
characters by normal spaces?

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: Use after free in __dst_destroy_metrics_generic

2017-09-16 Thread Cong Wang
On Fri, Sep 15, 2017 at 2:00 PM, Eric Dumazet  wrote:
>
> Hi Cong
>
> I believe your patch makes a lot of sense, please submit it formally ?
>

I have been waiting for Subash's testing, since I myself never even run it.


Re: RTL8192EE PCIe Wireless Network Adapter crashed with linux-4.13

2017-09-16 Thread Larry Finger

On 09/16/2017 06:27 AM, Zwindl wrote:
Hi, I've done the test, and the weird thing happened. The kernel buit with this 
config file https://ptpb.pw/HF1g which is from 
https://aur.archlinux.org/packages/linux-git/  can run properly, the wifi can 
connect, despite which version it is, but, with this config file 
https://ptpb.pw/7GuV which comes from the archlinux's official package build 
repo(linux-package 
), 
all the version begin with 4.13 was failed to connect wifi.
So, I think the issue is not caused by the kernel code, is caused by some 
options in the config file, but I can't fully understand the meaning of these 
options so that I can't determine which option caused that issue, what should I 
do now, maybe report this bug to archlinux's maintainer?
By the way, maybe I'll lost internet connection tomorrow, it's time to back to 
university, but I'm happy to help to push the debug progress.


Yes, you need to report this to archlinux's bugzilla or maintainer, whichever is 
appropriate. I have seen a configuration error cause some feature to be silently 
missing, but leading to a WARN is rare.


I looked at your two configurations, but did not see a definitive difference.

Larry



Re: [PATCH] Documentation: fix ascii art in networking docs

2017-09-16 Thread Andrew Lunn
On Sat, Sep 16, 2017 at 06:22:17PM +0200, Pavel Machek wrote:
> 
> Fix ascii-art.
> 
> Signed-off-by: Pavel Machek 
> 
> ---
> 
> Resent, because I did not get DaveM's address right.
> 
> diff --git a/Documentation/networking/switchdev.txt 
> b/Documentation/networking/switchdev.txt
> index 5e40e1f..6309e90 100644
> --- a/Documentation/networking/switchdev.txt
> +++ b/Documentation/networking/switchdev.txt
> @@ -29,7 +29,7 @@ with SR-IOV or soft switches, such as OVS, are possible.
>  ??sw1p1??? + 
>  sw1p3  + ???sw1p5  +  eth1
>  
> +|+|+|+
>  
> |||||||
> -???+--++++-+--++---+??+-+-+
> +???+--++++++---+??+-+-+
>  
> ???|???Switch???driver???|??|mgmt?|
>  
> ???|(this???document)|??|?driver??|
>  
> ???|?|??|?|

Hi Pavel

This is not very readable. Has the patch been mangled by your email?

   Andrew



[GIT] Networking

2017-09-16 Thread David Miller

1) Fix hotplug deadlock in hv_netvsc, from Stephen Hemminger.

2) Fix double-free in rmnet driver, from Dan Carpenter.

3) INET connection socket layer can double put request sockets,
   fix from Eric Dumazet.

4) Don't match collect metadata-mode tunnels if the device is down,
   from Haishuang Yan.

5) Do not perform TSO6/GSO on ipv6 packets with extensions headers in
   be2net driver, from Suresh Reddy.

6) Fix scaling error in gen_estimator, from Eric Dumazet.

7) Fix 64-bit statistics deadlock in systemport driver, from Florian
   Fainelli.

8) Fix use-after-free in sctp_sock_dump, from Xin Long.

9) Reject invalid BPF_END instructions in verifier, from Edward Cree.

Please pull, thanks a lot!

The following changes since commit ad9a19d003703ae06a6e8efc64cf26a939d9e84d:

  Merge tag 'nfsd-4.14' of git://linux-nfs.org/~bfields/linux (2017-09-09 
13:31:49 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to 8e29f97979c300406c21994986bdfcdb67fe4ff7:

  mlxsw: spectrum_router: Only handle IPv4 and IPv6 events (2017-09-16 09:21:43 
-0700)


Arkadi Sharshevsky (1):
  mlxsw: spectrum: Fix EEPROM access in case of SFP/SFP+

Arnd Bergmann (2):
  w90p910_ether: include linux/interrupt.h
  net: vrf: avoid gcc-4.6 warning

Christophe JAILLET (1):
  openvswitch: Fix an error handling path in 
'ovs_nla_init_match_and_action()'

Colin Ian King (1):
  tg3: clean up redundant initialization of tnapi

Cong Wang (3):
  net_sched: get rid of tcfa_rcu
  net_sched: fix reference counting of tc filter chain
  net_sched: carefully handle tcf_block_put()

Dan Carpenter (2):
  net: qualcomm: rmnet: Fix a double free
  sctp: potential read out of bounds in sctp_ulpevent_type_enabled()

David Ahern (1):
  net: ipv4: fix l3slave check for index returned in IP_PKTINFO

David Lebrun (1):
  ipv6: sr: remove duplicate routing header type check

David S. Miller (2):
  Merge branch 'net_sched-fix-filter-chain-reference-counting'
  Merge branch 'nfp-card-init'

Edward Cree (1):
  bpf/verifier: reject BPF_ALU64|BPF_END

Eric Dumazet (4):
  tcp/dccp: remove reqsk_put() from inet_child_forget()
  net_sched: gen_estimator: fix scaling error in bytes/packets samples
  tcp: update skb->skb_mstamp more carefully
  tcp: fix data delivery rate

Florian Fainelli (1):
  net: systemport: Fix 64-bit stats deadlock

Geert Uytterhoeven (1):
  net: smsc911x: Quieten netif during suspend

Haishuang Yan (2):
  ip_tunnel: fix ip tunnel lookup in collect_md mode
  ip6_tunnel: fix ip6 tunnel lookup in collect_md mode

Himanshu Jha (1):
  qed: remove unnecessary call to memset

Ido Schimmel (1):
  mlxsw: spectrum_router: Only handle IPv4 and IPv6 events

Jakub Kicinski (2):
  nfp: wait for board state before talking to the NSP
  nfp: wait for the NSP resource to appear on boot

Jesper Dangaard Brouer (1):
  xdp: implement xdp_redirect_map for generic XDP

Jiri Pirko (1):
  net: sched: fix use-after-free in tcf_action_destroy and tcf_del_walker

Josh Hunt (1):
  net/sched: fix pointer check in gen_handle

Kosuke Tatsukawa (1):
  net: bonding: Fix transmit load balancing in balance-alb mode if 
specified by sysfs

Nikolay Aleksandrov (1):
  net: bonding: fix tlb_dynamic_lb default value

Nisar Sayed (1):
  smsc95xx: Configure pause time to 0x when tx flow control enabled

Pavel Machek (1):
  Documentation: link in networking docs

Pieter Jansen van Vuuren (1):
  nfp: add whitelist of supported flow dissector

Sergei Shtylyov (1):
  MAINTAINERS: review Renesas DT bindings as well

Stephen Hemminger (3):
  hv_netvsc: fix deadlock on hotplug
  hv_netvsc: avoid unnecessary wakeups on subchannel creation
  netvsc: increase default receive buffer size

Suresh Reddy (1):
  be2net: fix TSO6/GSO issue causing TX-stall on Lancer/BEx

Tobias Klauser (1):
  tls: make tls_sw_free_resources static

Xin Long (2):
  sctp: fix an use-after-free issue in sctp_sock_dump
  sctp: do not mark sk dumped when inet_sctp_diag_fill returns err

Yonghong Song (1):
  perf/bpf: fix a clang compilation issue

Yuval Mintz (1):
  mlxsw: spectrum: Prevent mirred-related crash on removal

 Documentation/networking/filter.txt   |   2 +-
 MAINTAINERS   |   2 ++
 drivers/net/bonding/bond_main.c   |  17 ++---
 drivers/net/bonding/bond_options.c|   3 +++
 drivers/net/ethernet/broadcom/bcmsysport.c|   3 ---
 drivers/net/ethernet/broadcom/tg3.c   |   4 ++--
 drivers/net/ethernet/emulex/benet/be.h|   8 +++
 drivers/net/ethernet/emulex/benet/be_main.c   |  14 +++
 

Re: [patch net] mlxsw: spectrum_router: Only handle IPv4 and IPv6 events

2017-09-16 Thread David Miller
From: Jiri Pirko 
Date: Fri, 15 Sep 2017 15:31:07 +0200

> From: Ido Schimmel 
> 
> The driver doesn't support events from address families other than IPv4
> and IPv6, so ignore them. Otherwise, we risk queueing a work item before
> it's initialized.
> 
> This can happen in case a VRF is configured when MROUTE_MULTIPLE_TABLES
> is enabled, as the VRF driver will try to add an l3mdev rule for the
> IPMR family.
> 
> Fixes: 65e65ec137f4 ("mlxsw: spectrum_router: Don't ignore IPv6 
> notifications")
> Signed-off-by: Ido Schimmel 
> Reported-by: Andreas Rammhold 
> Reported-by: Florian Klink 
> Signed-off-by: Jiri Pirko 

Applied, thanks.


[PATCH] Documentation: fix ascii art in networking docs

2017-09-16 Thread Pavel Machek

Fix ascii-art.

Signed-off-by: Pavel Machek 

---

Resent, because I did not get DaveM's address right.

diff --git a/Documentation/networking/switchdev.txt 
b/Documentation/networking/switchdev.txt
index 5e40e1f..6309e90 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -29,7 +29,7 @@ with SR-IOV or soft switches, such as OVS, are possible.
   sw1p1  +  sw1p3  +  sw1p5  +  eth1
 +|+|+|+
 |||||||
- +--++++-+--++---+  +-+-+
+ +--++++++---+  +-+-+
  | Switch driver |  |mgmt   |
  |(this document)|  |   driver  |
  |   |  |   |

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html



- End forwarded message -

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH] Documentation: link in networking docs

2017-09-16 Thread David Miller
From: Pavel Machek 
Date: Sat, 16 Sep 2017 16:28:02 +0200

> Fix link in filter.txt.
> 
> Acked-by: Pavel Machek 

Applied, thanks Pavel.


Re: [PATCH net] tcp: fix data delivery rate

2017-09-16 Thread David Miller
From: Eric Dumazet 
Date: Fri, 15 Sep 2017 16:47:42 -0700

> From: Eric Dumazet 
> 
> Now skb->mstamp_skb is updated later, we also need to call
> tcp_rate_skb_sent() after the update is done.
> 
> Fixes: 8c72c65b426b ("tcp: update skb->skb_mstamp more carefully")
> Signed-off-by: Eric Dumazet 

Applied, thanks Eric.


[PATCH net] driver: e1000: fix race condition between e1000_down() and e1000_watchdog

2017-09-16 Thread Vincenzo Maffione
This patch fixes a race condition that can result into the interface being
up and carrier on, but with transmits disabled in the hardware.
The bug may show up by repeatedly IFF_DOWN+IFF_UP the interface, which
allows e1000_watchdog() interleave with e1000_down().

CPU x   CPU y

e1000_down():
netif_carrier_off()
e1000_watchdog():
if (carrier == off) {
netif_carrier_on();
enable_hw_transmit();
}
disable_hw_transmit();
e1000_watchdog():
/* carrier on, do nothing */

Signed-off-by: Vincenzo Maffione 
---
 drivers/net/ethernet/intel/e1000/e1000_main.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 98375e1e1185..1982f7917a8d 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -520,8 +520,6 @@ void e1000_down(struct e1000_adapter *adapter)
struct net_device *netdev = adapter->netdev;
u32 rctl, tctl;
 
-   netif_carrier_off(netdev);
-
/* disable receives in the hardware */
rctl = er32(RCTL);
ew32(RCTL, rctl & ~E1000_RCTL_EN);
@@ -537,6 +535,15 @@ void e1000_down(struct e1000_adapter *adapter)
E1000_WRITE_FLUSH();
msleep(10);
 
+   /* Set the carrier off after transmits have been disabled in the
+* hardware, to avoid race conditions with e1000_watchdog() (which
+* may be running concurrently to us, checking for the carrier
+* bit to decide whether it should enable transmits again). Such
+* a race condition would result into transmission being disabled
+* in the hardware until the next IFF_DOWN+IFF_UP cycle.
+*/
+   netif_carrier_off(netdev);
+
napi_disable(>napi);
 
e1000_irq_disable(adapter);
-- 
2.14.1



[PATCH] mwifiex: make const arrays static to shink object code size

2017-09-16 Thread Colin King
From: Colin Ian King 

Don't populate const arrays on the stack, instead make them static
Makes the object code smaller by nearly 300 bytes:

Before:
   textdata bss dec hex filename
  69260   16149 576   85985   14fe1 cfg80211.o

After:
   textdata bss dec hex filename
  68385   16725 576   85686   14eb6 cfg80211.o

Signed-off-by: Colin Ian King 
---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 32c5074da84c..c45b86fcfd8d 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -142,7 +142,7 @@ mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct 
net_device *netdev,
 u8 key_index, bool pairwise, const u8 *mac_addr)
 {
struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
-   const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+   static const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const u8 *peer_mac = pairwise ? mac_addr : bc_mac;
 
if (mwifiex_set_encode(priv, NULL, NULL, 0, key_index, peer_mac, 1)) {
@@ -454,7 +454,7 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct 
net_device *netdev,
 {
struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
struct mwifiex_wep_key *wep_key;
-   const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+   static const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
const u8 *peer_mac = pairwise ? mac_addr : bc_mac;
 
if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP &&
@@ -3250,8 +3250,8 @@ static int mwifiex_set_wowlan_mef_entry(struct 
mwifiex_private *priv,
int i, filt_num = 0, ret = 0;
bool first_pat = true;
u8 byte_seq[MWIFIEX_MEF_MAX_BYTESEQ + 1];
-   const u8 ipv4_mc_mac[] = {0x33, 0x33};
-   const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e};
+   static const u8 ipv4_mc_mac[] = {0x33, 0x33};
+   static const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e};
 
mef_entry->mode = MEF_MODE_HOST_SLEEP;
mef_entry->action = MEF_ACTION_ALLOW_AND_WAKEUP_HOST;
@@ -3544,9 +3544,9 @@ static int mwifiex_set_rekey_data(struct wiphy *wiphy, 
struct net_device *dev,
 
 static int mwifiex_get_coalesce_pkt_type(u8 *byte_seq)
 {
-   const u8 ipv4_mc_mac[] = {0x33, 0x33};
-   const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e};
-   const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff};
+   static const u8 ipv4_mc_mac[] = {0x33, 0x33};
+   static const u8 ipv6_mc_mac[] = {0x01, 0x00, 0x5e};
+   static const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff};
 
if ((byte_seq[0] & 0x01) &&
(byte_seq[MWIFIEX_COALESCE_MAX_BYTESEQ] == 1))
-- 
2.14.1



[PATCH] Documentation: link in networking docs

2017-09-16 Thread Pavel Machek

Fix link in filter.txt.

Acked-by: Pavel Machek 

diff --git a/Documentation/networking/filter.txt 
b/Documentation/networking/filter.txt
index e5e33ba..789b74d 100644
--- a/Documentation/networking/filter.txt
+++ b/Documentation/networking/filter.txt
@@ -45,7 +45,7 @@ in many more places. There's xt_bpf for netfilter, cls_bpf in 
the kernel
 qdisc layer, SECCOMP-BPF (SECure COMPuting [1]), and lots of other places
 such as team driver, PTP code, etc where BPF is being used.
 
- [1] Documentation/prctl/seccomp_filter.txt
+ [1] Documentation/userspace-api/seccomp_filter.rst
 
 Original BPF paper:
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


[PATCH net-next v2] bridge: also trigger RTM_NEWLINK when interface is released from bridge

2017-09-16 Thread Vincent Bernat
Currently, when an interface is released from a bridge via
ioctl(), we get a RTM_DELLINK event through netlink:

Deleted 2: dummy0:  mtu 1500 master bridge0 state 
UNKNOWN
link/ether 6e:23:c2:54:3a:b3

Userspace has to interpret that as a removal from the bridge, not as a
complete removal of the interface. When an bridged interface is
completely removed, we get two events:

Deleted 2: dummy0:  mtu 1500 master bridge0 state DOWN
link/ether 6e:23:c2:54:3a:b3
Deleted 2: dummy0:  mtu 1500 qdisc noop state DOWN group 
default
link/ether 6e:23:c2:54:3a:b3 brd ff:ff:ff:ff:ff:ff

In constrast, when an interface is released from a bond, we get a
RTM_NEWLINK with only the new characteristics (no master):

3: dummy1:  mtu 1500 qdisc noqueue master 
bond0 state UNKNOWN group default
link/ether ae:dc:7a:8c:9a:3c brd ff:ff:ff:ff:ff:ff
3: dummy1:  mtu 1500 qdisc noqueue state UNKNOWN 
group default
link/ether ae:dc:7a:8c:9a:3c brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noqueue state 
UP group default
link/ether ae:dc:7a:8c:9a:3c brd ff:ff:ff:ff:ff:ff
3: dummy1:  mtu 1500 qdisc noqueue state DOWN group default
link/ether ae:dc:7a:8c:9a:3c brd ff:ff:ff:ff:ff:ff
3: dummy1:  mtu 1500 qdisc noqueue state DOWN group default
link/ether ca:c8:7b:66:f8:25 brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noqueue state 
UP group default
link/ether ae:dc:7a:8c:9a:3c brd ff:ff:ff:ff:ff:ff

Userland may be confused by the fact we say a link is deleted while
its characteristics are only modified. A first solution would have
been to turn the RTM_DELLINK event in del_nbp() into a RTM_NEWLINK
event. However, maybe some piece of userland is relying on this
RTM_DELLINK to detect when a bridged interface is released. Instead,
we also emit a RTM_NEWLINK event once the interface is
released (without master info).

Deleted 2: dummy0:  mtu 1500 master bridge0 state 
UNKNOWN
link/ether 8a:bb:e7:94:b1:f8
2: dummy0:  mtu 1500 qdisc noqueue state UNKNOWN 
group default
link/ether 8a:bb:e7:94:b1:f8 brd ff:ff:ff:ff:ff:ff

This is done only when using ioctl(). When using Netlink, such an
event is already automatically emitted in do_setlink().

Signed-off-by: Vincent Bernat 
---
 net/bridge/br_ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 7970f8540cbb..3148cb3a8e82 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -99,8 +99,10 @@ static int add_del_if(struct net_bridge *br, int ifindex, 
int isadd)
 
if (isadd)
ret = br_add_if(br, dev);
-   else
+   else {
ret = br_del_if(br, dev);
+   rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_MASTER, GFP_KERNEL);
+   }
 
return ret;
 }
-- 
2.14.1



RE: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Jon Maloy


> -Original Message-
> From: netdev-ow...@vger.kernel.org [mailto:netdev-
> ow...@vger.kernel.org] On Behalf Of Joe Perches
> Sent: Saturday, September 16, 2017 06:18
> To: Ying Xue ; Thomas Meyer
> ; Jon Maloy ;
> netdev@vger.kernel.org; tipc-discuss...@lists.sourceforge.net; linux-
> ker...@vger.kernel.org; da...@davemloft.net
> Subject: Re: [PATCH V2] tipc: Use bsearch library function
> 
> On Sat, 2017-09-16 at 18:10 +0800, Ying Xue wrote:
> > On 09/16/2017 05:58 PM, Joe Perches wrote:
> > > On Sat, 2017-09-16 at 17:36 +0800, Ying Xue wrote:
> > > > On 09/16/2017 05:26 PM, Joe Perches wrote:
> > > > > On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
> > > > > > On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> > > > > > > Use common library function rather than explicitly coding
> > > > > > > some variant of it yourself.
> > > > > > >
> > > > > > > Signed-off-by: Thomas Meyer 
> > > > > >
> > > > > > Acked-by: Ying Xue 
> > > > >
> > > > > Are you sure you want to do this?
> > > > >
> > > > > Note the comment above nameseq_find_subseq
> > > > >
> > > > >  * Very time-critical, so binary searches through sub-sequence array.
> > > > >
> > > > > What impact does this change have on performance?
> > > >
> > > > Sorry, I couldn't see any essential difference between this new
> > > > implementation and the original one except that the former tries
> > > > to use the library function - bsearch() to replace the original
> > > > binary search algorithm implemented in TIPC itself. Therefore, I
> > > > don't think the change will have a big impact on performance.
> > > >
> > > > If I miss something, please let me know.
> > >
> > > Comparison via a function pointer in bsearch is slower than direct
> > > code without the function call overhead.
> > >
> >
> > Right, but probably we can tolerate the slight sacrifice here.
> 
> What part of "very time critical" have you verified and benchmarked as
> inconsequential?
> 
> Please post your results.

I agree with Joe here. This change does not simplify anything, it does not 
reduce the amount of code, plus that it introduce an unnecessary outline call 
in a place where we have every reason to let the compiler do its optimization 
job properly.

///jon


Re: Use after free in __dst_destroy_metrics_generic

2017-09-16 Thread Julian Anastasov

Hello,

On Fri, 15 Sep 2017, Subash Abhinov Kasiviswanathan wrote:

> > May be I'm missing some posting but I don't see if
> > the patch was tested successfully.
> > 
> Hi Julian
> 
> I've had this patch being tested for the last 3-4 days in our regression rack
> and I haven't seen the same issue being reproduced or even a related crash
> or leak in dst.

For now I see only its bug-hiding side effects, i.e.
it does not call kfree. Now if there is no double-free
there should be a leak, not for dst but for metrics.

> The original issue was reported only once to us from the regression rack only
> so the exact steps to reproduce is unknown.

OK, lets see, may be others can explain what happens.

Regards

--
Julian Anastasov 


[PATCH net] net/sched: cls_matchall: fix crash when used with classful qdisc

2017-09-16 Thread Davide Caratti
this script, edited from Linux Advanced Routing and Traffic Control guide

tc q a dev en0 root handle 1: htb default a
tc c a dev en0 parent 1:  classid 1:1 htb rate 6mbit burst 15k
tc c a dev en0 parent 1:1 classid 1:a htb rate 5mbit ceil 6mbit burst 15k
tc c a dev en0 parent 1:1 classid 1:b htb rate 1mbit ceil 6mbit burst 15k
tc f a dev en0 parent 1:0 prio 1 $clsname $clsargs classid 1:b
ping $address -c1
tc -s c s dev en0

classifies traffic to 1:b or 1:a, depending on whether the packet matches
or not the pattern $clsargs of filter $clsname. However, when $clsname is
'matchall', a systematic crash can be observed in htb_classify(). HTB and
classful qdiscs don't assign initial value to struct tcf_result, but then
they expect it to contain valid values after filters have been run. Thus,
current 'matchall' ignores the TCA_MATCHALL_CLASSID attribute, configured
by user, and makes HTB (and classful qdiscs) dereference random pointers.

By assigning head->res to *res in mall_classify(), before the actions are
invoked, we fix this crash and enable TCA_MATCHALL_CLASSID functionality,
that had no effect on 'matchall' classifier since its first introduction.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1460213
Reported-by: Jiri Benc 
Fixes: b87f7936a932 ("net/sched: introduce Match-all classifier")
Signed-off-by: Davide Caratti 
---
 net/sched/cls_matchall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index 21cc45caf842..eeac606c95ab 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -32,6 +32,7 @@ static int mall_classify(struct sk_buff *skb, const struct 
tcf_proto *tp,
if (tc_skip_sw(head->flags))
return -1;
 
+   *res = head->res;
return tcf_exts_exec(skb, >exts, res);
 }
 
-- 
2.13.5



Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Joe Perches
On Sat, 2017-09-16 at 18:10 +0800, Ying Xue wrote:
> On 09/16/2017 05:58 PM, Joe Perches wrote:
> > On Sat, 2017-09-16 at 17:36 +0800, Ying Xue wrote:
> > > On 09/16/2017 05:26 PM, Joe Perches wrote:
> > > > On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
> > > > > On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> > > > > > Use common library function rather than explicitly coding
> > > > > > some variant of it yourself.
> > > > > > 
> > > > > > Signed-off-by: Thomas Meyer 
> > > > > 
> > > > > Acked-by: Ying Xue 
> > > > 
> > > > Are you sure you want to do this?
> > > > 
> > > > Note the comment above nameseq_find_subseq
> > > > 
> > > >  * Very time-critical, so binary searches through sub-sequence array.
> > > > 
> > > > What impact does this change have on performance?
> > > 
> > > Sorry, I couldn't see any essential difference between this new
> > > implementation and the original one except that the former tries to use
> > > the library function - bsearch() to replace the original binary search
> > > algorithm implemented in TIPC itself. Therefore, I don't think the
> > > change will have a big impact on performance.
> > > 
> > > If I miss something, please let me know.
> > 
> > Comparison via a function pointer in bsearch is slower
> > than direct code without the function call overhead.
> > 
> 
> Right, but probably we can tolerate the slight sacrifice here.

What part of "very time critical" have you verified
and benchmarked as inconsequential?

Please post your results.


Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Ying Xue
On 09/16/2017 05:58 PM, Joe Perches wrote:
> On Sat, 2017-09-16 at 17:36 +0800, Ying Xue wrote:
>> On 09/16/2017 05:26 PM, Joe Perches wrote:
>>> On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
 On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> Use common library function rather than explicitly coding
> some variant of it yourself.
>
> Signed-off-by: Thomas Meyer 

 Acked-by: Ying Xue 
>>>
>>> Are you sure you want to do this?
>>>
>>> Note the comment above nameseq_find_subseq
>>>
>>>  * Very time-critical, so binary searches through sub-sequence array.
>>>
>>> What impact does this change have on performance?
>>
>> Sorry, I couldn't see any essential difference between this new
>> implementation and the original one except that the former tries to use
>> the library function - bsearch() to replace the original binary search
>> algorithm implemented in TIPC itself. Therefore, I don't think the
>> change will have a big impact on performance.
>>
>> If I miss something, please let me know.
> 
> Comparison via a function pointer in bsearch is slower
> than direct code without the function call overhead.
> 

Right, but probably we can tolerate the slight sacrifice here.

> 


Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Joe Perches
On Sat, 2017-09-16 at 17:36 +0800, Ying Xue wrote:
> On 09/16/2017 05:26 PM, Joe Perches wrote:
> > On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
> > > On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> > > > Use common library function rather than explicitly coding
> > > > some variant of it yourself.
> > > > 
> > > > Signed-off-by: Thomas Meyer 
> > > 
> > > Acked-by: Ying Xue 
> > 
> > Are you sure you want to do this?
> > 
> > Note the comment above nameseq_find_subseq
> > 
> >  * Very time-critical, so binary searches through sub-sequence array.
> > 
> > What impact does this change have on performance?
> 
> Sorry, I couldn't see any essential difference between this new
> implementation and the original one except that the former tries to use
> the library function - bsearch() to replace the original binary search
> algorithm implemented in TIPC itself. Therefore, I don't think the
> change will have a big impact on performance.
> 
> If I miss something, please let me know.

Comparison via a function pointer in bsearch is slower
than direct code without the function call overhead.



Re: [PATCH v2 0/2] enable hires timer to timeout datagram socket

2017-09-16 Thread Thomas Gleixner
On Fri, 8 Sep 2017, Eric Dumazet wrote:
> On Fri, 2017-09-08 at 11:55 -0700, Eduardo Valentin wrote:
> > Hello,
> > 
> > On Fri, Sep 08, 2017 at 10:26:45AM -0700, David Miller wrote:
> > > From: David Woodhouse 
> > > Date: Fri, 08 Sep 2017 18:23:22 +0100
> > > 
> > > > I don't know that anyone's ever tried saying "show me the chapter
> > and
> > > > verse of the documentation"
> > > 
> > > Do you know why I brought this up?  Because the person I am replying
> > > to told me that the syscall documentation should have suggested this
> > > or that.
> > > 
> > > That's why.
> > 
> > :-) My intention was for sure not to upset anybody.
> > 
> > Just to reiterate, the point of patch is simple, there was a change in
> > behavior in the system call from one kernel version to the other. As I
> > mentioned, I agree that the userspace could use other means to achieve
> > the same, but still the system call behavior has changed.
> > 
> > > 
> > > So let's concentrate on the other aspects of my reply, ok?
> > 
> > I agree. I would prefer to understand here what is the technical
> > reason not to accept these patches other than "use other system
> > calls".
> 
> So if we need to replace all 'legacy' timers to high resolution timer,
> because some application was _relying_ on jiffies being kind of precise,
> maybe it is better to revert the change done on legacy timers.

Which would be a major step back in terms of timer performance and system
disturbance caused by massive recascading operations.

> Or continue the migration and make them use high res internally.
> 
> select() and poll() are the standard way to have precise timeouts,
> it is silly we have to maintain a timeout handling in the datagram fast
> path.

A few years ago we switched select/poll over to use hrtimers because the
wheel timers were too inaccurate for some operations, so it feels
consequent to switch the timeout in the datagram rcv path over as well. I
agree that the whole timeout magic there feels silly, but unfortunately
it's a documented property of sockets.

Thanks,

tglx


Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Ying Xue
On 09/16/2017 05:26 PM, Joe Perches wrote:
> On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
>> On 09/16/2017 03:50 PM, Thomas Meyer wrote:
>>> Use common library function rather than explicitly coding
>>> some variant of it yourself.
>>>
>>> Signed-off-by: Thomas Meyer 
>>
>> Acked-by: Ying Xue 
> 
> Are you sure you want to do this?
> 
> Note the comment above nameseq_find_subseq
> 
>  * Very time-critical, so binary searches through sub-sequence array.
> 
> What impact does this change have on performance?

Sorry, I couldn't see any essential difference between this new
implementation and the original one except that the former tries to use
the library function - bsearch() to replace the original binary search
algorithm implemented in TIPC itself. Therefore, I don't think the
change will have a big impact on performance.

If I miss something, please let me know.

Thanks,
Ying

> 
>>> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
>>> index bd0aac87b41a..eeb4d7a13de2 100644
>>> --- a/net/tipc/name_table.c
>>> +++ b/net/tipc/name_table.c
>>> @@ -44,6 +44,7 @@
>>>  #include "addr.h"
>>>  #include "node.h"
>>>  #include 
>>> +#include 
>>>  
>>>  #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
>>>  
>>> @@ -168,6 +169,18 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
>>> struct hlist_head *seq_hea
>>> return nseq;
>>>  }
>>>  
>>> +static int nameseq_find_subseq_cmp(const void *key, const void *elt)
>>> +{
>>> +   struct sub_seq *sseq = (struct sub_seq *)elt;
>>> +   u32 instance = *(u32 *)key;
>>> +
>>> +   if (instance < sseq->lower)
>>> +   return -1;
>>> +   else if (instance > sseq->upper)
>>> +   return 1;
>>> +   return 0;
>>> +}
>>> +
>>>  /**
>>>   * nameseq_find_subseq - find sub-sequence (if any) matching a name 
>>> instance
>>>   *
>>> @@ -176,21 +189,8 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
>>> struct hlist_head *seq_hea
>>>  static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
>>>u32 instance)
>>>  {
>>> -   struct sub_seq *sseqs = nseq->sseqs;
>>> -   int low = 0;
>>> -   int high = nseq->first_free - 1;
>>> -   int mid;
>>> -
>>> -   while (low <= high) {
>>> -   mid = (low + high) / 2;
>>> -   if (instance < sseqs[mid].lower)
>>> -   high = mid - 1;
>>> -   else if (instance > sseqs[mid].upper)
>>> -   low = mid + 1;
>>> -   else
>>> -   return [mid];
>>> -   }
>>> -   return NULL;
>>> +   return bsearch(, nseq->sseqs, nseq->first_free,
>>> +  sizeof(struct sub_seq), nameseq_find_subseq_cmp);
>>>  }
>>>  
>>>  /**
>>>
> 


Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Joe Perches
On Sat, 2017-09-16 at 17:02 +0800, Ying Xue wrote:
> On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> > Use common library function rather than explicitly coding
> > some variant of it yourself.
> > 
> > Signed-off-by: Thomas Meyer 
> 
> Acked-by: Ying Xue 

Are you sure you want to do this?

Note the comment above nameseq_find_subseq

 * Very time-critical, so binary searches through sub-sequence array.

What impact does this change have on performance?

> > diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
> > index bd0aac87b41a..eeb4d7a13de2 100644
> > --- a/net/tipc/name_table.c
> > +++ b/net/tipc/name_table.c
> > @@ -44,6 +44,7 @@
> >  #include "addr.h"
> >  #include "node.h"
> >  #include 
> > +#include 
> >  
> >  #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
> >  
> > @@ -168,6 +169,18 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
> > struct hlist_head *seq_hea
> > return nseq;
> >  }
> >  
> > +static int nameseq_find_subseq_cmp(const void *key, const void *elt)
> > +{
> > +   struct sub_seq *sseq = (struct sub_seq *)elt;
> > +   u32 instance = *(u32 *)key;
> > +
> > +   if (instance < sseq->lower)
> > +   return -1;
> > +   else if (instance > sseq->upper)
> > +   return 1;
> > +   return 0;
> > +}
> > +
> >  /**
> >   * nameseq_find_subseq - find sub-sequence (if any) matching a name 
> > instance
> >   *
> > @@ -176,21 +189,8 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
> > struct hlist_head *seq_hea
> >  static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
> >u32 instance)
> >  {
> > -   struct sub_seq *sseqs = nseq->sseqs;
> > -   int low = 0;
> > -   int high = nseq->first_free - 1;
> > -   int mid;
> > -
> > -   while (low <= high) {
> > -   mid = (low + high) / 2;
> > -   if (instance < sseqs[mid].lower)
> > -   high = mid - 1;
> > -   else if (instance > sseqs[mid].upper)
> > -   low = mid + 1;
> > -   else
> > -   return [mid];
> > -   }
> > -   return NULL;
> > +   return bsearch(, nseq->sseqs, nseq->first_free,
> > +  sizeof(struct sub_seq), nameseq_find_subseq_cmp);
> >  }
> >  
> >  /**
> > 


Re: [PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Ying Xue
On 09/16/2017 03:50 PM, Thomas Meyer wrote:
> Use common library function rather than explicitly coding
> some variant of it yourself.
> 
> Signed-off-by: Thomas Meyer 

Acked-by: Ying Xue 

> ---
>  net/tipc/name_table.c | 30 +++---
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> V2: Coding style
> 
> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
> index bd0aac87b41a..eeb4d7a13de2 100644
> --- a/net/tipc/name_table.c
> +++ b/net/tipc/name_table.c
> @@ -44,6 +44,7 @@
>  #include "addr.h"
>  #include "node.h"
>  #include 
> +#include 
>  
>  #define TIPC_NAMETBL_SIZE 1024   /* must be a power of 2 */
>  
> @@ -168,6 +169,18 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
> struct hlist_head *seq_hea
>   return nseq;
>  }
>  
> +static int nameseq_find_subseq_cmp(const void *key, const void *elt)
> +{
> + struct sub_seq *sseq = (struct sub_seq *)elt;
> + u32 instance = *(u32 *)key;
> +
> + if (instance < sseq->lower)
> + return -1;
> + else if (instance > sseq->upper)
> + return 1;
> + return 0;
> +}
> +
>  /**
>   * nameseq_find_subseq - find sub-sequence (if any) matching a name instance
>   *
> @@ -176,21 +189,8 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
> struct hlist_head *seq_hea
>  static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
>  u32 instance)
>  {
> - struct sub_seq *sseqs = nseq->sseqs;
> - int low = 0;
> - int high = nseq->first_free - 1;
> - int mid;
> -
> - while (low <= high) {
> - mid = (low + high) / 2;
> - if (instance < sseqs[mid].lower)
> - high = mid - 1;
> - else if (instance > sseqs[mid].upper)
> - low = mid + 1;
> - else
> - return [mid];
> - }
> - return NULL;
> + return bsearch(, nseq->sseqs, nseq->first_free,
> +sizeof(struct sub_seq), nameseq_find_subseq_cmp);
>  }
>  
>  /**
> 


[PATCH V2] tipc: Use bsearch library function

2017-09-16 Thread Thomas Meyer
Use common library function rather than explicitly coding
some variant of it yourself.

Signed-off-by: Thomas Meyer 
---
 net/tipc/name_table.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

V2: Coding style

diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index bd0aac87b41a..eeb4d7a13de2 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -44,6 +44,7 @@
 #include "addr.h"
 #include "node.h"
 #include 
+#include 
 
 #define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
 
@@ -168,6 +169,18 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
struct hlist_head *seq_hea
return nseq;
 }
 
+static int nameseq_find_subseq_cmp(const void *key, const void *elt)
+{
+   struct sub_seq *sseq = (struct sub_seq *)elt;
+   u32 instance = *(u32 *)key;
+
+   if (instance < sseq->lower)
+   return -1;
+   else if (instance > sseq->upper)
+   return 1;
+   return 0;
+}
+
 /**
  * nameseq_find_subseq - find sub-sequence (if any) matching a name instance
  *
@@ -176,21 +189,8 @@ static struct name_seq *tipc_nameseq_create(u32 type, 
struct hlist_head *seq_hea
 static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
   u32 instance)
 {
-   struct sub_seq *sseqs = nseq->sseqs;
-   int low = 0;
-   int high = nseq->first_free - 1;
-   int mid;
-
-   while (low <= high) {
-   mid = (low + high) / 2;
-   if (instance < sseqs[mid].lower)
-   high = mid - 1;
-   else if (instance > sseqs[mid].upper)
-   low = mid + 1;
-   else
-   return [mid];
-   }
-   return NULL;
+   return bsearch(, nseq->sseqs, nseq->first_free,
+  sizeof(struct sub_seq), nameseq_find_subseq_cmp);
 }
 
 /**
-- 
2.11.0



Re: [Outreachy kernel] [PATCH] Staging: irda: Use !x instead of NULL comparison

2017-09-16 Thread Julia Lawall


On Sat, 16 Sep 2017, Srishti Sharma wrote:

> Test for NULL as !x where functions that return NULL on failure
> are used. Done using the following semantic patch by coccinelle.
>
> @ is_null @
> expression E;
> statement S;
> @@
>
> E = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|
> usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\)(...));
>
> (
> if(!E)
>S
> |
> -if(E==NULL)
> +if(!E)
> S
> )
>
> Signed-off-by: Srishti Sharma 

Acked-by: Julia Lawall 


> ---
>  drivers/staging/irda/net/discovery.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/irda/net/discovery.c 
> b/drivers/staging/irda/net/discovery.c
> index 364d70a..1e54954 100644
> --- a/drivers/staging/irda/net/discovery.c
> +++ b/drivers/staging/irda/net/discovery.c
> @@ -179,7 +179,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 
> saddr, int force)
>   /* Create the client specific buffer */
>   n = HASHBIN_GET_SIZE(log);
>   buffer = kmalloc(n * sizeof(struct 
> irda_device_info), GFP_ATOMIC);
> - if (buffer == NULL) {
> + if (!buffer) {
>   
> spin_unlock_irqrestore(>hb_spinlock, flags);
>   return;
>   }
> @@ -291,7 +291,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t 
> *log, int *pn,
>   /* Create the client specific buffer */
>   n = HASHBIN_GET_SIZE(log);
>   buffer = kmalloc(n * sizeof(struct 
> irda_device_info), GFP_ATOMIC);
> - if (buffer == NULL) {
> + if (!buffer) {
>   
> spin_unlock_irqrestore(>hb_spinlock, flags);
>   return NULL;
>   }
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups 
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to outreachy-kernel+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1505543667-4670-1-git-send-email-srishtishar%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


[PATCH] Staging: irda: Use !x instead of NULL comparison

2017-09-16 Thread Srishti Sharma
Test for NULL as !x where functions that return NULL on failure
are used. Done using the following semantic patch by coccinelle.

@ is_null @
expression E;
statement S;
@@

E = (\(kmalloc\|devm_kzalloc\|kmalloc_array\|devm_ioremap\|
usb_alloc_urb\|alloc_netdev\|dev_alloc_skb\)(...));

(
if(!E)
   S
|
-if(E==NULL)
+if(!E)
S
)

Signed-off-by: Srishti Sharma 
---
 drivers/staging/irda/net/discovery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/irda/net/discovery.c 
b/drivers/staging/irda/net/discovery.c
index 364d70a..1e54954 100644
--- a/drivers/staging/irda/net/discovery.c
+++ b/drivers/staging/irda/net/discovery.c
@@ -179,7 +179,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, 
int force)
/* Create the client specific buffer */
n = HASHBIN_GET_SIZE(log);
buffer = kmalloc(n * sizeof(struct 
irda_device_info), GFP_ATOMIC);
-   if (buffer == NULL) {
+   if (!buffer) {

spin_unlock_irqrestore(>hb_spinlock, flags);
return;
}
@@ -291,7 +291,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t 
*log, int *pn,
/* Create the client specific buffer */
n = HASHBIN_GET_SIZE(log);
buffer = kmalloc(n * sizeof(struct 
irda_device_info), GFP_ATOMIC);
-   if (buffer == NULL) {
+   if (!buffer) {

spin_unlock_irqrestore(>hb_spinlock, flags);
return NULL;
}
-- 
2.7.4



Re: [PATCH] bgmac: Remove all offloading features, including GRO.

2017-09-16 Thread Florian Fainelli
On September 15, 2017 5:38:42 PM PDT, ros...@gmail.com wrote:
>I have not. Unfortunately I own no gigabit hardware to test this on.
>The MIPS CPU runs at 300MHz on my unit.
>

bgmac is used on Gigabit capable hardware, like Northstar and Northstar Plus, 
and others too, so unless you can get access to such HW or get confirmation 
from someone that your patches changes something, I would just drop this change 
and not bother. This is already not 100mbits/sec linerate...

>On Fri, 2017-09-15 at 17:34 -0700, Eric Dumazet wrote:
>> On Fri, 2017-09-15 at 17:23 -0700, Rosen Penev wrote:
>> > On a linksys E1200v1 (actually a crossflashed E1000v2), the
>> > offloading features give no measurable benefit to speed or latency.
>> > Furthermore, disabling GRO actually improves iperf performance by a
>> > whoppimg 3mbps. Results:
>> > 
>> > Currently:
>> > 
>> > v2: Changed napi_gro_receive to netif_receive_skb. Seems to have an
>> > identical result.
>> > 
>> > Signed-off-by: Rosen Penev 
>> > ---
>> >  drivers/net/ethernet/broadcom/bgmac.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > 
>> > diff --git a/drivers/net/ethernet/broadcom/bgmac.c
>> > b/drivers/net/ethernet/broadcom/bgmac.c
>> > index 48d672b204a4..1fb0053aeee7 100644
>> > --- a/drivers/net/ethernet/broadcom/bgmac.c
>> > +++ b/drivers/net/ethernet/broadcom/bgmac.c
>> > @@ -483,7 +483,7 @@ static int bgmac_dma_rx_read(struct bgmac
>> > *bgmac, struct bgmac_dma_ring *ring,
>> >skb->protocol = eth_type_trans(skb, bgmac-
>> > >net_dev);
>> >bgmac->net_dev->stats.rx_bytes += len;
>> >bgmac->net_dev->stats.rx_packets++;
>> > -  napi_gro_receive(>napi, skb);
>> > +  netif_receive_skb(skb);
>> >handled++;
>> >} while (0);
>> >  
>> 
>> And have you tested 1Gbit link speed ?
>> ( Or 2.5 Gbit link speed )
>> 
>> If you want to disable GRO on your host, fine : you can use ethtool
>> -K
>> 
>> 
>> 

(please don't top-post)
-- 
Florian