[PATCH v3 06/20] brcm80211: constify usb_device_id

2017-08-10 Thread Arvind Yadav
usb_device_id are not supposed to change at runtime. All functions
working with usb_device_id provided by  work with
const usb_device_id. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
changes in v2:
  Re-submitting wireless separately.
changes in v3:
  Resolve Merge conflic.

 drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index 8f20a4b..11ffaa0 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1468,7 +1468,7 @@ static int brcmf_usb_reset_resume(struct usb_interface 
*intf)
 #define CYPRESS_USB_DEVICE(dev_id) \
{ USB_DEVICE(CY_USB_VENDOR_ID_CYPRESS, dev_id) }
 
-static struct usb_device_id brcmf_usb_devid_table[] = {
+static const struct usb_device_id brcmf_usb_devid_table[] = {
BRCMF_USB_DEVICE(BRCM_USB_43143_DEVICE_ID),
BRCMF_USB_DEVICE(BRCM_USB_43236_DEVICE_ID),
BRCMF_USB_DEVICE(BRCM_USB_43242_DEVICE_ID),
-- 
1.9.1



Re: [net-next 03/12] e1000e: add check on e1e_wphy() return value

2017-08-10 Thread Jeff Kirsher
On Thu, 2017-08-10 at 19:53 -0700, Joe Perches wrote:
> On Thu, 2017-08-10 at 21:47 -0500, Gustavo A. R. Silva wrote:
> > Hello everybody,
> > 
> > I'm a little confused. Is this patch causing any trouble?
> 
> Not to me.  I no longer have an e1000e.
> 
> Given the commit message, this just seemed to be a patch
> that _might_ cause an issue if this code patch is actually
> untested.
> 
> Compilation wise, it's obviously fine.

Fortunately, I have all patches submitted to me thoroughly tested.  It
was a good catch, and we confirmed it does provide a valid fix.

signature.asc
Description: This is a digitally signed message part


[PATCH net-next] net: skb_needs_check() removes CHECKSUM_UNNECESSARY check for tx.

2017-08-10 Thread Tonghao Zhang
Because we remove the UFO support, we will also remove the
CHECKSUM_UNNECESSARY check in skb_needs_check().

Cc: Willem de Bruijn 
Signed-off-by: Tonghao Zhang 
---
 net/core/dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 3f69f6e..1024d37 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2731,8 +2731,7 @@ struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
 static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
 {
if (tx_path)
-   return skb->ip_summed != CHECKSUM_PARTIAL &&
-  skb->ip_summed != CHECKSUM_UNNECESSARY;
+   return skb->ip_summed != CHECKSUM_PARTIAL;
 
return skb->ip_summed == CHECKSUM_NONE;
 }
-- 
1.8.3.1



Re: [net-next 03/12] e1000e: add check on e1e_wphy() return value

2017-08-10 Thread Gustavo A. R. Silva

Hello everybody,

I'm a little confused. Is this patch causing any trouble?

On 08/10/2017 12:56 PM, Joe Perches wrote:

On Wed, 2017-08-09 at 14:47 -0700, Jeff Kirsher wrote:

From: Gustavo A R Silva 

Check return value from call to e1e_wphy(). This value is being
checked during previous calls to function e1e_wphy() and it seems
a check was missing here.


The use of "it seems" here is less than compelling.



This is one of the first patches I sent. Maybe I should have added a 
note saying that this patch needed some testing, as I don't have the 
hardware to test it.



Perhaps the write of 0x3140 to MII_BMCR takes too long for
the return value used.

Many other uses of e1e_wphy.*MII_BMCR are also not checked.

For instance: the e100e/ethtool uses.


diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c 
b/drivers/net/ethernet/intel/e1000e/ich8lan.c

[]

@@ -2437,6 +2437,8 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct 
e1000_hw *hw)
if (hw->phy.revision < 2) {
e1000e_phy_sw_reset(hw);
ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
+   if (ret_val)
+   return ret_val;
}
}



Thanks
--
Gustavo A. R. Silva


Re: [net-next 03/12] e1000e: add check on e1e_wphy() return value

2017-08-10 Thread Joe Perches
On Thu, 2017-08-10 at 21:47 -0500, Gustavo A. R. Silva wrote:
> Hello everybody,
> 
> I'm a little confused. Is this patch causing any trouble?

Not to me.  I no longer have an e1000e.

Given the commit message, this just seemed to be a patch
that _might_ cause an issue if this code patch is actually
untested.

Compilation wise, it's obviously fine.

> On 08/10/2017 12:56 PM, Joe Perches wrote:
> > On Wed, 2017-08-09 at 14:47 -0700, Jeff Kirsher wrote:
> > > From: Gustavo A R Silva 
> > > 
> > > Check return value from call to e1e_wphy(). This value is being
> > > checked during previous calls to function e1e_wphy() and it seems
> > > a check was missing here.
> > 
> > The use of "it seems" here is less than compelling.
> > 
> 
> This is one of the first patches I sent. Maybe I should have added a 
> note saying that this patch needed some testing, as I don't have the 
> hardware to test it.
> 
> > Perhaps the write of 0x3140 to MII_BMCR takes too long for
> > the return value used.
> > 
> > Many other uses of e1e_wphy.*MII_BMCR are also not checked.
> > 
> > For instance: the e100e/ethtool uses.
> > 
> > > diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c 
> > > b/drivers/net/ethernet/intel/e1000e/ich8lan.c
> > 
> > []
> > > @@ -2437,6 +2437,8 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct 
> > > e1000_hw *hw)
> > >   if (hw->phy.revision < 2) {
> > >   e1000e_phy_sw_reset(hw);
> > >   ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
> > > + if (ret_val)
> > > + return ret_val;
> > >   }
> > >   }
> > > 
> 
> Thanks


Re: [PATCH 2/3] ARM: sun8i: sunxi-h3-h5: add phy-is-integrated property to internal PHY

2017-08-10 Thread Chen-Yu Tsai
Hi,

On Thu, Aug 10, 2017 at 4:51 PM, Corentin Labbe
 wrote:
> This patch add the new phy-is-integrated property to the internal PHY
> node.
>
> Signed-off-by: Corentin Labbe 
> ---
>  arch/arm/boot/dts/sunxi-h3-h5.dtsi | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/boot/dts/sunxi-h3-h5.dtsi 
> b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> index 4b599b5d26f6..54fc24e4c569 100644
> --- a/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> +++ b/arch/arm/boot/dts/sunxi-h3-h5.dtsi
> @@ -425,6 +425,7 @@
> reg = <1>;
> clocks = < CLK_BUS_EPHY>;
> resets = < RST_BUS_EPHY>;
> +   phy-is-integrated;

You also need to "delete" this property at the board level for
any board that has the external PHY at address <1>. Otherwise
they will stop working. This is due to the internal and external
PHYs having the same path and node name in the device tree, so
they are effectively the same node.

ChenYu

> };
> };
> };
> --
> 2.13.0
>


Re: [PATCH v1 net] TCP_USER_TIMEOUT and tcp_keepalive should conform to RFC5482

2017-08-10 Thread Jerry Chu
On Thu, Aug 10, 2017 at 2:05 PM, Rao Shoaib  wrote:
>
>
> On 08/09/2017 09:59 PM, Jerry Chu wrote:
>>
>> On Wed, Aug 9, 2017 at 8:32 PM, Jerry Chu  wrote:
>>>
>>> On Wed, Aug 9, 2017 at 5:47 PM, Rao Shoaib  wrote:


 On 08/09/2017 05:30 PM, David Miller wrote:
>
> From: Joe Smith 
> Date: Wed, 9 Aug 2017 17:20:32 -0700
>
>> Making Linux conform to standards and behavior that is logical seems
>> like a good enough reason.
>
> That's an awesome attitude to have when we're implementing something
> new and don't have the facility already.
>
> But when we have something already the only important consideration is
> not breaking existing apps which rely on that behavior.
>
> That is much, much, more important than standards compliance.
>
> If users are confused, just fix the documentation.

 David,

 If it was just confusion than sure fixing the documentation is fine.
 What if
 the logic is incorrect, does not conform to the standard that is says it
 is
>>>
>>> Not sure what part of logic is "incorrect" when it was a homegrown Linux
>>> API
>>> with no need to conform with any "standard"? Note that the new API was
>>> invented
>>> 7 years ago not out of need for RFC5482. In fact I initially call the
>>> option
>>> TCP_FAILFAST and did not even know the existence of RFC5482 until someone
>>> around the same time proposed a UTO option specifically for RFC5482 and I
>>> thought the two can be combined. (This is roughly the memory I can
>>> recollect so far.)
>>>
>>> So you see my focus back then was to devise a "failfast" option whereas
>>> RFC5482
>>> was meant for a "failslow" case. I think that explains why I let the
>>> option override
>>> keepalive so a TCP connection can "fail fast" while RFC5482 4.2 tries to
>>> prevent
>>> keepalive failure ahead of UTO, favoring "fail slow".
>>>
>>> If we start from a clean slate then perhaps one can argue the semantic
>>> either way
>>> but we do not have a clean slate. For that I still slightly favor not
>>> changing the code
>>> because the risk of breakage is definitely non-zero and the issue you're
>>> having
>>> seem to be only related to documentation.
>
> We all make mistakes and over look things, that seems to be the case here.

First of all, I do not understand what "mistake" has been committed? Like I
said, the API was not invented for RFC5482 specifically. It was really meant for
a "fail fast" case that was requested of me fir our internal use case
for a product
that back then had only 100 million users (but has mostly like grown to many
billions now).

> If this was so important than I am sure there was a use case. None has been
> presented. Without a use case I do not understand why we have to live with

I don't understand this one either. If you want a use case, you can
ask politely,
no need to flame or fume. Also why would I waste my energy on something
no one would use, then even more energy arguing now for maintaining its
semantic?

This API was requested of me by our Android group and has since been
deployed on all our Android servers. I initially pushed back and asked them to
just program a short KEEPALIVE time for all the Android connections but they
can't use it because it would wake up clients too often, unnecessarily
waste a lot
of battery power.

Its uses inside Google have proliferated since. Most recently (a few months ago)
I got an email from our Nest division saying they hit a bug related to
TCP_USER_TIMEOUT and even pointed me to
https://bugzilla.redhat.com/show_bug.cgi?id=1189241 (but i haven't got the time
to look into it and in the meantime they found a workaround)

So what's your use case then that really requires changing the implementation?

> broken logic when we have a chance to fix it and make the code better.
>
> If this change does break something (very very unlikely) we will understand
> the use case and provide an appropriate solution.
>
>> One more thing - the proposed patch compares TCP_KEEPIDLE against
>> TCP_USER_TIMEOUT. But I don't think TCP_KEEPIDLE is what the
>> "keep-alive
>> timer" referred to in RFC5482. Linux keepalive implementation seems to use
>> #
>> of retries (TCP_KEEPCNT) rather than time duration (keep-alive time) to
>> determine when to quit. If that is the case then your proposed change is
>> not
>> fully "compliant" either and the best is probably just don't change.
>
> Did you look at the patch and what it changes ?
>
> Take a look at the TCP_KEEPIDLE socket option and see what it does or just
> look at the man page of tcp(7)
>
> TCP_KEEPIDLE (since Linux 2.4) The time (in seconds) the connection needs to
> remain idle before TCP starts sending keepalive probes, if the socket option
> SO_KEEPALIVE has been set on this socket. This option should not be used in
> code intended to be portable.

Yes precisely my point 

Re: [PATCH net-next] net: skb_needs_check() removes CHECKSUM_NONE check for tx.

2017-08-10 Thread Tonghao Zhang
Hi Willem, because we change the CHECKSUM_NONE to CHECKSUM_UNNECESSARY
in skb_needs_check(), I can't revert 6e7bc478c9a0
("net: skb_needs_check() accepts CHECKSUM_NONE for tx").  I change it
directly and resubmit it.

On Fri, Aug 11, 2017 at 1:03 AM, Willem de Bruijn
 wrote:
> On Wed, Aug 9, 2017 at 6:02 PM, Tonghao Zhang  
> wrote:
>> Thanks for your work.
>
> You, too.
>
>> On Thu, Aug 10, 2017 at 2:30 AM, Willem de Bruijn
>>  wrote:
>>> On Wed, Aug 9, 2017 at 5:04 AM, Tonghao Zhang  
>>> wrote:
 This patch reverts the commit 6e7bc478c9a0
 ("net: skb_needs_check() accepts CHECKSUM_NONE for tx"),
 because we removed the UFO support.

 Cc: Eric Dumazet 
 Cc: Willem de Bruijn 
 Signed-off-by: Tonghao Zhang 
>>>
>>>
>>> I would wait until net is merged into net-next. This will cause a conflict.
>>>
>>> Also, while logically equivalent, it is not a real revert (as in `git
>>> revert $SHA1`) of that patch.
>>>
>>> Aside from those concerns, I agree that the original patch is no
>>> longer needed now that UFO is reverted.
>
> Please do resubmit the revert patch once net has been merged into net-next.


[PATCH net-next 14/14] sctp: fix some indents in sm_make_chunk.c

2017-08-10 Thread Xin Long
There are some bad indents of functions' defination in sm_make_chunk.c.
They have been there since beginning, it was probably caused by that
the typedef sctp_chunk_t was replaced with struct sctp_chunk.

So it's the best time to fix them in this patchset, it's also to fix
some bad indents in other functions' defination in sm_make_chunk.c.

Signed-off-by: Xin Long 
---
 include/net/sctp/sm.h| 158 ++---
 net/sctp/sm_make_chunk.c | 348 +++
 2 files changed, 249 insertions(+), 257 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 33077f3..2db3d3a 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -184,68 +184,69 @@ __u32 sctp_generate_verification_tag(void);
 void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
 
 /* Prototypes for chunk-building functions.  */
-struct sctp_chunk *sctp_make_init(const struct sctp_association *,
-const struct sctp_bind_addr *,
-gfp_t gfp, int vparam_len);
-struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *,
-const struct sctp_chunk *,
-const gfp_t gfp,
-const int unkparam_len);
-struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *,
-   const struct sctp_chunk *);
-struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *,
-  const struct sctp_chunk *);
-struct sctp_chunk *sctp_make_cwr(const struct sctp_association *,
+struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
+ const struct sctp_bind_addr *bp,
+ gfp_t gfp, int vparam_len);
+struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
+ const struct sctp_chunk *chunk,
+ const gfp_t gfp, const int unkparam_len);
+struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *asoc,
+const struct sctp_chunk *chunk);
+struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
+   const struct sctp_chunk *chunk);
+struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
 const __u32 lowest_tsn,
-const struct sctp_chunk *);
-struct sctp_chunk * sctp_make_datafrag_empty(struct sctp_association *,
-   const struct sctp_sndrcvinfo *sinfo,
-   int len, const __u8 flags,
-   __u16 ssn, gfp_t gfp);
-struct sctp_chunk *sctp_make_ecne(const struct sctp_association *,
- const __u32);
-struct sctp_chunk *sctp_make_sack(const struct sctp_association *);
+const struct sctp_chunk *chunk);
+struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc,
+   const struct sctp_sndrcvinfo *sinfo,
+   int len, const __u8 flags,
+   __u16 ssn, gfp_t gfp);
+struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc,
+ const __u32 lowest_tsn);
+struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc);
 struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,
  const struct sctp_chunk *chunk);
 struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
- const struct sctp_chunk *);
-struct sctp_chunk *sctp_make_shutdown_complete(const struct sctp_association *,
- const struct sctp_chunk *);
-void sctp_init_cause(struct sctp_chunk *, __be16 cause, size_t);
-struct sctp_chunk *sctp_make_abort(const struct sctp_association *,
- const struct sctp_chunk *,
- const size_t hint);
-struct sctp_chunk *sctp_make_abort_no_data(const struct sctp_association *,
- const struct sctp_chunk *,
- __u32 tsn);
-struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *,
-   struct msghdr *, size_t msg_len);
-struct sctp_chunk *sctp_make_abort_violation(const struct sctp_association *,
-  const struct sctp_chunk *,
-  const __u8 *,
-  const size_t );
-struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association 
*,
-  

[PATCH net-next 11/14] sctp: remove the unused typedef sctp_sm_command_t

2017-08-10 Thread Xin Long
Remove this typedef including the struct, there is even no places
using it.

Signed-off-by: Xin Long 
---
 include/net/sctp/sm.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 9af64b9..3ca75a6 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -65,11 +65,6 @@ typedef enum {
SCTP_DISPOSITION_BUG,/* This is a bug.  */
 } sctp_disposition_t;
 
-typedef struct {
-   int name;
-   int action;
-} sctp_sm_command_t;
-
 typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
  const struct sctp_endpoint *,
  const struct sctp_association *,
-- 
2.1.0



[PATCH net-next 12/14] sctp: remove the typedef sctp_sm_table_entry_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_sm_table_entry_t, and
replace with struct sctp_sm_table_entry in the places where it's
using this typedef.

It is also to fix some indents.

Signed-off-by: Xin Long 
---
 include/net/sctp/sm.h|  6 +++---
 net/sctp/sm_sideeffect.c |  2 +-
 net/sctp/sm_statetable.c | 42 +-
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 3ca75a6..7ad2402 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -72,10 +72,10 @@ typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
  void *arg,
  struct sctp_cmd_seq *);
 typedef void (sctp_timer_event_t) (unsigned long);
-typedef struct {
+struct sctp_sm_table_entry {
sctp_state_fn_t *fn;
const char *name;
-} sctp_sm_table_entry_t;
+};
 
 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
  * currently in use.
@@ -170,7 +170,7 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire;
 
 /* Prototypes for utility support functions.  */
 __u8 sctp_get_chunk_type(struct sctp_chunk *chunk);
