[PATCH net-next] net: qualcomm: rmnet: Remove set but not used variable 'cmd'

2018-11-28 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c: In function 
'rmnet_map_do_flow_control':
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c:23:36: warning:
 variable 'cmd' set but not used [-Wunused-but-set-variable]
  struct rmnet_map_control_command *cmd;

'cmd' not used anymore now, should also be removed.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c 
b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
index 8990307..f6cf59a 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_map_command.c
@@ -20,14 +20,12 @@ static u8 rmnet_map_do_flow_control(struct sk_buff *skb,
struct rmnet_port *port,
int enable)
 {
-   struct rmnet_map_control_command *cmd;
struct rmnet_endpoint *ep;
struct net_device *vnd;
u8 mux_id;
int r;
 
mux_id = RMNET_MAP_GET_MUX_ID(skb);
-   cmd = RMNET_MAP_GET_CMD_START(skb);
 
if (mux_id >= RMNET_MAX_LOGICAL_EP) {
kfree_skb(skb);





[PATCH net-next] e100: Fix passing zero to 'PTR_ERR' warning in e100_load_ucode_wait

2018-11-19 Thread YueHaibing
Fix a static code checker warning:
drivers/net/ethernet/intel/e100.c:1349
 e100_load_ucode_wait() warn: passing zero to 'PTR_ERR'

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/intel/e100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/e100.c 
b/drivers/net/ethernet/intel/e100.c
index 7c4b554..736115b 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -1345,8 +1345,8 @@ static inline int e100_load_ucode_wait(struct nic *nic)
 
fw = e100_request_firmware(nic);
/* If it's NULL, then no ucode is required */
-   if (!fw || IS_ERR(fw))
-   return PTR_ERR(fw);
+   if (IS_ERR_OR_NULL(fw))
+   return PTR_ERR_OR_ZERO(fw);
 
if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
netif_err(nic, probe, nic->netdev,
-- 
2.7.0




[PATCH net-next] SUNRPC: drop pointless static qualifier in xdr_get_next_encode_buffer()

2018-11-07 Thread YueHaibing
There is no need to have the '__be32 *p' variable static since new value
always be assigned before use it.

Signed-off-by: YueHaibing 
---
 net/sunrpc/xdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 2bbb8d3..d80b156 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -546,7 +546,7 @@ void xdr_commit_encode(struct xdr_stream *xdr)
 static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
size_t nbytes)
 {
-   static __be32 *p;
+   __be32 *p;
int space_left;
int frag1bytes, frag2bytes;





Re: [PATCH net-next] octeontx2-af: Remove set but not used variable 'block'

2018-10-21 Thread YueHaibing
On 2018/10/19 21:36, Sunil Kovvuri wrote:
> On Fri, Oct 19, 2018 at 6:11 PM YueHaibing  wrote:
>>
>> Fixes gcc '-Wunused-but-set-variable' warning:
>>
>> drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c: In function 
>> 'rvu_npa_init':
>> drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c:446:20: warning:
>>  variable 'block' set but not used [-Wunused-but-set-variable]
>>
>> It never used since introduction in
>> commit 7a37245ef23f ("octeontx2-af: NPA block admin queue init")
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c | 3 ---
>>  1 file changed, 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c 
>> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
>> index 0e43a69..7531fdc 100644
>> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
>> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
>> @@ -443,15 +443,12 @@ static int npa_aq_init(struct rvu *rvu, struct 
>> rvu_block *block)
>>  int rvu_npa_init(struct rvu *rvu)
>>  {
>> struct rvu_hwinfo *hw = rvu->hw;
>> -   struct rvu_block *block;
>> int blkaddr, err;
>>
>> blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
>> if (blkaddr < 0)
>> return 0;
>>
>> -   block = >block[blkaddr];
>> -
>> /* Initialize admin queue */
>> err = npa_aq_init(rvu, >block[blkaddr]);
>> if (err)
>>
> 
> Thanks for the patch.
> Which GCC version do you use ?

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)

> Before submitting patches I did test compiling specifically with these
> "make  arch=X86 -j8 -Werror=unused-function -Wunused-but-set-variable"
> but that didn't throw these warnings.
> 
> Thanks,
> Sunil.
> 
> .
> 



[PATCH net-next] octeontx2-af: Remove set but not used variable 'block'

2018-10-19 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c: In function 'rvu_npa_init':
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c:446:20: warning:
 variable 'block' set but not used [-Wunused-but-set-variable]

It never used since introduction in
commit 7a37245ef23f ("octeontx2-af: NPA block admin queue init")

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
index 0e43a69..7531fdc 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c
@@ -443,15 +443,12 @@ static int npa_aq_init(struct rvu *rvu, struct rvu_block 
*block)
 int rvu_npa_init(struct rvu *rvu)
 {
struct rvu_hwinfo *hw = rvu->hw;
-   struct rvu_block *block;
int blkaddr, err;
 
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
if (blkaddr < 0)
return 0;
 
-   block = >block[blkaddr];
-
/* Initialize admin queue */
err = npa_aq_init(rvu, >block[blkaddr]);
if (err)



[PATCH net-next] igc: Remove set but not used variable 'pci_using_dac'

2018-10-19 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/intel/igc/igc_main.c: In function 'igc_probe':
drivers/net/ethernet/intel/igc/igc_main.c:3535:11: warning:
 variable 'pci_using_dac' set but not used [-Wunused-but-set-variable]

It never used since introduction in commit
d89f88419f99 ("igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller 
support")

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/intel/igc/igc_main.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c 
b/drivers/net/ethernet/intel/igc/igc_main.c
index 9d85707..06a4afbe 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -3532,19 +3532,16 @@ static int igc_probe(struct pci_dev *pdev,
struct net_device *netdev;
struct igc_hw *hw;
const struct igc_info *ei = igc_info_tbl[ent->driver_data];
-   int err, pci_using_dac;
+   int err;
 
err = pci_enable_device_mem(pdev);
if (err)
return err;
 
-   pci_using_dac = 0;
err = dma_set_mask(>dev, DMA_BIT_MASK(64));
if (!err) {
err = dma_set_coherent_mask(>dev,
DMA_BIT_MASK(64));
-   if (!err)
-   pci_using_dac = 1;
} else {
err = dma_set_mask(>dev, DMA_BIT_MASK(32));
if (err) {



[PATCH net-next] igc: Remove set but not used variables 'ctrl_ext, link_mode'

2018-10-19 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/intel/igc/igc_base.c: In function 
'igc_init_phy_params_base':
drivers/net/ethernet/intel/igc/igc_base.c:240:6: warning:
 variable 'ctrl_ext' set but not used [-Wunused-but-set-variable]
  u32 ctrl_ext;
  
drivers/net/ethernet/intel/igc/igc_base.c: In function 
'igc_get_invariants_base':
drivers/net/ethernet/intel/igc/igc_base.c:290:6: warning:
 variable 'link_mode' set but not used [-Wunused-but-set-variable]
  u32 link_mode = 0;

It never used since introduction in
commit c0071c7aa5fe ("igc: Add HW initialization code")

Signed-off-by: YueHaibing 
---
I'm not sure that reading IGC_CTRL_EXT is necessary.
---
 drivers/net/ethernet/intel/igc/igc_base.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_base.c 
b/drivers/net/ethernet/intel/igc/igc_base.c
index 832da609..df40af7 100644
--- a/drivers/net/ethernet/intel/igc/igc_base.c
+++ b/drivers/net/ethernet/intel/igc/igc_base.c
@@ -237,7 +237,6 @@ static s32 igc_init_phy_params_base(struct igc_hw *hw)
 {
struct igc_phy_info *phy = >phy;
s32 ret_val = 0;
-   u32 ctrl_ext;
 
if (hw->phy.media_type != igc_media_type_copper) {
phy->type = igc_phy_none;
@@ -247,8 +246,6 @@ static s32 igc_init_phy_params_base(struct igc_hw *hw)
phy->autoneg_mask   = AUTONEG_ADVERTISE_SPEED_DEFAULT_2500;
phy->reset_delay_us = 100;
 
-   ctrl_ext = rd32(IGC_CTRL_EXT);
-
/* set lan id */
hw->bus.func = (rd32(IGC_STATUS) & IGC_STATUS_FUNC_MASK) >>
IGC_STATUS_FUNC_SHIFT;
@@ -287,8 +284,6 @@ static s32 igc_init_phy_params_base(struct igc_hw *hw)
 static s32 igc_get_invariants_base(struct igc_hw *hw)
 {
struct igc_mac_info *mac = >mac;
-   u32 link_mode = 0;
-   u32 ctrl_ext = 0;
s32 ret_val = 0;
 
switch (hw->device_id) {
@@ -302,9 +297,6 @@ static s32 igc_get_invariants_base(struct igc_hw *hw)
 
hw->phy.media_type = igc_media_type_copper;
 
-   ctrl_ext = rd32(IGC_CTRL_EXT);
-   link_mode = ctrl_ext & IGC_CTRL_EXT_LINK_MODE_MASK;
-
/* mac initialization and operations */
ret_val = igc_init_mac_params_base(hw);
if (ret_val)



[PATCH net-next] rocker: Drop pointless static qualifier

2018-10-19 Thread YueHaibing
There is no need to have the 'struct rocker_desc_info *desc_info'
variable static since new value always be assigned before use it.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/rocker/rocker_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 8721c05..beb0662 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -371,7 +371,7 @@ static void rocker_desc_cookie_ptr_set(const struct 
rocker_desc_info *desc_info,
 static struct rocker_desc_info *
 rocker_desc_head_get(const struct rocker_dma_ring_info *info)
 {
-   static struct rocker_desc_info *desc_info;
+   struct rocker_desc_info *desc_info;
u32 head = __pos_inc(info->head, info->size);
 
desc_info = >desc_info[info->head];
@@ -402,7 +402,7 @@ static void rocker_desc_head_set(const struct rocker 
*rocker,
 static struct rocker_desc_info *
 rocker_desc_tail_get(struct rocker_dma_ring_info *info)
 {
-   static struct rocker_desc_info *desc_info;
+   struct rocker_desc_info *desc_info;
 
if (info->tail == info->head)
return NULL; /* nothing to be done between head and tail */



[PATCH net-next] octeontx2-af: Remove set but not used variable 'dev'

2018-10-11 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/marvell/octeontx2/af/cgx.c: In function 
'cgx_fwi_event_handler':
drivers/net/ethernet/marvell/octeontx2/af/cgx.c:257:17: warning:
 variable 'dev' set but not used [-Wunused-but-set-variable]

It never be used since introduction in
commit 1463f382f58d ("octeontx2-af: Add support for CGX link management")

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c 
b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
index f290b1d..2cf8e40 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c
@@ -254,7 +254,6 @@ static inline bool cgx_event_is_linkevent(u64 event)
 static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
 {
struct lmac *lmac = data;
-   struct device *dev;
struct cgx *cgx;
u64 event;
 
@@ -265,8 +264,6 @@ static irqreturn_t cgx_fwi_event_handler(int irq, void 
*data)
if (!FIELD_GET(EVTREG_ACK, event))
return IRQ_NONE;
 
-   dev = >pdev->dev;
-
switch (FIELD_GET(EVTREG_EVT_TYPE, event)) {
case CGX_EVT_CMD_RESP:
/* Copy the response. Since only one command is active at a



[PATCH v3] rxrpc: use correct kvec num while send response packet in rxrpc_reject_packets

2018-10-09 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

net/rxrpc/output.c: In function 'rxrpc_reject_packets':
net/rxrpc/output.c:527:11: warning:
 variable 'ioc' set but not used [-Wunused-but-set-variable]

'ioc' is the correct kvec num while send response packet.

Fixes: ece64fec164f ("rxrpc: Emit BUSY packets when supposed to rather than 
ABORTs")
Signed-off-by: YueHaibing 
---
v3: remove 'commit' from Fixes info.
v2: use 'ioc' rather than remove it.
---
 net/rxrpc/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index e8fb892..a141ee3 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -572,7 +572,8 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
whdr.flags  ^= RXRPC_CLIENT_INITIATED;
whdr.flags  &= RXRPC_CLIENT_INITIATED;
 
-   ret = kernel_sendmsg(local->socket, , iov, 2, size);
+   ret = kernel_sendmsg(local->socket, ,
+iov, ioc, size);
if (ret < 0)
trace_rxrpc_tx_fail(local->debug_id, 0, ret,
rxrpc_tx_point_reject);



Re: [PATCH v2] rxrpc: use correct kvec num while send response packet in rxrpc_reject_packets

2018-10-09 Thread YueHaibing
On 2018/10/9 23:34, Sergei Shtylyov wrote:
> On 10/09/2018 05:15 PM, YueHaibing wrote:
> 
>> Fixes gcc '-Wunused-but-set-variable' warning:
>>
>> net/rxrpc/output.c: In function 'rxrpc_reject_packets':
>> net/rxrpc/output.c:527:11: warning:
>>  variable 'ioc' set but not used [-Wunused-but-set-variable]
>>
>> 'ioc' is the correct kvec num while send response packet.
>>
>> Fixes: commit ece64fec164f ("rxrpc: Emit BUSY packets when supposed to 
>> rather than 
> ABORTs")
> 
>"commit" not needed here.

Thank you for review.

> 
>> Signed-off-by: YueHaibing 
> [...]
> 
> MBR, Sergei
> 
> 
> 



[PATCH v2] rxrpc: use correct kvec num while send response packet in rxrpc_reject_packets

2018-10-09 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

net/rxrpc/output.c: In function 'rxrpc_reject_packets':
net/rxrpc/output.c:527:11: warning:
 variable 'ioc' set but not used [-Wunused-but-set-variable]

'ioc' is the correct kvec num while send response packet.

Fixes: commit ece64fec164f ("rxrpc: Emit BUSY packets when supposed to rather 
than ABORTs")
Signed-off-by: YueHaibing 
---
 net/rxrpc/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index e8fb892..a141ee3 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -572,7 +572,8 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
whdr.flags  ^= RXRPC_CLIENT_INITIATED;
whdr.flags  &= RXRPC_CLIENT_INITIATED;
 
-   ret = kernel_sendmsg(local->socket, , iov, 2, size);
+   ret = kernel_sendmsg(local->socket, ,
+iov, ioc, size);
if (ret < 0)
trace_rxrpc_tx_fail(local->debug_id, 0, ret,
rxrpc_tx_point_reject);



Re: [PATCH net-next] rxrpc: Remove set but not used variable 'ioc'

2018-10-09 Thread YueHaibing
On 2018/10/9 18:13, David Howells wrote:
> YueHaibing  wrote:
> 
>> net/rxrpc/output.c: In function 'rxrpc_reject_packets':
>> net/rxrpc/output.c:527:11: warning:
>>  variable 'ioc' set but not used [-Wunused-but-set-variable]
>>
>> It never used since introduction in
> 
> I wonder why my compiler doesn't show this warning.
Just use make W=1
> 
> Anyway, NAK: just removing the variable is the wrong fix - you need to look at
> the code more closely.  The actual fix is to pass it to kernel_sendmsg()
> instead of 2.

I didn't notice this, Thank you for correction.

> 
> But thanks anyway!  Do you want to respin your patch?

Sure, I will fix it.

> 
>> commit ece64fec164f ("rxrpc: Emit BUSY packets when supposed to rather than 
>> ABORTs")
> 
> Btw, this should be a 'Fixes:  ("subject")' line and the patch needs
> to go to net, not net-next.
> 
> David
> 
> .
> 



[PATCH net-next] rxrpc: Remove set but not used variable 'ioc'

2018-10-08 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

net/rxrpc/output.c: In function 'rxrpc_reject_packets':
net/rxrpc/output.c:527:11: warning:
 variable 'ioc' set but not used [-Wunused-but-set-variable]

It never used since introduction in
commit ece64fec164f ("rxrpc: Emit BUSY packets when supposed to rather than 
ABORTs")

Signed-off-by: YueHaibing 
---
 net/rxrpc/output.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c
index e8fb892..f3ed16a 100644
--- a/net/rxrpc/output.c
+++ b/net/rxrpc/output.c
@@ -524,7 +524,7 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
struct kvec iov[2];
size_t size;
__be32 code;
-   int ret, ioc;
+   int ret;
 
_enter("%d", local->debug_id);
 
@@ -548,13 +548,11 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
case RXRPC_SKB_MARK_REJECT_BUSY:
whdr.type = RXRPC_PACKET_TYPE_BUSY;
size = sizeof(whdr);
-   ioc = 1;
break;
case RXRPC_SKB_MARK_REJECT_ABORT:
whdr.type = RXRPC_PACKET_TYPE_ABORT;
code = htonl(skb->priority);
size = sizeof(whdr) + sizeof(code);
-   ioc = 2;
break;
default:
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);



[PATCH net-next] net: mscc: ocelot: remove set but not used variable 'phy_mode'

2018-10-08 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/mscc/ocelot_board.c: In function 'mscc_ocelot_probe':
drivers/net/ethernet/mscc/ocelot_board.c:262:17: warning:
 variable 'phy_mode' set but not used [-Wunused-but-set-variable]
   enum phy_mode phy_mode;

It never used since introduction in 
commit 71e32a20cfbf ("net: mscc: ocelot: make use of SerDes PHYs for handling 
their configuration")

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/mscc/ocelot_board.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_board.c 
b/drivers/net/ethernet/mscc/ocelot_board.c
index 953b326..0cf0b09 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -259,7 +259,6 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
struct phy_device *phy;
struct resource *res;
struct phy *serdes;
-   enum phy_mode phy_mode;
void __iomem *regs;
char res_name[8];
u32 port;
@@ -297,10 +296,8 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
case PHY_INTERFACE_MODE_NA:
continue;
case PHY_INTERFACE_MODE_SGMII:
-   phy_mode = PHY_MODE_SGMII;
break;
case PHY_INTERFACE_MODE_QSGMII:
-   phy_mode = PHY_MODE_QSGMII;
break;
default:
dev_err(ocelot->dev,



Re: [PATCH can-next] can: ucan: remove set but not used variable 'udev'

2018-09-27 Thread YueHaibing
ping.

On 2018/8/29 9:46, YueHaibing wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/net/can/usb/ucan.c: In function 'ucan_disconnect':
> drivers/net/can/usb/ucan.c:1578:21: warning:
>  variable 'udev' set but not used [-Wunused-but-set-variable]
>   struct usb_device *udev;
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/net/can/usb/ucan.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
> index 0678a38..c9fd83e 100644
> --- a/drivers/net/can/usb/ucan.c
> +++ b/drivers/net/can/usb/ucan.c
> @@ -1575,11 +1575,8 @@ static int ucan_probe(struct usb_interface *intf,
>  /* disconnect the device */
>  static void ucan_disconnect(struct usb_interface *intf)
>  {
> - struct usb_device *udev;
>   struct ucan_priv *up = usb_get_intfdata(intf);
>  
> - udev = interface_to_usbdev(intf);
> -
>   usb_set_intfdata(intf, NULL);
>  
>   if (up) {
> 
> 
> .
> 



Re: [PATCH can-next] can: ucan: remove duplicated include from ucan.c

2018-09-27 Thread YueHaibing
ping.

On 2018/8/29 9:25, YueHaibing wrote:
> Remove duplicated include.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/net/can/usb/ucan.c | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
> index 0678a38..c6f4b41 100644
> --- a/drivers/net/can/usb/ucan.c
> +++ b/drivers/net/can/usb/ucan.c
> @@ -35,10 +35,6 @@
>  #include 
>  #include 
>  
> -#include 
> -#include 
> -#include 
> -
>  #define UCAN_DRIVER_NAME "ucan"
>  #define UCAN_MAX_RX_URBS 8
>  /* the CAN controller needs a while to enable/disable the bus */
> 
> 
> .
> 



[PATCH net-next] qed: Remove set but not used variable 'p_archipelago'

2018-09-27 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/qlogic/qed/qed_ooo.c: In function 'qed_ooo_delete_isles':
drivers/net/ethernet/qlogic/qed/qed_ooo.c:354:30: warning:
 variable 'p_archipelago' set but not used [-Wunused-but-set-variable]
 
drivers/net/ethernet/qlogic/qed/qed_ooo.c: In function 'qed_ooo_join_isles':
drivers/net/ethernet/qlogic/qed/qed_ooo.c:463:30: warning:
 variable 'p_archipelago' set but not used [-Wunused-but-set-variable]

Since commit 1eec2437d14c ("qed: Make OOO archipelagos into an array"),
'p_archipelago' is no longer in use.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/qlogic/qed/qed_ooo.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ooo.c 
b/drivers/net/ethernet/qlogic/qed/qed_ooo.c
index 63931df..ffac4ac 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ooo.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ooo.c
@@ -351,11 +351,9 @@ void qed_ooo_delete_isles(struct qed_hwfn *p_hwfn,
  struct qed_ooo_info *p_ooo_info,
  u32 cid, u8 drop_isle, u8 drop_size)
 {
-   struct qed_ooo_archipelago *p_archipelago = NULL;
struct qed_ooo_isle *p_isle = NULL;
u8 isle_idx;
 
-   p_archipelago = qed_ooo_seek_archipelago(p_hwfn, p_ooo_info, cid);
for (isle_idx = 0; isle_idx < drop_size; isle_idx++) {
p_isle = qed_ooo_seek_isle(p_hwfn, p_ooo_info, cid, drop_isle);
if (!p_isle) {
@@ -460,7 +458,6 @@ void qed_ooo_add_new_buffer(struct qed_hwfn *p_hwfn,
 void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, u32 cid, u8 left_isle)
 {
-   struct qed_ooo_archipelago *p_archipelago = NULL;
struct qed_ooo_isle *p_right_isle = NULL;
struct qed_ooo_isle *p_left_isle = NULL;
 
@@ -473,7 +470,6 @@ void qed_ooo_join_isles(struct qed_hwfn *p_hwfn,
return;
}
 
-   p_archipelago = qed_ooo_seek_archipelago(p_hwfn, p_ooo_info, cid);
list_del(_right_isle->list_entry);
p_ooo_info->cur_isles_number--;
if (left_isle) {



Re: [PATCH net-next] net/smc: cast sizeof to int for comparison

2018-09-16 Thread YueHaibing
On 2018/9/15 19:35, Andreas Schwab wrote:
> On Sep 15 2018, YueHaibing  wrote:
> 
>> Comparing an int to a size, which is unsigned, causes the int to become
>> unsigned, giving the wrong result. kernel_sendmsg can return a negative
>> error code.
>>
>> Signed-off-by: YueHaibing 
>> ---
>>  net/smc/smc_clc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
>> index 83aba9a..fd0f5ce 100644
>> --- a/net/smc/smc_clc.c
>> +++ b/net/smc/smc_clc.c
>> @@ -446,7 +446,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, int 
>> smc_type,
>>  vec[i++].iov_len = sizeof(trl);
>>  /* due to the few bytes needed for clc-handshake this cannot block */
>>  len = kernel_sendmsg(smc->clcsock, , vec, i, plen);
>> -if (len < sizeof(pclc)) {
>> +if (len < (int)sizeof(pclc)) {
>>  if (len >= 0) {
>>  reason_code = -ENETUNREACH;
>>  smc->sk.sk_err = -reason_code;
> 
> It would perhaps be better to handle len < 0 first.

That need refactor the err hangding, is worth doing it?

> 
> Andreas.
> 



[PATCH net-next] qlcnic: Remove set but not used variables 'fw_mbx' and 'hdr_size'

2018-09-11 Thread YueHaibing
From: Yue Haibing 

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c: In function 
'qlcnic_sriov_pull_bc_msg':
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c:907:6: warning:
 variable 'fw_mbx' set but not used [-Wunused-but-set-variable]

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c: In function 
'qlcnic_sriov_issue_bc_post':
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c:939:16: warning:
 variable 'hdr_size' set but not used [-Wunused-but-set-variable]

Signed-off-by: Yue Haibing 
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c 
b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 77e386e..f7c2f32 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -904,13 +904,11 @@ static void qlcnic_sriov_pull_bc_msg(struct 
qlcnic_adapter *adapter,
 u32 *hdr, u32 *pay, u32 size)
 {
struct qlcnic_hardware_context *ahw = adapter->ahw;
-   u32 fw_mbx;
u8 i, max = 2, hdr_size, j;
 
hdr_size = (sizeof(struct qlcnic_bc_hdr) / sizeof(u32));
max = (size / sizeof(u32)) + hdr_size;
 
-   fw_mbx = readl(QLCNIC_MBX_FW(ahw, 0));
for (i = 2, j = 0; j < hdr_size; i++, j++)
*(hdr++) = readl(QLCNIC_MBX_FW(ahw, i));
for (; j < max; i++, j++)
@@ -936,7 +934,7 @@ static int __qlcnic_sriov_issue_bc_post(struct 
qlcnic_vf_info *vf)
 static int qlcnic_sriov_issue_bc_post(struct qlcnic_bc_trans *trans, u8 type)
 {
struct qlcnic_vf_info *vf = trans->vf;
-   u32 pay_size, hdr_size;
+   u32 pay_size;
u32 *hdr, *pay;
int ret;
u8 pci_func = trans->func_id;
@@ -947,14 +945,12 @@ static int qlcnic_sriov_issue_bc_post(struct 
qlcnic_bc_trans *trans, u8 type)
if (type == QLC_BC_COMMAND) {
hdr = (u32 *)(trans->req_hdr + trans->curr_req_frag);
pay = (u32 *)(trans->req_pay + trans->curr_req_frag);
-   hdr_size = (sizeof(struct qlcnic_bc_hdr) / sizeof(u32));
pay_size = qlcnic_sriov_get_bc_paysize(trans->req_pay_size,
   trans->curr_req_frag);
pay_size = (pay_size / sizeof(u32));
} else {
hdr = (u32 *)(trans->rsp_hdr + trans->curr_rsp_frag);
pay = (u32 *)(trans->rsp_pay + trans->curr_rsp_frag);
-   hdr_size = (sizeof(struct qlcnic_bc_hdr) / sizeof(u32));
pay_size = qlcnic_sriov_get_bc_paysize(trans->rsp_pay_size,
   trans->curr_rsp_frag);
pay_size = (pay_size / sizeof(u32));



[PATCH net-next] liquidio CN23XX: Remove set but not used variable 'ring_flag'

2018-09-06 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c: In function 
'cn23xx_setup_octeon_vf_device':
drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c:619:20: warning:
 variable 'ring_flag' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c 
b/drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c
index 962bb62..fda4940 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_vf_device.c
@@ -616,7 +616,7 @@ static void cn23xx_disable_vf_interrupt(struct 
octeon_device *oct, u8 intr_flag)
 int cn23xx_setup_octeon_vf_device(struct octeon_device *oct)
 {
struct octeon_cn23xx_vf *cn23xx = (struct octeon_cn23xx_vf *)oct->chip;
-   u32 rings_per_vf, ring_flag;
+   u32 rings_per_vf;
u64 reg_val;
 
if (octeon_map_pci_barx(oct, 0, 0))
@@ -634,8 +634,6 @@ int cn23xx_setup_octeon_vf_device(struct octeon_device *oct)
 
rings_per_vf = reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK;
 
-   ring_flag = 0;
-
cn23xx->conf  = oct_get_config_info(oct, LIO_23XX);
if (!cn23xx->conf) {
dev_err(>pci_dev->dev, "%s No Config found for CN23XX\n",



[PATCH net-next] bnxt_en: remove set but not used variable 'addr_type'

2018-09-05 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c: In function 'bnxt_tc_parse_flow':
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c:186:6: warning:
 variable 'addr_type' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
index 092c817..f4ba9b3 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
@@ -181,7 +181,6 @@ static int bnxt_tc_parse_flow(struct bnxt *bp,
  struct bnxt_tc_flow *flow)
 {
struct flow_dissector *dissector = tc_flow_cmd->dissector;
-   u16 addr_type = 0;
 
/* KEY_CONTROL and KEY_BASIC are needed for forming a meaningful key */
if ((dissector->used_keys & BIT(FLOW_DISSECTOR_KEY_CONTROL)) == 0 ||
@@ -191,13 +190,6 @@ static int bnxt_tc_parse_flow(struct bnxt *bp,
return -EOPNOTSUPP;
}
 
-   if (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_CONTROL)) {
-   struct flow_dissector_key_control *key =
-   GET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_CONTROL);
-
-   addr_type = key->addr_type;
-   }
-
if (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_dissector_key_basic *key =
GET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_BASIC);
@@ -293,13 +285,6 @@ static int bnxt_tc_parse_flow(struct bnxt *bp,
flow->l4_mask.icmp.code = mask->code;
}
 
-   if (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_ENC_CONTROL)) {
-   struct flow_dissector_key_control *key =
-   GET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_ENC_CONTROL);
-
-   addr_type = key->addr_type;
-   }
-
if (dissector_uses_key(dissector, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS)) {
struct flow_dissector_key_ipv4_addrs *key =
GET_KEY(tc_flow_cmd, FLOW_DISSECTOR_KEY_ENC_IPV4_ADDRS);



[PATCH v2 net-next] failover: Add missing check to validate 'slave_dev' in net_failover_slave_unregister

2018-09-03 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/net_failover.c: In function 'net_failover_slave_unregister':
drivers/net/net_failover.c:598:35: warning:
 variable 'primary_dev' set but not used [-Wunused-but-set-variable]

There should check the validity of 'slave_dev'.

Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")

Signed-off-by: YueHaibing 
---
v2: use WARN_ON_ONCE as Liran Alon suggested
---
 drivers/net/net_failover.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 7ae1856..5a749dc 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -603,6 +603,9 @@ static int net_failover_slave_unregister(struct net_device 
*slave_dev,
primary_dev = rtnl_dereference(nfo_info->primary_dev);
standby_dev = rtnl_dereference(nfo_info->standby_dev);
 
+   if (WARN_ON_ONCE(slave_dev != primary_dev && slave_dev != standby_dev))
+   return -ENODEV;
+
vlan_vids_del_by_dev(slave_dev, failover_dev);
dev_uc_unsync(slave_dev, failover_dev);
dev_mc_unsync(slave_dev, failover_dev);



[PATCH net-next] failover: Add missing check to validate 'slave_dev' in net_failover_slave_unregister

2018-08-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/net_failover.c: In function 'net_failover_slave_unregister':
drivers/net/net_failover.c:598:35: warning:
 variable 'primary_dev' set but not used [-Wunused-but-set-variable]

There should check the validity of 'slave_dev'.

Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
Suggested-by: Samudrala, Sridhar 
Signed-off-by: YueHaibing 
---
 drivers/net/net_failover.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 7ae1856..af1ece8 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -602,6 +602,9 @@ static int net_failover_slave_unregister(struct net_device 
*slave_dev,
nfo_info = netdev_priv(failover_dev);
primary_dev = rtnl_dereference(nfo_info->primary_dev);
standby_dev = rtnl_dereference(nfo_info->standby_dev);
+
+   if (slave_dev != primary_dev && slave_dev != standby_dev)
+   return -ENODEV;
 
vlan_vids_del_by_dev(slave_dev, failover_dev);
dev_uc_unsync(slave_dev, failover_dev);



Re: [PATCH net-next] failover: remove set but not used variable 'primary_dev'

2018-08-31 Thread YueHaibing



On 2018/9/1 0:39, Samudrala, Sridhar wrote:
> On 8/30/2018 8:46 PM, YueHaibing wrote:
>> Fixes gcc '-Wunused-but-set-variable' warning:
>>
>> drivers/net/net_failover.c: In function 'net_failover_slave_unregister':
>> drivers/net/net_failover.c:598:35: warning:
>>   variable 'primary_dev' set but not used [-Wunused-but-set-variable]
> 
> Actually this gcc option found a bug.
> We need to add this check after accessing primary_dev and standby_dev.
> 
> if (slave_dev != primary_dev && slave_dev != standby_dev)
> return -ENODEV;
> 
> Can you resubmit with the right fix?
> 

sure, thank you. will send v2

> 
>>
>> Signed-off-by: YueHaibing 
>> ---
>>   drivers/net/net_failover.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
>> index 7ae1856..e103c94e 100644
>> --- a/drivers/net/net_failover.c
>> +++ b/drivers/net/net_failover.c
>> @@ -595,12 +595,11 @@ static int net_failover_slave_pre_unregister(struct 
>> net_device *slave_dev,
>>   static int net_failover_slave_unregister(struct net_device *slave_dev,
>>struct net_device *failover_dev)
>>   {
>> -struct net_device *standby_dev, *primary_dev;
>> +struct net_device *standby_dev;
>>   struct net_failover_info *nfo_info;
>>   bool slave_is_standby;
>> nfo_info = netdev_priv(failover_dev);
>> -primary_dev = rtnl_dereference(nfo_info->primary_dev);
>>   standby_dev = rtnl_dereference(nfo_info->standby_dev);
>> vlan_vids_del_by_dev(slave_dev, failover_dev);
>>
> 
> 
> .
> 



[PATCH v2 net-next] liquidio: remove set but not used variable 'irh'

2018-08-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/cavium/liquidio/request_manager.c: In function 
'lio_process_iq_request_list':
drivers/net/ethernet/cavium/liquidio/request_manager.c:383:27: warning:
 variable 'irh' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
v2: fix patch description,remove 'cHECK-'
---
 drivers/net/ethernet/cavium/liquidio/request_manager.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c 
b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index bd0153e..c6f4cbd 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -380,7 +380,6 @@ static inline void __copy_cmd_into_iq(struct 
octeon_instr_queue *iq,
u32 inst_count = 0;
unsigned int pkts_compl = 0, bytes_compl = 0;
struct octeon_soft_command *sc;
-   struct octeon_instr_irh *irh;
unsigned long flags;
 
while (old != iq->octeon_read_index) {
@@ -402,14 +401,6 @@ static inline void __copy_cmd_into_iq(struct 
octeon_instr_queue *iq,
case REQTYPE_RESP_NET:
case REQTYPE_SOFT_COMMAND:
sc = buf;
-
-   if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct))
-   irh = (struct octeon_instr_irh *)
-   >cmd.cmd3.irh;
-   else
-   irh = (struct octeon_instr_irh *)
-   >cmd.cmd2.irh;
-
/* We're expecting a response from Octeon.
 * It's up to lio_process_ordered_list() to
 * process  sc. Add sc to the ordered soft



Re: [PATCH net-next] liquidio: cHECK-remove set but not used variable 'irh'

2018-08-31 Thread YueHaibing
sorry, patch description is messy, will fix it in V2.

On 2018/8/31 19:53, YueHaibing wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/net/ethernet/cavium/liquidio/request_manager.c: In function 
> 'lio_process_iq_request_list':
> drivers/net/ethernet/cavium/liquidio/request_manager.c:383:27: warning:
>  variable 'irh' set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/net/ethernet/cavium/liquidio/request_manager.c | 9 -
>  1 file changed, 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c 
> b/drivers/net/ethernet/cavium/liquidio/request_manager.c
> index bd0153e..c6f4cbd 100644
> --- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
> +++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
> @@ -380,7 +380,6 @@ static inline void __copy_cmd_into_iq(struct 
> octeon_instr_queue *iq,
>   u32 inst_count = 0;
>   unsigned int pkts_compl = 0, bytes_compl = 0;
>   struct octeon_soft_command *sc;
> - struct octeon_instr_irh *irh;
>   unsigned long flags;
>  
>   while (old != iq->octeon_read_index) {
> @@ -402,14 +401,6 @@ static inline void __copy_cmd_into_iq(struct 
> octeon_instr_queue *iq,
>   case REQTYPE_RESP_NET:
>   case REQTYPE_SOFT_COMMAND:
>   sc = buf;
> -
> - if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct))
> - irh = (struct octeon_instr_irh *)
> - >cmd.cmd3.irh;
> - else
> - irh = (struct octeon_instr_irh *)
> - >cmd.cmd2.irh;
> -
>   /* We're expecting a response from Octeon.
>* It's up to lio_process_ordered_list() to
>* process  sc. Add sc to the ordered soft
> 
> 
> .
> 



[PATCH net-next] liquidio: cHECK-remove set but not used variable 'irh'

2018-08-31 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/cavium/liquidio/request_manager.c: In function 
'lio_process_iq_request_list':
drivers/net/ethernet/cavium/liquidio/request_manager.c:383:27: warning:
 variable 'irh' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/cavium/liquidio/request_manager.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c 
b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index bd0153e..c6f4cbd 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -380,7 +380,6 @@ static inline void __copy_cmd_into_iq(struct 
octeon_instr_queue *iq,
u32 inst_count = 0;
unsigned int pkts_compl = 0, bytes_compl = 0;
struct octeon_soft_command *sc;
-   struct octeon_instr_irh *irh;
unsigned long flags;
 
while (old != iq->octeon_read_index) {
@@ -402,14 +401,6 @@ static inline void __copy_cmd_into_iq(struct 
octeon_instr_queue *iq,
case REQTYPE_RESP_NET:
case REQTYPE_SOFT_COMMAND:
sc = buf;
-
-   if (OCTEON_CN23XX_PF(oct) || OCTEON_CN23XX_VF(oct))
-   irh = (struct octeon_instr_irh *)
-   >cmd.cmd3.irh;
-   else
-   irh = (struct octeon_instr_irh *)
-   >cmd.cmd2.irh;
-
/* We're expecting a response from Octeon.
 * It's up to lio_process_ordered_list() to
 * process  sc. Add sc to the ordered soft



[PATCH net-next] bnxt_en: remove set but not used variable 'rx_stats'

2018-08-30 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c: In function 'bnxt_vf_rep_rx':
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c:212:28: warning:
 variable 'rx_stats' set but not used [-Wunused-but-set-variable]
  struct bnxt_vf_rep_stats *rx_stats;

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
index e31f5d8..b574fe8 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
@@ -209,9 +209,7 @@ struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 
cfa_code)
 void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb)
 {
struct bnxt_vf_rep *vf_rep = netdev_priv(skb->dev);
-   struct bnxt_vf_rep_stats *rx_stats;
 
-   rx_stats = _rep->rx_stats;
vf_rep->rx_stats.bytes += skb->len;
vf_rep->rx_stats.packets++;



[PATCH net-next] failover: remove set but not used variable 'primary_dev'

2018-08-30 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/net_failover.c: In function 'net_failover_slave_unregister':
drivers/net/net_failover.c:598:35: warning:
 variable 'primary_dev' set but not used [-Wunused-but-set-variable]

Signed-off-by: YueHaibing 
---
 drivers/net/net_failover.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 7ae1856..e103c94e 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -595,12 +595,11 @@ static int net_failover_slave_pre_unregister(struct 
net_device *slave_dev,
 static int net_failover_slave_unregister(struct net_device *slave_dev,
 struct net_device *failover_dev)
 {
-   struct net_device *standby_dev, *primary_dev;
+   struct net_device *standby_dev;
struct net_failover_info *nfo_info;
bool slave_is_standby;
 
nfo_info = netdev_priv(failover_dev);
-   primary_dev = rtnl_dereference(nfo_info->primary_dev);
standby_dev = rtnl_dereference(nfo_info->standby_dev);
 
vlan_vids_del_by_dev(slave_dev, failover_dev);



[PATCH net-next] net: remove duplicated include from net_failover.c

2018-08-30 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/net/net_failover.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 7ae1856..192ae1c 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -19,7 +19,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



[PATCH net-next] net/ncsi: remove duplicated include from ncsi-netlink.c

2018-08-29 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 net/ncsi/ncsi-netlink.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
index 45f33d6..32cb775 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



[PATCH can-next] can: ucan: remove set but not used variable 'udev'

2018-08-28 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/can/usb/ucan.c: In function 'ucan_disconnect':
drivers/net/can/usb/ucan.c:1578:21: warning:
 variable 'udev' set but not used [-Wunused-but-set-variable]
  struct usb_device *udev;

Signed-off-by: YueHaibing 
---
 drivers/net/can/usb/ucan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index 0678a38..c9fd83e 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -1575,11 +1575,8 @@ static int ucan_probe(struct usb_interface *intf,
 /* disconnect the device */
 static void ucan_disconnect(struct usb_interface *intf)
 {
-   struct usb_device *udev;
struct ucan_priv *up = usb_get_intfdata(intf);
 
-   udev = interface_to_usbdev(intf);
-
usb_set_intfdata(intf, NULL);
 
if (up) {



[PATCH can-next] can: ucan: remove duplicated include from ucan.c

2018-08-28 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 drivers/net/can/usb/ucan.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index 0678a38..c6f4b41 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -35,10 +35,6 @@
 #include 
 #include 
 
-#include 
-#include 
-#include 
-
 #define UCAN_DRIVER_NAME "ucan"
 #define UCAN_MAX_RX_URBS 8
 /* the CAN controller needs a while to enable/disable the bus */



[PATCH bpf-next] bpf: remove duplicated include from syscall.c

2018-08-28 Thread YueHaibing
Remove duplicated include.

Signed-off-by: YueHaibing 
---
 kernel/bpf/syscall.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 8339d81..3c9636f 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \



[PATCH net-next] bnxt_en: combine 'else if' and 'else' into single branche

2018-07-25 Thread YueHaibing
The else-if branch and else branch set mac_ok to true similarly,
so combine the two into single else branch.

Aslo add comments to explain the two conditions, which
from Michael Chan and Vasundhara Volam.

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index a649108..f560845 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -956,9 +956,13 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, 
struct bnxt_vf_info *vf)
} else if (is_valid_ether_addr(vf->vf_mac_addr)) {
if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
mac_ok = true;
-   } else if (bp->hwrm_spec_code < 0x10202) {
-   mac_ok = true;
} else {
+   /* There are two cases:
+* 1.If firmware spec < 0x10202,VF MAC address is not forwarded
+*   to the PF and so it doesn't have to match
+* 2.Allow VF to modify it's own MAC when PF has not assigned a
+*   valid MAC address and firmware spec >= 0x10202
+*/
mac_ok = true;
}
if (mac_ok)
-- 
2.7.0




Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac

2018-07-25 Thread YueHaibing
On 2018/7/25 5:48, Michael Chan wrote:
> On Tue, Jul 24, 2018 at 9:01 AM, Vasundhara Volam
>  wrote:
>> On Tue, Jul 24, 2018 at 1:01 PM, Michael Chan  
>> wrote:
>>>
>>> On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing  wrote:
>>>> Based on the comments,req->l2addr must match the VF MAC address
>>>> if firmware spec >= 1.2.2, mac_ok can be true.
>>>>
>>>> Signed-off-by: YueHaibing 
>>>> ---
>>>>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-
>>>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 
>>>> b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> index a649108..7925964 100644
>>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, 
>>>> struct bnxt_vf_info *vf)
>>>> if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->mac_addr))
>>>> mac_ok = true;
>>>> } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>>>> -   if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->vf_mac_addr))
>>>> +   if (ether_addr_equal((const u8 *)req->l2_addr, 
>>>> vf->vf_mac_addr) &&
>>>> +   bp->hwrm_spec_code >= 0x10202)
>>>> mac_ok = true;
>>>
>>> I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
>>> MAC address is not forwarded to the PF and so it doesn't have to match
>>> and mac_ok should still be true.  I think we are missing that
>>> condition with this patch.
>>>
>>> I need to let my colleague Vasundhara comment on this.  She is more
>>> familiar with this logic.
>> Yes Michael, you are right. Also, the plain else condition is to cover
>> a special case to allow VF to modify
>> it's own MAC when PF has not assigned a valid MAC address and HWRM
>> spec code > 0x10202.
> 
> We should combine the "else if" and "else" below into a plain else and
> add some comments to explain the conditions.

Thank you for clarification.

I will send a new patch for this.

> 
>>>
>>>> -   } else if (bp->hwrm_spec_code < 0x10202) {
>>>> -   mac_ok = true;
>>>> -   } else {
>>>> -   mac_ok = true;
>>>> }
>>>> if (mac_ok)
>>>> return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
>>>> --
>>>> 2.7.0
>>>>
>>>>
> 
> .
> 



[PATCH net-next] tipc: add missing dev_put() on error in tipc_enable_l2_media

2018-07-25 Thread YueHaibing
when tipc_own_id failed to obtain node identity,dev_put should
be call before return -EINVAL.

Fixes: 682cd3cf946b ("tipc: confgiure and apply UDP bearer MTU on running 
links")
Signed-off-by: YueHaibing 
---
 net/tipc/bearer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index fd6d8f1..418f03d 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -395,6 +395,7 @@ int tipc_enable_l2_media(struct net *net, struct 
tipc_bearer *b,
tipc_net_init(net, node_id, 0);
}
if (!tipc_own_id(net)) {
+   dev_put(dev);
pr_warn("Failed to obtain node identity\n");
return -EINVAL;
}
-- 
2.7.0




[PATCH ipsec-next] xfrm: fix 'passing zero to ERR_PTR()' warning

2018-07-25 Thread YueHaibing
Fix a static code checker warning:

  net/xfrm/xfrm_policy.c:1836 xfrm_resolve_and_create_bundle() warn: passing 
zero to 'ERR_PTR'

xfrm_tmpl_resolve return 0 just means no xdst found, return NULL
instead of passing zero to ERR_PTR.

Fixes: d809ec895505 ("xfrm: do not assume that template resolving always 
returns xfrms")
Signed-off-by: YueHaibing 
---
 net/xfrm/xfrm_policy.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5f48251..4adbeb2 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1831,7 +1831,10 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy 
**pols, int num_pols,
/* Try to instantiate a bundle */
err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);
if (err <= 0) {
-   if (err != 0 && err != -EAGAIN)
+   if (err == 0)
+   return NULL;
+
+   if (err != -EAGAIN)
XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
return ERR_PTR(err);
}
-- 
2.7.0




[PATCH net] net: qcom/emac: Add missing of_node_put()

2018-06-11 Thread YueHaibing
Add missing of_node_put() call for device node returned by
of_parse_phandle().

Signed-off-by: YueHaibing 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index e78e5db..c694e34 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -384,6 +384,7 @@ int emac_sgmii_config(struct platform_device *pdev, struct 
emac_adapter *adpt)
}
 
sgmii_pdev = of_find_device_by_node(np);
+   of_node_put(np);
if (!sgmii_pdev) {
dev_err(>dev, "invalid internal-phy property\n");
return -ENODEV;
-- 
2.7.0




[PATCH bpf-next] bpf: hide the unused 'off' variable

2018-05-28 Thread YueHaibing
The local variable is only used while CONFIG_IPV6 enabled

net/core/filter.c: In function ‘sk_msg_convert_ctx_access’:
net/core/filter.c:6489:6: warning: unused variable ‘off’ [-Wunused-variable]
  int off;
  ^
This puts it into #ifdef.

Fixes: 303def35f64e ("bpf: allow sk_msg programs to read sock fields")
Signed-off-by: YueHaibing 
---
 net/core/filter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index 24e6ce8..0ce93ed 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -6486,7 +6486,9 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type 
type,
 struct bpf_prog *prog, u32 *target_size)
 {
struct bpf_insn *insn = insn_buf;
+#if IS_ENABLED(CONFIG_IPV6)
int off;
+#endif
 
switch (si->off) {
case offsetof(struct sk_msg_md, data):
-- 
2.7.0




[PATCH net-next] net: remove unnecessary genlmsg_cancel() calls

2018-05-26 Thread YueHaibing
the message be freed immediately, no need to trim it
back to the previous size.

Inspired by commit 7a9b3ec1e19f ("nl80211: remove unnecessary genlmsg_cancel() 
calls")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/team/team.c   |  2 --
 drivers/net/wireless/mac80211_hwsim.c |  1 -
 net/core/devlink.c|  4 
 net/ipv6/seg6.c   |  1 -
 net/ncsi/ncsi-netlink.c   |  1 -
 net/nfc/netlink.c | 17 -
 6 files changed, 26 deletions(-)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index e6730a0..267dcc9 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2426,7 +2426,6 @@ static int team_nl_send_options_get(struct team *team, 
u32 portid, u32 seq,
 nla_put_failure:
err = -EMSGSIZE;
 errout:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2720,7 +2719,6 @@ static int team_nl_send_port_list_get(struct team *team, 
u32 portid, u32 seq,
 nla_put_failure:
err = -EMSGSIZE;
 errout:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index c26469b..38e1135 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2514,7 +2514,6 @@ static void hwsim_mcast_new_radio(int id, struct 
genl_info *info,
return;
 
 out_err:
-   genlmsg_cancel(mcast_skb, data);
nlmsg_free(mcast_skb);
 }
 
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 475246b..f75ee02 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1826,7 +1826,6 @@ static int devlink_dpipe_tables_fill(struct genl_info 
*info,
 nla_put_failure:
err = -EMSGSIZE;
 err_table_put:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2032,7 +2031,6 @@ int devlink_dpipe_entry_ctx_prepare(struct 
devlink_dpipe_dump_ctx *dump_ctx)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(dump_ctx->skb, dump_ctx->hdr);
nlmsg_free(dump_ctx->skb);
return -EMSGSIZE;
 }
@@ -2249,7 +2247,6 @@ static int devlink_dpipe_headers_fill(struct genl_info 
*info,
 nla_put_failure:
err = -EMSGSIZE;
 err_table_put:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
@@ -2551,7 +2548,6 @@ static int devlink_resource_fill(struct genl_info *info,
err = -EMSGSIZE;
 err_resource_put:
 err_skb_send_alloc:
-   genlmsg_cancel(skb, hdr);
nlmsg_free(skb);
return err;
 }
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index 7f5621d..0fdf2a5 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -226,7 +226,6 @@ static int seg6_genl_get_tunsrc(struct sk_buff *skb, struct 
genl_info *info)
 
 nla_put_failure:
rcu_read_unlock();
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -ENOMEM;
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
index b09ef77..99f4c22 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -201,7 +201,6 @@ static int ncsi_pkg_info_nl(struct sk_buff *msg, struct 
genl_info *info)
return genlmsg_reply(skb, info);
 
 err:
-   genlmsg_cancel(skb, hdr);
kfree_skb(skb);
return rc;
 }
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f018eaf..376181c 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -206,7 +206,6 @@ int nfc_genl_targets_found(struct nfc_dev *dev)
return genlmsg_multicast(_genl_family, msg, 0, 0, GFP_ATOMIC);
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -237,7 +236,6 @@ int nfc_genl_target_lost(struct nfc_dev *dev, u32 
target_idx)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -269,7 +267,6 @@ int nfc_genl_tm_activated(struct nfc_dev *dev, u32 protocol)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -299,7 +296,6 @@ int nfc_genl_tm_deactivated(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -340,7 +336,6 @@ int nfc_genl_device_added(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -370,7 +365,6 @@ int nfc_genl_device_removed(struct nfc_dev *dev)
return 0;
 
 nla_put_failure:
-   genlmsg_cancel(msg, hdr);
 free_msg:
nlmsg_free(msg);
return -EMSGSIZE;
@@ -434,8 +428,6 @@ int nfc_genl_llc_send_sdres(struct nfc_dev *dev, struct 
hlist_head *sdres_list)
return genlmsg_multicast(_genl_family, msg, 0, 0, GFP_AT

Re: [PATCH net-next] bpfilter: fix a build err

2018-05-25 Thread YueHaibing
On 2018/5/26 0:19, Alexei Starovoitov wrote:
> On Fri, May 25, 2018 at 06:17:57PM +0800, YueHaibing wrote:
>> gcc-7.3.0 report following err:
>>
>>   HOSTCC  net/bpfilter/main.o
>> In file included from net/bpfilter/main.c:9:0:
>> ./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such 
>> file or directory
>>  #include 
>>
>> remove it by adding a include path.
>> Fixes: d2ba09c17a06 ("net: add skeleton of bpfilter kernel module")
>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
>> ---
>>  net/bpfilter/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
>> index 2af752c..3f3cb87 100644
>> --- a/net/bpfilter/Makefile
>> +++ b/net/bpfilter/Makefile
>> @@ -5,7 +5,7 @@
>>  
>>  hostprogs-y := bpfilter_umh
>>  bpfilter_umh-objs := main.o
>> -HOSTCFLAGS += -I. -Itools/include/
>> +HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
> 
> Strangely I don't see this error with gcc 7.3
> I've tried this patch and it doesn't hurt,
> but before it gets applied could you please try
> the top two patches from this tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/?h=ipt_bpf
> in your environment?
> These two patches add the actual meat of bpfilter and I'd like
> to make sure the build setup is good for everyone before
> we proceed too far.

after applied these two patches on net-next, the err still here:
 bpfilter: rough bpfilter codegen example hack
 bpfilter: add iptable get/set parsing

  HOSTCC  net/bpfilter/main.o
In file included from net/bpfilter/main.c:13:0:
./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such file 
or directory
 #include 
  ^~~~
compilation terminated.
make[2]: *** [net/bpfilter/main.o] Error 1
make[1]: *** [net/bpfilter] Error 2
make: *** [net] Error 2

Also I compile your tree, error is same

my gcc version info as follow:
[root@localhost net-next]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/yuehb/gcc-7.3.0-tools/libexec/gcc/x86_64-pc-linux-gnu/7.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-7.3.0/configure --enable-checking=release 
--enable-languages=c,c++
--disable-multilib --prefix=/home/yuehb/gcc-7.3.0-tools
Thread model: posix
gcc version 7.3.0 (GCC)

> 
> 
> .
> 



[PATCH net-next] bpfilter: fix a build err

2018-05-25 Thread YueHaibing
gcc-7.3.0 report following err:

  HOSTCC  net/bpfilter/main.o
In file included from net/bpfilter/main.c:9:0:
./include/uapi/linux/bpf.h:12:10: fatal error: linux/bpf_common.h: No such file 
or directory
 #include 

remove it by adding a include path.
Fixes: d2ba09c17a06 ("net: add skeleton of bpfilter kernel module")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 net/bpfilter/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index 2af752c..3f3cb87 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -5,7 +5,7 @@
 
 hostprogs-y := bpfilter_umh
 bpfilter_umh-objs := main.o
-HOSTCFLAGS += -I. -Itools/include/
+HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
 ifeq ($(CONFIG_BPFILTER_UMH), y)
 # builtin bpfilter_umh should be compiled with -static
 # since rootfs isn't mounted at the time of __init
-- 
2.7.0




Re: [PATCH net-next] cxgb4: Check for kvzalloc allocation failure

2018-05-24 Thread YueHaibing
On 2018/5/24 23:07, David Miller wrote:
> From: YueHaibing <yuehaib...@huawei.com>
> Date: Tue, 22 May 2018 15:07:18 +0800
> 
>> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
>> b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> index 130d1ee..019cffe 100644
>> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
>> @@ -4135,6 +4135,10 @@ static int adap_init0(struct adapter *adap)
>>   * card
>>   */
>>  card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL);
>> +if (!card_fw) {
>> +ret = -ENOMEM;
>> +goto bye;
>> +}
>>  
> 
> On error, this leaks fw_info.

Hi David,

I checked fw_info is an element of fw_info_array,there all members of struct 
fw_info no need free.

It likes this :

static struct fw_info fw_info_array[] = {
{
.chip = CHELSIO_T4,
.fs_name = FW4_CFNAME,
.fw_mod_name = FW4_FNAME,
.fw_hdr = {
.chip = FW_HDR_CHIP_T4,
.fw_ver = __cpu_to_be32(FW_VERSION(T4)),
.intfver_nic = FW_INTFVER(T4, NIC),
.intfver_vnic = FW_INTFVER(T4, VNIC),
.intfver_ri = FW_INTFVER(T4, RI),
.intfver_iscsi = FW_INTFVER(T4, ISCSI),
.intfver_fcoe = FW_INTFVER(T4, FCOE),
},
}, {


Am I missing something?
> 
> .
> 



[PATCH net-next] net: fec: remove stale comment

2018-05-24 Thread YueHaibing
This comment is outdated as fec_ptp_ioctl has been replaced by 
fec_ptp_set/fec_ptp_get 
since commit 1d5244d0e43b ("fec: Implement the SIOCGHWTSTAMP ioctl")

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c 
b/drivers/net/ethernet/freescale/fec_ptp.c
index f814397..d438ef8 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -466,12 +466,6 @@ static int fec_ptp_enable(struct ptp_clock_info *ptp,
return -EOPNOTSUPP;
 }
 
-/**
- * fec_ptp_hwtstamp_ioctl - control hardware time stamping
- * @ndev: pointer to net_device
- * @ifreq: ioctl data
- * @cmd: particular ioctl requested
- */
 int fec_ptp_set(struct net_device *ndev, struct ifreq *ifr)
 {
struct fec_enet_private *fep = netdev_priv(ndev);
-- 
2.7.0




[PATCH net-next] ixgbe: introduce a helper to simplify code

2018-05-23 Thread YueHaibing
ixgbe_dbg_reg_ops_read and ixgbe_dbg_netdev_ops_read copy-pasting
the same code except for ixgbe_dbg_netdev_ops_buf/ixgbe_dbg_reg_ops_buf,
so introduce a helper ixgbe_dbg_common_ops_read to remove redundant code.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 57 +---
 1 file changed, 21 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
index 55fe811..50dfb02 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -10,15 +10,9 @@ static struct dentry *ixgbe_dbg_root;
 
 static char ixgbe_dbg_reg_ops_buf[256] = "";
 
-/**
- * ixgbe_dbg_reg_ops_read - read for reg_ops datum
- * @filp: the opened file
- * @buffer: where to write the data for the user to read
- * @count: the size of the user's buffer
- * @ppos: file position offset
- **/
-static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char __user *buffer,
-   size_t count, loff_t *ppos)
+static ssize_t ixgbe_dbg_common_ops_read(struct file *filp, char __user 
*buffer,
+size_t count, loff_t *ppos,
+char *dbg_buf)
 {
struct ixgbe_adapter *adapter = filp->private_data;
char *buf;
@@ -29,8 +23,7 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char 
__user *buffer,
return 0;
 
buf = kasprintf(GFP_KERNEL, "%s: %s\n",
-   adapter->netdev->name,
-   ixgbe_dbg_reg_ops_buf);
+   adapter->netdev->name, dbg_buf);
if (!buf)
return -ENOMEM;
 
@@ -46,6 +39,20 @@ static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, 
char __user *buffer,
 }
 
 /**
+ * ixgbe_dbg_reg_ops_read - read for reg_ops datum
+ * @filp: the opened file
+ * @buffer: where to write the data for the user to read
+ * @count: the size of the user's buffer
+ * @ppos: file position offset
+ **/
+static ssize_t ixgbe_dbg_reg_ops_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+   return ixgbe_dbg_common_ops_read(filp, buffer, count, ppos,
+ixgbe_dbg_reg_ops_buf);
+}
+
+/**
  * ixgbe_dbg_reg_ops_write - write into reg_ops datum
  * @filp: the opened file
  * @buffer: where to find the user's data
@@ -121,33 +128,11 @@ static char ixgbe_dbg_netdev_ops_buf[256] = "";
  * @count: the size of the user's buffer
  * @ppos: file position offset
  **/
-static ssize_t ixgbe_dbg_netdev_ops_read(struct file *filp,
-char __user *buffer,
+static ssize_t ixgbe_dbg_netdev_ops_read(struct file *filp, char __user 
*buffer,
 size_t count, loff_t *ppos)
 {
-   struct ixgbe_adapter *adapter = filp->private_data;
-   char *buf;
-   int len;
-
-   /* don't allow partial reads */
-   if (*ppos != 0)
-   return 0;
-
-   buf = kasprintf(GFP_KERNEL, "%s: %s\n",
-   adapter->netdev->name,
-   ixgbe_dbg_netdev_ops_buf);
-   if (!buf)
-   return -ENOMEM;
-
-   if (count < strlen(buf)) {
-   kfree(buf);
-   return -ENOSPC;
-   }
-
-   len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-
-   kfree(buf);
-   return len;
+   return ixgbe_dbg_common_ops_read(filp, buffer, count, ppos,
+ixgbe_dbg_netdev_ops_buf);
 }
 
 /**
-- 
2.7.0




[PATCH] atmel: Add missing call to pci_disable_device()

2018-05-23 Thread YueHaibing
add pci_disable_device in error handling while init_atmel_card failed.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/wireless/atmel/atmel_pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/atmel/atmel_pci.c 
b/drivers/net/wireless/atmel/atmel_pci.c
index bcf1f27..30df58a 100644
--- a/drivers/net/wireless/atmel/atmel_pci.c
+++ b/drivers/net/wireless/atmel/atmel_pci.c
@@ -61,8 +61,10 @@ static int atmel_pci_probe(struct pci_dev *pdev,
dev = init_atmel_card(pdev->irq, pdev->resource[1].start,
  ATMEL_FW_TYPE_506,
  >dev, NULL, NULL);
-   if (!dev)
+   if (!dev) {
+   pci_disable_device(pdev);
return -ENODEV;
+   }
 
pci_set_drvdata(pdev, dev);
return 0;
-- 
2.7.0




[PATCH] netfilter: uapi: includes linux/types.h

2018-05-23 Thread YueHaibing
gcc-7.3.0 report following warning:
./usr/include/linux/netfilter/nf_osf.h:27: found __[us]{8,16,32,64} type 
without #include 

includes linux/types.h to fix it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 include/uapi/linux/netfilter/nf_osf.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/netfilter/nf_osf.h 
b/include/uapi/linux/netfilter/nf_osf.h
index 45376ea..d1dbe00 100644
--- a/include/uapi/linux/netfilter/nf_osf.h
+++ b/include/uapi/linux/netfilter/nf_osf.h
@@ -1,6 +1,8 @@
 #ifndef _NF_OSF_H
 #define _NF_OSF_H
 
+#include 
+
 #define MAXGENRELEN32
 
 #define NF_OSF_GENRE   (1 << 0)
-- 
2.7.0




[PATCH net-next] cxgb4: Check for kvzalloc allocation failure

2018-05-22 Thread YueHaibing
t4_prep_fw doesn't check for card_fw pointer before store the read data,
which could lead to a NULL pointer dereference if kvzalloc failed.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 130d1ee..019cffe 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4135,6 +4135,10 @@ static int adap_init0(struct adapter *adap)
 * card
 */
card_fw = kvzalloc(sizeof(*card_fw), GFP_KERNEL);
+   if (!card_fw) {
+   ret = -ENOMEM;
+   goto bye;
+   }
 
/* Get FW from from /lib/firmware/ */
ret = request_firmware(, fw_info->fw_mod_name,
-- 
2.7.0




Re: [PATCH] bpf: check NULL for sk_to_full_sk()

2018-05-21 Thread YueHaibing
On 2018/5/21 23:17, Eric Dumazet wrote:
> 
> 
> On 05/21/2018 12:55 AM, YueHaibing wrote:
>> like commit df39a9f106d5 ("bpf: check NULL for sk_to_full_sk() return 
>> value"),
>> we should check sk_to_full_sk return value against NULL.
>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
>> ---
>>  include/linux/bpf-cgroup.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
>> index 30d15e6..fd3fbeb 100644
>> --- a/include/linux/bpf-cgroup.h
>> +++ b/include/linux/bpf-cgroup.h
>> @@ -91,7 +91,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 
>> major, u32 minor,
>>  int __ret = 0; \
>>  if (cgroup_bpf_enabled && sk && sk == skb->sk) {   \
>>  typeof(sk) __sk = sk_to_full_sk(sk);   \
>> -if (sk_fullsock(__sk)) \
>> +if (__sk && sk_fullsock(__sk)) \
>>  __ret = __cgroup_bpf_run_filter_skb(__sk, skb, \
>>BPF_CGROUP_INET_EGRESS); \
>>  }  \
>>
> 
> Why is this needed ???

BPF_CGROUP_RUN_PROG_INET_EGRESS is called in ip_output

I just misunderstood, sorry for noise.
> 
> 



[PATCH] bpf: check NULL for sk_to_full_sk()

2018-05-21 Thread YueHaibing
like commit df39a9f106d5 ("bpf: check NULL for sk_to_full_sk() return value"),
we should check sk_to_full_sk return value against NULL.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 include/linux/bpf-cgroup.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index 30d15e6..fd3fbeb 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -91,7 +91,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 
major, u32 minor,
int __ret = 0; \
if (cgroup_bpf_enabled && sk && sk == skb->sk) {   \
typeof(sk) __sk = sk_to_full_sk(sk);   \
-   if (sk_fullsock(__sk)) \
+   if (__sk && sk_fullsock(__sk)) \
__ret = __cgroup_bpf_run_filter_skb(__sk, skb, \
  BPF_CGROUP_INET_EGRESS); \
}  \
-- 
2.7.0




[PATCH net-next] vmxnet3: Replace msleep(1) with usleep_range()

2018-05-16 Thread YueHaibing
As documented in Documentation/timers/timers-howto.txt,
replace msleep(1) with usleep_range().

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 6 +++---
 drivers/net/vmxnet3/vmxnet3_ethtool.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c 
b/drivers/net/vmxnet3/vmxnet3_drv.c
index 9ebe2a6..2234a33 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2945,7 +2945,7 @@ vmxnet3_close(struct net_device *netdev)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
vmxnet3_quiesce_dev(adapter);
 
@@ -2995,7 +2995,7 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (netif_running(netdev)) {
vmxnet3_quiesce_dev(adapter);
@@ -3567,7 +3567,7 @@ static void vmxnet3_shutdown_device(struct pci_dev *pdev)
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED,
 >state)) {
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c 
b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 2ff2731..559db05 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -600,7 +600,7 @@ vmxnet3_set_ringparam(struct net_device *netdev,
 * completion.
 */
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, >state))
-   msleep(1);
+   usleep_range(1000, 2000);
 
if (netif_running(netdev)) {
vmxnet3_quiesce_dev(adapter);
-- 
2.7.0




Re: [PATCH net-next] ath10k: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
On 2018/5/16 19:42, Kalle Valo wrote:
> YueHaibing <yuehaib...@huawei.com> writes:
> 
>> clk_disable_unprepare() already checks that the clock pointer is valid.
>> No need to test it before calling it.
>>
>> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
> 
> Just a note that ath10k patches are applied to my ath.git tree, not to
> net-next. So adding net-next to the subject is wrong, but no need to
> resend just because of that.
> 

OK, got it, thank you




[PATCH net-next] net: ethoc: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/ethoc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 8bb0db9..00a5727 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -1246,8 +1246,7 @@ static int ethoc_probe(struct platform_device *pdev)
mdiobus_unregister(priv->mdio);
mdiobus_free(priv->mdio);
 free2:
-   if (priv->clk)
-   clk_disable_unprepare(priv->clk);
+   clk_disable_unprepare(priv->clk);
 free:
free_netdev(netdev);
 out:
@@ -1271,8 +1270,7 @@ static int ethoc_remove(struct platform_device *pdev)
mdiobus_unregister(priv->mdio);
mdiobus_free(priv->mdio);
}
-   if (priv->clk)
-   clk_disable_unprepare(priv->clk);
+   clk_disable_unprepare(priv->clk);
unregister_netdev(netdev);
free_netdev(netdev);
}
-- 
2.7.0




[PATCH net-next] net: stmmac: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 13133b3..f08625a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1104,30 +1104,20 @@ static int gmac_clk_enable(struct rk_priv_data 
*bsp_priv, bool enable)
} else {
if (bsp_priv->clk_enabled) {
if (phy_iface == PHY_INTERFACE_MODE_RMII) {
-   if (!IS_ERR(bsp_priv->mac_clk_rx))
-   clk_disable_unprepare(
-   bsp_priv->mac_clk_rx);
+   clk_disable_unprepare(bsp_priv->mac_clk_rx);
 
-   if (!IS_ERR(bsp_priv->clk_mac_ref))
-   clk_disable_unprepare(
-   bsp_priv->clk_mac_ref);
+   clk_disable_unprepare(bsp_priv->clk_mac_ref);
 
-   if (!IS_ERR(bsp_priv->clk_mac_refout))
-   clk_disable_unprepare(
-   bsp_priv->clk_mac_refout);
+   clk_disable_unprepare(bsp_priv->clk_mac_refout);
}
 
-   if (!IS_ERR(bsp_priv->clk_phy))
-   clk_disable_unprepare(bsp_priv->clk_phy);
+   clk_disable_unprepare(bsp_priv->clk_phy);
 
-   if (!IS_ERR(bsp_priv->aclk_mac))
-   clk_disable_unprepare(bsp_priv->aclk_mac);
+   clk_disable_unprepare(bsp_priv->aclk_mac);
 
-   if (!IS_ERR(bsp_priv->pclk_mac))
-   clk_disable_unprepare(bsp_priv->pclk_mac);
+   clk_disable_unprepare(bsp_priv->pclk_mac);
 
-   if (!IS_ERR(bsp_priv->mac_clk_tx))
-   clk_disable_unprepare(bsp_priv->mac_clk_tx);
+   clk_disable_unprepare(bsp_priv->mac_clk_tx);
/**
 * if (!IS_ERR(bsp_priv->clk_mac))
 *  clk_disable_unprepare(bsp_priv->clk_mac);
-- 
2.7.0




[PATCH net-next] ath10k: Remove useless test before clk_disable_unprepare

2018-05-16 Thread YueHaibing
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/wireless/ath/ath10k/ahb.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ahb.c 
b/drivers/net/wireless/ath/ath10k/ahb.c
index 35d1049..fa39fff 100644
--- a/drivers/net/wireless/ath/ath10k/ahb.c
+++ b/drivers/net/wireless/ath/ath10k/ahb.c
@@ -180,14 +180,11 @@ static void ath10k_ahb_clock_disable(struct ath10k *ar)
 {
struct ath10k_ahb *ar_ahb = ath10k_ahb_priv(ar);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->cmd_clk))
-   clk_disable_unprepare(ar_ahb->cmd_clk);
+   clk_disable_unprepare(ar_ahb->cmd_clk);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->ref_clk))
-   clk_disable_unprepare(ar_ahb->ref_clk);
+   clk_disable_unprepare(ar_ahb->ref_clk);
 
-   if (!IS_ERR_OR_NULL(ar_ahb->rtc_clk))
-   clk_disable_unprepare(ar_ahb->rtc_clk);
+   clk_disable_unprepare(ar_ahb->rtc_clk);
 }
 
 static int ath10k_ahb_rst_ctrl_init(struct ath10k *ar)
-- 
2.7.0




[PATCH bpf] tools: bpf: fix NULL return handling in bpf__prepare_load

2018-05-11 Thread YueHaibing
bpf_object__open()/bpf_object__open_buffer can return error pointer or NULL,
check the return values with IS_ERR_OR_NULL() in bpf__prepare_load and
bpf__prepare_load_buffer

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 tools/perf/util/bpf-loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index af7ad81..cee6587 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -66,7 +66,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, 
const char *name)
}
 
obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, name);
-   if (IS_ERR(obj)) {
+   if (IS_ERR_OR_NULL(obj)) {
pr_debug("bpf: failed to load buffer\n");
return ERR_PTR(-EINVAL);
}
@@ -102,14 +102,14 @@ struct bpf_object *bpf__prepare_load(const char 
*filename, bool source)
pr_debug("bpf: successfull builtin compilation\n");
obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, filename);
 
-   if (!IS_ERR(obj) && llvm_param.dump_obj)
+   if (!IS_ERR_OR_NULL(obj) && llvm_param.dump_obj)
llvm__dump_obj(filename, obj_buf, obj_buf_sz);
 
free(obj_buf);
} else
obj = bpf_object__open(filename);
 
-   if (IS_ERR(obj)) {
+   if (IS_ERR_OR_NULL(obj)) {
pr_debug("bpf: failed to load %s\n", filename);
return obj;
}
-- 
2.7.0




[PATCH net-next] can: dev: use skb_put_zero to simplfy code

2018-04-28 Thread YueHaibing
use helper skb_put_zero to replace the pattern of skb_put() && memset()

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/can/dev.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index b177956..d8140a9 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -649,8 +649,7 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, 
struct can_frame **cf)
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;
 
-   *cf = skb_put(skb, sizeof(struct can_frame));
-   memset(*cf, 0, sizeof(struct can_frame));
+   *cf = skb_put_zero(skb, sizeof(struct can_frame));
 
return skb;
 }
@@ -678,8 +677,7 @@ struct sk_buff *alloc_canfd_skb(struct net_device *dev,
can_skb_prv(skb)->ifindex = dev->ifindex;
can_skb_prv(skb)->skbcnt = 0;
 
-   *cfd = skb_put(skb, sizeof(struct canfd_frame));
-   memset(*cfd, 0, sizeof(struct canfd_frame));
+   *cfd = skb_put_zero(skb, sizeof(struct canfd_frame));
 
return skb;
 }
-- 
2.7.0




[PATCH net-next] libcxgb,cxgb4: use __skb_put_zero to simplfy code

2018-04-27 Thread YueHaibing
use helper __skb_put_zero to replace the pattern of __skb_put() && memset()

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c |  3 +--
 drivers/net/ethernet/chelsio/cxgb4/srq.c  |  3 +--
 drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h | 15 +--
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index db92f18..aae9802 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -64,8 +64,7 @@ static int set_tcb_field(struct adapter *adap, struct 
filter_entry *f,
if (!skb)
return -ENOMEM;
 
-   req = (struct cpl_set_tcb_field *)__skb_put(skb, sizeof(*req));
-   memset(req, 0, sizeof(*req));
+   req = (struct cpl_set_tcb_field *)__skb_put_zero(skb, sizeof(*req));
INIT_TP_WR_CPL(req, CPL_SET_TCB_FIELD, ftid);
req->reply_ctrl = htons(REPLY_CHAN_V(0) |
QUEUENO_V(adap->sge.fw_evtq.abs_id) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/srq.c 
b/drivers/net/ethernet/chelsio/cxgb4/srq.c
index 6228a57..82b70a5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/srq.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/srq.c
@@ -84,8 +84,7 @@ int cxgb4_get_srq_entry(struct net_device *dev,
if (!skb)
return -ENOMEM;
req = (struct cpl_srq_table_req *)
-   __skb_put(skb, sizeof(*req));
-   memset(req, 0, sizeof(*req));
+   __skb_put_zero(skb, sizeof(*req));
INIT_TP_WR(req, 0);
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SRQ_TABLE_REQ,
  TID_TID_V(srq_idx) |
diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h 
b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
index 4b5aacc..240ba9d 100644
--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_cm.h
@@ -90,8 +90,7 @@ cxgb_mk_tid_release(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan)
 {
struct cpl_tid_release *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
@@ -104,8 +103,7 @@ cxgb_mk_close_con_req(struct sk_buff *skb, u32 len, u32 
tid, u16 chan,
 {
struct cpl_close_con_req *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, tid));
@@ -119,8 +117,7 @@ cxgb_mk_abort_req(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan,
 {
struct cpl_abort_req *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_REQ, tid));
@@ -134,8 +131,7 @@ cxgb_mk_abort_rpl(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan)
 {
struct cpl_abort_rpl *rpl;
 
-   rpl = __skb_put(skb, len);
-   memset(rpl, 0, len);
+   rpl = __skb_put_zero(skb, len);
 
INIT_TP_WR(rpl, tid);
OPCODE_TID(rpl) = cpu_to_be32(MK_OPCODE_TID(CPL_ABORT_RPL, tid));
@@ -149,8 +145,7 @@ cxgb_mk_rx_data_ack(struct sk_buff *skb, u32 len, u32 tid, 
u16 chan,
 {
struct cpl_rx_data_ack *req;
 
-   req = __skb_put(skb, len);
-   memset(req, 0, len);
+   req = __skb_put_zero(skb, len);
 
INIT_TP_WR(req, tid);
OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_RX_DATA_ACK, tid));
-- 
2.7.0




[PATCH] ptp_pch: use helpers function for converting between ns and timespec

2018-04-27 Thread YueHaibing
use ns_to_timespec64() and timespec64_to_ns() instead of open coding

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/ptp/ptp_pch.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
index b328517..78ccf93 100644
--- a/drivers/ptp/ptp_pch.c
+++ b/drivers/ptp/ptp_pch.c
@@ -452,7 +452,6 @@ static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 
delta)
 static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
u64 ns;
-   u32 remainder;
unsigned long flags;
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
@@ -461,8 +460,7 @@ static int ptp_pch_gettime(struct ptp_clock_info *ptp, 
struct timespec64 *ts)
ns = pch_systime_read(regs);
spin_unlock_irqrestore(_dev->register_lock, flags);
 
-   ts->tv_sec = div_u64_rem(ns, 10, );
-   ts->tv_nsec = remainder;
+   *ts = ns_to_timespec64(ns);
return 0;
 }
 
@@ -474,8 +472,7 @@ static int ptp_pch_settime(struct ptp_clock_info *ptp,
struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
struct pch_ts_regs __iomem *regs = pch_dev->regs;
 
-   ns = ts->tv_sec * 10ULL;
-   ns += ts->tv_nsec;
+   ns = timespec64_to_ns(ts);
 
spin_lock_irqsave(_dev->register_lock, flags);
pch_systime_write(regs, ns);
-- 
2.7.0




Re: [PATCH] mac80211_hwsim: fix a possible memory leak in hwsim_new_radio_nl()

2018-04-27 Thread YueHaibing

cc  Ben Hutchings <ben.hutchi...@codethink.co.uk>

On 2018/4/24 11:08, YueHaibing wrote:
> 'hwname' should be freed before leaving from the error handling cases,
> otherwise it will cause mem leak
> 
> Fixes: cb1a5bae5684 ("mac80211_hwsim: add permanent mac address option for 
> new radios")
> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
> ---
>  drivers/net/wireless/mac80211_hwsim.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/wireless/mac80211_hwsim.c 
> b/drivers/net/wireless/mac80211_hwsim.c
> index 96d26cf..4a017a0 100644
> --- a/drivers/net/wireless/mac80211_hwsim.c
> +++ b/drivers/net/wireless/mac80211_hwsim.c
> @@ -3236,6 +3236,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, 
> struct genl_info *info)
>   GENL_SET_ERR_MSG(info,"MAC is no valid source addr");
>   NL_SET_BAD_ATTR(info->extack,
>   info->attrs[HWSIM_ATTR_PERM_ADDR]);
> + kfree(hwname);
>   return -EINVAL;
>   }
>  
> 



[PATCH net-next] bridge: use hlist_entry_safe

2018-04-25 Thread YueHaibing
Use hlist_entry_safe() instead of open-coding it.

Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 net/bridge/br_forward.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index b4eed11..7a7fd67 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -274,8 +274,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
struct net_bridge_port *port, *lport, *rport;
 
lport = p ? p->port : NULL;
-   rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) :
-NULL;
+   rport = hlist_entry_safe(rp, struct net_bridge_port, rlist);
 
if ((unsigned long)lport > (unsigned long)rport) {
port = lport;
-- 
2.7.0




[PATCH] mac80211_hwsim: fix a possible memory leak in hwsim_new_radio_nl()

2018-04-23 Thread YueHaibing
'hwname' should be freed before leaving from the error handling cases,
otherwise it will cause mem leak

Fixes: cb1a5bae5684 ("mac80211_hwsim: add permanent mac address option for new 
radios")
Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/wireless/mac80211_hwsim.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mac80211_hwsim.c 
b/drivers/net/wireless/mac80211_hwsim.c
index 96d26cf..4a017a0 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3236,6 +3236,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct 
genl_info *info)
GENL_SET_ERR_MSG(info,"MAC is no valid source addr");
NL_SET_BAD_ATTR(info->extack,
info->attrs[HWSIM_ATTR_PERM_ADDR]);
+   kfree(hwname);
return -EINVAL;
}
 
-- 
2.7.0




[PATCH net] tg3: don't clear stats while tg3_close

2017-05-03 Thread YueHaibing
Now tg3 NIC's stats will be cleared after ifdown/ifup. bond_get_stats traverse
its salves to get statistics,cumulative the increment.If a tg3 NIC is added to
bonding as a slave,ifdown/ifup will cause bonding's stats become tremendous 
value
(ex.1638.3 PiB) because of negative increment.

Fixes: 92feeabf3f67 ("tg3: Save stats across chip resets")
Signed-off-by: YueHaibing <yuehaib...@huawei.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c 
b/drivers/net/ethernet/broadcom/tg3.c
index 30d1eb9..29beba1 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -11722,10 +11722,6 @@ static int tg3_close(struct net_device *dev)
 
tg3_stop(tp);
 
-   /* Clear stats across close / open calls */
-   memset(>net_stats_prev, 0, sizeof(tp->net_stats_prev));
-   memset(>estats_prev, 0, sizeof(tp->estats_prev));
-
if (pci_device_is_present(tp->pdev)) {
tg3_power_down_prepare(tp);
 
-- 
2.5.0




Re: [PATCH RFC net-next 2/7] net: add dst_pending_confirm flag to skbuff

2017-01-19 Thread YueHaibing

On 2016/12/20 4:37, Julian Anastasov wrote:
> 
>   Hello,
> 
> On Mon, 19 Dec 2016, Eric Dumazet wrote:
> 
>> I am still digesting this awesome patch series ;)
> 
>   Thanks. I don't feel quite comfortable with some
> of the changes (mostly XFRM, dst_confirm usage in CXGB) and
> I hope the discussion can provide adequate solution.
> 
>> Not sure why you used an unlikely() here. TCP for example would hit this
>> path quite often.
> 
>   I was not sure, may be because ACKs can come with lower
> rate than the sent packets. Also because non-TCP rarely uses
> MSG_CONFIRM. If you still think it is better without unlikely,
> I'll remove it.
> 
>> So considering sk_dst_pending_confirm might be dirtied quite often,further 
>>
>> I am not sure why you placed it in the cache line that contains
>> sk_rx_dst (in 1st patch)
> 
>   I saw your recent changes and was worried if the
> sk_dst_confirm() calling on RX can cause unwanted dirtying of
> additional cache line. My preliminary analyze pointed
> sk_omem_alloc as good candidate for moving to next cache
> line. I know how critical is to properly place the new flags,
> so I really need recommendations about this.
> 
> Regards
> 
> --
> Julian Anastasov 
> 
> .
> 

Sorry for so late reply.
I have test your new patch, It works well in my scene.

Everybody,Is there any further comment about this awesome patch series?




Re: net/arp: ARP cache aging failed.

2016-12-14 Thread YueHaibing

On 2016/12/15 4:15, Julian Anastasov wrote:
> 
>   Hello,
> 
> On Wed, 14 Dec 2016, YueHaibing wrote:
> 
>> On 2016/11/26 4:40, Julian Anastasov wrote:
>>>
>>> So, the idea is to move TCP and other similar
>>> users to the new dst_confirm_sk() method. If other
>>> dst_confirm() users are left, they should be checked
>>> if dsts with rt_gateway = 0 can be wrongly used.
>>
>> Sorry for so late.
> 
>   In fact, I'm late too because I almost finished
> my changes, the only remaining part is the cxgb files...
> 
>> Based on your ideas, I make a patch and test it for a while.
> 
>   The problem is that it is valid only for TCP.
> Also, this flag should be reset sometimes, eg. when sk dst
> changes...
> 
>> It works for me.
>>
>> @@ -847,7 +847,7 @@ static int ping_v4_sendmsg(struct sock *sk, struct 
>> msghdr *msg, size_t len)
>>  return err;
>>
>>  do_confirm:
>> -dst_confirm(>dst);
>> +dst_confirm_sk(sk);
> 
>   MSG_CONFIRM from sendmsg needs special treatment. The
> problem is that UDP sending does not lock the socket, so I also
> added a skb flag to handle this situation in ip*_append_data.
> We do not want threaded application firing at different
> destinations to confirm the wrong neighbour. MSG_PROBE is
> another issue, the XFRM dst chaining, etc...
> 
>   I hope, I'll be ready this weekend with few patches
> that change all dst_confirm users... There I'll explain
> everything in detail.
> 
> Regards
> 
> --
> Julian Anastasov <j...@ssi.bg>
> 
> .
> 

Great, I'll be glad to do a testing.



Re: net/arp: ARP cache aging failed.

2016-12-14 Thread YueHaibing
On 2016/11/26 4:40, Julian Anastasov wrote:
> 
>   Hello,
> 
> On Fri, 25 Nov 2016, Hannes Frederic Sowa wrote:
> 
>> On 25.11.2016 09:18, Julian Anastasov wrote:
>>>
>>> Another option would be to add similar bit to
>>> struct sock (sk_dst_pending_confirm), may be ip_finish_output2
>>> can propagate it to dst_neigh_output via new arg and then to
>>> reset it.
>>
>> I don't understand how this can help? Maybe I understood it wrong?
> 
>   The idea is, the indication from highest level (TCP) to
> be propagated to lowest level (neigh).
> 
>>> Or to change n->confirmed via some new inline sock
>>> function instead of changing dst_neigh_output. At this place 
>>> skb->sk is optional, may be we need (skb->sk && dst ==
>>> skb->sk->sk_dst_cache) check. Also, when sk_dst_cache changes
>>> we should clear this flag.
>>
>> In "(skb->sk && dst == skb->sk->sk_dst_cache)" where does dst come from?
> 
>   This is in case we do not want to propagate indication
> from TCP to tunnels, see below...
> 
>> I don't see a possibility besides using mac_header or inner_mac_header
>> to look up the incoming MAC address and confirm that one in the neighbor
>> cache so far (we could try to optimize this case for rt_gateway though).
> 
>   My idea is as follows:
> 
> - TCP instead of calling dst_confirm should call new func
> dst_confirm_sk(sk) where sk->sk_dst_pending_confirm is set,
> not dst->pending_confirm.
> 
> - ip_finish_output2: use skb->sk (TCP) to check for
> sk_dst_pending_confirm and update n->confirmed in some
> new inline func
> 
>   Correct me if I'm wrong but here is how I see the
> situation:
> 
> - TCP caches output dst in socket, for example, dst1,
> sets it as skb->dst
> 
> - if xfrm tunnels are used then dst1 can point to some tunnel,
> i.e. it is not in all cases the same skb->dst, as seen by 
> ip_finish_output2
> 
> - netfilter can DNAT and assign different skb->dst
> 
> - as result, before now, dst1->pending_confirm is set but
> it is not used properly because ip_finish_output2 uses
> the final skb->dst which can be different or with
> rt_gateway = 0
> 
> - considering that tunnels do not use dst_confirm,
> n->confirmed is not changed every time. There are some
> interesting cases:
> 
> 1. both dst1 and the final skb->dst point to same
> dst with rt_gateway = 0: n->confirmed is updated but
> as wee see it can be for wrong neigh.
> 
> 2. dst1 is different from skb->dst, so n->confirmed is
> not changed. This can happen on DNAT or when using
> tunnel to secure gateway.
> 
> - in ip_finish_output2 we have skb->sk (original TCP sk) and
> sk arg (equal to skb->sk or second option is sock of some UDP
> tunnel, etc). The idea is to use skb->sk->sk_dst_pending_confirm,
> i.e. highest level sk because the sk arg, if different, does not
> have such flag set (tunnels do not call dst_confirm).
> 
> - ip_finish_output2 should call new func dst_neigh_confirm_sk
> (which has nothing related to dst, hm... better name is needed):
> 
>   if (!IS_ERR(neigh)) {
> - int res = dst_neigh_output(dst, neigh, skb);
> + int res;
> +
> + dst_neigh_confirm_sk(skb->sk, neigh);
> + res = dst_neigh_output(dst, neigh, skb);
> 
>   which should do something like this:
> 
>   if (sk && sk->sk_dst_pending_confirm) {
>   unsigned long now = jiffies;
> 
>   sk->sk_dst_pending_confirm = 0;
>   /* avoid dirtying neighbour */
>   if (n->confirmed != now)
>   n->confirmed = now;
>   }
> 
>   Additional dst == skb->sk->sk_dst_cache check will
> not propagate the indication on DNAT/tunnel. For me,
> it is better without such check.
> 
>   So, the idea is to move TCP and other similar
> users to the new dst_confirm_sk() method. If other
> dst_confirm() users are left, they should be checked
> if dsts with rt_gateway = 0 can be wrongly used.
> 
> Regards
> 
> --
> Julian Anastasov 
> 
> .
> 

Sorry for so late.

Based on your ideas, I make a patch and test it for a while.

It works for me.

>From dc033fe4bac8931590e15774a298f04ccea8ed4c Mon Sep 17 00:00:00 2001
From: YueHabing 
Date: Wed, 14 Dec 2016 02:43:51 -0500
Subject: [PATCH] arp: do neigh confirm based on sk arg

Signed-off-by: YueHabing 
---
 include/net/sock.h | 18 ++
 net/ipv4/ip_output.c   |  5 -
 net/ipv4/ping.c|  2 +-
 net/ipv4/raw.c |  2 +-
 net/ipv4/tcp_input.c   |  8 ++--
 net/ipv4/tcp_metrics.c |  5 +++--
 net/ipv4/udp.c |  2 +-
 net/ipv6/raw.c |  2 +-
 net/ipv6/route.c   |  6 +++---
 net/ipv6/udp.c |  2 +-
 10 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 92b2697..ece8dfa 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -434,6 +434,7 @@ struct sock {
struct sk_buff  *sk_send_head;
__s32 

Re: net/arp: ARP cache aging failed.

2016-11-24 Thread YueHaibing
On 2016/11/24 15:51, Julian Anastasov wrote:
> 
>   Hello,
> 
> On Wed, 23 Nov 2016, Eric Dumazet wrote:
> 
>> On Wed, 2016-11-23 at 15:37 +0100, Hannes Frederic Sowa wrote:
>>
>>> Irregardless about the question if bonding should keep the MAC address
>>> alive, a MAC address can certainly change below a TCP connection.
>>
>> Of course ;)
>>

I configured bonding fail_over_mac=1 ,so the bonding MAC always be the MAC
address of the currently active slave.

>>>
>>> dst_entry is 1:n to neigh_entry and as such we can end up confirming an
>>> aging neighbor while sending a reply with dst->pending_confirm set while
>>> the confirming packet actually came from a different neighbor.
>>>
>>> I agree with Julian, pending_confirm became useless in this way.
>>
>> Let's kill it then ;)
> 
>   It works for traffic via gateway. I now see that
> we can even avoid write in dst_confirm:
> 
>   if (!dst->pending_confirm)
>   dst->pending_confirm = 1;
> 
>   because it is called by non-dup TCP ACKs.
> 
>   But for traffic to hosts on LAN we need different solution,
> i.e. for cached dsts with rt_gateway = 0 (last entry below).
> 
> rt_uses_gateway rt_gateway DST_NOCACHE Description
> 
> 1   nh_gw  ANY Traffic via gateway
> 0   LAN_host   1   FLOWI_FLAG_KNOWN_NH (nexthop
>set by IPVS, hdrincl, xt_TEE)
> 0   0  0   1 dst for many subnet hosts
> 
> Regards
> 
> --
> Julian Anastasov 
> 
> .
> 

As above,Is there a plan to fix the problem ? Should we just not call 
dst_confirm
when in the case rt->rt_uses_gateway/DST_NOCACHE?



net/arp: ARP cache aging failed.

2016-11-22 Thread yuehaibing

 Hi,

I've encountered a arp cache aging failed bug in 4.9 kernel.The topo is 
as follow:


HOST1     -
  IP1 | Switch |IP2-| HOST2 |
 |    -
  --Bonging  |
   |   | IP3
 MAC1MAC2  | HOST3 |


HOST1 have a bonding interface which including two NICs

IP1:192.168.1.100/24
IP2:192.168.1.200/24
IP2:192.168.1.300/24

There are large numbers of TCP transaction between HOST2 and HOST3.


The Host2 can ping HOST1 normally.However,It cannot ping after HOST1 
bonding interface deactived a working NIC.


on HOST2 ,use fowllow command:

watch "ip -s neigh show|grep 192.168.1.100"

I noticed the old HOST1 arp cache aging counter is gradually  increased 
,then reset before it reached 30.This process is repeated,
thus the arp cache holding REACHABLE status.The new HOST1 MAC arp cache cannot 
been renewed ,and thus ping cannot sendto the correct HOST1 MAC.

Then I found n->confirmed is freshed  in dst_neigh_output while 
dst->pending_confirm is set to 1.

include/net/dst.h

static inline void dst_confirm(struct dst_entry *dst)
{
dst->pending_confirm = 1;
}

static inline int dst_neigh_output(struct dst_entry *dst, struct neighbour *n,
   struct sk_buff *skb)
{
const struct hh_cache *hh;

if (dst->pending_confirm) {
unsigned long now = jiffies;

dst->pending_confirm = 0;
/* avoid dirtying neighbour */
if (n->confirmed != now)
n->confirmed = now;
}
...
}

dst_confirm can be called by tcp_ack in net/ipv4/tcp_input.c.

/* This routine deals with incoming acks, but not outgoing ones. */
static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
{
.
if ((flag & FLAG_FORWARD_PROGRESS) || !(flag & FLAG_NOT_DUP)) {
struct dst_entry *dst = __sk_dst_get(sk);
if (dst)
dst_confirm(dst);
}
.
}

As to my topo,HOST1 and HOST3 share one route on HOST2, tcp connection 
between HOST2 and HOST3 may call tcp_ack to set dst->pending_confirm.

So dst_neigh_output may wrongly freshed  n->confirmed which stands for 
HOST1,however HOST1'MAC had been changed.

The possibility of this occurred Significantly increases ,when ping and 
TCP transaction are set the same processor affinity on the HOST2.

It seems that the issue is brought in commit 
5110effee8fde2edfacac9cd12a9960ab2dc39ea ("net: Do delayed neigh 
confirmation.").







Hello

2016-10-14 Thread yuehaibing
subscribe linux-kernel