-const sctp_sm_table_entry_t *sctp_sm_lookup_event(
+const struct sctp_sm_table_entry *sctp_sm_lookup_event(
struct net *net,
enum sctp_event event_type,
enum sctp_state state,
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 6dd5934..2bc1204 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -1146,7 +1146,7 @@ int sctp_do_sm(struct net *net, enum sctp_event 
event_type,
   void *event_arg, gfp_t gfp)
 {
struct sctp_cmd_seq commands;
-   const sctp_sm_table_entry_t *state_fn;
+   const struct sctp_sm_table_entry *state_fn;
sctp_disposition_t status;
int error = 0;
typedef const char *(printfn_t)(union sctp_subtype);
diff --git a/net/sctp/sm_statetable.c b/net/sctp/sm_statetable.c
index d437f38..79b6bee 100644
--- a/net/sctp/sm_statetable.c
+++ b/net/sctp/sm_statetable.c
@@ -45,27 +45,27 @@
 #include 
 #include 
 
-static const sctp_sm_table_entry_t
+static const struct sctp_sm_table_entry
 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
-static const sctp_sm_table_entry_t
+static const struct sctp_sm_table_entry
 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
-static const sctp_sm_table_entry_t
+static const struct sctp_sm_table_entry
 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
 
-static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(
+static const struct sctp_sm_table_entry *sctp_chunk_event_lookup(
struct net *net,
enum sctp_cid cid,
enum sctp_state state);
 
 
-static const sctp_sm_table_entry_t bug = {
+static const struct sctp_sm_table_entry bug = {
.fn = sctp_sf_bug,
.name = "sctp_sf_bug"
 };
 
 #define DO_LOOKUP(_max, _type, _table) \
 ({ \
-   const sctp_sm_table_entry_t *rtn;   \
+   const struct sctp_sm_table_entry *rtn;  \
\
if ((event_subtype._type > (_max))) {   \
pr_warn("table %p possible attack: event %d exceeds max %d\n", \
@@ -77,7 +77,7 @@ static const sctp_sm_table_entry_t bug = {
rtn;\
 })
 
-const sctp_sm_table_entry_t *sctp_sm_lookup_event(
+const struct sctp_sm_table_entry *sctp_sm_lookup_event(
struct net *net,
enum sctp_event event_type,
enum sctp_state state,
@@ -394,7 +394,8 @@ const sctp_sm_table_entry_t *sctp_sm_lookup_event(
  *
  * For base protocol (RFC 2960).
  */
-static const sctp_sm_table_entry_t 
chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
+static const struct sctp_sm_table_entry
+chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
TYPE_SCTP_DATA,
TYPE_SCTP_INIT,
TYPE_SCTP_INIT_ACK,
@@ -453,7 +454,8 @@ static const sctp_sm_table_entry_t 
chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][
 /* The primary index for this table is the chunk type.
  * The secondary index for this table is the state.
  */
-static const sctp_sm_table_entry_t 
addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
+static const struct sctp_sm_table_entry

[PATCH net-next 13/14] sctp: remove the typedef sctp_disposition_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_disposition_t, and
replace with enum sctp_disposition in the places where it's
using this typedef.

It's also to fix the indent for many functions' defination.

Signed-off-by: Xin Long 
---
 include/net/sctp/sm.h|   19 +-
 net/sctp/probe.c |   13 +-
 net/sctp/sm_sideeffect.c |   50 +-
 net/sctp/sm_statefuns.c  | 1316 --
 4 files changed, 717 insertions(+), 681 deletions(-)

diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 7ad2402..33077f3 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -53,7 +53,7 @@
 /*
  * Possible values for the disposition are:
  */
-typedef enum {
+enum sctp_disposition {
SCTP_DISPOSITION_DISCARD,/* No further processing.  */
SCTP_DISPOSITION_CONSUME,/* Process return values normally.  */
SCTP_DISPOSITION_NOMEM,  /* We ran out of memory--recover.  */
@@ -63,14 +63,15 @@ typedef enum {
SCTP_DISPOSITION_NOT_IMPL,   /* This entry is not implemented.  */
SCTP_DISPOSITION_ERROR,  /* This is plain old user error.  */
SCTP_DISPOSITION_BUG,/* This is a bug.  */
-} sctp_disposition_t;
-
-typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
- const struct sctp_endpoint *,
- const struct sctp_association *,
- const union sctp_subtype type,
- void *arg,
- struct sctp_cmd_seq *);
+};
+
+typedef enum sctp_disposition (sctp_state_fn_t) (
+   struct net *net,
+   const struct sctp_endpoint *ep,
+   const struct sctp_association *asoc,
+   const union sctp_subtype type,
+   void *arg,
+   struct sctp_cmd_seq *commands);
 typedef void (sctp_timer_event_t) (unsigned long);
 struct sctp_sm_table_entry {
sctp_state_fn_t *fn;
diff --git a/net/sctp/probe.c b/net/sctp/probe.c
index 34097a1..1280f85 100644
--- a/net/sctp/probe.c
+++ b/net/sctp/probe.c
@@ -127,12 +127,13 @@ static const struct file_operations sctpprobe_fops = {
.llseek = noop_llseek,
 };
 
-static sctp_disposition_t jsctp_sf_eat_sack(struct net *net,
-   const struct sctp_endpoint *ep,
-   const struct sctp_association *asoc,
-   const union sctp_subtype type,
-   void *arg,
-   struct sctp_cmd_seq *commands)
+static enum sctp_disposition jsctp_sf_eat_sack(
+   struct net *net,
+   const struct sctp_endpoint *ep,
+   const struct sctp_association *asoc,
+   const union sctp_subtype type,
+   void *arg,
+   struct sctp_cmd_seq *commands)
 {
struct sctp_chunk *chunk = arg;
struct sk_buff *skb = chunk->skb;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 2bc1204..e6a2974 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -57,7 +57,7 @@ static int sctp_cmd_interpreter(enum sctp_event event_type,
struct sctp_endpoint *ep,
struct sctp_association *asoc,
void *event_arg,
-   sctp_disposition_t status,
+   enum sctp_disposition status,
struct sctp_cmd_seq *commands,
gfp_t gfp);
 static int sctp_side_effects(enum sctp_event event_type,
@@ -66,7 +66,7 @@ static int sctp_side_effects(enum sctp_event event_type,
 struct sctp_endpoint *ep,
 struct sctp_association **asoc,
 void *event_arg,
-sctp_disposition_t status,
+enum sctp_disposition status,
 struct sctp_cmd_seq *commands,
 gfp_t gfp);
 
@@ -97,8 +97,8 @@ static void sctp_do_ecn_ce_work(struct sctp_association *asoc,
  * that was originally marked with the CE bit.
  */
 static struct sctp_chunk *sctp_do_ecn_ecne_work(struct sctp_association *asoc,
-  __u32 lowest_tsn,
-  struct sctp_chunk *chunk)
+   __u32 

[PATCH net-next 09/14] sctp: remove the typedef sctp_arg_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_arg_t, and
replace with union sctp_arg in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/command.h | 26 +-
 net/sctp/sm_statefuns.c|  2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index cbf6798..f5fc425 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -117,7 +117,7 @@ typedef enum {
  */
 #define SCTP_MAX_NUM_COMMANDS 20
 
-typedef union {
+union sctp_arg {
void *zero_all; /* Set to NULL to clear the entire union */
__s32 i32;
__u32 u32;
@@ -137,24 +137,24 @@ typedef union {
struct sctp_packet *packet;
struct sctp_sackhdr *sackh;
struct sctp_datamsg *msg;
-} sctp_arg_t;
+};
 
 /* We are simulating ML type constructors here.
  *
  * SCTP_ARG_CONSTRUCTOR(NAME, TYPE, ELT) builds a function called
  * SCTP_NAME() which takes an argument of type TYPE and returns an
- * sctp_arg_t.  It does this by inserting the sole argument into the
- * ELT union element of a local sctp_arg_t.
+ * union sctp_arg.  It does this by inserting the sole argument into
+ * the ELT union element of a local union sctp_arg.
  *
  * E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg),
- * which takes an __s32 and returns a sctp_arg_t containing the
+ * which takes an __s32 and returns a union sctp_arg containing the
  * __s32.  So, after foo = SCTP_I32(arg), foo.i32 == arg.
  */
 
 #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \
-static inline sctp_arg_t   \
+static inline union sctp_arg   \
 SCTP_## name (type arg)\
-{ sctp_arg_t retval;\
+{ union sctp_arg retval;\
   retval.zero_all = NULL;\
   retval.elt = arg;\
   return retval;\
@@ -179,25 +179,25 @@ SCTP_ARG_CONSTRUCTOR(PACKET,  struct sctp_packet *, 
packet)
 SCTP_ARG_CONSTRUCTOR(SACKH,struct sctp_sackhdr *, sackh)
 SCTP_ARG_CONSTRUCTOR(DATAMSG,  struct sctp_datamsg *, msg)
 
-static inline sctp_arg_t SCTP_FORCE(void)
+static inline union sctp_arg SCTP_FORCE(void)
 {
return SCTP_I32(1);
 }
 
-static inline sctp_arg_t SCTP_NOFORCE(void)
+static inline union sctp_arg SCTP_NOFORCE(void)
 {
return SCTP_I32(0);
 }
 
-static inline sctp_arg_t SCTP_NULL(void)
+static inline union sctp_arg SCTP_NULL(void)
 {
-   sctp_arg_t retval;
+   union sctp_arg retval;
retval.zero_all = NULL;
return retval;
 }
 
 struct sctp_cmd {
-   sctp_arg_t obj;
+   union sctp_arg obj;
sctp_verb_t verb;
 };
 
@@ -226,7 +226,7 @@ static inline int sctp_init_cmd_seq(struct sctp_cmd_seq 
*seq)
  * to wrap data which goes in the obj argument.
  */
 static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq, sctp_verb_t verb,
-  sctp_arg_t obj)
+  union sctp_arg obj)
 {
struct sctp_cmd *cmd = seq->last_used_slot - 1;
 
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 93b6f42..3394c4d 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -2975,8 +2975,8 @@ sctp_disposition_t sctp_sf_eat_data_6_2(struct net *net,
void *arg,
struct sctp_cmd_seq *commands)
 {
+   union sctp_arg force = SCTP_NOFORCE();
struct sctp_chunk *chunk = arg;
-   sctp_arg_t force = SCTP_NOFORCE();
int error;
 
if (!sctp_vtag_verify(chunk, asoc)) {
-- 
2.1.0



[PATCH net-next 10/14] sctp: remove the typedef sctp_verb_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_verb_t, and
replace with enum sctp_verb in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/command.h | 10 +-
 net/sctp/sm_statefuns.c|  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index f5fc425..b55c6a4 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -40,7 +40,7 @@
 #include 
 
 
-typedef enum {
+enum sctp_verb {
SCTP_CMD_NOP = 0,   /* Do nothing. */
SCTP_CMD_NEW_ASOC,  /* Register a new association.  */
SCTP_CMD_DELETE_TCB,/* Delete the current association. */
@@ -108,7 +108,7 @@ typedef enum {
SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/
SCTP_CMD_SET_ASOC,   /* Restore association context */
SCTP_CMD_LAST
-} sctp_verb_t;
+};
 
 /* How many commands can you put in an struct sctp_cmd_seq?
  * This is a rather arbitrary number, ideally derived from a careful
@@ -198,7 +198,7 @@ static inline union sctp_arg SCTP_NULL(void)
 
 struct sctp_cmd {
union sctp_arg obj;
-   sctp_verb_t verb;
+   enum sctp_verb verb;
 };
 
 struct sctp_cmd_seq {
@@ -225,8 +225,8 @@ static inline int sctp_init_cmd_seq(struct sctp_cmd_seq 
*seq)
  * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
  * to wrap data which goes in the obj argument.
  */
-static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq, sctp_verb_t verb,
-  union sctp_arg obj)
+static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq,
+  enum sctp_verb verb, union sctp_arg obj)
 {
struct sctp_cmd *cmd = seq->last_used_slot - 1;
 
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 3394c4d..adc1dde 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6205,7 +6205,7 @@ static int sctp_eat_data(const struct sctp_association 
*asoc,
struct sctp_datahdr *data_hdr;
struct sctp_chunk *err;
size_t datalen;
-   sctp_verb_t deliver;
+   enum sctp_verb deliver;
int tmp;
__u32 tsn;
struct sctp_tsnmap *map = (struct sctp_tsnmap *)>peer.tsn_map;
-- 
2.1.0



[PATCH net-next 05/14] sctp: remove the typedef sctp_dbg_objcnt_entry_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_dbg_objcnt_entry_t, and
replace with struct sctp_dbg_objcnt_entry in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h | 4 ++--
 net/sctp/objcnt.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index e171d3a..b6d75b3 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1992,9 +1992,9 @@ struct sctp_cmsgs {
 };
 
 /* Structure for tracking memory objects */
-typedef struct {
+struct sctp_dbg_objcnt_entry {
char *label;
atomic_t *counter;
-} sctp_dbg_objcnt_entry_t;
+};
 
 #endif /* __sctp_structs_h__ */
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c
index 105ac33..aeea6da 100644
--- a/net/sctp/objcnt.c
+++ b/net/sctp/objcnt.c
@@ -57,7 +57,7 @@ SCTP_DBG_OBJCNT(keys);
 /* An array to make it easy to pretty print the debug information
  * to the proc fs.
  */
-static sctp_dbg_objcnt_entry_t sctp_dbg_objcnt[] = {
+static struct sctp_dbg_objcnt_entry sctp_dbg_objcnt[] = {
SCTP_DBG_OBJCNT_ENTRY(sock),
SCTP_DBG_OBJCNT_ENTRY(ep),
SCTP_DBG_OBJCNT_ENTRY(assoc),
-- 
2.1.0



[PATCH net-next 08/14] sctp: remove the typedef sctp_cmd_seq_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_cmd_seq_t, and
replace with struct sctp_cmd_seq in the places where it's
using this typedef.

Note that it doesn't fix many indents although it should,
as sctp_disposition_t's removal would mess them up again.
So better to fix them when removing sctp_disposition_t in
the later patch.

Signed-off-by: Xin Long 
---
 include/net/sctp/command.h |  14 +--
 include/net/sctp/sm.h  |   2 +-
 net/sctp/probe.c   |   2 +-
 net/sctp/sm_sideeffect.c   |  54 ++--
 net/sctp/sm_statefuns.c| 216 +++--
 5 files changed, 145 insertions(+), 143 deletions(-)

diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 4e9e589..cbf6798 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -110,7 +110,7 @@ typedef enum {
SCTP_CMD_LAST
 } sctp_verb_t;
 
-/* How many commands can you put in an sctp_cmd_seq_t?
+/* How many commands can you put in an struct sctp_cmd_seq?
  * This is a rather arbitrary number, ideally derived from a careful
  * analysis of the state functions, but in reality just taken from
  * thin air in the hopes othat we don't trigger a kernel panic.
@@ -201,17 +201,17 @@ struct sctp_cmd {
sctp_verb_t verb;
 };
 
-typedef struct {
+struct sctp_cmd_seq {
struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS];
struct sctp_cmd *last_used_slot;
struct sctp_cmd *next_cmd;
-} sctp_cmd_seq_t;
+};
 
 
 /* Initialize a block of memory as a command sequence.
  * Return 0 if the initialization fails.
  */
-static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
+static inline int sctp_init_cmd_seq(struct sctp_cmd_seq *seq)
 {
/* cmds[] is filled backwards to simplify the overflow BUG() check */
seq->last_used_slot = seq->cmds + SCTP_MAX_NUM_COMMANDS;
@@ -220,12 +220,12 @@ static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
 }
 
 
-/* Add a command to an sctp_cmd_seq_t.
+/* Add a command to an struct sctp_cmd_seq.
  *
  * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
  * to wrap data which goes in the obj argument.
  */
-static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,
+static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq, sctp_verb_t verb,
   sctp_arg_t obj)
 {
struct sctp_cmd *cmd = seq->last_used_slot - 1;
@@ -240,7 +240,7 @@ static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, 
sctp_verb_t verb,
 /* Return the next command structure in an sctp_cmd_seq.
  * Return NULL at the end of the sequence.
  */
-static inline struct sctp_cmd *sctp_next_cmd(sctp_cmd_seq_t *seq)
+static inline struct sctp_cmd *sctp_next_cmd(struct sctp_cmd_seq *seq)
 {
if (seq->next_cmd <= seq->last_used_slot)
return NULL;
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 1e7651c..9af64b9 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -75,7 +75,7 @@ typedef sctp_disposition_t (sctp_state_fn_t) (struct net *,
  const struct sctp_association *,
  const union sctp_subtype type,
  void *arg,
- sctp_cmd_seq_t *);
+ struct sctp_cmd_seq *);
 typedef void (sctp_timer_event_t) (unsigned long);
 typedef struct {
sctp_state_fn_t *fn;
diff --git a/net/sctp/probe.c b/net/sctp/probe.c
index 43837df..34097a1 100644
--- a/net/sctp/probe.c
+++ b/net/sctp/probe.c
@@ -132,7 +132,7 @@ static sctp_disposition_t jsctp_sf_eat_sack(struct net *net,
const struct sctp_association *asoc,
const union sctp_subtype type,
void *arg,
-   sctp_cmd_seq_t *commands)
+   struct sctp_cmd_seq *commands)
 {
struct sctp_chunk *chunk = arg;
struct sk_buff *skb = chunk->skb;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 0cb3d5a..6dd5934 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -58,7 +58,7 @@ static int sctp_cmd_interpreter(enum sctp_event event_type,
struct sctp_association *asoc,
void *event_arg,
sctp_disposition_t status,
-   sctp_cmd_seq_t *commands,
+   struct sctp_cmd_seq *commands,
gfp_t gfp);
 static int sctp_side_effects(enum sctp_event event_type,
 union sctp_subtype subtype,
@@ -67,7 +67,7 @@ static int sctp_side_effects(enum sctp_event event_type,
 struct sctp_association **asoc,

[PATCH net-next 06/14] sctp: remove the typedef sctp_socket_type_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_socket_type_t, and
replace with enum sctp_socket_type in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/sctp.h| 3 ++-
 include/net/sctp/structs.h | 6 +++---
 net/sctp/socket.c  | 7 ---
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 24ff793..06b4f51 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -550,7 +550,8 @@ static inline int sctp_ep_hashfn(struct net *net, __u16 
lport)
 
 /* Is a socket of this style? */
 #define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
-static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style)
+static inline int __sctp_style(const struct sock *sk,
+  enum sctp_socket_type style)
 {
return sctp_sk(sk)->type == style;
 }
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index b6d75b3..0477945 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -150,18 +150,18 @@ extern struct sctp_globals {
 #define sctp_checksum_disable  (sctp_globals.checksum_disable)
 
 /* SCTP Socket type: UDP or TCP style. */
-typedef enum {
+enum sctp_socket_type {
SCTP_SOCKET_UDP = 0,
SCTP_SOCKET_UDP_HIGH_BANDWIDTH,
SCTP_SOCKET_TCP
-} sctp_socket_type_t;
+};
 
 /* Per socket SCTP information. */
 struct sctp_sock {
/* inet_sock has to be the first member of sctp_sock */
struct inet_sock inet;
/* What kind of a socket is this? */
-   sctp_socket_type_t type;
+   enum sctp_socket_type type;
 
/* PF_ family specific functions.  */
struct sctp_pf *pf;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 0181906..c01af72 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -100,8 +100,9 @@ static int sctp_send_asconf(struct sctp_association *asoc,
struct sctp_chunk *chunk);
 static int sctp_do_bind(struct sock *, union sctp_addr *, int);
 static int sctp_autobind(struct sock *sk);
-static void sctp_sock_migrate(struct sock *, struct sock *,
- struct sctp_association *, sctp_socket_type_t);
+static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
+ struct sctp_association *assoc,
+ enum sctp_socket_type type);
 
 static unsigned long sctp_memory_pressure;
 static atomic_long_t sctp_memory_allocated;
@@ -8086,7 +8087,7 @@ static inline void sctp_copy_descendant(struct sock 
*sk_to,
  */
 static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
  struct sctp_association *assoc,
- sctp_socket_type_t type)
+ enum sctp_socket_type type)
 {
struct sctp_sock *oldsp = sctp_sk(oldsk);
struct sctp_sock *newsp = sctp_sk(newsk);
-- 
2.1.0



[PATCH net-next 04/14] sctp: remove the typedef sctp_cmsgs_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_cmsgs_t, and
replace with struct sctp_cmsgs in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h | 4 ++--
 net/sctp/socket.c  | 9 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 937187f..e171d3a 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1985,11 +1985,11 @@ int sctp_cmp_addr_exact(const union sctp_addr *ss1,
 struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc);
 
 /* A convenience structure to parse out SCTP specific CMSGs. */
-typedef struct sctp_cmsgs {
+struct sctp_cmsgs {
struct sctp_initmsg *init;
struct sctp_sndrcvinfo *srinfo;
struct sctp_sndinfo *sinfo;
-} sctp_cmsgs_t;
+};
 
 /* Structure for tracking memory objects */
 typedef struct {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a1e2113..0181906 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1593,7 +1593,8 @@ static int sctp_error(struct sock *sk, int flags, int err)
  */
 /* BUG:  We do not implement the equivalent of sk_stream_wait_memory(). */
 
-static int sctp_msghdr_parse(const struct msghdr *, sctp_cmsgs_t *);
+static int sctp_msghdr_parse(const struct msghdr *msg,
+struct sctp_cmsgs *cmsgs);
 
 static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
 {
@@ -1609,7 +1610,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t msg_len)
struct sctp_sndrcvinfo *sinfo;
struct sctp_initmsg *sinit;
sctp_assoc_t associd = 0;
-   sctp_cmsgs_t cmsgs = { NULL };
+   struct sctp_cmsgs cmsgs = { NULL };
enum sctp_scope scope;
bool fill_sinfo_ttl = false, wait_connect = false;
struct sctp_datamsg *datamsg;
@@ -7445,10 +7446,10 @@ static int sctp_autobind(struct sock *sk)
  * msg_control
  * points here
  */
-static int sctp_msghdr_parse(const struct msghdr *msg, sctp_cmsgs_t *cmsgs)
+static int sctp_msghdr_parse(const struct msghdr *msg, struct sctp_cmsgs 
*cmsgs)
 {
-   struct cmsghdr *cmsg;
struct msghdr *my_msg = (struct msghdr *)msg;
+   struct cmsghdr *cmsg;
 
for_each_cmsghdr(cmsg, my_msg) {
if (!CMSG_OK(my_msg, cmsg))
-- 
2.1.0



[PATCH net-next 07/14] sctp: remove the typedef sctp_cmd_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_cmd_t, and
replace with enum sctp_cmd in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/command.h | 14 +++---
 net/sctp/sm_sideeffect.c   |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 376cb78..4e9e589 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -196,15 +196,15 @@ static inline sctp_arg_t SCTP_NULL(void)
return retval;
 }
 
-typedef struct {
+struct sctp_cmd {
sctp_arg_t obj;
sctp_verb_t verb;
-} sctp_cmd_t;
+};
 
 typedef struct {
-   sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS];
-   sctp_cmd_t *last_used_slot;
-   sctp_cmd_t *next_cmd;
+   struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS];
+   struct sctp_cmd *last_used_slot;
+   struct sctp_cmd *next_cmd;
 } sctp_cmd_seq_t;
 
 
@@ -228,7 +228,7 @@ static inline int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
 static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb,
   sctp_arg_t obj)
 {
-   sctp_cmd_t *cmd = seq->last_used_slot - 1;
+   struct sctp_cmd *cmd = seq->last_used_slot - 1;
 
BUG_ON(cmd < seq->cmds);
 
@@ -240,7 +240,7 @@ static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, 
sctp_verb_t verb,
 /* Return the next command structure in an sctp_cmd_seq.
  * Return NULL at the end of the sequence.
  */
-static inline sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
+static inline struct sctp_cmd *sctp_next_cmd(sctp_cmd_seq_t *seq)
 {
if (seq->next_cmd <= seq->last_used_slot)
return NULL;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 5e8e418..0cb3d5a 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -1277,7 +1277,7 @@ static int sctp_cmd_interpreter(enum sctp_event 
event_type,
struct sctp_sock *sp = sctp_sk(sk);
int error = 0;
int force;
-   sctp_cmd_t *cmd;
+   struct sctp_cmd *cmd;
struct sctp_chunk *new_obj;
struct sctp_chunk *chunk = NULL;
struct sctp_packet *packet;
-- 
2.1.0



[PATCH net-next 03/14] sctp: remove the typedef sctp_endpoint_type_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_endpoint_type_t, and
replace with enum sctp_endpoint_type in the places where it's
using this typedef.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 60033a2..937187f 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1142,10 +1142,10 @@ int sctp_is_ep_boundall(struct sock *sk);
 
 
 /* What type of endpoint?  */
-typedef enum {
+enum sctp_endpoint_type {
SCTP_EP_TYPE_SOCKET,
SCTP_EP_TYPE_ASSOCIATION,
-} sctp_endpoint_type_t;
+};
 
 /*
  * A common base class to bridge the implmentation view of a
@@ -1169,7 +1169,7 @@ struct sctp_ep_common {
int hashent;
 
/* Runtime type information.  What kind of endpoint is this? */
-   sctp_endpoint_type_t type;
+   enum sctp_endpoint_type type;
 
/* Some fields to help us manage this object.
 *   refcnt   - Reference count access to this object.
-- 
2.1.0



[PATCH net-next 01/14] sctp: remove the unused typedef sctp_packet_phandler_t

2017-08-10 Thread Xin Long
Remove this function typedef, there is even no places
using it.

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index fbe6e81..73e9509 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -657,8 +657,6 @@ struct sctp_sockaddr_entry {
 
 #define SCTP_ADDRESS_TICK_DELAY500
 
-typedef struct sctp_chunk *(sctp_packet_phandler_t)(struct sctp_association *);
-
 /* This structure holds lists of chunks as we are assembling for
  * transmission.
  */
-- 
2.1.0



[PATCH net-next 02/14] sctp: remove the typedef sctp_sender_hb_info_t

2017-08-10 Thread Xin Long
This patch is to remove the typedef sctp_sender_hb_info_t, and
replace with struct sctp_sender_hb_info in the places where it's
using this typedef.

It is also to use sizeof(variable) instead of sizeof(type).

Signed-off-by: Xin Long 
---
 include/net/sctp/structs.h |  4 ++--
 net/sctp/sm_make_chunk.c   |  6 +++---
 net/sctp/sm_sideeffect.c   |  4 ++--
 net/sctp/sm_statefuns.c| 12 +---
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 73e9509..60033a2 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -371,12 +371,12 @@ union sctp_params {
  *chunk is sent and the destination transport address to which this
  *HEARTBEAT is sent (see Section 8.3).
  */
-typedef struct sctp_sender_hb_info {
+struct sctp_sender_hb_info {
struct sctp_paramhdr param_hdr;
union sctp_addr daddr;
unsigned long sent_at;
__u64 hb_nonce;
-} sctp_sender_hb_info_t;
+};
 
 int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt,
 gfp_t gfp);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 3a8fb1d..51de638 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1142,10 +1142,10 @@ struct sctp_chunk *sctp_make_violation_max_retrans(
 
 /* Make a HEARTBEAT chunk.  */
 struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
- const struct sctp_transport *transport)
+  const struct sctp_transport *transport)
 {
+   struct sctp_sender_hb_info hbinfo;
struct sctp_chunk *retval;
-   sctp_sender_hb_info_t hbinfo;
 
retval = sctp_make_control(asoc, SCTP_CID_HEARTBEAT, 0,
   sizeof(hbinfo), GFP_ATOMIC);
@@ -1154,7 +1154,7 @@ struct sctp_chunk *sctp_make_heartbeat(const struct 
sctp_association *asoc,
goto nodata;
 
hbinfo.param_hdr.type = SCTP_PARAM_HEARTBEAT_INFO;
-   hbinfo.param_hdr.length = htons(sizeof(sctp_sender_hb_info_t));
+   hbinfo.param_hdr.length = htons(sizeof(hbinfo));
hbinfo.daddr = transport->ipaddr;
hbinfo.sent_at = jiffies;
hbinfo.hb_nonce = transport->hb_nonce;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 4a12d29..5e8e418 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -714,7 +714,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
  struct sctp_transport *t,
  struct sctp_chunk *chunk)
 {
-   sctp_sender_hb_info_t *hbinfo;
+   struct sctp_sender_hb_info *hbinfo;
int was_unconfirmed = 0;
 
/* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the
@@ -768,7 +768,7 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
if (t->rto_pending == 0)
t->rto_pending = 1;
 
-   hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;
+   hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data;
sctp_transport_update_rto(t, (jiffies - hbinfo->sent_at));
 
/* Update the heartbeat timer.  */
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index ac6aaa0..af93419 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1155,27 +1155,25 @@ sctp_disposition_t sctp_sf_backbeat_8_3(struct net *net,
void *arg,
sctp_cmd_seq_t *commands)
 {
+   struct sctp_sender_hb_info *hbinfo;
struct sctp_chunk *chunk = arg;
-   union sctp_addr from_addr;
struct sctp_transport *link;
-   sctp_sender_hb_info_t *hbinfo;
unsigned long max_interval;
+   union sctp_addr from_addr;
 
if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
 
/* Make sure that the HEARTBEAT-ACK chunk has a valid length.  */
if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_chunkhdr) +
-   sizeof(sctp_sender_hb_info_t)))
+   sizeof(*hbinfo)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
  commands);
 
-   hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;
+   hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data;
/* Make sure that the length of the parameter is what we expect */
-   if (ntohs(hbinfo->param_hdr.length) !=
-   sizeof(sctp_sender_hb_info_t)) {
+   if (ntohs(hbinfo->param_hdr.length) != sizeof(*hbinfo))
return SCTP_DISPOSITION_DISCARD;
-   }
 
from_addr = hbinfo->daddr;
link = sctp_assoc_lookup_paddr(asoc, _addr);
-- 
2.1.0



[PATCH net-next 00/14] sctp: remove typedefs from structures part 6

2017-08-10 Thread Xin Long
As we know, typedef is suggested not to use in kernel, even checkpatch.pl
also gives warnings about it. Now sctp is using it for many structures.

All this kind of typedef's using should be removed. This patchset is the
part 6 to remove all typedefs in include/net/sctp/structs.h, command.h
and sm.h.

Just as the part 1-5, No any code's logic would be changed in these patches,
only cleaning up.

Note that this is the last part for this typedef cleaning up. after this
patchset, no more inappropriate typedefs in sctp. It's also to tidy some
codes when removing them, like fixing many indents, reodering some local
params, especially in the last 2 patches.

Xin Long (14):
  sctp: remove the unused typedef sctp_packet_phandler_t
  sctp: remove the typedef sctp_sender_hb_info_t
  sctp: remove the typedef sctp_endpoint_type_t
  sctp: remove the typedef sctp_cmsgs_t
  sctp: remove the typedef sctp_dbg_objcnt_entry_t
  sctp: remove the typedef sctp_socket_type_t
  sctp: remove the typedef sctp_cmd_t
  sctp: remove the typedef sctp_cmd_seq_t
  sctp: remove the typedef sctp_arg_t
  sctp: remove the typedef sctp_verb_t
  sctp: remove the unused typedef sctp_sm_command_t
  sctp: remove the typedef sctp_sm_table_entry_t
  sctp: remove the typedef sctp_disposition_t
  sctp: fix some indents in sm_make_chunk.c

 include/net/sctp/command.h |   58 +-
 include/net/sctp/sctp.h|3 +-
 include/net/sctp/sm.h  |  188 +++---
 include/net/sctp/structs.h |   26 +-
 net/sctp/objcnt.c  |2 +-
 net/sctp/probe.c   |   13 +-
 net/sctp/sm_make_chunk.c   |  354 ++--
 net/sctp/sm_sideeffect.c   |  106 ++--
 net/sctp/sm_statefuns.c| 1368 +++-
 net/sctp/sm_statetable.c   |   42 +-
 net/sctp/socket.c  |   16 +-
 11 files changed, 1104 insertions(+), 1072 deletions(-)

-- 
2.1.0



[PATCH iproute2 net-next] config: put CFLAGS/LDLIBS in config.mk

2017-08-10 Thread Stephen Hemminger
This renames Config to config.mk and includes more Make input.
Now configure generates all the required CFLAGS and LDLIBS for
the optional libraries.

Also, use pkg-config to test for libelf, rather than using a test
program. This makes it consistent with other libraries.

Signed-off-by: Stephen Hemminger 
---
 .gitignore   |  1 -
 Makefile |  8 +++---
 README   |  5 ++--
 bridge/Makefile  | 11 +---
 configure| 81 
 devlink/Makefile |  3 ++-
 genl/Makefile|  7 +
 ip/Makefile  | 15 +--
 lib/Makefile | 14 +-
 misc/Makefile| 16 +--
 netem/Makefile   |  7 +
 tc/Makefile  | 15 +--
 tipc/Makefile|  5 ++--
 13 files changed, 59 insertions(+), 129 deletions(-)

diff --git a/.gitignore b/.gitignore
index c3b8d386450b..308aec6ba80b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
 static-syms.h
 config.*
-Config
 *.o
 *.a
 *.so
diff --git a/Makefile b/Makefile
index 1f88f7f56691..b0ea6794285c 100644
--- a/Makefile
+++ b/Makefile
@@ -54,12 +54,12 @@ SUBDIRS=lib ip tc bridge misc netem genl tipc devlink man
 LIBNETLINK=../lib/libnetlink.a ../lib/libutil.a
 LDLIBS += $(LIBNETLINK)
 
-all: Config
+all: config.mk
@set -e; \
for i in $(SUBDIRS); \
do echo; echo $$i; $(MAKE) $(MFLAGS) -C $$i; done
 
-Config:
+config.mk:
sh configure $(KERNEL_INCLUDE)
 
 install: all
@@ -88,9 +88,9 @@ clean:
do $(MAKE) $(MFLAGS) -C $$i clean; done
 
 clobber:
-   touch Config
+   touch config.mk
$(MAKE) $(MFLAGS) clean
-   rm -f Config cscope.*
+   rm -f config.mk cscope.*
 
 distclean: clobber
 
diff --git a/README b/README
index c7a5118dd6d0..386fbaf6cf7d 100644
--- a/README
+++ b/README
@@ -21,8 +21,9 @@ database routines.  Often this is in the db-devel package.
 
 2. make
 
-The makefile will automatically build a Config file which
-contains whether or not ATM is available, etc.
+The makefile will automatically build a config.mk file which
+contains definitions of libraries that may or may not be available
+on the system such as: ATM, ELF, MNL, and SELINUX.
 
 3. To make documentation, cd to doc/ directory , then
look at start of Makefile and set correct values for
diff --git a/bridge/Makefile b/bridge/Makefile
index fa448ea2e4fa..b2ae0a4ed04d 100644
--- a/bridge/Makefile
+++ b/bridge/Makefile
@@ -1,15 +1,6 @@
 BROBJ = bridge.o fdb.o monitor.o link.o mdb.o vlan.o
 
-include ../Config
-
-ifeq ($(IP_CONFIG_SETNS),y)
-   CFLAGS += -DHAVE_SETNS
-endif
-
-ifeq ($(HAVE_MNL),y)
-   CFLAGS += -DHAVE_LIBMNL $(shell $(PKG_CONFIG) libmnl --cflags)
-   LDLIBS += $(shell $(PKG_CONFIG) libmnl --libs)
-endif
+include ../config.mk
 
 all: bridge
 
diff --git a/configure b/configure
index 88cbdb825689..7be8fb113cc9 100755
--- a/configure
+++ b/configure
@@ -3,6 +3,9 @@
 #
 INCLUDE=${1:-"$PWD/include"}
 
+# Output file which is input to Makefile
+CONFIG=config.mk
+
 # Make a temp directory in build tree.
 TMPDIR=$(mktemp -d config.XX)
 trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT QUIT TERM
@@ -10,7 +13,7 @@ trap 'status=$?; rm -rf $TMPDIR; exit $status' EXIT HUP INT 
QUIT TERM
 check_prog()
 {
 echo -n "$2"
-command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> Config; echo "yes") || 
(echo "no"; return 1)
+command -v $1 >/dev/null 2>&1 && (echo "$3:=y" >> $CONFIG; echo "yes") || 
(echo "no"; return 1)
 }
 
 check_docs()
@@ -30,9 +33,9 @@ check_toolchain()
 : ${PKG_CONFIG:=pkg-config}
 : ${AR=ar}
 : ${CC=gcc}
-echo "PKG_CONFIG:=${PKG_CONFIG}" >>Config
-echo "AR:=${AR}" >>Config
-echo "CC:=${CC}" >>Config
+echo "PKG_CONFIG:=${PKG_CONFIG}" >>$CONFIG
+echo "AR:=${AR}" >>$CONFIG
+echo "CC:=${CC}" >>$CONFIG
 }
 
 check_atm()
@@ -49,7 +52,7 @@ EOF
 $CC -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1
 if [ $? -eq 0 ]
 then
-   echo "TC_CONFIG_ATM:=y" >>Config
+   echo "TC_CONFIG_ATM:=y" >>$CONFIG
echo yes
 else
echo no
@@ -61,7 +64,7 @@ check_xtables()
 {
if ! ${PKG_CONFIG} xtables --exists
then
-   echo "TC_CONFIG_NO_XT:=y" >>Config
+   echo "TC_CONFIG_NO_XT:=y" >>$CONFIG
fi
 }
 
@@ -90,7 +93,7 @@ EOF
 if $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL \
$(${PKG_CONFIG} xtables --cflags --libs) -ldl >/dev/null 2>&1
 then
-   echo "TC_CONFIG_XT:=y" >>Config
+   echo "TC_CONFIG_XT:=y" >>$CONFIG
echo "using xtables"
 fi
 rm -f $TMPDIR/ipttest.c $TMPDIR/ipttest
@@ -99,7 +102,7 @@ EOF
 check_xt_old()
 {
 # bail if previous XT checks has already succeded.
-if grep -q TC_CONFIG_XT Config
+if grep -q TC_CONFIG_XT $CONFIG
 then
return
 fi
@@ -129,7 +132,7 @@ EOF
 $CC -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl 
>/dev/null 2>&1
  

[PATCH] selftests: bpf: add check for ip XDP redirect

2017-08-10 Thread William Tu
Kernel test robot reports error when running test_xdp_redirect.sh.
Check if ip tool supports xdpgeneric, if not, skip the test.

Signed-off-by: William Tu 
Cc: Daniel Borkmann 
Cc: John Fastabend 
---
 tools/testing/selftests/bpf/test_xdp_redirect.sh | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_xdp_redirect.sh 
b/tools/testing/selftests/bpf/test_xdp_redirect.sh
index d8c73ed6e040..c5a8b7173c12 100755
--- a/tools/testing/selftests/bpf/test_xdp_redirect.sh
+++ b/tools/testing/selftests/bpf/test_xdp_redirect.sh
@@ -23,6 +23,11 @@ cleanup()
ip netns del ns2 2> /dev/null
 }
 
+ip link set dev lo xdpgeneric off 2>/dev/null > /dev/null
+if [ $? -ne 0 ];then
+echo "selftests: [SKIP] Could not run test without the ip xdpgeneric 
support"
+exit 0
+fi
 set -e
 
 ip netns add ns1
-- 
2.7.4



Re: [PATCH iproute2 master] bpf: unbreak libelf linkage for bpf obj loader

2017-08-10 Thread Stephen Hemminger
On Thu, 10 Aug 2017 10:44:13 +0200
Daniel Borkmann  wrote:

> On 08/10/2017 02:35 AM, Stephen Hemminger wrote:
> > On Thu, 10 Aug 2017 00:15:41 +0200
> > Daniel Borkmann  wrote:
> >  
> >> Commit 69fed534a533 ("change how Config is used in Makefile's") moved
> >> HAVE_MNL specific CFLAGS/LDLIBS for building with libmnl out of the
> >> top level Makefile into sub-Makefiles. However, it also removed the
> >> HAVE_ELF specific CFLAGS/LDLIBS entirely, which breaks the BPF object
> >> loader for tc and ip with "No ELF library support compiled in." despite
> >> having libelf detected in configure script. Fix it similarly as in
> >> 69fed534a533 for HAVE_ELF.
> >>
> >> Fixes: 69fed534a533 ("change how Config is used in Makefile's")
> >> Reported-by: Jeffrey Panneman 
> >> Signed-off-by: Daniel Borkmann   
> >
> > Thanks, but I am thinking maybe a better solution long term would be to
> > move all the package specific stuff into the generated Config file.
> >
> > That way only the generation shell script would have to change.
> >
> > Also, all the flags should probably be using pkg-config to get the values.  
> 
> Sure, sounds all good, for the time being, I would like to have
> that breakage undone though, so users can work with loading BPF
> programs again on -master.
> 
> Thanks,
> Daniel

Agree. I will merge this for master, and work on better config management
in net-next.


Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information

2017-08-10 Thread James Morris
On Thu, 10 Aug 2017, Paul Moore wrote:

> On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore  wrote:
> > From: Paul Moore 
> >
> > Signed-off-by: Paul Moore 
> > ---
> >  MAINTAINERS |   24 ++--
> >  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> I'm planning on sending this up via the SELinux tree with some other
> MAINTAINERS updates, consider this more of a FYI posting.

Oops, already applied to -next.

> 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 65990909fe73..be25ebaaeec3 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -9112,15 +9112,6 @@ F:   net/*/netfilter/
> >  F: net/netfilter/
> >  F: net/bridge/br_netfilter*.c
> >
> > -NETLABEL
> > -M: Paul Moore 
> > -W: http://netlabel.sf.net
> > -L: netdev@vger.kernel.org
> > -S: Maintained
> > -F: Documentation/netlabel/
> > -F: include/net/netlabel.h
> > -F: net/netlabel/
> > -
> >  NETROM NETWORK LAYER
> >  M: Ralf Baechle 
> >  L: linux-h...@vger.kernel.org
> > @@ -9248,10 +9239,23 @@ F:  net/ipv6/
> >  F: include/net/ip*
> >  F: arch/x86/net/*
> >
> > -NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
> > +NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
> >  M: Paul Moore 
> > +W: https://github.com/netlabel
> >  L: netdev@vger.kernel.org
> > +L: linux-security-mod...@vger.kernel.org
> >  S: Maintained
> > +F: Documentation/netlabel/
> > +F: include/net/calipso.h
> > +F: include/net/cipso_ipv4.h
> > +F: include/net/netlabel.h
> > +F: include/uapi/linux/netfilter/xt_SECMARK.h
> > +F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
> > +F: net/netlabel/
> > +F: net/ipv4/cipso_ipv4.c
> > +F: net/ipv6/calipso.c
> > +F: net/netfilter/xt_CONNSECMARK.c
> > +F: net/netfilter/xt_SECMARK.c
> >
> >  NETWORKING [TLS]
> >  M: Ilya Lesokhin 
> 
> 

-- 
James Morris




Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information

2017-08-10 Thread James Morris
On Thu, 10 Aug 2017, Paul Moore wrote:

> From: Paul Moore 
> 
> Signed-off-by: Paul Moore 

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next

-- 
James Morris




[PATCH v3 net-next 2/2] wan: dscc4: convert to plain DMA API

2017-08-10 Thread Alexey Khoroshilov
Make use the dma_*() interfaces rather than the pci_*() interfaces.

Signed-off-by: Alexey Khoroshilov 
---
 drivers/net/wan/dscc4.c | 96 ++---
 1 file changed, 51 insertions(+), 45 deletions(-)

diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 8480dbf..a043fb1 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -483,20 +483,20 @@ static void dscc4_tx_print(struct net_device *dev,
 
 static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
 {
-   struct pci_dev *pdev = dpriv->pci_priv->pdev;
+   struct device *d = >pci_priv->pdev->dev;
struct TxFD *tx_fd = dpriv->tx_fd;
struct RxFD *rx_fd = dpriv->rx_fd;
struct sk_buff **skbuff;
int i;
 
-   pci_free_consistent(pdev, TX_TOTAL_SIZE, tx_fd, dpriv->tx_fd_dma);
-   pci_free_consistent(pdev, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
+   dma_free_coherent(d, TX_TOTAL_SIZE, tx_fd, dpriv->tx_fd_dma);
+   dma_free_coherent(d, RX_TOTAL_SIZE, rx_fd, dpriv->rx_fd_dma);
 
skbuff = dpriv->tx_skbuff;
for (i = 0; i < TX_RING_SIZE; i++) {
if (*skbuff) {
-   pci_unmap_single(pdev, le32_to_cpu(tx_fd->data),
-   (*skbuff)->len, PCI_DMA_TODEVICE);
+   dma_unmap_single(d, le32_to_cpu(tx_fd->data),
+(*skbuff)->len, DMA_TO_DEVICE);
dev_kfree_skb(*skbuff);
}
skbuff++;
@@ -506,8 +506,9 @@ static void dscc4_release_ring(struct dscc4_dev_priv *dpriv)
skbuff = dpriv->rx_skbuff;
for (i = 0; i < RX_RING_SIZE; i++) {
if (*skbuff) {
-   pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
-   RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
+   dma_unmap_single(d, le32_to_cpu(rx_fd->data),
+RX_MAX(HDLC_MAX_MRU),
+DMA_FROM_DEVICE);
dev_kfree_skb(*skbuff);
}
skbuff++;
@@ -519,7 +520,7 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv 
*dpriv,
 struct net_device *dev)
 {
unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE;
-   struct pci_dev *pdev = dpriv->pci_priv->pdev;
+   struct device *d = >pci_priv->pdev->dev;
struct RxFD *rx_fd = dpriv->rx_fd + dirty;
const int len = RX_MAX(HDLC_MAX_MRU);
struct sk_buff *skb;
@@ -530,8 +531,8 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv 
*dpriv,
goto err_out;
 
skb->protocol = hdlc_type_trans(skb, dev);
-   addr = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
-   if (pci_dma_mapping_error(pdev, addr))
+   addr = dma_map_single(d, skb->data, len, DMA_FROM_DEVICE);
+   if (dma_mapping_error(d, addr))
goto err_free_skb;
 
dpriv->rx_skbuff[dirty] = skb;
@@ -654,7 +655,7 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv 
*dpriv,
struct net_device *dev)
 {
struct RxFD *rx_fd = dpriv->rx_fd + dpriv->rx_current%RX_RING_SIZE;
-   struct pci_dev *pdev = dpriv->pci_priv->pdev;
+   struct device *d = >pci_priv->pdev->dev;
struct sk_buff *skb;
int pkt_len;
 
@@ -664,8 +665,8 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv 
*dpriv,
goto refill;
}
pkt_len = TO_SIZE(le32_to_cpu(rx_fd->state2));
-   pci_unmap_single(pdev, le32_to_cpu(rx_fd->data),
-RX_MAX(HDLC_MAX_MRU), PCI_DMA_FROMDEVICE);
+   dma_unmap_single(d, le32_to_cpu(rx_fd->data),
+RX_MAX(HDLC_MAX_MRU), DMA_FROM_DEVICE);
if ((skb->data[--pkt_len] & FrameOk) == FrameOk) {
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
@@ -782,8 +783,8 @@ static int dscc4_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 
rc = -ENOMEM;
 
-   priv->iqcfg = (__le32 *) pci_alloc_consistent(pdev,
-   IRQ_RING_SIZE*sizeof(__le32), >iqcfg_dma);
+   priv->iqcfg = (__le32 *)dma_alloc_coherent(>dev,
+   IRQ_RING_SIZE*sizeof(__le32), >iqcfg_dma, GFP_KERNEL);
if (!priv->iqcfg)
goto err_free_irq_5;
writel(priv->iqcfg_dma, ioaddr + IQCFG);
@@ -794,16 +795,18 @@ static int dscc4_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
 */
for (i = 0; i < dev_per_card; i++) {
dpriv = priv->root + i;
-   dpriv->iqtx = (__le32 *) pci_alloc_consistent(pdev,
-   IRQ_RING_SIZE*sizeof(u32), >iqtx_dma);
+   dpriv->iqtx = (__le32 *)dma_alloc_coherent(>dev,
+   IRQ_RING_SIZE*sizeof(u32), >iqtx_dma,
+   

[PATCH v3 net-next 1/2] wan: dscc4: add checks for dma mapping errors

2017-08-10 Thread Alexey Khoroshilov
The driver does not check if mapping dma memory succeed.
The patch adds the checks and failure handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
v2: Fix issues noted by David Miller and Francois Romieu.
v3: Improve code per Francois Romieu recommendations.
Convert to plain DMA API.

 drivers/net/wan/dscc4.c | 53 ++---
 1 file changed, 37 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 799830f..8480dbf 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -519,22 +519,30 @@ static inline int try_get_rx_skb(struct dscc4_dev_priv 
*dpriv,
 struct net_device *dev)
 {
unsigned int dirty = dpriv->rx_dirty%RX_RING_SIZE;
+   struct pci_dev *pdev = dpriv->pci_priv->pdev;
struct RxFD *rx_fd = dpriv->rx_fd + dirty;
const int len = RX_MAX(HDLC_MAX_MRU);
struct sk_buff *skb;
-   int ret = 0;
+   dma_addr_t addr;
 
skb = dev_alloc_skb(len);
+   if (!skb)
+   goto err_out;
+
+   skb->protocol = hdlc_type_trans(skb, dev);
+   addr = pci_map_single(pdev, skb->data, len, PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(pdev, addr))
+   goto err_free_skb;
+
dpriv->rx_skbuff[dirty] = skb;
-   if (skb) {
-   skb->protocol = hdlc_type_trans(skb, dev);
-   rx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
- skb->data, len, PCI_DMA_FROMDEVICE));
-   } else {
-   rx_fd->data = 0;
-   ret = -1;
-   }
-   return ret;
+   rx_fd->data = cpu_to_le32(addr);
+   return 0;
+
+err_free_skb:
+   dev_kfree_skb_any(skb);
+err_out:
+   rx_fd->data = 0;
+   return -1;
 }
 
 /*
@@ -1145,16 +1153,23 @@ static netdev_tx_t dscc4_start_xmit(struct sk_buff *skb,
  struct net_device *dev)
 {
struct dscc4_dev_priv *dpriv = dscc4_priv(dev);
-   struct dscc4_pci_priv *ppriv = dpriv->pci_priv;
+   struct pci_dev *pdev = dpriv->pci_priv->pdev;
struct TxFD *tx_fd;
+   dma_addr_t addr;
int next;
 
+   addr = pci_map_single(pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
+   if (pci_dma_mapping_error(pdev, addr)) {
+   dev_kfree_skb_any(skb);
+   dev->stats.tx_dropped++;
+   return NETDEV_TX_OK;
+   }
+
next = dpriv->tx_current%TX_RING_SIZE;
dpriv->tx_skbuff[next] = skb;
tx_fd = dpriv->tx_fd + next;
tx_fd->state = FrameEnd | TO_STATE_TX(skb->len);
-   tx_fd->data = cpu_to_le32(pci_map_single(ppriv->pdev, skb->data, 
skb->len,
-PCI_DMA_TODEVICE));
+   tx_fd->data = cpu_to_le32(addr);
tx_fd->complete = 0x;
tx_fd->jiffies = jiffies;
mb();
@@ -1887,16 +1902,22 @@ static struct sk_buff *dscc4_init_dummy_skb(struct 
dscc4_dev_priv *dpriv)
 
skb = dev_alloc_skb(DUMMY_SKB_SIZE);
if (skb) {
+   struct pci_dev *pdev = dpriv->pci_priv->pdev;
int last = dpriv->tx_dirty%TX_RING_SIZE;
struct TxFD *tx_fd = dpriv->tx_fd + last;
+   dma_addr_t addr;
 
skb->len = DUMMY_SKB_SIZE;
skb_copy_to_linear_data(skb, version,
strlen(version) % DUMMY_SKB_SIZE);
+   addr = pci_map_single(pdev, skb->data, DUMMY_SKB_SIZE,
+ PCI_DMA_TODEVICE);
+   if (pci_dma_mapping_error(pdev, addr)) {
+   dev_kfree_skb_any(skb);
+   return NULL;
+   }
tx_fd->state = FrameEnd | TO_STATE_TX(DUMMY_SKB_SIZE);
-   tx_fd->data = cpu_to_le32(pci_map_single(dpriv->pci_priv->pdev,
-skb->data, DUMMY_SKB_SIZE,
-PCI_DMA_TODEVICE));
+   tx_fd->data = cpu_to_le32(addr);
dpriv->tx_skbuff[last] = skb;
}
return skb;
-- 
2.7.4



Re: [PATCHv2 net-next iproute2] gre: add support for ERSPAN tunnel

2017-08-10 Thread Stephen Hemminger
On Thu, 10 Aug 2017 13:14:27 -0700
William Tu  wrote:

> +
> + if (greinfo[IFLA_GRE_ERSPAN_INDEX])
> + erspan_idx = 
> rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
>   }

Are you missing a ntohl() here?

It is encoded as htonl() when sending to kernel.

addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
+   addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, htonl(erspan_idx));

Is erspan_idx == 0 a reserved value?
You should only send erspan_idx to kernel if it is given on command line.


[PATCH net-next v2] vxlan: change vxlan_[config_]validate() to use netlink_ext_ack for error reporting

2017-08-10 Thread Girish Moodalbail
The kernel log is not where users expect error messages for netlink
requests; as we have extended acks now, we can replace pr_debug() with
NL_SET_ERR_MSG_ATTR().

Signed-off-by: Matthias Schiffer 
Signed-off-by: Girish Moodalbail 

---
v1 -> v2:
   - addressed, error messages rewording, comments from Jiri Benc
   - started off with what Matthias had, and I covered error reporting
 for all of the unsuccessful returns
---
 drivers/net/vxlan.c | 98 +++--
 1 file changed, 72 insertions(+), 26 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 35e84a9e..ec302cd7 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2729,12 +2729,14 @@ static int vxlan_validate(struct nlattr *tb[], struct 
nlattr *data[],
 {
if (tb[IFLA_ADDRESS]) {
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
-   pr_debug("invalid link address (not ethernet)\n");
+   NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_ADDRESS],
+   "Provided link layer address is not 
Ethernet");
return -EINVAL;
}
 
if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) {
-   pr_debug("invalid all zero ethernet address\n");
+   NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_ADDRESS],
+   "Provided Ethernet address is not 
unicast");
return -EADDRNOTAVAIL;
}
}
@@ -2742,18 +2744,27 @@ static int vxlan_validate(struct nlattr *tb[], struct 
nlattr *data[],
if (tb[IFLA_MTU]) {
u32 mtu = nla_get_u32(tb[IFLA_MTU]);
 
-   if (mtu < ETH_MIN_MTU || mtu > ETH_MAX_MTU)
+   if (mtu < ETH_MIN_MTU || mtu > ETH_MAX_MTU) {
+   NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_MTU],
+   "MTU must be between 68 and 65535");
return -EINVAL;
+   }
}
 
-   if (!data)
+   if (!data) {
+   NL_SET_ERR_MSG(extack,
+  "Not enough attributes provided to perform the 
operation");
return -EINVAL;
+   }
 
if (data[IFLA_VXLAN_ID]) {
u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
 
-   if (id >= VXLAN_N_VID)
+   if (id >= VXLAN_N_VID) {
+   NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_ID],
+   "VXLAN ID must be lower than 
16777216");
return -ERANGE;
+   }
}
 
if (data[IFLA_VXLAN_PORT_RANGE]) {
@@ -2761,8 +2772,8 @@ static int vxlan_validate(struct nlattr *tb[], struct 
nlattr *data[],
= nla_data(data[IFLA_VXLAN_PORT_RANGE]);
 
if (ntohs(p->high) < ntohs(p->low)) {
-   pr_debug("port range %u .. %u not valid\n",
-ntohs(p->low), ntohs(p->high));
+   NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_PORT_RANGE],
+   "Provided source port range bounds 
is invalid");
return -EINVAL;
}
}
@@ -2919,7 +2930,8 @@ static int vxlan_sock_add(struct vxlan_dev *vxlan)
 
 static int vxlan_config_validate(struct net *src_net, struct vxlan_config 
*conf,
 struct net_device **lower,
-struct vxlan_dev *old)
+struct vxlan_dev *old,
+struct netlink_ext_ack *extack)
 {
struct vxlan_net *vn = net_generic(src_net, vxlan_net_id);
struct vxlan_dev *tmp;
@@ -2933,6 +2945,8 @@ static int vxlan_config_validate(struct net *src_net, 
struct vxlan_config *conf,
 */
if ((conf->flags & ~VXLAN_F_ALLOWED_GPE) ||
!(conf->flags & VXLAN_F_COLLECT_METADATA)) {
+   NL_SET_ERR_MSG(extack,
+  "VXLAN GPE does not support this 
combination of attributes");
return -EINVAL;
}
}
@@ -2947,15 +2961,23 @@ static int vxlan_config_validate(struct net *src_net, 
struct vxlan_config *conf,
conf->saddr.sa.sa_family = conf->remote_ip.sa.sa_family;
}
 
-   if (conf->saddr.sa.sa_family != conf->remote_ip.sa.sa_family)
+   if (conf->saddr.sa.sa_family != conf->remote_ip.sa.sa_family) {
+   NL_SET_ERR_MSG(extack,
+  "Local and remote address must be from the same 
family");
return -EINVAL;
+   }
 
-   if (vxlan_addr_multicast(>saddr))
+   if (vxlan_addr_multicast(>saddr)) {
+   NL_SET_ERR_MSG(extack, "Local 

Re: [PATCH v1 net] TCP_USER_TIMEOUT and tcp_keepalive should conform to RFC5482

2017-08-10 Thread Rao Shoaib



On 08/09/2017 09:59 PM, Jerry Chu wrote:

On Wed, Aug 9, 2017 at 8:32 PM, Jerry Chu  wrote:

On Wed, Aug 9, 2017 at 5:47 PM, Rao Shoaib  wrote:


On 08/09/2017 05:30 PM, David Miller wrote:

From: Joe Smith 
Date: Wed, 9 Aug 2017 17:20:32 -0700


Making Linux conform to standards and behavior that is logical seems
like a good enough reason.

That's an awesome attitude to have when we're implementing something
new and don't have the facility already.

But when we have something already the only important consideration is
not breaking existing apps which rely on that behavior.

That is much, much, more important than standards compliance.

If users are confused, just fix the documentation.

David,

If it was just confusion than sure fixing the documentation is fine. What if
the logic is incorrect, does not conform to the standard that is says it is

Not sure what part of logic is "incorrect" when it was a homegrown Linux API
with no need to conform with any "standard"? Note that the new API was invented
7 years ago not out of need for RFC5482. In fact I initially call the option
TCP_FAILFAST and did not even know the existence of RFC5482 until someone
around the same time proposed a UTO option specifically for RFC5482 and I
thought the two can be combined. (This is roughly the memory I can
recollect so far.)

So you see my focus back then was to devise a "failfast" option whereas RFC5482
was meant for a "failslow" case. I think that explains why I let the
option override
keepalive so a TCP connection can "fail fast" while RFC5482 4.2 tries to prevent
keepalive failure ahead of UTO, favoring "fail slow".

If we start from a clean slate then perhaps one can argue the semantic
either way
but we do not have a clean slate. For that I still slightly favor not
changing the code
because the risk of breakage is definitely non-zero and the issue you're having
seem to be only related to documentation.
We all make mistakes and over look things, that seems to be the case 
here. If this was so important than I am sure there was a use case. None 
has been presented. Without a use case I do not understand why we have 
to live with broken logic when we have a chance to fix it and make the 
code better.


If this change does break something (very very unlikely) we will 
understand the use case and provide an appropriate solution.



One more thing - the proposed patch compares TCP_KEEPIDLE against
TCP_USER_TIMEOUT. But I don't think TCP_KEEPIDLE is what the
"keep-alive
timer" referred to in RFC5482. Linux keepalive implementation seems to use #
of retries (TCP_KEEPCNT) rather than time duration (keep-alive time) to
determine when to quit. If that is the case then your proposed change is not
fully "compliant" either and the best is probably just don't change.

Did you look at the patch and what it changes ?

Take a look at the TCP_KEEPIDLE socket option and see what it does or 
just look at the man page of tcp(7)


TCP_KEEPIDLE (since Linux 2.4) The time (in seconds) the connection 
needs to remain idle before TCP starts sending keepalive probes, if the 
socket option SO_KEEPALIVE has been set on this socket. This option 
should not be used in code intended to be portable.


Shoaib.



Jerry


implementing and easy to fix with little or no risk of breakage.

The proposed patch changes a feature that no one uses. It also imposes the
relation ship between keepalive and timeout values that is required by the
RFC and make sense.

You are the final authority, if you say we should just fix the documentation
than that is fine.

Shoaib





[PATCH net-next] net: ipv4: set orig_oif based on fib result for local traffic

2017-08-10 Thread David Ahern
Attempts to connect to a local address with a socket bound
to a device with the local address hangs if there is no listener:

  $ ip addr sh dev eth1
  3: eth1:  mtu 1500 qdisc mq state UP group 
default qlen 1000
link/ether 02:e0:f9:1c:00:37 brd ff:ff:ff:ff:ff:ff
inet 10.100.1.4/24 scope global eth1
   valid_lft forever preferred_lft forever
inet6 2001:db8:1::4/120 scope global
   valid_lft forever preferred_lft forever
inet6 fe80::e0:f9ff:fe1c:37/64 scope link
   valid_lft forever preferred_lft forever

  $ vrf-test -I eth1 -r 10.100.1.4
  

(don't let the command name fool you; vrf-test works without vrfs.)

The problem is that the original intended device, eth1 in this case, is
lost when the tcp reset is sent, so the socket lookup does not find a
match for the reset and the connect attempt hangs. Fix by adjusting
orig_oif for local traffic to the device from the fib lookup result.

With this patch you get the more user friendly:
  $ vrf-test -I eth1 -r 10.100.1.4
  connect failed: 111: Connection refused

orig_oif is saved to the newly created rtable as rt_iif and when set
it is used as the dif for socket lookups. It is set based on flowi4_oif
passed in to ip_route_output_key_hash_rcu and will be set to either
the loopback device, an l3mdev device, nothing (flowi4_oif = 0 which
is the case in the example above) or a netdev index depending on the
lookup path. In each case, resetting orig_oif to the device in the fib
result for the RTN_LOCAL case allows the actual device to be preserved
as the skb tx and rx is done over the loopback or VRF device.

Signed-off-by: David Ahern 
---
As far as I can tell the current behavior goes back to the 2.6 days
at least. Not sure it is worth adding to stable branches.

 net/ipv4/route.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2ef46294475f..aae8f681ce1b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2439,6 +2439,12 @@ struct rtable *ip_route_output_key_hash_rcu(struct net 
*net, struct flowi4 *fl4,
/* L3 master device is the loopback for that domain */
dev_out = l3mdev_master_dev_rcu(FIB_RES_DEV(*res)) ? :
net->loopback_dev;
+
+   /* make sure orig_oif points to fib result device even
+* though packet rx/tx happens over loopback or l3mdev
+*/
+   orig_oif = FIB_RES_OIF(*res);
+
fl4->flowi4_oif = dev_out->ifindex;
flags |= RTCF_LOCAL;
goto make_route;
-- 
2.1.4



[PATCH 1/2] mpls: add handlers

2017-08-10 Thread Amine Kherbouche
Mpls handler allows creation/deletion of mpls routes without using
rtnetlink. When an incoming mpls packet matches this route, the saved
function handler is called.

Signed-off-by: Amine Kherbouche 
Signed-off-by: David Lamparter 
---
 include/net/mpls.h  | 10 +++
 net/mpls/af_mpls.c  | 75 +
 net/mpls/internal.h |  3 +++
 3 files changed, 88 insertions(+)

diff --git a/include/net/mpls.h b/include/net/mpls.h
index 1dbc669..0ff51b6 100644
--- a/include/net/mpls.h
+++ b/include/net/mpls.h
@@ -33,4 +33,14 @@ static inline struct mpls_shim_hdr *mpls_hdr(const struct 
sk_buff *skb)
 {
return (struct mpls_shim_hdr *)skb_network_header(skb);
 }
+
+typedef int (*mpls_handler)(void *arg, struct sk_buff *skb,
+   struct net_device *dev, u32 index, u8 bos);
+
+extern int mpls_handler_add(struct net *net, u32 index, u8 via_table, u8 via[],
+   mpls_handler handler, void *handler_arg,
+   struct netlink_ext_ack *extack);
+extern int mpls_handler_del(struct net *net, u32 index,
+   struct netlink_ext_ack *extack);
+
 #endif
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index c5b9ce4..82d2126 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -299,6 +300,7 @@ static bool mpls_egress(struct net *net, struct mpls_route 
*rt,
success = true;
break;
}
+   case MPT_HANDLER:
case MPT_UNSPEC:
/* Should have decided which protocol it is by now */
break;
@@ -356,6 +358,10 @@ static int mpls_forward(struct sk_buff *skb, struct 
net_device *dev,
goto drop;
}
 
+   if (rt->rt_payload_type == MPT_HANDLER)
+   return rt->rt_handler(rt->rt_harg, skb, dev,
+ dec.label, dec.bos);
+
nh = mpls_select_multipath(rt, skb);
if (!nh)
goto err;
@@ -457,6 +463,8 @@ static const struct nla_policy rtm_mpls_policy[RTA_MAX+1] = 
{
 struct mpls_route_config {
u32 rc_protocol;
u32 rc_ifindex;
+   mpls_handlerrc_handler;
+   void*rc_harg;
u8  rc_via_table;
u8  rc_via_alen;
u8  rc_via[MAX_VIA_ALEN];
@@ -995,6 +1003,11 @@ static int mpls_route_add(struct mpls_route_config *cfg,
rt->rt_payload_type = cfg->rc_payload_type;
rt->rt_ttl_propagate = cfg->rc_ttl_propagate;
 
+   if (cfg->rc_handler) {
+   rt->rt_handler = cfg->rc_handler;
+   rt->rt_harg = cfg->rc_harg;
+   }
+
if (cfg->rc_mp)
err = mpls_nh_build_multi(cfg, rt, max_labels, extack);
else
@@ -1271,6 +1284,68 @@ static int mpls_netconf_dump_devconf(struct sk_buff *skb,
return skb->len;
 }
 
+int mpls_handler_add(struct net *net, u32 label, u8 via_table, u8 via[],
+mpls_handler handler, void *handler_arg,
+struct netlink_ext_ack *extack)
+{
+   struct net_device *dev = handler_arg;
+   struct mpls_route_config *cfg;
+   u8 alen = 0;
+   int err;
+
+   cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return -ENOMEM;
+
+   memset(cfg, 0, sizeof(*cfg));
+   if (via_table == NEIGH_ARP_TABLE)
+   alen = sizeof(struct in_addr);
+   else if (via_table == NEIGH_ND_TABLE)
+   alen = sizeof(struct in6_addr);
+
+   cfg->rc_ttl_propagate   = MPLS_TTL_PROP_DEFAULT;
+   cfg->rc_protocol= RTPROT_KERNEL;
+   cfg->rc_nlflags |= NLM_F_CREATE;
+   cfg->rc_payload_type= MPT_HANDLER;
+   cfg->rc_via_table   = via_table;
+   cfg->rc_label   = label;
+   cfg->rc_via_alen= alen;
+   memcpy(>rc_via, via, alen);
+   cfg->rc_ifindex = dev->ifindex;
+   cfg->rc_nlinfo.nl_net   = net;
+   cfg->rc_harg= handler_arg;
+   cfg->rc_handler = handler;
+   cfg->rc_output_labels   = 0;
+
+   err = mpls_route_add(cfg, extack);
+   kfree(cfg);
+
+   return err;
+}
+EXPORT_SYMBOL(mpls_handler_add);
+
+int mpls_handler_del(struct net *net, u32 index,
+struct netlink_ext_ack *extack)
+{
+   struct mpls_route_config *cfg;
+   int err = 0;
+
+   cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+   if (!cfg)
+   return -ENOMEM;
+
+   memset(cfg, 0, sizeof(*cfg));
+   cfg->rc_protocol= RTPROT_KERNEL;
+   cfg->rc_label   = index;
+   cfg->rc_nlinfo.nl_net   = net;
+
+   err = mpls_route_del(cfg, extack);
+   kfree(cfg);
+
+   return err;
+}

[PATCH 2/2] drivers: add vpls support

2017-08-10 Thread Amine Kherbouche
This commit introduces the support of VPLS virtual device, that allows
performing  L2VPN multipoint to multipoint communication over MPLS PSN.

VPLS device encap received ethernet frame over mpls packet and send it the
output device, in the other direction, when receiving the right configured
mpls packet, the matched mpls route calls the handler vpls function,
then pulls out the mpls header and send it back the entry point via
netif_rx().

Two functions, mpls_entry_encode() and mpls_output_possible() are
exported from mpls/internal.h to be able to use them inside vpls driver.

Signed-off-by: Amine Kherbouche 
---
 drivers/net/Kconfig  |   8 +
 drivers/net/Makefile |   1 +
 drivers/net/vpls.c   | 531 +++
 include/net/mpls.h   |  15 ++
 include/net/vpls.h   |  21 ++
 include/uapi/linux/if_link.h |  15 ++
 net/mpls/internal.h  |  12 -
 7 files changed, 591 insertions(+), 12 deletions(-)
 create mode 100644 drivers/net/vpls.c
 create mode 100644 include/net/vpls.h

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 83a1616..2ae5a23 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -363,6 +363,14 @@ config VSOCKMON
  mostly intended for developers or support to debug vsock issues. If
  unsure, say N.
 
+config VPLS
+   tristate "Virtual Private LAN Service (VPLS)"
+   depends on MPLS_ROUTING
+   ---help---
+ This allows one to create VPLS virtual interfaces that provide
+ Layer 2 Networks multipoint to multipoint communication over MPLS
+ PSN.
+
 endif # NET_CORE
 
 config SUNGEM_PHY
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index b2f6556..7488975 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_GTP) += gtp.o
 obj-$(CONFIG_NLMON) += nlmon.o
 obj-$(CONFIG_NET_VRF) += vrf.o
 obj-$(CONFIG_VSOCKMON) += vsockmon.o
+obj-$(CONFIG_VPLS) += vpls.o
 
 #
 # Networking Drivers
diff --git a/drivers/net/vpls.c b/drivers/net/vpls.c
new file mode 100644
index 000..b51e31a
--- /dev/null
+++ b/drivers/net/vpls.c
@@ -0,0 +1,531 @@
+/*
+ * Copyright (c) 2017 6WIND S.A.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME   "vpls"
+#define DRV_VERSION"0.1"
+#define VPLS_MAX_ID256 /* Max VPLS WireID (arbitrary) */
+#define VPLS_DEFAULT_TTL   255 /* Max TTL */
+
+static struct rtnl_link_ops vpls_link_ops;
+
+union vpls_nh {
+   struct in6_addr addr6;
+   struct in_addr  addr;
+};
+
+struct vpls_dst {
+   struct net_device   *dev;
+   union vpls_nh   addr;
+   u32 label_in, label_out;
+   u32 id;
+   u16 vlan_id;
+   u8  via_table;
+   u8  flags;
+   u8  ttl;
+};
+
+struct vpls_priv {
+   struct net  *encap_net;
+   struct vpls_dst dst;
+};
+
+static struct nla_policy vpls_policy[IFLA_VPLS_MAX + 1] = {
+   [IFLA_VPLS_ID]  = { .type = NLA_U32 },
+   [IFLA_VPLS_IN_LABEL]= { .type = NLA_U32 },
+   [IFLA_VPLS_OUT_LABEL]   = { .type = NLA_U32 },
+   [IFLA_VPLS_OIF] = { .type = NLA_U32 },
+   [IFLA_VPLS_TTL] = { .type = NLA_U8  },
+   [IFLA_VPLS_VLANID]  = { .type = NLA_U8 },
+   [IFLA_VPLS_NH]  = { .type = NLA_U32 },
+   [IFLA_VPLS_NH6] = { .len = sizeof(struct in6_addr) },
+};
+
+static netdev_tx_t vpls_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+   struct vpls_priv *priv = netdev_priv(dev);
+   struct vpls_dst *dst = >dst;
+   struct pcpu_sw_netstats *stats;
+   unsigned int new_header_size;
+   struct net_device *out_dev;
+   struct mpls_shim_hdr *hdr;
+   int ret = NET_RX_DROP;
+   unsigned int hh_len;
+
+   out_dev = dst->dev;
+   skb_orphan(skb);
+   skb_forward_csum(skb);
+   stats = this_cpu_ptr(dev->tstats);
+
+   if (!mpls_output_possible(dst->dev) || skb_warn_if_lro(skb)) {
+   dev->stats.tx_errors++;
+   goto end;
+   }
+
+   new_header_size = 1 * sizeof(struct mpls_shim_hdr);
+
+   hh_len = LL_RESERVED_SPACE(out_dev);
+   if (!out_dev->header_ops)
+   hh_len = 0;
+
+   ret = skb_cow(skb, hh_len + 

[RFC PATCH 0/2] Support of VPLS MPLS

2017-08-10 Thread Amine Kherbouche
This small series implements the support of VPLS dataplane using MPLS
encapsulation to perform a l2VPN using a virtual network device.

The ingress ethernet frames are encapsulated and carried over an MPLS packet
switched network, then decapsulated in the egress router (LER) by a vpls
device.

This small schema describe how to configure a vpls device to perform l2VPN
over MPLS PSN:

in LER0:
  - ip link add name br0 type bridge
  - ip link set dev0 master br0
  - ip link add name vpls0 type vpls id 10 output 111 input 222 \
via {{dev3_addr}} dev dev1
  - ip link set vpls0 master br0

in LER1:
  - ip link add name br1 type bridge
  - ip link set dev2 master br0
  - ip link add name vpls1 type vpls id 20 output 222 input 111 \
via {{dev1_addr}} dev dev3
  - ip link set vpls1 master br1

LER0 LER1
   +--+   +--+
   |  |   |  |
   | +- br0--+|   |  vpls1   |
   | |   ||   ++  || |
 --- dev0+   ||   ||  ||  +-dev2 --
   | |   dev1 --- |MPLS PSN| --- dev3  |  |  |
10.1.0.0/24| ||   ||  ||  |  | 10.1.0.0/24
   |   vpls0  |   ++  |+--br1-+  |
   |  |   |  |
   +--+   +--+

packet dissection:

 | |
ether0/ip0/payload   | ether1/mpls0/ether0/ip0/payload | ether0/ip0/payload
 | |

An Iproute2 patch is available to complete this serie here:
https://github.com/6WIND/iproute2/commit/0d1d3f2a5733421baf08e247d4ce2fb03cd666f1

Example of more detailed configurations with iproute2:

Create a VPLS vdev "vpls0" to neighbor 10.200.0.2 via dev1, encapsulate the
incoming Ethernet frame from the bridge in MPLS packets with label 111 with
ttl 10 and uncap recieved MPLS packets from dev1 with label 222:

ip link add name vpls0 type vpls id 10 output 111 input 222 ttl 10 \
via 10.200.0.2 dev dev1

Same configuration than the previous one just use Ipv6:

ip link add name vpls0 type vpls id 10 output 111 input 222 ttl 10 \
via fd00:200::2 dev dev1

Now the same configuration but tag the outer Ethernet frame with vlan id 55:

ip link add name vpls0 type vpls id 10 output 111 input 222 vlan 55 \
ttl 10 via 10.200.0.2 dev dev1

The approch for configuration is from OpenBSD, more information:
https://man.openbsd.org/mpw.4

TODO next:
  - Support of Pseudowire Emulation Edge-to-Edge (PWE3) datapath.
https://tools.ietf.org/html/rfc4385
  - Add the support of lightweight VPLS tunnel for scalability. ie one device
with many tunnels.



[PATCHv2 net-next iproute2] gre: add support for ERSPAN tunnel

2017-08-10 Thread William Tu
The patch adds ERSPAN type II tunnel support.  The implementation
is based on the draft at https://tools.ietf.org/html/draft-foschiano-erspan-01
One of the purposes is for Linux box to be able to receive ERSPAN
monitoring traffic sent from the Cisco switch, by creating a ERSPAN
tunnel device.  In addition, the patch also adds ERSPAN TX, so traffic
can also be encapsulated into ERSPAN and sent out.

The implementation reuses the key as ERSPAN session ID, and
field 'erspan' as ERSPAN Index fields:
./ip link add dev ers11 type erspan seq key 100 erspan 123 \
local 172.16.1.200 remote 172.16.1.100

Signed-off-by: William Tu 
Signed-off-by: Meenakshi Vohra 
Cc: Stephen Hemminger 
Cc: Alexey Kuznetsov 
---
v1->v2:
  Add manual entry for ERSPAN.
  Check 20-bit ERSPAN index field.
---
 include/linux/if_tunnel.h |  1 +
 ip/ipaddress.c|  2 +-
 ip/iplink.c   |  5 +++--
 ip/link_gre.c | 28 +++-
 man/man8/ip-address.8.in  |  1 +
 man/man8/ip-link.8.in | 19 ---
 6 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index 7375335a0773..21834cac4c0d 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -134,6 +134,7 @@ enum {
IFLA_GRE_COLLECT_METADATA,
IFLA_GRE_IGNORE_DF,
IFLA_GRE_FWMARK,
+   IFLA_GRE_ERSPAN_INDEX,
__IFLA_GRE_MAX,
 };
 
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4d37c5e04507..f7296991e483 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -76,7 +76,7 @@ static void usage(void)
fprintf(stderr, "LFT := forever | SECONDS\n");
fprintf(stderr, "TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | 
macvtap |\n");
fprintf(stderr, "  bridge | bond | ipoib | ip6tnl | ipip | sit 
| vxlan | lowpan |\n");
-   fprintf(stderr, "  gre | gretap | ip6gre | ip6gretap | vti | 
nlmon | can |\n");
+   fprintf(stderr, "  gre | gretap | erspan | ip6gre | ip6gretap | 
vti | nlmon | can |\n");
fprintf(stderr, "  bond_slave | ipvlan | geneve | bridge_slave 
| vrf | hsr | macsec }\n");
 
exit(-1);
diff --git a/ip/iplink.c b/ip/iplink.c
index 5aff2fde38da..62430110bfab 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -112,8 +112,9 @@ void iplink_usage(void)
"\n"
"TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | 
macvtap |\n"
"  bridge | bond | team | ipoib | ip6tnl | ipip 
| sit | vxlan |\n"
-   "  gre | gretap | ip6gre | ip6gretap | vti | 
nlmon | team_slave |\n"
-   "  bond_slave | ipvlan | geneve | bridge_slave 
| vrf | macsec }\n");
+   "  gre | gretap | erspan | ip6gre | ip6gretap | 
vti | nlmon |\n"
+   "  team_slave | bond_slave | ipvlan | geneve | 
bridge_slave |\n"
+   "  vrf | macsec }\n");
}
exit(-1);
 }
diff --git a/ip/link_gre.c b/ip/link_gre.c
index c2ec5f26902f..e3fcab3a8ca7 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -26,7 +26,7 @@
 static void print_usage(FILE *f)
 {
fprintf(f,
-   "Usage: ... { gre | gretap } [ remote ADDR ]\n"
+   "Usage: ... { gre | gretap | erspan } [ remote ADDR ]\n"
"[ local ADDR ]\n"
"[ [i|o]seq ]\n"
"[ [i|o]key KEY ]\n"
@@ -44,6 +44,7 @@ static void print_usage(FILE *f)
"[ [no]encap-csum6 ]\n"
"[ [no]encap-remcsum ]\n"
"[ fwmark MARK ]\n"
+   "[ erspan IDX ]\n"
"\n"
"Where: ADDR := { IP_ADDRESS | any }\n"
"   TOS  := { NUMBER | inherit }\n"
@@ -96,6 +97,7 @@ static int gre_parse_opt(struct link_util *lu, int argc, char 
**argv,
__u8 metadata = 0;
__u8 ignore_df = 0;
__u32 fwmark = 0;
+   __u32 erspan_idx = 0;
 
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
if (rtnl_talk(, , , sizeof(req)) < 0) {
@@ -172,6 +174,9 @@ get_failed:
 
if (greinfo[IFLA_GRE_FWMARK])
fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
+
+   if (greinfo[IFLA_GRE_ERSPAN_INDEX])
+   erspan_idx = 
rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
}
 
while (argc > 0) {
@@ -328,6 +333,12 @@ get_failed:
NEXT_ARG();
if (get_u32(, *argv, 0))
invarg("invalid fwmark\n", *argv);
+   } else if 

Re: unregister_netdevice: waiting for eth0 to become free. Usage count = 1

2017-08-10 Thread Wei Wang
On Thu, Aug 10, 2017 at 11:12 AM, John Stultz  wrote:
> On Wed, Aug 9, 2017 at 10:41 PM, Wei Wang  wrote:
>> Hi John,
>>
>> Is it possible to try the attached patch?
>
> Thanks so much for the quick turn around!
>
> So I dropped all the reverts you suggested, and applied this one
> against 4.13-rc4, but I'm still seeing the problematic behavior.
>

Thanks for confirming.
I have been going through the code and not yet found any leaks.
I am also trying to reproduce the issue myself.
Martin seems to also see this issue.
I will continue investigating.

>> I am not sure if it actually fixes the issue. But I think it is worth a try.
>> Also, could you get me all the ipv6 routes when you plug in the usb
>> using "ip -6 route show"? (If you have multiple routing tables
>> configured, could you dump them all?)
>
> # ip -6 route show
> 2601:1c2:1002:83f0::/64 dev eth0  proto kernel  metric 256  expires
> 345599sec pref medium
> fe80::/64 dev eth0  proto kernel  metric 256  pref medium
> default via fe80::200:caff:fe11:2233 dev eth0  proto ra  metric 1024
> expires 1799sec hoplimit 64 pref medium
>
>
> After unplugging the device (and getting the unregister_netdevice errors):
> # ip -6 route show
> #
>

Thanks for the logs.


>
> thanks
> -john


Re: [PATCH 2/6] wl1251: Use request_firmware_prefer_user() for loading NVS calibration data

2017-08-10 Thread Luis R. Rodriguez
On Fri, Jun 30, 2017 at 11:35:41PM +0200, Arend van Spriel wrote:
> On 23-06-17 23:53, Luis R. Rodriguez wrote:
> > On Tue, May 16, 2017 at 10:41:08AM +0200, Arend Van Spriel wrote:
> >> On 16-5-2017 1:13, Luis R. Rodriguez wrote:
> >>> Since no upstream delta is needed for firmwared I'd like to first 
> >>> encourage
> >>> evaluating the above. While distributions don't carry it yet that may be 
> >>> seen as
> >>> an issue but since what we are looking for are corner cases, only folks 
> >>> needing
> >>> to deploy a specific solution would need it or a custom proprietary 
> >>> solution.
> >>
> >> Ok. I will go try and run firmwared in OpenWrt on a router platform.
> >> Have to steal one from a colleague :-p Will study firmwared.
> > 
> > Arend, curious how this effort goes. Its important to me as we know then 
> > that
> > if this works its a good approach to recommend moving forward which should 
> > also
> > prove less complex than that soup we had with the custom fallback stuff.
> 
> Hi Luis,
> 
> So I looked at firmwared and we basically need to extend it.

And actually as me and Johannes spoke long ago at Plumbers, its rather
expected folks would need this or just fork it off completely. firmwared
would just be a reference codebase on how to do these custom loaders.

*How regular* Linux distributions embrace this is still up in the air then,
because as Lennart has pointed out there is no plan to merge firmwared
to systemd.

*If* this is a requirement only for non-upstream drivers or patches on
which will not be merged upstream then this will work long term. If you
need regular distros to do something custom then their respective upstream
tools would need to be evaluated for how something similar would be done.

As far as I can tell perhaps the remote-proc thing would count as one
possible use-case for upstream drivers -- but even then the systems
that use it seem likely to use Android and then some custom userspace.

> For our
> router platform we need to obtain nvram calibration data from an MTD
> partition which contains the raw data, ie. no file-system on it. So
> firmwared would need some sort of configuration to map a particular
> firmware file to some action obtaining the data like kicking off some
> mtd-utils in my case.

I see. So platform specific.

Thanks for the update!
 
 Luis


Re: [PATCH RFC 0/2] stap: Socket tap

2017-08-10 Thread David Ahern
On 8/7/17 4:12 PM, Tom Herbert wrote:
> A socket tap is enabled on socket using SO_ULP socket option with
> ulp type "stap". The socket option takes ULP specific configuration

How about sktap instead of stap since stap has a history of referring to
system tap?


Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information

2017-08-10 Thread David Miller
From: Paul Moore 
Date: Thu, 10 Aug 2017 15:15:23 -0400

> On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore  wrote:
>> From: Paul Moore 
>>
>> Signed-off-by: Paul Moore 
>> ---
>>  MAINTAINERS |   24 ++--
>>  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> I'm planning on sending this up via the SELinux tree with some other
> MAINTAINERS updates, consider this more of a FYI posting.

Yep, works for me:

Acked-by: David S. Miller 


Re: [PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information

2017-08-10 Thread Paul Moore
On Thu, Aug 10, 2017 at 3:13 PM, Paul Moore  wrote:
> From: Paul Moore 
>
> Signed-off-by: Paul Moore 
> ---
>  MAINTAINERS |   24 ++--
>  1 file changed, 14 insertions(+), 10 deletions(-)

I'm planning on sending this up via the SELinux tree with some other
MAINTAINERS updates, consider this more of a FYI posting.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 65990909fe73..be25ebaaeec3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9112,15 +9112,6 @@ F:   net/*/netfilter/
>  F: net/netfilter/
>  F: net/bridge/br_netfilter*.c
>
> -NETLABEL
> -M: Paul Moore 
> -W: http://netlabel.sf.net
> -L: netdev@vger.kernel.org
> -S: Maintained
> -F: Documentation/netlabel/
> -F: include/net/netlabel.h
> -F: net/netlabel/
> -
>  NETROM NETWORK LAYER
>  M: Ralf Baechle 
>  L: linux-h...@vger.kernel.org
> @@ -9248,10 +9239,23 @@ F:  net/ipv6/
>  F: include/net/ip*
>  F: arch/x86/net/*
>
> -NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
> +NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
>  M: Paul Moore 
> +W: https://github.com/netlabel
>  L: netdev@vger.kernel.org
> +L: linux-security-mod...@vger.kernel.org
>  S: Maintained
> +F: Documentation/netlabel/
> +F: include/net/calipso.h
> +F: include/net/cipso_ipv4.h
> +F: include/net/netlabel.h
> +F: include/uapi/linux/netfilter/xt_SECMARK.h
> +F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
> +F: net/netlabel/
> +F: net/ipv4/cipso_ipv4.c
> +F: net/ipv6/calipso.c
> +F: net/netfilter/xt_CONNSECMARK.c
> +F: net/netfilter/xt_SECMARK.c
>
>  NETWORKING [TLS]
>  M: Ilya Lesokhin 

-- 
paul moore
www.paul-moore.com


Re: [PATCH V4 net 0/2] ipv6: fix flowlabel issue for reset packet

2017-08-10 Thread Shaohua Li
On Thu, Aug 10, 2017 at 11:30:51AM -0700, Tom Herbert wrote:
> On Thu, Aug 10, 2017 at 9:30 AM, Shaohua Li  wrote:
> > On Wed, Aug 09, 2017 at 09:40:08AM -0700, Tom Herbert wrote:
> >> On Mon, Jul 31, 2017 at 3:19 PM, Shaohua Li  wrote:
> >> > From: Shaohua Li 
> >> >
> >> > Please see below tcpdump output:
> >> > 21:00:48.109122 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 40) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [S], cksum 0x0529 (incorrect -> 
> >> > 0xf56c), seq 3282214508, win 43690, options [mss 65476,sackOK,TS val 
> >> > 2500903437 ecr 0,nop,wscale 7], length 0
> >> > 21:00:48.109381 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> >> > payload length: 40) fec0::5054:ff:fe12:3456. > 
> >> > fec0::5054:ff:fe12:3456.55804: Flags [S.], cksum 0x0529 (incorrect -> 
> >> > 0x49ad), seq 1923801573, ack 3282214509, win 43690, options [mss 
> >> > 65476,sackOK,TS val 2500903437 ecr 2500903437,nop,wscale 7], length 0
> >> > 21:00:48.109548 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> >> > 0x1bdf), seq 1, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 
> >> > 2500903437], length 0
> >> > 21:00:48.109823 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 62) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x053f (incorrect -> 
> >> > 0xb8b1), seq 1:31, ack 1, win 342, options [nop,nop,TS val 2500903437 
> >> > ecr 2500903437], length 30
> >> > 21:00:48.109910 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> >> > payload length: 32) fec0::5054:ff:fe12:3456. > 
> >> > fec0::5054:ff:fe12:3456.55804: Flags [.], cksum 0x0521 (incorrect -> 
> >> > 0x1bc1), seq 1, ack 31, win 342, options [nop,nop,TS val 2500903437 ecr 
> >> > 2500903437], length 0
> >> > 21:00:48.110043 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> >> > payload length: 56) fec0::5054:ff:fe12:3456. > 
> >> > fec0::5054:ff:fe12:3456.55804: Flags [P.], cksum 0x0539 (incorrect -> 
> >> > 0xb726), seq 1:25, ack 31, win 342, options [nop,nop,TS val 2500903438 
> >> > ecr 2500903437], length 24
> >> > 21:00:48.110173 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> >> > 0x1ba7), seq 31, ack 25, win 342, options [nop,nop,TS val 2500903438 ecr 
> >> > 2500903438], length 0
> >> > 21:00:48.110211 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> >> > payload length: 32) fec0::5054:ff:fe12:3456. > 
> >> > fec0::5054:ff:fe12:3456.55804: Flags [F.], cksum 0x0521 (incorrect -> 
> >> > 0x1ba7), seq 25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 
> >> > 2500903437], length 0
> >> > 21:00:48.151099 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> >> > 0x1ba6), seq 31, ack 26, win 342, options [nop,nop,TS val 2500903438 ecr 
> >> > 2500903438], length 0
> >> > 21:00:49.110524 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> >> > payload length: 56) fec0::5054:ff:fe12:3456.55804 > 
> >> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x0539 (incorrect -> 
> >> > 0xb324), seq 31:55, ack 26, win 342, options [nop,nop,TS val 2500904438 
> >> > ecr 2500903438], length 24
> >> > 21:00:49.110637 IP6 (flowlabel 0xb34d5, hlim 64, next-header TCP (6) 
> >> > payload length: 20) fec0::5054:ff:fe12:3456. > 
> >> > fec0::5054:ff:fe12:3456.55804: Flags [R], cksum 0x0515 (incorrect -> 
> >> > 0x668c), seq 1923801599, win 0, length 0
> >> >
> >> > The flowlabel of reset packet (0xb34d5) and flowlabel of normal packet
> >> > (0xd827f) are different. This causes our router doesn't correctly close 
> >> > tcp
> >> > connection. The patches try to fix the issue.
> >> >
> >> Shaohua,
> >>
> >> Can you give some more detail about what the router doesn't close the
> >> TCP connection means? I'm guessing the problem is either: 1) the
> >> router is maintaining connection state that includes the flow label in
> >> a connection tuple. 2) some router in the path is maintaining
> >> connection state, but when the flow label changes the flow's packet
> >> are routed through a different router that doesn't have a state for
> >> the flow it drops the packet. #1 should be easily fix in the router,
> >> flow labels cannot be used as state. #2 is the known problem that
> >> stateful firewalls have killed our ability to use multihoming.
> >
> > The #2 is exactly the problem we saw.
> >
> >> Another consideration is that sk_txhash is also used in routing
> >> decisions by the local host (flow label is normally derived 

[PATCH] MAINTAINERS: update the NetLabel and Labeled Networking information

2017-08-10 Thread Paul Moore
From: Paul Moore 

Signed-off-by: Paul Moore 
---
 MAINTAINERS |   24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 65990909fe73..be25ebaaeec3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9112,15 +9112,6 @@ F:   net/*/netfilter/
 F: net/netfilter/
 F: net/bridge/br_netfilter*.c
 
-NETLABEL
-M: Paul Moore 
-W: http://netlabel.sf.net
-L: netdev@vger.kernel.org
-S: Maintained
-F: Documentation/netlabel/
-F: include/net/netlabel.h
-F: net/netlabel/
-
 NETROM NETWORK LAYER
 M: Ralf Baechle 
 L: linux-h...@vger.kernel.org
@@ -9248,10 +9239,23 @@ F:  net/ipv6/
 F: include/net/ip*
 F: arch/x86/net/*
 
-NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
+NETWORKING [LABELED] (NetLabel, Labeled IPsec, SECMARK)
 M: Paul Moore 
+W: https://github.com/netlabel
 L: netdev@vger.kernel.org
+L: linux-security-mod...@vger.kernel.org
 S: Maintained
+F: Documentation/netlabel/
+F: include/net/calipso.h
+F: include/net/cipso_ipv4.h
+F: include/net/netlabel.h
+F: include/uapi/linux/netfilter/xt_SECMARK.h
+F: include/uapi/linux/netfilter/xt_CONNSECMARK.h
+F: net/netlabel/
+F: net/ipv4/cipso_ipv4.c
+F: net/ipv6/calipso.c
+F: net/netfilter/xt_CONNSECMARK.c
+F: net/netfilter/xt_SECMARK.c
 
 NETWORKING [TLS]
 M: Ilya Lesokhin 



Re: [PATCH] bonding: require speed/duplex only for 802.3ad, alb and tlb

2017-08-10 Thread महेश बंडेवार
On Wed, Aug 9, 2017 at 9:41 PM, Andreas Born  wrote:
> The patch c4adfc822bf5 ("bonding: make speed, duplex setting consistent
> with link state") puts the link state to down if
> bond_update_speed_duplex() cannot retrieve speed and duplex settings.
> Assumably the patch was written with 802.3ad mode in mind which relies
> on link speed/duplex settings. For other modes like active-backup these
> settings are not required.
> Thus, only for these other modes, this patch
> reintroduces support for slaves that do not support reporting speed or
> duplex such as wireless devices. This fixes the regression reported in
> bug 196547 (https://bugzilla.kernel.org/show_bug.cgi?id=196547).
>
> Fixes: c4adfc822bf5 ("bonding: make speed, duplex setting consistent
> with link state")
> Signed-off-by: Andreas Born 
Acked-by: Mahesh Bandewar 
> ---
>  drivers/net/bonding/bond_main.c | 6 --
>  include/net/bonding.h   | 5 +
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 9bee6c1c70cc..85bb272d2a34 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct 
> net_device *slave_dev)
> new_slave->delay = 0;
> new_slave->link_failure_count = 0;
>
> -   if (bond_update_speed_duplex(new_slave))
> +   if (bond_update_speed_duplex(new_slave) &&
> +   bond_needs_speed_duplex(bond))
> new_slave->link = BOND_LINK_DOWN;
>
> new_slave->last_rx = jiffies -
> @@ -2140,7 +2141,8 @@ static void bond_miimon_commit(struct bonding *bond)
> continue;
>
> case BOND_LINK_UP:
> -   if (bond_update_speed_duplex(slave)) {
> +   if (bond_update_speed_duplex(slave) &&
> +   bond_needs_speed_duplex(bond)) {
> slave->link = BOND_LINK_DOWN;
> netdev_warn(bond->dev,
> "failed to get link speed/duplex 
> for %s\n",
> diff --git a/include/net/bonding.h b/include/net/bonding.h
> index b00508d22e0a..b2e68657a216 100644
> --- a/include/net/bonding.h
> +++ b/include/net/bonding.h
> @@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond)
>BOND_MODE(bond) == BOND_MODE_ALB;
>  }
>
> +static inline bool bond_needs_speed_duplex(const struct bonding *bond)
> +{
> +   return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
> +}
> +
>  static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
>  {
> return (BOND_MODE(bond) == BOND_MODE_TLB)  &&
> --
> 2.14.0
>


Re: [PATCH V4 net 0/2] ipv6: fix flowlabel issue for reset packet

2017-08-10 Thread Tom Herbert
On Thu, Aug 10, 2017 at 9:30 AM, Shaohua Li  wrote:
> On Wed, Aug 09, 2017 at 09:40:08AM -0700, Tom Herbert wrote:
>> On Mon, Jul 31, 2017 at 3:19 PM, Shaohua Li  wrote:
>> > From: Shaohua Li 
>> >
>> > Please see below tcpdump output:
>> > 21:00:48.109122 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 40) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [S], cksum 0x0529 (incorrect -> 
>> > 0xf56c), seq 3282214508, win 43690, options [mss 65476,sackOK,TS val 
>> > 2500903437 ecr 0,nop,wscale 7], length 0
>> > 21:00:48.109381 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
>> > payload length: 40) fec0::5054:ff:fe12:3456. > 
>> > fec0::5054:ff:fe12:3456.55804: Flags [S.], cksum 0x0529 (incorrect -> 
>> > 0x49ad), seq 1923801573, ack 3282214509, win 43690, options [mss 
>> > 65476,sackOK,TS val 2500903437 ecr 2500903437,nop,wscale 7], length 0
>> > 21:00:48.109548 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
>> > 0x1bdf), seq 1, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 
>> > 2500903437], length 0
>> > 21:00:48.109823 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 62) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x053f (incorrect -> 
>> > 0xb8b1), seq 1:31, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 
>> > 2500903437], length 30
>> > 21:00:48.109910 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
>> > payload length: 32) fec0::5054:ff:fe12:3456. > 
>> > fec0::5054:ff:fe12:3456.55804: Flags [.], cksum 0x0521 (incorrect -> 
>> > 0x1bc1), seq 1, ack 31, win 342, options [nop,nop,TS val 2500903437 ecr 
>> > 2500903437], length 0
>> > 21:00:48.110043 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
>> > payload length: 56) fec0::5054:ff:fe12:3456. > 
>> > fec0::5054:ff:fe12:3456.55804: Flags [P.], cksum 0x0539 (incorrect -> 
>> > 0xb726), seq 1:25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 
>> > 2500903437], length 24
>> > 21:00:48.110173 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
>> > 0x1ba7), seq 31, ack 25, win 342, options [nop,nop,TS val 2500903438 ecr 
>> > 2500903438], length 0
>> > 21:00:48.110211 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
>> > payload length: 32) fec0::5054:ff:fe12:3456. > 
>> > fec0::5054:ff:fe12:3456.55804: Flags [F.], cksum 0x0521 (incorrect -> 
>> > 0x1ba7), seq 25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 
>> > 2500903437], length 0
>> > 21:00:48.151099 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
>> > 0x1ba6), seq 31, ack 26, win 342, options [nop,nop,TS val 2500903438 ecr 
>> > 2500903438], length 0
>> > 21:00:49.110524 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
>> > payload length: 56) fec0::5054:ff:fe12:3456.55804 > 
>> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x0539 (incorrect -> 
>> > 0xb324), seq 31:55, ack 26, win 342, options [nop,nop,TS val 2500904438 
>> > ecr 2500903438], length 24
>> > 21:00:49.110637 IP6 (flowlabel 0xb34d5, hlim 64, next-header TCP (6) 
>> > payload length: 20) fec0::5054:ff:fe12:3456. > 
>> > fec0::5054:ff:fe12:3456.55804: Flags [R], cksum 0x0515 (incorrect -> 
>> > 0x668c), seq 1923801599, win 0, length 0
>> >
>> > The flowlabel of reset packet (0xb34d5) and flowlabel of normal packet
>> > (0xd827f) are different. This causes our router doesn't correctly close tcp
>> > connection. The patches try to fix the issue.
>> >
>> Shaohua,
>>
>> Can you give some more detail about what the router doesn't close the
>> TCP connection means? I'm guessing the problem is either: 1) the
>> router is maintaining connection state that includes the flow label in
>> a connection tuple. 2) some router in the path is maintaining
>> connection state, but when the flow label changes the flow's packet
>> are routed through a different router that doesn't have a state for
>> the flow it drops the packet. #1 should be easily fix in the router,
>> flow labels cannot be used as state. #2 is the known problem that
>> stateful firewalls have killed our ability to use multihoming.
>
> The #2 is exactly the problem we saw.
>
>> Another consideration is that sk_txhash is also used in routing
>> decisions by the local host (flow label is normally derived from
>> txhash). If you want to ensure that connections are routed
>> consistently for timewait state you might need sk_txhash saved also.
>
> As far as I understood, we don't use sk_txhash for routing selection. The code
> does 

Re: unregister_netdevice: waiting for eth0 to become free. Usage count = 1

2017-08-10 Thread John Stultz
On Wed, Aug 9, 2017 at 10:41 PM, Wei Wang  wrote:
> Hi John,
>
> Is it possible to try the attached patch?

Thanks so much for the quick turn around!

So I dropped all the reverts you suggested, and applied this one
against 4.13-rc4, but I'm still seeing the problematic behavior.

> I am not sure if it actually fixes the issue. But I think it is worth a try.
> Also, could you get me all the ipv6 routes when you plug in the usb
> using "ip -6 route show"? (If you have multiple routing tables
> configured, could you dump them all?)

# ip -6 route show
2601:1c2:1002:83f0::/64 dev eth0  proto kernel  metric 256  expires
345599sec pref medium
fe80::/64 dev eth0  proto kernel  metric 256  pref medium
default via fe80::200:caff:fe11:2233 dev eth0  proto ra  metric 1024
expires 1799sec hoplimit 64 pref medium


After unplugging the device (and getting the unregister_netdevice errors):
# ip -6 route show
#


thanks
-john


Re: [net-next 03/12] e1000e: add check on e1e_wphy() return value

2017-08-10 Thread Joe Perches
On Wed, 2017-08-09 at 14:47 -0700, Jeff Kirsher wrote:
> From: Gustavo A R Silva 
> 
> Check return value from call to e1e_wphy(). This value is being
> checked during previous calls to function e1e_wphy() and it seems
> a check was missing here.

The use of "it seems" here is less than compelling.

Perhaps the write of 0x3140 to MII_BMCR takes too long for
the return value used.

Many other uses of e1e_wphy.*MII_BMCR are also not checked.

For instance: the e100e/ethtool uses.

> diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c 
> b/drivers/net/ethernet/intel/e1000e/ich8lan.c
[]
> @@ -2437,6 +2437,8 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct 
> e1000_hw *hw)
>   if (hw->phy.revision < 2) {
>   e1000e_phy_sw_reset(hw);
>   ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
> + if (ret_val)
> + return ret_val;
>   }
>   }
>  


Re: Regression: Bug 196547 - Since 4.12 - bonding module not working with wireless drivers

2017-08-10 Thread Andreas Born
Hi everyone,

2017-08-10 14:43 GMT+02:00 Arend van Spriel :
>
>
> On 10-08-17 07:39, Kalle Valo wrote:
>>
>> Hi Mahesh and Andy,
>>
>> James Feeney reported that there's a serious regression in bonding
>> module since v4.12, it doesn't work with wireless drivers anymore as
>> wireless drivers don't report the link speed via ethtool:
>>
>> https://bugzilla.kernel.org/show_bug.cgi?id=196547
>>
>> In the bug report it's said that this commit is the culprit:
>>
>> 3f3c278c94dd bonding: fix active-backup transition
>
>
> This commit references another one. ie. commit c4adfc822bf5 ("bonding: make 
> speed, duplex setting consistent with link state"). Before this commit the 
> result of __ethtool_get_link_ksettings() was simply ignored.

Actually it was not simply ignored in any case: Further down in
bond_miimon_commit() there's a conditional call to
bond_3ad_handle_link_change() which triggers an update using
__get_link_speed() to actually access the result. A similar handler is
also called for lb modes.

>
> Commit 3f3c278c94dd ("bonding: fix active-backup transition") moves setting 
> the link state to the call sites of bond_update_speed_duplex(), just not all 
> call sites.
>
>> Is there a fix for this or should that commit be reverted? This seems to
>> be a serious regression as there are multiple reports already and we
>> should get it fixed for v4.13, and the fix backported to v4.12 stable
>> release.
>
>
> The ethtool callbacks really seem optional. At least in brcmfmac, the 
> wireless driver I maintain, I only provide get_drvinfo callback and there is 
> no warning triggered upon registering the netdev. The changes above now 
> require each netdev to implement the get_link_ksettings callback 
> (get_settings is deprecated) or the link is marked as DOWN ruling it out to 
> be used as active bond slave. To the end-users who were using bonding this is 
> simply a regression. So to fix that both changes should be reverted in my 
> opinion.

Yes, also to me as user of a wireless slave in an active-backup bond
it's clearly a regression. But only partially for some modes like
active-backup since the bonding documentation [1] clearly lists as a
prerequisite

1) for 802.3ad: "Ethtool support in the base drivers for retrieving
the speed and duplex of each slave."
2) for tlb/alb: "Ethtool support in the base drivers for retrieving
the speed of each slave."

This was previously not directly enforced in the bonding code and thus
probably occasionally caused unexpected behavior. At least such
behavior is what to my understanding commit c4adfc822bf5 ("bonding:
make speed, duplex setting consistent with link state") and
3f3c278c94dd ("bonding: fix active-backup transition") intend to fix
with an apparent focus on 802.3ad. However those commits went too far
by requiring a get_link_ksettings implementation by every slave driver
REGARDLESS of the bond mode.

Earlier today I submitted the patch (bonding: require speed/duplex
only for 802.3ad, alb and tlb) [2] that only partially reverts what is
a regression following my aforementioned logic. This seems to me like
the best solution in the short term since it should satisfy both
usergroups represented by Mahesh and James and restores consistence
with the bonding documentation. James already commented approvingly on
that patch in the bug report. [3]

Regards
Andreas

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/bonding.txt
[2] https://www.spinics.net/lists/netdev/msg448662.html
[3] https://bugzilla.kernel.org/show_bug.cgi?id=196547#c10


[GIT] Networking

2017-08-10 Thread David Miller

1) Fix handling of initial STATE message in TIPC, from Jon Paul
   Maloy.

2) Fix stats handling in bcm_sysport_get_stats(), from Florian
   Fainelli.

3) Reject 16777215 VNI value in geneve_validate(), from Girish
   Moodalbail.

4) Fix initial IGMP sysctl setting regression, from Nikolay Borisov.

5) Once a UFO fragmented frame is treated as UFO, we should continue
   doing so.  Likewise once a frame has been segmented, we should
   continue doing that and not try to convert it to a UFO frame.
   From Willem de Bruijn.

6) Test the AF_PACKET RX/TX ring pg_vec state under the socket lock
   to prevent races.  From Willem de Bruijn.

Please pull, thanks a lot!

The following changes since commit 48fb6f4db940e92cfb16cd878cddd59ea6120d06:

  futex: Remove unnecessary warning from get_futex_key (2017-08-09 14:00:54 
-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 c27927e372f0785f3303e8fad94b85945e2c97b7:

  packet: fix tp_reserve race in packet_set_ring (2017-08-10 09:52:12 -0700)


Florian Fainelli (1):
  net: systemport: Fix software statistics for SYSTEMPORT Lite

Girish Moodalbail (1):
  geneve: maximum value of VNI cannot be used

Jon Paul Maloy (1):
  tipc: remove premature ESTABLISH FSM event at link synchronization

Nikolay Borisov (1):
  igmp: Fix regression caused by igmp sysctl namespace code.

Willem de Bruijn (2):
  udp: consistently apply ufo or fragmentation
  packet: fix tp_reserve race in packet_set_ring

Xin Long (1):
  net: sched: set xt_tgchk_param par.nft_compat as 0 in ipt_init_target

 drivers/net/ethernet/broadcom/bcmsysport.c |  4 
 drivers/net/geneve.c   |  2 +-
 net/ipv4/af_inet.c |  7 +++
 net/ipv4/igmp.c|  6 --
 net/ipv4/ip_output.c   |  8 +---
 net/ipv4/udp.c |  2 +-
 net/ipv6/ip6_output.c  |  7 ---
 net/packet/af_packet.c | 13 +
 net/sched/act_ipt.c|  2 +-
 net/tipc/node.c|  4 +---
 10 files changed, 33 insertions(+), 22 deletions(-)


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Stephen Hemminger
On Thu, 10 Aug 2017 10:55:01 -0600
David Ahern  wrote:

> On 8/10/17 10:48 AM, David Miller wrote:
> > From: Andrew Lunn 
> > Date: Thu, 10 Aug 2017 18:27:22 +0200
> >   
> >> On Thu, Aug 10, 2017 at 05:24:55PM +0200, Vitaly Kuznetsov wrote:  
> >>> Andrew Lunn  writes:
> >>>  
> > We are - rtnetlink_event() does the job. We, however, don't have a
> > special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.  
> 
>  What is in this event? Old and new name? Just the new name?  
> >>>
> >>> Basically, it's everything we know about the interface - type, index,
> >>> name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
> >>> it's only the new name.  
> >>
> >> So the program needs to keep track of ifindex to know which interface
> >> has changed name. Doable.
> >>
> >> I still expect this has the potential to break something. You probably
> >> should be asking on linux-api for the API experts opinion.  
> > 
> > But a greater point is that nobody is monitoring device renames
> > explicitly right now.  
> 
> Just to throw in an example:
>   https://github.com/kobolabs/dhcpcd/blob/kobo/if-linux.c#L761
> 
> Learned of its use from a recent regression:
> https://bugzilla.kernel.org/show_bug.cgi?id=196355

Quagga is another example of what might break. Especially with all the new
forks..


[PATCH ipsec-next] net: xfrm: support setting an output mark.

2017-08-10 Thread Lorenzo Colitti
On systems that use mark-based routing it may be necessary for
routing lookups to use marks in order for packets to be routed
correctly. An example of such a system is Android, which uses
socket marks to route packets via different networks.

Currently, routing lookups in tunnel mode always use a mark of
zero, making routing incorrect on such systems.

This patch adds a new output_mark element to the xfrm state and
a corresponding XFRMA_OUTPUT_MARK netlink attribute. The output
mark differs from the existing xfrm mark in two ways:

1. The xfrm mark is used to match xfrm policies and states, while
   the xfrm output mark is used to set the mark (and influence
   the routing) of the packets emitted by those states.
2. The existing mark is constrained to be a subset of the bits of
   the originating socket or transformed packet, but the output
   mark is arbitrary and depends only on the state.

The use of a separate mark provides additional flexibility. For
example:

- A packet subject to two transforms (e.g., transport mode inside
  tunnel mode) can have two different output marks applied to it,
  one for the transport mode SA and one for the tunnel mode SA.
- On a system where socket marks determine routing, the packets
  emitted by an IPsec tunnel can be routed based on a mark that
  is determined by the tunnel, not by the marks of the
  unencrypted packets.
- Support for setting the output marks can be introduced without
  breaking any existing setups that employ both mark-based
  routing and xfrm tunnel mode. Simply changing the code to use
  the xfrm mark for routing output packets could xfrm mark could
  change behaviour in a way that breaks these setups.

If the output mark is unspecified or set to zero, the mark is not
set or changed.

Tested: make allyesconfig; make -j64
Tested: https://android-review.googlesource.com/452776
Signed-off-by: Lorenzo Colitti 
---
 include/net/xfrm.h|  9 ++---
 include/uapi/linux/xfrm.h |  1 +
 net/ipv4/xfrm4_policy.c   | 14 +-
 net/ipv6/xfrm6_policy.c   |  9 ++---
 net/xfrm/xfrm_device.c|  3 ++-
 net/xfrm/xfrm_output.c|  3 +++
 net/xfrm/xfrm_policy.c| 17 +
 net/xfrm/xfrm_user.c  | 11 +++
 8 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 18d7de34a5..9c7b70cce6 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -165,6 +165,7 @@ struct xfrm_state {
int header_len;
int trailer_len;
u32 extra_flags;
+   u32 output_mark;
} props;
 
struct xfrm_lifetime_cfg lft;
@@ -298,10 +299,12 @@ struct xfrm_policy_afinfo {
struct dst_entry*(*dst_lookup)(struct net *net,
   int tos, int oif,
   const xfrm_address_t *saddr,
-  const xfrm_address_t *daddr);
+  const xfrm_address_t *daddr,
+  u32 mark);
int (*get_saddr)(struct net *net, int oif,
 xfrm_address_t *saddr,
-xfrm_address_t *daddr);
+xfrm_address_t *daddr,
+u32 mark);
void(*decode_session)(struct sk_buff *skb,
  struct flowi *fl,
  int reverse);
@@ -1640,7 +1643,7 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, 
struct sk_buff *skb)
 struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif,
const xfrm_address_t *saddr,
const xfrm_address_t *daddr,
-   int family);
+   int family, u32 mark);
 
 struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp);
 
diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 2b384ff09f..5fe7370a2b 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -304,6 +304,7 @@ enum xfrm_attr_type_t {
XFRMA_ADDRESS_FILTER,   /* struct xfrm_address_filter */
XFRMA_PAD,
XFRMA_OFFLOAD_DEV,  /* struct xfrm_state_offload */
+   XFRMA_OUTPUT_MARK,  /* __u32 */
__XFRMA_MAX
 
 #define XFRMA_MAX (__XFRMA_MAX - 1)
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 4aefb149fe..d7bf0b0418 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -20,7 +20,8 @@
 static struct dst_entry *__xfrm4_dst_lookup(struct net *net, struct flowi4 
*fl4,
int tos, int oif,
 

Re: [PATCH V5 1/2] firmware: add more flexible request_firmware_async function

2017-08-10 Thread Luis R. Rodriguez
On Thu, Aug 03, 2017 at 05:55:18AM +, Coelho, Luciano wrote:
> On Thu, 2017-08-03 at 08:23 +0300, Kalle Valo wrote:
> > "Luis R. Rodriguez"  writes:
> > 
> > > > +int request_firmware_nowait(struct module *module, bool uevent,
> > > > +   const char *name, struct device *device, 
> > > > gfp_t gfp,
> > > > +   void *context,
> > > > +   void (*cont)(const struct firmware *fw, 
> > > > void *context))
> > > > +{
> > > > +   unsigned int opt_flags = FW_OPT_FALLBACK |
> > > > +   (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
> > > > +
> > > > +   return __request_firmware_nowait(module, opt_flags, name, 
> > > > device, gfp,
> > > > +context, cont);
> > > > +}
> > > >  EXPORT_SYMBOL(request_firmware_nowait);
> > > >  
> > > > +int __request_firmware_async(struct module *module, const char *name,
> > > > +struct firmware_opts *fw_opts, struct 
> > > > device *dev,
> > > > +void *context,
> > > > +void (*cont)(const struct firmware *fw, 
> > > > void *context))
> > > > +{
> > > > +   unsigned int opt_flags = FW_OPT_UEVENT;
> > > 
> > > This exposes a long issue. Think -- why do we want this enabled by 
> > > default? Its
> > > actually because even though the fallback stuff is optional and can be, 
> > > the uevent
> > > internal flag *also* provides caching support as a side consequence only. 
> > > We
> > > don't want to add a new API without first cleaning up that mess.
> > > 
> > > This is a slipery slope and best to clean that up before adding any new 
> > > API.
> > > 
> > > That and also Greg recently stated he would like to see at least 3 users 
> > > of
> > > a feature before adding it. Although I think that's pretty arbitrary, and
> > > considering that request_firmware_into_buf() only has *one* user -- its 
> > > what
> > > he wishes.
> > 
> > ath10k at least needs a way to silence the warning for missing firmware
> > and I think iwlwifi also.
> 
> Yes, iwlwifi needs to silence the warning.  It the feature (only one,
> really) that I've been waiting for.

Luca,

can you confirm? The API revision thing is one thing but as I noted to
Kalle that can be done using a different API scheme as I had proposed on
the driver data API.

Other than that are there specific firmware requests which are async which
are not API revision style (min...max) for which an async request is optional?

 Luis


Re: [PATCH V5 1/2] firmware: add more flexible request_firmware_async function

2017-08-10 Thread Luis R. Rodriguez
On Thu, Aug 03, 2017 at 08:23:00AM +0300, Kalle Valo wrote:
> "Luis R. Rodriguez"  writes:
> 
> >> +int request_firmware_nowait(struct module *module, bool uevent,
> >> +  const char *name, struct device *device, gfp_t gfp,
> >> +  void *context,
> >> +  void (*cont)(const struct firmware *fw, void 
> >> *context))
> >> +{
> >> +  unsigned int opt_flags = FW_OPT_FALLBACK |
> >> +  (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
> >> +
> >> +  return __request_firmware_nowait(module, opt_flags, name, device, gfp,
> >> +   context, cont);
> >> +}
> >>  EXPORT_SYMBOL(request_firmware_nowait);
> >>  
> >> +int __request_firmware_async(struct module *module, const char *name,
> >> +   struct firmware_opts *fw_opts, struct device *dev,
> >> +   void *context,
> >> +   void (*cont)(const struct firmware *fw, void 
> >> *context))
> >> +{
> >> +  unsigned int opt_flags = FW_OPT_UEVENT;
> >
> > This exposes a long issue. Think -- why do we want this enabled by default? 
> > Its
> > actually because even though the fallback stuff is optional and can be, the 
> > uevent
> > internal flag *also* provides caching support as a side consequence only. We
> > don't want to add a new API without first cleaning up that mess.
> >
> > This is a slipery slope and best to clean that up before adding any new API.
> >
> > That and also Greg recently stated he would like to see at least 3 users of
> > a feature before adding it. Although I think that's pretty arbitrary, and
> > considering that request_firmware_into_buf() only has *one* user -- its what
> > he wishes.
> 
> ath10k at least needs a way to silence the warning for missing firmware
> and I think iwlwifi also.

It would seem ath10k actually does not need an async version of the no-warn
thing proposed here.

Below an analysis of how ath10k uses the firmware API. Note that I think
that iwlwifi may be on the same boat but the case and issue is slightly
different: both drivers use an API revision scheme, intermediate files
which are not found are not fatal as revisions go from min..max and only
one file is needed. A warning may be needed only if *no* file is found
at all.

I had proposed a new API call to handle this in the driver API series but
had only converted iwlwifi. It would seem ath10k can also be converted to
it and also they could end up sharing the same revision loop scheme so
less code on both drivers.

Below my analysis of how ath10k uses the firmware API:

You noted in private that ath10k long ago addressed the warning issue by
switching to request_firmware_direct() entirely:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f5bcfe93315d75da4cc46bd30b536966559359a

Below is a list of the file name schemes used for all the different firmwares
types used in ath10k:

1)
/* pre-cal--.bin */
scnprintf(filename, sizeof(filename), "pre-cal-%s-%s.bin", 

2)

/* cal--.bin */
scnprintf(filename, sizeof(filename), "cal-%s-%s.bin",  
  ath10k_bus_str(ar->hif.bus), dev_name(ar->dev)); 


This seems fine as-is if indeed they are optional.

3) ath10k_core_fetch_board_data_api_1():

ar->hw_params.fw.dir/ar->hw_params.fw.board

This seems fine if indeed its optional.

3) Then you have a board file on ath10k_core_fetch_board_data_api_n():

boardname/ATH10K_BOARD_API2_FILE

This seems fine if indeed its optional.

4) Finally you have the actual firmware files which use a revision scheme
in ath10k_core_fetch_firmware_api_n():

for (i = ATH10K_FW_API_MAX; i >= ATH10K_FW_API_MIN; i--) {  
ar->fw_api = i; 
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n",   
   ar->fw_api); 

ath10k_core_get_fw_name(ar, fw_name, sizeof(fw_name), 
ar->fw_api);
ret = ath10k_core_fetch_firmware_api_n(ar, fw_name, 
   
>normal_mode_fw.fw_file);
if (!ret)   
goto success;   
}

This ends up using the ar->hw_params.fw.dir/fw_name but fw_name is constructed
above using a API revision scheme. The fw_name can be of two types as per
ath10k_core_get_fw_name():

For SDIO:

scnprintf(fw_name, fw_name_len, "%s-%s-%d.bin", 
  ATH10K_FW_FILE_BASE, ath10k_bus_str(ar->hif.bus), 
  fw_api); 


Re: [PATCH net-next] net: skb_needs_check() removes CHECKSUM_NONE check for tx.

2017-08-10 Thread Willem de Bruijn
On Wed, Aug 9, 2017 at 6:02 PM, Tonghao Zhang  wrote:
> Thanks for your work.

You, too.

> On Thu, Aug 10, 2017 at 2:30 AM, Willem de Bruijn
>  wrote:
>> On Wed, Aug 9, 2017 at 5:04 AM, Tonghao Zhang  
>> wrote:
>>> This patch reverts the commit 6e7bc478c9a0
>>> ("net: skb_needs_check() accepts CHECKSUM_NONE for tx"),
>>> because we removed the UFO support.
>>>
>>> Cc: Eric Dumazet 
>>> Cc: Willem de Bruijn 
>>> Signed-off-by: Tonghao Zhang 
>>
>>
>> I would wait until net is merged into net-next. This will cause a conflict.
>>
>> Also, while logically equivalent, it is not a real revert (as in `git
>> revert $SHA1`) of that patch.
>>
>> Aside from those concerns, I agree that the original patch is no
>> longer needed now that UFO is reverted.

Please do resubmit the revert patch once net has been merged into net-next.


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread David Ahern
On 8/10/17 10:48 AM, David Miller wrote:
> From: Andrew Lunn 
> Date: Thu, 10 Aug 2017 18:27:22 +0200
> 
>> On Thu, Aug 10, 2017 at 05:24:55PM +0200, Vitaly Kuznetsov wrote:
>>> Andrew Lunn  writes:
>>>
> We are - rtnetlink_event() does the job. We, however, don't have a
> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.

 What is in this event? Old and new name? Just the new name?
>>>
>>> Basically, it's everything we know about the interface - type, index,
>>> name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
>>> it's only the new name.
>>
>> So the program needs to keep track of ifindex to know which interface
>> has changed name. Doable.
>>
>> I still expect this has the potential to break something. You probably
>> should be asking on linux-api for the API experts opinion.
> 
> But a greater point is that nobody is monitoring device renames
> explicitly right now.

Just to throw in an example:
  https://github.com/kobolabs/dhcpcd/blob/kobo/if-linux.c#L761

Learned of its use from a recent regression:
https://bugzilla.kernel.org/show_bug.cgi?id=196355


Re: [PATCH net] packet: fix tp_reserve race in packet_set_ring

2017-08-10 Thread David Miller
From: Willem de Bruijn 
Date: Thu, 10 Aug 2017 12:41:58 -0400

> From: Willem de Bruijn 
> 
> Updates to tp_reserve can race with reads of the field in
> packet_set_ring. Avoid this by holding the socket lock during
> updates in setsockopt PACKET_RESERVE.
> 
> This bug was discovered by syzkaller.
> 
> Fixes: 8913336a7e8d ("packet: add PACKET_RESERVE sockopt")
> Reported-by: Andrey Konovalov 
> Signed-off-by: Willem de Bruijn 

Also applied and queued up for -stable, thanks Willem.


Re: [PATCH net] udp: consistently apply ufo or fragmentation

2017-08-10 Thread David Miller
From: Willem de Bruijn 
Date: Thu, 10 Aug 2017 12:29:19 -0400

> From: Willem de Bruijn 
> 
> When iteratively building a UDP datagram with MSG_MORE and that
> datagram exceeds MTU, consistently choose UFO or fragmentation.
> 
> Once skb_is_gso, always apply ufo. Conversely, once a datagram is
> split across multiple skbs, do not consider ufo.
> 
> Sendpage already maintains the first invariant, only add the second.
> IPv6 does not have a sendpage implementation to modify.
> 
> A gso skb must have a partial checksum, do not follow sk_no_check_tx
> in udp_send_skb.
> 
> Found by syzkaller.
> 
> Fixes: e89e9cf539a2 ("[IPv4/IPv6]: UFO Scatter-gather approach")
> Reported-by: Andrey Konovalov 
> Signed-off-by: Willem de Bruijn 

Applied and queued up for -stable.


Re: [PATCH 0/3] ARM: dts: keystone-k2g: Add DCAN instances to 66AK2G

2017-08-10 Thread santosh.shilim...@oracle.com

On 8/7/17 2:31 PM, Franklin S Cooper Jr wrote:


Hi Santosh,
On 08/04/2017 12:07 PM, Santosh Shilimkar wrote:

Hi Franklin,

On 8/2/2017 1:18 PM, Franklin S Cooper Jr wrote:

Add D CAN nodes to 66AK2G based SoC dtsi.

Franklin S Cooper Jr (2):
dt-bindings: net: c_can: Update binding for clock and power-domains
  property
ARM: configs: keystone: Enable D_CAN driver

Lokesh Vutla (1):
ARM: dts: k2g: Add DCAN nodes


Any DCAN driver dependency with these patchset ? If not, I can
queue this up so do let me know.


There aren't any dependencies.


Applied. Thanks !!

Regards,
Santosh



Re: [PATCH net-next 0/6] rtnetlink: fix initial rtnl pushdown fallout

2017-08-10 Thread David Miller
From: Florian Westphal 
Date: Thu, 10 Aug 2017 16:52:56 +0200

> This series fixes various bugs and splats reported since the
> allow-handler-to-run-with-no-rtnl series went in.
> 
> Last patch adds a script that can be used to add further
> tests in case more bugs are reported.
> In case you prefer reverting the original series instead of
> fixing fallout I can resend this patch on its own.

Series applied, thanks Florian.


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread David Miller
From: Andrew Lunn 
Date: Thu, 10 Aug 2017 18:27:22 +0200

> On Thu, Aug 10, 2017 at 05:24:55PM +0200, Vitaly Kuznetsov wrote:
>> Andrew Lunn  writes:
>> 
>> >> We are - rtnetlink_event() does the job. We, however, don't have a
>> >> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.
>> >
>> > What is in this event? Old and new name? Just the new name?
>> 
>> Basically, it's everything we know about the interface - type, index,
>> name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
>> it's only the new name.
> 
> So the program needs to keep track of ifindex to know which interface
> has changed name. Doable.
> 
> I still expect this has the potential to break something. You probably
> should be asking on linux-api for the API experts opinion.

But a greater point is that nobody is monitoring device renames
explicitly right now.

It's hard to legitimize imposing new requirements like this on daemons
which didn't exist before.

If they could assume the name didn't change, they probably are doing
so.

You can't expect that just because they might already be listening to
this event for device up and down tracking that they are handling
device renames.


[PATCH net] packet: fix tp_reserve race in packet_set_ring

2017-08-10 Thread Willem de Bruijn
From: Willem de Bruijn 

Updates to tp_reserve can race with reads of the field in
packet_set_ring. Avoid this by holding the socket lock during
updates in setsockopt PACKET_RESERVE.

This bug was discovered by syzkaller.

Fixes: 8913336a7e8d ("packet: add PACKET_RESERVE sockopt")
Reported-by: Andrey Konovalov 
Signed-off-by: Willem de Bruijn 
---
 net/packet/af_packet.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 0615c2a950fa..008a45ca3112 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3700,14 +3700,19 @@ packet_setsockopt(struct socket *sock, int level, int 
optname, char __user *optv
 
if (optlen != sizeof(val))
return -EINVAL;
-   if (po->rx_ring.pg_vec || po->tx_ring.pg_vec)
-   return -EBUSY;
if (copy_from_user(, optval, sizeof(val)))
return -EFAULT;
if (val > INT_MAX)
return -EINVAL;
-   po->tp_reserve = val;
-   return 0;
+   lock_sock(sk);
+   if (po->rx_ring.pg_vec || po->tx_ring.pg_vec) {
+   ret = -EBUSY;
+   } else {
+   po->tp_reserve = val;
+   ret = 0;
+   }
+   release_sock(sk);
+   return ret;
}
case PACKET_LOSS:
{
-- 
2.14.0.434.g98096fd7a8-goog



Re: [PATCH 1/3] dt-bindings: net: c_can: Update binding for clock and power-domains property

2017-08-10 Thread Rob Herring
On Wed, Aug 02, 2017 at 03:18:20PM -0500, Franklin S Cooper Jr wrote:
> CAN driver uses the clk_get_rate call to determine the frequency of the
> functional clock. OMAP based SoCs do not require the clock property since
> hwmod already handles creating a "fck" clock thats accessible to drivers.

that's

> However, this isn't the case for 66AK2G which makes the clocks property
> require for that SoC.

required

> 
> 66AK2G requires a new property. Therefore, update the binding to also make
> this property requirement clear. Also clarify that for OMAP based SoCs
> ti,hwmod is a required property.
> 
> Signed-off-by: Franklin S Cooper Jr 
> ---
>  Documentation/devicetree/bindings/net/can/c_can.txt | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)

Otherwise,

Acked-by: Rob Herring 


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Vitaly Kuznetsov
Andrew Lunn  writes:

> On Thu, Aug 10, 2017 at 05:24:55PM +0200, Vitaly Kuznetsov wrote:
>> Andrew Lunn  writes:
>> 
>> >> We are - rtnetlink_event() does the job. We, however, don't have a
>> >> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.
>> >
>> > What is in this event? Old and new name? Just the new name?
>> 
>> Basically, it's everything we know about the interface - type, index,
>> name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
>> it's only the new name.
>
> So the program needs to keep track of ifindex to know which interface
> has changed name. Doable.
>

Yes, and I'd expect that's what these daemons do nowdays to track name
changes for down interfaces (if/when they care).

> I still expect this has the potential to break something. You probably
> should be asking on linux-api for the API experts opinion.
>

Good idea, I'll do RFCv2 submission.

-- 
  Vitaly


Re: [PATCH V4 net 0/2] ipv6: fix flowlabel issue for reset packet

2017-08-10 Thread Shaohua Li
On Wed, Aug 09, 2017 at 09:40:08AM -0700, Tom Herbert wrote:
> On Mon, Jul 31, 2017 at 3:19 PM, Shaohua Li  wrote:
> > From: Shaohua Li 
> >
> > Please see below tcpdump output:
> > 21:00:48.109122 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 40) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [S], cksum 0x0529 (incorrect -> 
> > 0xf56c), seq 3282214508, win 43690, options [mss 65476,sackOK,TS val 
> > 2500903437 ecr 0,nop,wscale 7], length 0
> > 21:00:48.109381 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> > payload length: 40) fec0::5054:ff:fe12:3456. > 
> > fec0::5054:ff:fe12:3456.55804: Flags [S.], cksum 0x0529 (incorrect -> 
> > 0x49ad), seq 1923801573, ack 3282214509, win 43690, options [mss 
> > 65476,sackOK,TS val 2500903437 ecr 2500903437,nop,wscale 7], length 0
> > 21:00:48.109548 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> > 0x1bdf), seq 1, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 
> > 2500903437], length 0
> > 21:00:48.109823 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 62) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x053f (incorrect -> 
> > 0xb8b1), seq 1:31, ack 1, win 342, options [nop,nop,TS val 2500903437 ecr 
> > 2500903437], length 30
> > 21:00:48.109910 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> > payload length: 32) fec0::5054:ff:fe12:3456. > 
> > fec0::5054:ff:fe12:3456.55804: Flags [.], cksum 0x0521 (incorrect -> 
> > 0x1bc1), seq 1, ack 31, win 342, options [nop,nop,TS val 2500903437 ecr 
> > 2500903437], length 0
> > 21:00:48.110043 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> > payload length: 56) fec0::5054:ff:fe12:3456. > 
> > fec0::5054:ff:fe12:3456.55804: Flags [P.], cksum 0x0539 (incorrect -> 
> > 0xb726), seq 1:25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 
> > 2500903437], length 24
> > 21:00:48.110173 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> > 0x1ba7), seq 31, ack 25, win 342, options [nop,nop,TS val 2500903438 ecr 
> > 2500903438], length 0
> > 21:00:48.110211 IP6 (flowlabel 0xd827f, hlim 64, next-header TCP (6) 
> > payload length: 32) fec0::5054:ff:fe12:3456. > 
> > fec0::5054:ff:fe12:3456.55804: Flags [F.], cksum 0x0521 (incorrect -> 
> > 0x1ba7), seq 25, ack 31, win 342, options [nop,nop,TS val 2500903438 ecr 
> > 2500903437], length 0
> > 21:00:48.151099 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 32) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [.], cksum 0x0521 (incorrect -> 
> > 0x1ba6), seq 31, ack 26, win 342, options [nop,nop,TS val 2500903438 ecr 
> > 2500903438], length 0
> > 21:00:49.110524 IP6 (flowlabel 0x43304, hlim 64, next-header TCP (6) 
> > payload length: 56) fec0::5054:ff:fe12:3456.55804 > 
> > fec0::5054:ff:fe12:3456.: Flags [P.], cksum 0x0539 (incorrect -> 
> > 0xb324), seq 31:55, ack 26, win 342, options [nop,nop,TS val 2500904438 ecr 
> > 2500903438], length 24
> > 21:00:49.110637 IP6 (flowlabel 0xb34d5, hlim 64, next-header TCP (6) 
> > payload length: 20) fec0::5054:ff:fe12:3456. > 
> > fec0::5054:ff:fe12:3456.55804: Flags [R], cksum 0x0515 (incorrect -> 
> > 0x668c), seq 1923801599, win 0, length 0
> >
> > The flowlabel of reset packet (0xb34d5) and flowlabel of normal packet
> > (0xd827f) are different. This causes our router doesn't correctly close tcp
> > connection. The patches try to fix the issue.
> >
> Shaohua,
> 
> Can you give some more detail about what the router doesn't close the
> TCP connection means? I'm guessing the problem is either: 1) the
> router is maintaining connection state that includes the flow label in
> a connection tuple. 2) some router in the path is maintaining
> connection state, but when the flow label changes the flow's packet
> are routed through a different router that doesn't have a state for
> the flow it drops the packet. #1 should be easily fix in the router,
> flow labels cannot be used as state. #2 is the known problem that
> stateful firewalls have killed our ability to use multihoming.

The #2 is exactly the problem we saw.
 
> Another consideration is that sk_txhash is also used in routing
> decisions by the local host (flow label is normally derived from
> txhash). If you want to ensure that connections are routed
> consistently for timewait state you might need sk_txhash saved also.

As far as I understood, we don't use sk_txhash for routing selection. The code
does routing selection with flowlabel user configured, at that time we don't
derive fl6.flowlabel from skb->hash (which is from sk_txhash). The code always
does 

[PATCH net] udp: consistently apply ufo or fragmentation

2017-08-10 Thread Willem de Bruijn
From: Willem de Bruijn 

When iteratively building a UDP datagram with MSG_MORE and that
datagram exceeds MTU, consistently choose UFO or fragmentation.

Once skb_is_gso, always apply ufo. Conversely, once a datagram is
split across multiple skbs, do not consider ufo.

Sendpage already maintains the first invariant, only add the second.
IPv6 does not have a sendpage implementation to modify.

A gso skb must have a partial checksum, do not follow sk_no_check_tx
in udp_send_skb.

Found by syzkaller.

Fixes: e89e9cf539a2 ("[IPv4/IPv6]: UFO Scatter-gather approach")
Reported-by: Andrey Konovalov 
Signed-off-by: Willem de Bruijn 
---
 net/ipv4/ip_output.c  | 8 +---
 net/ipv4/udp.c| 2 +-
 net/ipv6/ip6_output.c | 7 ---
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 50c74cd890bc..e153c40c2436 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -965,11 +965,12 @@ static int __ip_append_data(struct sock *sk,
csummode = CHECKSUM_PARTIAL;
 
cork->length += length;
-   if length + (skb ? skb->len : fragheaderlen)) > mtu) ||
-(skb && skb_is_gso(skb))) &&
+   if ((skb && skb_is_gso(skb)) ||
+   (((length + (skb ? skb->len : fragheaderlen)) > mtu) &&
+   (skb_queue_len(queue) <= 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(>dst) &&
-   (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) {
+   (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx)) {
err = ip_ufo_append_data(sk, queue, getfrag, from, length,
 hh_len, fragheaderlen, transhdrlen,
 maxfraglen, flags);
@@ -1288,6 +1289,7 @@ ssize_t   ip_append_page(struct sock *sk, struct flowi4 
*fl4, struct page *page,
return -EINVAL;
 
if ((size + skb->len > mtu) &&
+   (skb_queue_len(>sk_write_queue) == 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO)) {
if (skb->ip_summed != CHECKSUM_PARTIAL)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e6276fa3750b..a7c804f73990 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -802,7 +802,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 
*fl4)
if (is_udplite)  /* UDP-Lite  */
csum = udplite_csum(skb);
 
-   else if (sk->sk_no_check_tx) {   /* UDP csum disabled */
+   else if (sk->sk_no_check_tx && !skb_is_gso(skb)) {   /* UDP csum off */
 
skb->ip_summed = CHECKSUM_NONE;
goto send;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 162efba0d0cd..2dfe50d8d609 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1381,11 +1381,12 @@ static int __ip6_append_data(struct sock *sk,
 */
 
cork->length += length;
-   if length + (skb ? skb->len : headersize)) > mtu) ||
-(skb && skb_is_gso(skb))) &&
+   if ((skb && skb_is_gso(skb)) ||
+   (((length + (skb ? skb->len : headersize)) > mtu) &&
+   (skb_queue_len(queue) <= 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(>dst) &&
-   (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
+   (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk))) {
err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
  hh_len, fragheaderlen, exthdrlen,
  transhdrlen, mtu, flags, fl6);
-- 
2.14.0.434.g98096fd7a8-goog



Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Andrew Lunn
On Thu, Aug 10, 2017 at 05:24:55PM +0200, Vitaly Kuznetsov wrote:
> Andrew Lunn  writes:
> 
> >> We are - rtnetlink_event() does the job. We, however, don't have a
> >> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.
> >
> > What is in this event? Old and new name? Just the new name?
> 
> Basically, it's everything we know about the interface - type, index,
> name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
> it's only the new name.

So the program needs to keep track of ifindex to know which interface
has changed name. Doable.

I still expect this has the potential to break something. You probably
should be asking on linux-api for the API experts opinion.

   Andrew


Re: [PATCHv2 1/2] drivers: net: davinci_mdio: remove busy loop on wait user access

2017-08-10 Thread Grygorii Strashko



On 08/10/2017 02:47 AM, Max Uvarov wrote:

Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
due to busy loop in wait(). Add small delay to relax cpu.

Signed-off-by: Max Uvarov 


yep. cover letter is good to have.

Reviewed-by: Grygorii Strashko 


---
  v2: fix spelling in commit description.

  drivers/net/ethernet/ti/davinci_mdio.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c 
b/drivers/net/ethernet/ti/davinci_mdio.c
index 33df340..611e7cc 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -198,8 +198,10 @@ static inline int wait_for_user_access(struct 
davinci_mdio_data *data)
return 0;
  
  		reg = __raw_readl(>control);

-   if ((reg & CONTROL_IDLE) == 0)
+   if ((reg & CONTROL_IDLE) == 0) {
+   usleep_range(100, 200);
continue;
+   }
  
  		/*

 * An emac soft_reset may have clobbered the mdio controller's



--
regards,
-grygorii


Re: [PATCH 4/8] tty/bcm63xx_uart: allow naming clock in device tree

2017-08-10 Thread Rob Herring
On Wed, Aug 02, 2017 at 11:34:25AM +0200, Jonas Gorski wrote:
> Codify using a named clock for the refclk of the uart. This makes it
> easier if we might need to add a gating clock (like present on the
> BCM6345).
> 
> Signed-off-by: Jonas Gorski 
> ---
>  Documentation/devicetree/bindings/serial/brcm,bcm6345-uart.txt | 6 ++
>  drivers/tty/serial/bcm63xx_uart.c  | 6 --
>  2 files changed, 10 insertions(+), 2 deletions(-)

Acked-by: Rob Herring 


Re: [PATCH v2 net-next 0/7] rtnetlink: allow selected handlers to run without rtnl

2017-08-10 Thread David Ahern
On 8/10/17 5:29 AM, Florian Westphal wrote:
> David Ahern  wrote:
> 
>> On 8/9/17 6:21 PM, David Miller wrote:
>>>
>>> Ok series applied, let's see where this goes :-)
>>>
>>
>> 1 hour in, 1 problem reported
> 
> Its even worse.  Would you rather see a revert?

no.

> 
> I'm sure that you are aware that the widespread rtnl usage is a
> problem because it does hurt scalability. I still think its worth trying
> to disentangle this where possible.

agreed. Going to be pain along the way, but it needs to be done. Thanks
for taking the initiative on it.


Re: [PATCHv2 2/2] drivers: net: davinci_mdio: print bus frequency

2017-08-10 Thread Grygorii Strashko



On 08/10/2017 02:47 AM, Max Uvarov wrote:

Frequency can be adjusted in DT it make sense to
print current used value on driver init.

Signed-off-by: Max Uvarov 


 Reviewed-by: Grygorii Strashko 


---
  drivers/net/ethernet/ti/davinci_mdio.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c 
b/drivers/net/ethernet/ti/davinci_mdio.c
index 611e7cc..3c33f45 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -159,8 +159,10 @@ static int davinci_mdio_reset(struct mii_bus *bus)
  
  	/* dump hardware version info */

ver = __raw_readl(>regs->version);
-   dev_info(data->dev, "davinci mdio revision %d.%d\n",
-(ver >> 8) & 0xff, ver & 0xff);
+   dev_info(data->dev,
+"davinci mdio revision %d.%d, bus freq %ld\n",
+(ver >> 8) & 0xff, ver & 0xff,
+data->pdata.bus_freq);
  
  	if (data->skip_scan)

goto done;



--
regards,
-grygorii


Re: [PATCH net-next 3/6] rtnetlink: switch rtnl_link_get_slave_info_data_size to rcu

2017-08-10 Thread David Ahern
On 8/10/17 8:52 AM, Florian Westphal wrote:
> David Ahern reports following splat:
>  RTNL: assertion failed at net/core/dev.c (5717)
>  netdev_master_upper_dev_get+0x5f/0x70
>  if_nlmsg_size+0x158/0x240
>  rtnl_calcit.isra.26+0xa3/0xf0
> 
> rtnl_link_get_slave_info_data_size currently assumes RTNL protection, but
> there appears to be no hard requirement for this, so use rcu instead.
> 
> At the time of this writing, there are three 'get_slave_size' callbacks
> (now invoked under rcu): bond_get_slave_size, vrf_get_slave_size and
> br_port_get_slave_size, all return constant only (i.e. they don't sleep).
> 
> Fixes: 6853dd488119 ("rtnetlink: protect handler table with rcu")
> Reported-by: David Ahern 
> Signed-off-by: Florian Westphal 
> ---
>  net/core/rtnetlink.c | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)

Acked-by: David Ahern 


Re: [PATCH net-next] net: core: fix compile error inside flow_dissector due to new dsa callback

2017-08-10 Thread David Miller
From: John Crispin 
Date: Thu, 10 Aug 2017 10:09:03 +0200

> The following error was introduced by
> commit 43e665287f93 ("net-next: dsa: fix flow dissection")
> due to a missing #if guard
> 
> net/core/flow_dissector.c: In function '__skb_flow_dissect':
> net/core/flow_dissector.c:448:18: error: 'struct net_device' has no member 
> named 'dsa_ptr'
> ops = skb->dev->dsa_ptr->tag_ops;
> ^
> make[3]: *** [net/core/flow_dissector.o] Error 1
> 
> Signed-off-by: John Crispin 

Applied, thanks.


Re: [PATCH] hv_set_ifconfig.sh double check before setting ip

2017-08-10 Thread David Miller
From: Eduardo Otubo 
Date: Thu, 10 Aug 2017 09:40:27 +0200

> On 08/09/2017 11:02 AM, Eduardo Otubo wrote:
>> On 08/09/2017 06:11 AM, David Miller wrote:
>>> From: Eduardo Otubo 
>>> Date: Tue,  8 Aug 2017 15:53:45 +0200
>>>
 This patch fixes the behavior of the hv_set_ifconfig script when
 setting
 the interface ip. Sometimes the interface has already been configured
 by
 network daemon, in this case hv_set_ifconfig causes "RTNETLINK: file
 exists error"; in order to avoid this error this patch makes sure
 double
 checks the interface before trying anything.

 Signed-off-by: Eduardo Otubo 
>>>
>>> And if the daemon sets the address after you test it but before
>>> you try to set it in the script, what happens?
>>>
>>> This is why I hate changes like this.  They don't remove the problem,
>>> they make it smaller.  And smaller in a bad way.  Smaller makes the
>>> problem even more harder to diagnose when it happens.
>>>
>>> There is implicitly no synchonization between network configuration
>>> daemons and things people run by hand like this script.
>>>
>>> So, caveat emptor.
>>>
>>> I'm not applying this, sorry.
> 
> But also, looking from a different point of view, the current upstream
> solution does not avoid the problems you mentioned. My fix at least
> avoids double configuration and RTNETLINK errors. So perhaps you could
> consider this as "a better version walking towards an ideal fix"?

I didn't say upstream avoids the problem.

In fact, that's the good thing.  It doesn't try to do something it
cannot do without explicit pieces of synchronization infrastructure
between such tools.


Re: [PATCH net] geneve: maximum value of VNI cannot be used

2017-08-10 Thread Girish Moodalbail

On 8/9/17 10:41 PM, David Miller wrote:

From: Girish Moodalbail 
Date: Tue,  8 Aug 2017 17:26:24 -0700


Geneve's Virtual Network Identifier (VNI) is 24 bit long, so the range
of values for it would be from 0 to 16777215 (2^24 -1).  However, one
cannot create a geneve device with VNI set to 16777215. This patch fixes
this issue.

Signed-off-by: Girish Moodalbail 


I always worry that someone, somewhere, might be using this in some
way and this will break things.

But I'll apply this for now.

Thanks David. As per the output of 'ip link help geneve', 16777215 is a valid 
value. However, due to incorrect check in the kernel that value was not supported.


$ ip link help geneve |egrep -A1 VNI
Usage: ... geneve id VNI
  remote ADDR
--
Where: VNI   := 0-16777215
   ADDR  := IP_ADDRESS

So, this is an off-by-one bug and no one had tripped over it until now.

regards,
~Girish



Re: [PATCH net-next 1/6] rtnetlink: use rcu_dereference_raw to silence rcu splat

2017-08-10 Thread Ido Schimmel
On Thu, Aug 10, 2017 at 04:52:57PM +0200, Florian Westphal wrote:
> Ido reports a rcu splat in __rtnl_register.
> The splat is correct; as rtnl_register doesn't grab any logs
> and doesn't use rcu locks either.  It has always been like this.
> handler families are not registered in parallel so there are no
> races wrt. the kmalloc ordering.
> 
> The only reason to use rcu_dereference in the first place was to
> avoid sparse from complaining about this.
> 
> Thus this switches to _raw() to not have rcu checks here.
> 
> The alternative is to add rtnl locking to register/unregister,
> however, I don't see a compelling reason to do so as this has been
> lockless for the past twenty years or so.
> 
> Fixes: 6853dd4881 ("rtnetlink: protect handler table with rcu")
> Reported-by: Ido Schimmel 
> Signed-off-by: Florian Westphal 

Tested-by: Ido Schimmel 

Thanks!


Re: [PATCH v4 1/4] can: dev: Add support for limiting configured bitrate

2017-08-10 Thread Marc Kleine-Budde
Hello,

sorry for stepping in late

On 08/10/2017 02:59 AM, Franklin S Cooper Jr wrote:
> Various CAN or CAN-FD IP may be able to run at a faster rate than
> what the transceiver the CAN node is connected to. This can lead to
> unexpected errors. However, CAN transceivers typically have fixed
> limitations and provide no means to discover these limitations at
> runtime. Therefore, add support for a can-transceiver node that
> can be reused by other CAN peripheral drivers to determine for both
> CAN and CAN-FD what the max bitrate that can be used. If the user
> tries to configure CAN to pass these maximum bitrates it will throw
> an error.
> 
> Signed-off-by: Franklin S Cooper Jr 
> ---
> Version 4 changes:
> Used can-transceiver instead of fixed-transceiver.
> 
>  drivers/net/can/dev.c   | 50 
> +
>  include/linux/can/dev.h |  5 +
>  2 files changed, 55 insertions(+)
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 365a8cc..372108f 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define MOD_DESC "CAN device driver interface"
> @@ -814,6 +815,39 @@ int open_candev(struct net_device *dev)
>  }
>  EXPORT_SYMBOL_GPL(open_candev);
>  
> +#ifdef CONFIG_OF
> +/*
> + * Common function that can be used to understand the limitation of
> + * a transceiver when it provides no means to determine these limitations
> + * at runtime.
> + */
> +void of_can_transceiver(struct net_device *dev)
> +{
> + struct device_node *dn;
> + struct can_priv *priv = netdev_priv(dev);
> + struct device_node *np;
> + unsigned int max_bitrate;
> + int ret;
> +
> + np = dev->dev.parent->of_node;
> +
> + dn = of_get_child_by_name(np, "can-transceiver");
> + if (!dn)
> + return;
> +
> + max_bitrate = 0;
> + ret = of_property_read_u32(dn, "max-bitrate", _bitrate);

IIRC the last argument is only modified in case of no error, so what about:
ret = of_property_read_u32(dn, "max-bitrate",
>max_bitrate);

> +
> + if (max_bitrate > 0) {
> + priv->max_bitrate = max_bitrate;
> + priv->is_bitrate_limited = true;

Do we need is_bitrate_limited...

> + } else if (ret != -EINVAL) {
> + netdev_warn(dev, "Invalid value for transceiver max bitrate\n");
> + }
> +}
> +EXPORT_SYMBOL(of_can_transceiver);
> +#endif
> +
>  /*
>   * Common close function for cleanup before the device gets closed.
>   *
> @@ -913,6 +947,14 @@ static int can_changelink(struct net_device *dev, struct 
> nlattr *tb[],
>   priv->bitrate_const_cnt);
>   if (err)
>   return err;
> +
> + if (priv->is_bitrate_limited &&
> + bt.bitrate > priv->max_bitrate) {

...can we just use priv->max_bitrate?

if (priv->max_bitrate && bt.bitrate > priv->max_bitrate)

> + netdev_err(dev, "arbitration bitrate surpasses 
> transceiver capabilities of %d bps\n",
> +priv->max_bitrate);
> + return -EINVAL;
> + }
> +
>   memcpy(>bittiming, , sizeof(bt));
>  
>   if (priv->do_set_bittiming) {
> @@ -997,6 +1039,14 @@ static int can_changelink(struct net_device *dev, 
> struct nlattr *tb[],
>   priv->data_bitrate_const_cnt);
>   if (err)
>   return err;
> +
> + if (priv->is_bitrate_limited &&
> + dbt.bitrate > priv->max_bitrate) {
> + netdev_err(dev, "canfd data bitrate surpasses 
> transceiver capabilities of %d bps\n",
> +priv->max_bitrate);
> + return -EINVAL;
> + }
> +
>   memcpy(>data_bittiming, , sizeof(dbt));
>  
>   if (priv->do_set_data_bittiming) {
> diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
> index 141b05a..5519f59 100644
> --- a/include/linux/can/dev.h
> +++ b/include/linux/can/dev.h
> @@ -47,6 +47,9 @@ struct can_priv {
>   unsigned int data_bitrate_const_cnt;
>   struct can_clock clock;
>  
> + unsigned int max_bitrate;
> + bool is_bitrate_limited;
> +
>   enum can_state state;
>  
>   /* CAN controller features - see include/uapi/linux/can/netlink.h */
> @@ -165,6 +168,8 @@ void can_put_echo_skb(struct sk_buff *skb, struct 
> net_device *dev,
>  unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
>  void can_free_echo_skb(struct net_device *dev, unsigned int idx);
>  
> +void of_can_transceiver(struct net_device *dev);
> +
>  struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf);
>  struct sk_buff *alloc_canfd_skb(struct net_device *dev,
>   

Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Vitaly Kuznetsov
Andrew Lunn  writes:

>> We are - rtnetlink_event() does the job. We, however, don't have a
>> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.
>
> What is in this event? Old and new name? Just the new name?

Basically, it's everything we know about the interface - type, index,
name, mtu, qdisc, ... - see rtnl_fill_ifinfo(). Back to your question -
it's only the new name.

-- 
  Vitaly


Re: [PATCH net-next] phylink: Fix an uninitialized variable bug

2017-08-10 Thread Andrew Lunn
On Thu, Aug 10, 2017 at 12:35:50AM +0300, Dan Carpenter wrote:
> "ret" isn't necessarily initialized here.
> 
> Fixes: 9525ae83959b ("phylink: add phylink infrastructure")
> Signed-off-by: Dan Carpenter 

Reviewed-by: Andrew Lunn 

Andrew


[patch v1 2/2] Change Kconfig description

2017-08-10 Thread Ohad Oz
Mellanox devices can be cards or switch therefore naming it device.

Signed-off-by: Ohad Oz 
---
 drivers/net/ethernet/mellanox/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/Kconfig 
b/drivers/net/ethernet/mellanox/Kconfig
index 0949741..01c3623 100644
--- a/drivers/net/ethernet/mellanox/Kconfig
+++ b/drivers/net/ethernet/mellanox/Kconfig
@@ -7,7 +7,7 @@ config NET_VENDOR_MELLANOX
default y
depends on PCI || I2C
---help---
- If you have a network (Ethernet) card belonging to this class, say Y.
+ If you have a network (Ethernet) device belonging to this class, say 
Y.
 
  Note that the answer to this question doesn't directly affect the
  kernel: saying N will just cause the configurator to skip all
-- 
2.8.0



[patch v1 1/2] Allow Mellanox network vendor to be configured if only I2C bus is configured

2017-08-10 Thread Ohad Oz
Patch allows Mellanox devices on system with no PCI, but with I2C only.

Signed-off-by: Ohad Oz 
---
 drivers/net/ethernet/mellanox/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/Kconfig 
b/drivers/net/ethernet/mellanox/Kconfig
index 84a2007..0949741 100644
--- a/drivers/net/ethernet/mellanox/Kconfig
+++ b/drivers/net/ethernet/mellanox/Kconfig
@@ -5,7 +5,7 @@
 config NET_VENDOR_MELLANOX
bool "Mellanox devices"
default y
-   depends on PCI
+   depends on PCI || I2C
---help---
  If you have a network (Ethernet) card belonging to this class, say Y.
 
-- 
2.8.0



[PATCH v3] net: stmmac: Use the right logging function in stmmac_mdio_register

2017-08-10 Thread Romain Perier
Currently, the function stmmac_mdio_register() is only used by
stmmac_dvr_probe() from stmmac_main.c, in order to register the MDIO bus
and probe information about the PHY. As this function is called before
calling register_netdev(), all messages logged from stmmac_mdio_register
are prefixed by "(unnamed net_device)". The goal of netdev_info or
netdev_err is to dump useful infos about a net_device, when this data
structure is partially initialized, there is no point for using these
functions.

This commit fixes the issue by replacing all netdev_*() by the
corresponding dev_*() function for logging. The last netdev_info is
replaced by phy_attached_info(), as a valid phydev can be used at this
point.

Signed-off-by: Romain Perier 
Reviewed-by: Andrew Lunn 
---

Changes in v3:
- Replaced phy_attached_print by phy_attached_info, makes more sense
- Added Reviewed-by tag by Andrew

Changes in v2:
- Replaced dev_info() by phy_attached_print()
- Simplified message because informations were redudant
- Updated commit message

 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index db157a47000c..72ec711fcba2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
struct stmmac_priv *priv = netdev_priv(ndev);
struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
struct device_node *mdio_node = priv->plat->mdio_node;
+   struct device *dev = ndev->dev.parent;
int addr, found;
 
if (!mdio_bus_data)
@@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
else
err = mdiobus_register(new_bus);
if (err != 0) {
-   netdev_err(ndev, "Cannot register the MDIO bus\n");
+   dev_err(dev, "Cannot register the MDIO bus\n");
goto bus_register_fail;
}
 
@@ -285,14 +286,12 @@ int stmmac_mdio_register(struct net_device *ndev)
irq_str = irq_num;
break;
}
-   netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n",
-   phydev->phy_id, addr, irq_str, phydev_name(phydev),
-   act ? " active" : "");
+   phy_attached_info(phydev);
found = 1;
}
 
if (!found && !mdio_node) {
-   netdev_warn(ndev, "No PHY found\n");
+   dev_warn(dev, "No PHY found\n");
mdiobus_unregister(new_bus);
mdiobus_free(new_bus);
return -ENODEV;
-- 
2.11.0



[PATCH net-next 5/6] rtnetlink: fallback to UNSPEC if current family has no doit callback

2017-08-10 Thread Florian Westphal
We need to use PF_UNSPEC in case the requested family has no doit
callback, otherwise this now fails with EOPNOTSUPP instead of running the
unspec doit callback, as before.

Fixes: 6853dd488119 ("rtnetlink: protect handler table with rcu")
Signed-off-by: Florian Westphal 
---
 net/core/rtnetlink.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 59eda6952bc9..9e9f1419be60 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4221,6 +4221,12 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
return err;
}
 
+   doit = READ_ONCE(handlers[type].doit);
+   if (!doit) {
+   family = PF_UNSPEC;
+   handlers = rcu_dereference(rtnl_msg_handlers[family]);
+   }
+
flags = READ_ONCE(handlers[type].flags);
if (flags & RTNL_FLAG_DOIT_UNLOCKED) {
refcount_inc(_msg_handlers_ref[family]);
-- 
2.13.0



[PATCH net-next 6/6] selftests: add rtnetlink test script

2017-08-10 Thread Florian Westphal
add a simple script to exercise some rtnetlink call paths, so KASAN,
lockdep etc. can yell at developer before patches are sent upstream.

This can be extended to also cover bond, team, vrf and the like.

Signed-off-by: Florian Westphal 
---
  This test crashes the kernel, fix is already queued here:
  https://patchwork.ozlabs.org/patch/800144/

 tools/testing/selftests/net/Makefile |   2 +-
 tools/testing/selftests/net/rtnetlink.sh | 199 +++
 2 files changed, 200 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/net/rtnetlink.sh

diff --git a/tools/testing/selftests/net/Makefile 
b/tools/testing/selftests/net/Makefile
index 6135a8448900..de1f5772b878 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -3,7 +3,7 @@
 CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
 CFLAGS += -I../../../../usr/include/
 
-TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh
+TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh 
rtnetlink.sh
 TEST_GEN_FILES =  socket
 TEST_GEN_FILES += psock_fanout psock_tpacket
 TEST_GEN_FILES += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
diff --git a/tools/testing/selftests/net/rtnetlink.sh 
b/tools/testing/selftests/net/rtnetlink.sh
new file mode 100755
index ..5b04ad912525
--- /dev/null
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -0,0 +1,199 @@
+#!/bin/sh
+#
+# This test is for checking rtnetlink callpaths, and get as much coverage as 
possible.
+#
+# set -e
+
+devdummy="test-dummy0"
+ret=0
+
+# set global exit status, but never reset nonzero one.
+check_err()
+{
+   if [ $ret -eq 0 ]; then
+   ret=$1
+   fi
+}
+
+kci_add_dummy()
+{
+   ip link add name "$devdummy" type dummy
+   check_err $?
+   ip link set "$devdummy" up
+   check_err $?
+}
+
+kci_del_dummy()
+{
+   ip link del dev "$devdummy"
+   check_err $?
+}
+
+# add a bridge with vlans on top
+kci_test_bridge()
+{
+   devbr="test-br0"
+   vlandev="testbr-vlan1"
+
+   ret=0
+   ip link add name "$devbr" type bridge
+   check_err $?
+
+   ip link set dev "$devdummy" master "$devbr"
+   check_err $?
+
+   ip link set "$devbr" up
+   check_err $?
+
+   ip link add link "$devbr" name "$vlandev" type vlan id 1
+   check_err $?
+   ip addr add dev "$vlandev" 10.200.7.23/30
+   check_err $?
+   ip -6 addr add dev "$vlandev" dead:42::1234/64
+   check_err $?
+   ip -d link > /dev/null
+   check_err $?
+   ip r s t all > /dev/null
+   check_err $?
+   ip -6 addr del dev "$vlandev" dead:42::1234/64
+   check_err $?
+
+   ip link del dev "$vlandev"
+   check_err $?
+   ip link del dev "$devbr"
+   check_err $?
+
+   if [ $ret -ne 0 ];then
+   echo "FAIL: bridge setup"
+   return 1
+   fi
+   echo "PASS: bridge setup"
+
+}
+
+kci_test_gre()
+{
+   gredev=neta
+   rem=10.42.42.1
+   loc=10.0.0.1
+
+   ret=0
+   ip tunnel add $gredev mode gre remote $rem local $loc ttl 1
+   check_err $?
+   ip link set $gredev up
+   check_err $?
+   ip addr add 10.23.7.10 dev $gredev
+   check_err $?
+   ip route add 10.23.8.0/30 dev $gredev
+   check_err $?
+   ip addr add dev "$devdummy" 10.23.7.11/24
+   check_err $?
+   ip link > /dev/null
+   check_err $?
+   ip addr > /dev/null
+   check_err $?
+   ip addr del dev "$devdummy" 10.23.7.11/24
+   check_err $?
+
+   ip link del $gredev
+   check_err $?
+
+   if [ $ret -ne 0 ];then
+   echo "FAIL: gre tunnel endpoint"
+   return 1
+   fi
+   echo "PASS: gre tunnel endpoint"
+}
+
+# tc uses rtnetlink too, for full tc testing
+# please see tools/testing/selftests/tc-testing.
+kci_test_tc()
+{
+   dev=lo
+   ret=0
+
+   tc qdisc add dev "$dev" root handle 1: htb
+   check_err $?
+   tc class add dev "$dev" parent 1: classid 1:10 htb rate 1mbit
+   check_err $?
+   tc filter add dev "$dev" parent 1:0 prio 5 handle ffe: protocol ip u32 
divisor 256
+   check_err $?
+   tc filter add dev "$dev" parent 1:0 prio 5 handle ffd: protocol ip u32 
divisor 256
+   check_err $?
+   tc filter add dev "$dev" parent 1:0 prio 5 handle ffc: protocol ip u32 
divisor 256
+   check_err $?
+   tc filter add dev "$dev" protocol ip parent 1: prio 5 handle ffe:2:3 
u32 ht ffe:2: match ip src 10.0.0.3 flowid 1:10
+   check_err $?
+   tc filter add dev "$dev" protocol ip parent 1: prio 5 handle ffe:2:2 
u32 ht ffe:2: match ip src 10.0.0.2 flowid 1:10
+   check_err $?
+   tc filter show dev "$dev" parent  1:0 > /dev/null
+   check_err $?
+   tc filter del dev "$dev" protocol ip parent 1: prio 5 handle ffe:2:3 u32
+   check_err $?
+   tc filter show dev "$dev" parent  1:0 > /dev/null

[PATCH net-next 4/6] rtnetlink: init handler refcounts to 1

2017-08-10 Thread Florian Westphal
If using CONFIG_REFCOUNT_FULL=y we get following splat:
 refcount_t: increment on 0; use-after-free.
WARNING: CPU: 0 PID: 304 at lib/refcount.c:152 refcount_inc+0x47/0x50
Call Trace:
 rtnetlink_rcv_msg+0x191/0x260
 ...

This warning is harmless (0 is "no callback running", not "memory
was freed").

Use '1' as the new 'no handler is running' base instead of 0 to avoid
this.

Fixes: 019a316992ee ("rtnetlink: add reference counting to prevent module 
unload while dump is in progress")
Reported-by: Sabrina Dubroca 
Reported-by: kernel test robot 
Signed-off-by: Florian Westphal 
---
 net/core/rtnetlink.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 087f2434813a..59eda6952bc9 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -262,7 +262,7 @@ void rtnl_unregister_all(int protocol)
 
synchronize_net();
 
-   while (refcount_read(_msg_handlers_ref[protocol]) > 0)
+   while (refcount_read(_msg_handlers_ref[protocol]) > 1)
schedule();
kfree(handlers);
 }
@@ -4324,6 +4324,11 @@ static struct pernet_operations rtnetlink_net_ops = {
 
 void __init rtnetlink_init(void)
 {
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(rtnl_msg_handlers_ref); i++)
+   refcount_set(_msg_handlers_ref[i], 1);
+
if (register_pernet_subsys(_net_ops))
panic("rtnetlink_init: cannot initialize rtnetlink\n");
 
-- 
2.13.0



[PATCH net-next 0/6] rtnetlink: fix initial rtnl pushdown fallout

2017-08-10 Thread Florian Westphal
This series fixes various bugs and splats reported since the
allow-handler-to-run-with-no-rtnl series went in.

Last patch adds a script that can be used to add further
tests in case more bugs are reported.
In case you prefer reverting the original series instead of
fixing fallout I can resend this patch on its own.



[PATCH net-next 2/6] rtnetlink: do not use RTM_GETLINK directly

2017-08-10 Thread Florian Westphal
Userspace sends RTM_GETLINK type, but the kernel substracts
RTM_BASE from this, i.e. 'type' doesn't contain RTM_GETLINK
anymore but instead RTM_GETLINK - RTM_BASE.

This caused the calcit callback to not be invoked when it
should have been (and vice versa).

While at it, also fix a off-by one when checking family index. vs
handler array size.

Fixes: e1fa6d216dd ("rtnetlink: call rtnl_calcit directly")
Signed-off-by: Florian Westphal 
---
 net/core/rtnetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a5bc5bd0dc12..a9b5ebc1af21 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4167,7 +4167,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
return -EPERM;
 
-   if (family > ARRAY_SIZE(rtnl_msg_handlers))
+   if (family >= ARRAY_SIZE(rtnl_msg_handlers))
family = PF_UNSPEC;
 
rcu_read_lock();
@@ -4196,7 +4196,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct 
nlmsghdr *nlh,
 
refcount_inc(_msg_handlers_ref[family]);
 
-   if (type == RTM_GETLINK)
+   if (type == RTM_GETLINK - RTM_BASE)
min_dump_alloc = rtnl_calcit(skb, nlh);
 
rcu_read_unlock();
-- 
2.13.0



[PATCH net-next 3/6] rtnetlink: switch rtnl_link_get_slave_info_data_size to rcu

2017-08-10 Thread Florian Westphal
David Ahern reports following splat:
 RTNL: assertion failed at net/core/dev.c (5717)
 netdev_master_upper_dev_get+0x5f/0x70
 if_nlmsg_size+0x158/0x240
 rtnl_calcit.isra.26+0xa3/0xf0

rtnl_link_get_slave_info_data_size currently assumes RTNL protection, but
there appears to be no hard requirement for this, so use rcu instead.

At the time of this writing, there are three 'get_slave_size' callbacks
(now invoked under rcu): bond_get_slave_size, vrf_get_slave_size and
br_port_get_slave_size, all return constant only (i.e. they don't sleep).

Fixes: 6853dd488119 ("rtnetlink: protect handler table with rcu")
Reported-by: David Ahern 
Signed-off-by: Florian Westphal 
---
 net/core/rtnetlink.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a9b5ebc1af21..087f2434813a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -402,16 +402,24 @@ static size_t rtnl_link_get_slave_info_data_size(const 
struct net_device *dev)
 {
struct net_device *master_dev;
const struct rtnl_link_ops *ops;
+   size_t size = 0;
 
-   master_dev = netdev_master_upper_dev_get((struct net_device *) dev);
+   rcu_read_lock();
+
+   master_dev = netdev_master_upper_dev_get_rcu((struct net_device *)dev);
if (!master_dev)
-   return 0;
+   goto out;
+
ops = master_dev->rtnl_link_ops;
if (!ops || !ops->get_slave_size)
-   return 0;
+   goto out;
/* IFLA_INFO_SLAVE_DATA + nested data */
-   return nla_total_size(sizeof(struct nlattr)) +
+   size = nla_total_size(sizeof(struct nlattr)) +
   ops->get_slave_size(master_dev, dev);
+
+out:
+   rcu_read_unlock();
+   return size;
 }
 
 static size_t rtnl_link_get_size(const struct net_device *dev)
-- 
2.13.0



[PATCH net-next 1/6] rtnetlink: use rcu_dereference_raw to silence rcu splat

2017-08-10 Thread Florian Westphal
Ido reports a rcu splat in __rtnl_register.
The splat is correct; as rtnl_register doesn't grab any logs
and doesn't use rcu locks either.  It has always been like this.
handler families are not registered in parallel so there are no
races wrt. the kmalloc ordering.

The only reason to use rcu_dereference in the first place was to
avoid sparse from complaining about this.

Thus this switches to _raw() to not have rcu checks here.

The alternative is to add rtnl locking to register/unregister,
however, I don't see a compelling reason to do so as this has been
lockless for the past twenty years or so.

Fixes: 6853dd4881 ("rtnetlink: protect handler table with rcu")
Reported-by: Ido Schimmel 
Signed-off-by: Florian Westphal 
---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index dd4e50dfa248..a5bc5bd0dc12 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -172,7 +172,7 @@ int __rtnl_register(int protocol, int msgtype,
BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
msgindex = rtm_msgindex(msgtype);
 
-   tab = rcu_dereference(rtnl_msg_handlers[protocol]);
+   tab = rcu_dereference_raw(rtnl_msg_handlers[protocol]);
if (tab == NULL) {
tab = kcalloc(RTM_NR_MSGTYPES, sizeof(*tab), GFP_KERNEL);
if (tab == NULL)
-- 
2.13.0



Re: [PATCH v2] net: stmmac: Use the right logging function in stmmac_mdio_register

2017-08-10 Thread Romain Perier
Hi Andrew,


Le 10/08/2017 à 15:56, Andrew Lunn a écrit :
> On Thu, Aug 10, 2017 at 09:38:26AM +0200, Romain Perier wrote:
>> Currently, the function stmmac_mdio_register() is only used by
>> stmmac_dvr_probe() from stmmac_main.c, in order to register the MDIO bus
>> and probe information about the PHY. As this function is called before
>> calling register_netdev(), all messages logged from stmmac_mdio_register
>> are prefixed by "(unnamed net_device)". The goal of netdev_info or
>> netdev_err is to dump useful infos about a net_device, when this data
>> structure is partially initialized, there is no point for using these
>> functions.
>>
>> This commit fixes the issue by replacing all netdev_*() by the
>> corresponding dev_*() function for logging. The last netdev_info is
>> replaced by phy_attached_info(), as a valid phydev can be used at this
>> point.
>>
>> Signed-off-by: Romain Perier 
>> ---
>>
>> Changes in v2:
>> - Replaced dev_info() by phy_attached_print()
>> - Simplified message because informations were redudant
>> - Updated commit message
>>
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 ++-
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c 
>> b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
>> index db157a47000c..e0fbf8657103 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
>> @@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
>>  struct stmmac_priv *priv = netdev_priv(ndev);
>>  struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
>>  struct device_node *mdio_node = priv->plat->mdio_node;
>> +struct device *dev = ndev->dev.parent;
>>  int addr, found;
>>  
>>  if (!mdio_bus_data)
>> @@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
>>  else
>>  err = mdiobus_register(new_bus);
>>  if (err != 0) {
>> -netdev_err(ndev, "Cannot register the MDIO bus\n");
>> +dev_err(dev, "Cannot register the MDIO bus\n");
>>  goto bus_register_fail;
>>  }
>>  
>> @@ -285,14 +286,14 @@ int stmmac_mdio_register(struct net_device *ndev)
>>  irq_str = irq_num;
>>  break;
>>  }
>> -netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n",
>> -phydev->phy_id, addr, irq_str, phydev_name(phydev),
>> -act ? " active" : "");
>> +phy_attached_print(phydev, "PHY ID %08x IRQ %s %s\n",
>> +   phydev->phy_id, irq_str,
>> +   act ? " active" : "");
> I don't want to go round and round with this patch, with feature creep. 
>
> But there are only two drivers which use phy_attached_print() to print
> more than the standard printed by phy_attached_info().
> phy_attached_info() will give you the driver name, so do you need the
> ID? phy_attached_info() prints the irq as a number, rather than a nice
> string.
>
> act is just odd. The loop is effectively phy_find_first(). The act
> means it has found a phy, but not the phy indicated in the platform
> data, but it is going to use it anyway!
>
> So i will give:
>
> Reviewed-by: Andrew Lunn 
>
> but if you think phy_attached_info() is acceptable, that would be
> great.
>
> Andrew

Good point, initially I just wanted to propose a fix about logging and
not change the message, in order to avoid to lose informations (but
that's very arguable).
phy_attached_print or phy_attached_info already display the model of the
PHY, so I think that removing PHY ID is okay, because in this case it is
completely useless.

I will post a v3 with your Reviewed-by:

Romain


Re: [PATCHv2 1/2] drivers: net: davinci_mdio: remove busy loop on wait user access

2017-08-10 Thread Andrew Lunn
On Thu, Aug 10, 2017 at 10:47:46AM +0300, Max Uvarov wrote:
> Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
> due to busy loop in wait(). Add small delay to relax cpu.

Hi Max

Please include a cover note when you have multiple patches in a
series.

With 14 devices, it makes sense to swap to using PHY interrupts if you
can. That should prevent the PHY state machine polling the PHYs every
second.

Reviewed-by: Andrew Lunn 

Andrew


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Andrew Lunn
> We are - rtnetlink_event() does the job. We, however, don't have a
> special IFLA_EVENT_* for name change and end up with IFLA_EVENT_NONE.

What is in this event? Old and new name? Just the new name?

 Andrew


Re: [PATCH RFC net-next] net: Allow name change of IFF_UP interfaces

2017-08-10 Thread Andrew Lunn
> >> Can you think of any particular real world scenarios which are broken by
> >> the change?
> >
> > How about:
> >
> > man 8 dhclient-script
> >
> > The interface name is passed in $interface to the scripts. Do we get
> > the old name or the new name? I suspect scripts are going to break if
> > they are given the old name, which no longer exists.
> 
> Yes but why would anyone change interface name while dhclient-script is
> running? Things will also go wrong if you try bringing interface down
> during the run or do some other configuration, right?

dhclient already handles the interface going down. sendto/recvfrom
fails and returns an error code. As far as i remember, dhclient then
exits.

> Running multiple configuration tools at the same moment is a bad
> idea, you never know what you're gonna end up with.

It could be argued that configuring an interface vs renaming an
interface are at different levels.

  Andrew


Re: [PATCH v2] net: stmmac: Use the right logging function in stmmac_mdio_register

2017-08-10 Thread Andrew Lunn
On Thu, Aug 10, 2017 at 09:38:26AM +0200, Romain Perier wrote:
> Currently, the function stmmac_mdio_register() is only used by
> stmmac_dvr_probe() from stmmac_main.c, in order to register the MDIO bus
> and probe information about the PHY. As this function is called before
> calling register_netdev(), all messages logged from stmmac_mdio_register
> are prefixed by "(unnamed net_device)". The goal of netdev_info or
> netdev_err is to dump useful infos about a net_device, when this data
> structure is partially initialized, there is no point for using these
> functions.
> 
> This commit fixes the issue by replacing all netdev_*() by the
> corresponding dev_*() function for logging. The last netdev_info is
> replaced by phy_attached_info(), as a valid phydev can be used at this
> point.
> 
> Signed-off-by: Romain Perier 
> ---
> 
> Changes in v2:
> - Replaced dev_info() by phy_attached_print()
> - Simplified message because informations were redudant
> - Updated commit message
> 
>  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c 
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> index db157a47000c..e0fbf8657103 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
> @@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
>   struct stmmac_priv *priv = netdev_priv(ndev);
>   struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
>   struct device_node *mdio_node = priv->plat->mdio_node;
> + struct device *dev = ndev->dev.parent;
>   int addr, found;
>  
>   if (!mdio_bus_data)
> @@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
>   else
>   err = mdiobus_register(new_bus);
>   if (err != 0) {
> - netdev_err(ndev, "Cannot register the MDIO bus\n");
> + dev_err(dev, "Cannot register the MDIO bus\n");
>   goto bus_register_fail;
>   }
>  
> @@ -285,14 +286,14 @@ int stmmac_mdio_register(struct net_device *ndev)
>   irq_str = irq_num;
>   break;
>   }
> - netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n",
> - phydev->phy_id, addr, irq_str, phydev_name(phydev),
> - act ? " active" : "");
> + phy_attached_print(phydev, "PHY ID %08x IRQ %s %s\n",
> +phydev->phy_id, irq_str,
> +act ? " active" : "");

I don't want to go round and round with this patch, with feature creep. 

But there are only two drivers which use phy_attached_print() to print
more than the standard printed by phy_attached_info().
phy_attached_info() will give you the driver name, so do you need the
ID? phy_attached_info() prints the irq as a number, rather than a nice
string.

act is just odd. The loop is effectively phy_find_first(). The act
means it has found a phy, but not the phy indicated in the platform
data, but it is going to use it anyway!

So i will give:

Reviewed-by: Andrew Lunn 

but if you think phy_attached_info() is acceptable, that would be
great.

Andrew


[PATCH v5 11/11] ARM64: dts: rockchip: Enable gmac2phy for rk3328-evb

2017-08-10 Thread David Wu
Enable the gmac2phy, make the gmac2phy work on
the rk3328-evb board.

Signed-off-by: David Wu 
---
 arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts 
b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index cf27239..b9f36da 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -50,6 +50,23 @@
chosen {
stdout-path = "serial2:150n8";
};
+
+   vcc_phy: vcc-phy-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_phy";
+   regulator-always-on;
+   regulator-boot-on;
+   };
+};
+
+ {
+   phy-supply = <_phy>;
+   clock_in_out = "output";
+   assigned-clocks = < SCLK_MAC2PHY_SRC>;
+   assigned-clock-rate = <5000>;
+   assigned-clocks = < SCLK_MAC2PHY>;
+   assigned-clock-parents = < SCLK_MAC2PHY_SRC>;
+   status = "okay";
 };
 
  {
-- 
1.9.1




[PATCH v5 10/11] ARM64: dts: rockchip: Add gmac2phy node support for rk3328

2017-08-10 Thread David Wu
The gmac2phy controller of rk3328 is connected to integrated PHY
directly inside, add the node for the integrated PHY support.

Signed-off-by: David Wu 
---
changes in v5:
 - Use phy-is-integrated property via PHY node.
 - Move the PHY clock, reset control, pinctrl to PHY node. 

 arch/arm64/boot/dts/rockchip/rk3328.dtsi | 39 
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
index 0be96ce..d48bf5d 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
@@ -63,6 +63,8 @@
i2c1 = 
i2c2 = 
i2c3 = 
+   ethernet0 = 
+   ethernet1 = 
};
 
cpus {
@@ -424,6 +426,43 @@
status = "disabled";
};
 
+   gmac2phy: ethernet@ff55 {
+   compatible = "rockchip,rk3328-gmac";
+   reg = <0x0 0xff55 0x0 0x1>;
+   rockchip,grf = <>;
+   interrupts = ;
+   interrupt-names = "macirq";
+   clocks = < SCLK_MAC2PHY_SRC>, < SCLK_MAC2PHY_RXTX>,
+< SCLK_MAC2PHY_RXTX>, < SCLK_MAC2PHY_REF>,
+< ACLK_MAC2PHY>, < PCLK_MAC2PHY>,
+< SCLK_MAC2PHY_OUT>;
+   clock-names = "stmmaceth", "mac_clk_rx",
+ "mac_clk_tx", "clk_mac_ref",
+ "aclk_mac", "pclk_mac",
+ "clk_macphy";
+   resets = < SRST_GMAC2PHY_A>, < SRST_MACPHY>;
+   reset-names = "stmmaceth", "mac-phy";
+   phy-mode = "rmii";
+   phy-handle = <>;
+   status = "disabled";
+
+   mdio {
+   compatible = "snps,dwmac-mdio";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   phy: phy@0 {
+   compatible = "ethernet-phy-id1234.d400", 
"ethernet-phy-ieee802.3-c22";
+   reg = <0>;
+   clocks = < SCLK_MAC2PHY_OUT>;
+   resets = < SRST_MACPHY>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_rxm1 _linkm1>;
+   phy-is-integrated;
+   };
+   };
+   };
+
gic: interrupt-controller@ff811000 {
compatible = "arm,gic-400";
#interrupt-cells = <3>;
-- 
1.9.1




[PATCH v5 09/11] ARM: dts: rk3228-evb: Enable the integrated PHY for gmac

2017-08-10 Thread David Wu
This patch enables the integrated PHY for rk3228 evb board
by default.
To use the external 1000M PHY on evb board, need to make
some switch of evb board to be on.

Signed-off-by: David Wu 
Reviewed-by: Florian Fainelli 
---
changes in v5:
 - Use phy-is-integrated property via PHY node.
 - Move the PHY clock and reset control to PHY node.

 arch/arm/boot/dts/rk3228-evb.dts | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm/boot/dts/rk3228-evb.dts b/arch/arm/boot/dts/rk3228-evb.dts
index 5883433..456ddf7 100644
--- a/arch/arm/boot/dts/rk3228-evb.dts
+++ b/arch/arm/boot/dts/rk3228-evb.dts
@@ -50,6 +50,16 @@
device_type = "memory";
reg = <0x6000 0x4000>;
};
+
+   vcc_phy: vcc-phy-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   regulator-name = "vcc_phy";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
 };
 
  {
@@ -60,6 +70,30 @@
status = "okay";
 };
 
+ {
+   assigned-clocks = < SCLK_MAC_SRC>;
+   assigned-clock-rates = <5000>;
+   clock_in_out = "output";
+   phy-supply = <_phy>;
+   phy-mode = "rmii";
+   phy-handle = <>;
+   status = "okay";
+
+   mdio {
+   compatible = "snps,dwmac-mdio";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   phy@0 {
+   compatible = "ethernet-phy-id1234.d400", 
"ethernet-phy-ieee802.3-c22";
+   reg = <0>;
+   clocks = < SCLK_MAC_PHY>;
+   resets = < SRST_MACPHY>;
+   phy-is-integrated;
+   };
+   };
+};
+
  {
status = "okay";
 
-- 
1.9.1




[PATCH v5 07/11] net: stmmac: dwmac-rk: Add integrated PHY support for rk3228

2017-08-10 Thread David Wu
There is only one mac controller in rk3228, which could connect to
external PHY or integrated PHY, use the grf_com_mux bit15 to route
external/integrated PHY.

Signed-off-by: David Wu 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 9019917..b6db3ff 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -86,6 +86,8 @@ struct rk_priv_data {
 #define RK3228_GRF_MAC_CON00x0900
 #define RK3228_GRF_MAC_CON10x0904
 
+#define RK3228_GRF_CON_MUX 0x50
+
 /* RK3228_GRF_MAC_CON0 */
 #define RK3228_GMAC_CLK_RX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 7)
 #define RK3228_GMAC_CLK_TX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 0)
@@ -111,6 +113,9 @@ struct rk_priv_data {
 #define RK3228_GMAC_RXCLK_DLY_ENABLE   GRF_BIT(1)
 #define RK3228_GMAC_RXCLK_DLY_DISABLE  GRF_CLR_BIT(1)
 
+/* RK3228_GRF_COM_MUX */
+#define RK3228_GRF_CON_MUX_GMAC_INTEGRATED_PHY GRF_BIT(15)
+
 static void rk3228_set_to_rgmii(struct rk_priv_data *bsp_priv,
int tx_delay, int rx_delay)
 {
@@ -191,11 +196,18 @@ static void rk3228_set_rmii_speed(struct rk_priv_data 
*bsp_priv, int speed)
dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
 }
 
+static void rk3228_integrated_phy_powerup(struct rk_priv_data *priv)
+{
+   regmap_write(priv->grf, RK3228_GRF_CON_MUX,
+RK3228_GRF_CON_MUX_GMAC_INTEGRATED_PHY);
+}
+
 static const struct rk_gmac_ops rk3228_ops = {
.set_to_rgmii = rk3228_set_to_rgmii,
.set_to_rmii = rk3228_set_to_rmii,
.set_rgmii_speed = rk3228_set_rgmii_speed,
.set_rmii_speed = rk3228_set_rmii_speed,
+   .integrated_phy_powerup =  rk3228_integrated_phy_powerup,
 };
 
 #define RK3288_GRF_SOC_CON10x0248
-- 
1.9.1




[PATCH v5 08/11] net: stmmac: dwmac-rk: Add integrated PHY supprot for rk3328

2017-08-10 Thread David Wu
There are two mac controllers in the rk3328, the one connects
to external PHY, and the other one connects to integrated PHY.
Like the mac of external PHY, the integrated PHY's mac also
needs to configure the related mac registers at GRF.

Signed-off-by: David Wu 
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index b6db3ff..2176403 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -323,6 +323,8 @@ static void rk3288_set_rmii_speed(struct rk_priv_data 
*bsp_priv, int speed)
 
 #define RK3328_GRF_MAC_CON00x0900
 #define RK3328_GRF_MAC_CON10x0904
+#define RK3328_GRF_MAC_CON20x0908
+#define RK3328_GRF_MACPHY_CON1 0xb04
 
 /* RK3328_GRF_MAC_CON0 */
 #define RK3328_GMAC_CLK_RX_DL_CFG(val) HIWORD_UPDATE(val, 0x7F, 7)
@@ -349,6 +351,9 @@ static void rk3288_set_rmii_speed(struct rk_priv_data 
*bsp_priv, int speed)
 #define RK3328_GMAC_RXCLK_DLY_ENABLE   GRF_BIT(1)
 #define RK3328_GMAC_RXCLK_DLY_DISABLE  GRF_CLR_BIT(0)
 
+/* RK3328_GRF_MACPHY_CON1 */
+#define RK3328_MACPHY_RMII_MODEGRF_BIT(9)
+
 static void rk3328_set_to_rgmii(struct rk_priv_data *bsp_priv,
int tx_delay, int rx_delay)
 {
@@ -373,13 +378,17 @@ static void rk3328_set_to_rgmii(struct rk_priv_data 
*bsp_priv,
 static void rk3328_set_to_rmii(struct rk_priv_data *bsp_priv)
 {
struct device *dev = _priv->pdev->dev;
+   unsigned int reg;
 
if (IS_ERR(bsp_priv->grf)) {
dev_err(dev, "Missing rockchip,grf property\n");
return;
}
 
-   regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1,
+   reg = bsp_priv->integrated_phy ? RK3328_GRF_MAC_CON2 :
+ RK3328_GRF_MAC_CON1;
+
+   regmap_write(bsp_priv->grf, reg,
 RK3328_GMAC_PHY_INTF_SEL_RMII |
 RK3328_GMAC_RMII_MODE);
 }
@@ -409,29 +418,40 @@ static void rk3328_set_rgmii_speed(struct rk_priv_data 
*bsp_priv, int speed)
 static void rk3328_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
 {
struct device *dev = _priv->pdev->dev;
+   unsigned int reg;
 
if (IS_ERR(bsp_priv->grf)) {
dev_err(dev, "Missing rockchip,grf property\n");
return;
}
 
+   reg = bsp_priv->integrated_phy ? RK3328_GRF_MAC_CON2 :
+ RK3328_GRF_MAC_CON1;
+
if (speed == 10)
-   regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1,
+   regmap_write(bsp_priv->grf, reg,
 RK3328_GMAC_RMII_CLK_2_5M |
 RK3328_GMAC_SPEED_10M);
else if (speed == 100)
-   regmap_write(bsp_priv->grf, RK3328_GRF_MAC_CON1,
+   regmap_write(bsp_priv->grf, reg,
 RK3328_GMAC_RMII_CLK_25M |
 RK3328_GMAC_SPEED_100M);
else
dev_err(dev, "unknown speed value for RMII! speed=%d", speed);
 }
 
+static void rk3328_integrated_phy_powerup(struct rk_priv_data *priv)
+{
+   regmap_write(priv->grf, RK3328_GRF_MACPHY_CON1,
+RK3328_MACPHY_RMII_MODE);
+}
+
 static const struct rk_gmac_ops rk3328_ops = {
.set_to_rgmii = rk3328_set_to_rgmii,
.set_to_rmii = rk3328_set_to_rmii,
.set_rgmii_speed = rk3328_set_rgmii_speed,
.set_rmii_speed = rk3328_set_rmii_speed,
+   .integrated_phy_powerup =  rk3328_integrated_phy_powerup,
 };
 
 #define RK3366_GRF_SOC_CON60x0418
-- 
1.9.1




  1   2   >