Re: [PATCH net v2] openvswitch: Fix egress tunnel info.

2015-10-22 Thread kbuild test robot
Hi Pravin,

[auto build test WARNING on net/master -- if it's inappropriate base, please 
suggest rules for selecting the more suitable base]

url:
https://github.com/0day-ci/linux/commits/Pravin-B-Shelar/openvswitch-Fix-egress-tunnel-info/20151023-053247
config: x86_64-randconfig-x010-10211707 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   net/openvswitch/actions.c: In function 'output_userspace':
>> net/openvswitch/actions.c:771:24: warning: unused variable 'info' 
>> [-Wunused-variable]
 struct ip_tunnel_info info;
   ^

vim +/info +771 net/openvswitch/actions.c

7f8a436e Joe Stringer 2015-08-26  755   
ethertype = vlan_get_protocol(skb);
7f8a436e Joe Stringer 2015-08-26  756   }
7f8a436e Joe Stringer 2015-08-26  757  
7f8a436e Joe Stringer 2015-08-26  758   ovs_fragment(vport, 
skb, mru, ethertype);
7f8a436e Joe Stringer 2015-08-26  759   } else {
7f8a436e Joe Stringer 2015-08-26  760   kfree_skb(skb);
7f8a436e Joe Stringer 2015-08-26  761   }
7f8a436e Joe Stringer 2015-08-26  762   } else {
738967b8 Andy Zhou2014-09-08  763   kfree_skb(skb);
ccb1352e Jesse Gross  2011-10-25  764   }
7f8a436e Joe Stringer 2015-08-26  765  }
ccb1352e Jesse Gross  2011-10-25  766  
ccb1352e Jesse Gross  2011-10-25  767  static int output_userspace(struct 
datapath *dp, struct sk_buff *skb,
ccea7445 Neil McKee   2015-05-26  768   struct sw_flow_key 
*key, const struct nlattr *attr,
ccea7445 Neil McKee   2015-05-26  769   const struct nlattr 
*actions, int actions_len)
ccb1352e Jesse Gross  2011-10-25  770  {
1d8fff90 Thomas Graf  2015-07-21 @771   struct ip_tunnel_info info;
ccb1352e Jesse Gross  2011-10-25  772   struct dp_upcall_info upcall;
ccb1352e Jesse Gross  2011-10-25  773   const struct nlattr *a;
ccb1352e Jesse Gross  2011-10-25  774   int rem;
ccb1352e Jesse Gross  2011-10-25  775  
ccea7445 Neil McKee   2015-05-26  776   memset(, 0, sizeof(upcall));
ccb1352e Jesse Gross  2011-10-25  777   upcall.cmd = OVS_PACKET_CMD_ACTION;
7f8a436e Joe Stringer 2015-08-26  778   upcall.mru = OVS_CB(skb)->mru;
ccb1352e Jesse Gross  2011-10-25  779  

:: The code at line 771 was first introduced by commit
:: 1d8fff907342d2339796dbd27ea47d0e76a6a2d0 ip_tunnel: Make ovs_tunnel_info 
and ovs_key_ipv4_tunnel generic

:: TO: Thomas Graf 
:: CC: David S. Miller 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH net v2] openvswitch: Fix egress tunnel info.

2015-10-22 Thread Pravin B Shelar
While transitioning to netdev based vport we broke OVS
feature which allows user to retrieve tunnel packet egress
information for lwtunnel devices.  Following patch fixes it
by introducing ndo operation to get the tunnel egress info.
Same ndo operation can be used for lwtunnel devices and compat
ovs-tnl-vport devices. So after adding such device operation
we can remove similar operation from ovs-vport.

Fixes: 614732eaa12d ("openvswitch: Use regular VXLAN net_device device").
Signed-off-by: Pravin B Shelar 
---
v1-v2:
- changed ndo operation name to ndo_fill_metadata_dst()
- Fix geneve stats update
---
 drivers/net/geneve.c   |   40 ++-
 drivers/net/vxlan.c|   41 
 include/linux/netdevice.h  |7 +
 include/net/dst_metadata.h |   32 ++
 net/core/dev.c |   27 ++
 net/ipv4/ip_gre.c  |   46 +--
 net/openvswitch/actions.c  |8 ++---
 net/openvswitch/datapath.c |5 +--
 net/openvswitch/datapath.h |1 -
 net/openvswitch/flow_netlink.c |   18 +---
 net/openvswitch/flow_netlink.h |6 ++--
 net/openvswitch/vport-geneve.c |   13 -
 net/openvswitch/vport-gre.c|8 -
 net/openvswitch/vport-vxlan.c  |   19 -
 net/openvswitch/vport.c|   58 
 net/openvswitch/vport.h|   35 
 16 files changed, 192 insertions(+), 172 deletions(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index cde29f8..445071c 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -594,14 +594,12 @@ static struct rtable *geneve_get_rt(struct sk_buff *skb,
rt = ip_route_output_key(geneve->net, fl4);
if (IS_ERR(rt)) {
netdev_dbg(dev, "no route to %pI4\n", >daddr);
-   dev->stats.tx_carrier_errors++;
-   return rt;
+   return ERR_PTR(-ENETUNREACH);
}
if (rt->dst.dev == dev) { /* is this necessary? */
netdev_dbg(dev, "circular route to %pI4\n", >daddr);
-   dev->stats.collisions++;
ip_rt_put(rt);
-   return ERR_PTR(-EINVAL);
+   return ERR_PTR(-ELOOP);
}
return rt;
 }
@@ -627,12 +625,12 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, 
struct net_device *dev)
struct ip_tunnel_info *info = NULL;
struct rtable *rt = NULL;
const struct iphdr *iip; /* interior IP header */
+   int err = -EINVAL;
struct flowi4 fl4;
__u8 tos, ttl;
__be16 sport;
bool udp_csum;
__be16 df;
-   int err;
 
if (geneve->collect_md) {
info = skb_tunnel_info(skb);
@@ -647,7 +645,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct 
net_device *dev)
rt = geneve_get_rt(skb, dev, , info);
if (IS_ERR(rt)) {
netdev_dbg(dev, "no route to %pI4\n", );
-   dev->stats.tx_carrier_errors++;
+   err = PTR_ERR(rt);
goto tx_error;
}
 
@@ -699,10 +697,37 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, 
struct net_device *dev)
 tx_error:
dev_kfree_skb(skb);
 err:
-   dev->stats.tx_errors++;
+   if (err == -ELOOP)
+   dev->stats.collisions++;
+   else if (err == -ENETUNREACH)
+   dev->stats.tx_carrier_errors++;
+   else
+   dev->stats.tx_errors++;
return NETDEV_TX_OK;
 }
 
+static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff 
*skb)
+{
+   struct ip_tunnel_info *info = skb_tunnel_info(skb);
+   struct geneve_dev *geneve = netdev_priv(dev);
+   struct rtable *rt;
+   struct flowi4 fl4;
+
+   if (ip_tunnel_info_af(info) != AF_INET)
+   return -EINVAL;
+
+   rt = geneve_get_rt(skb, dev, , info);
+   if (IS_ERR(rt))
+   return PTR_ERR(rt);
+
+   ip_rt_put(rt);
+   info->key.u.ipv4.src = fl4.saddr;
+   info->key.tp_src = udp_flow_src_port(geneve->net, skb,
+1, USHRT_MAX, true);
+   info->key.tp_dst = geneve->dst_port;
+   return 0;
+}
+
 static const struct net_device_ops geneve_netdev_ops = {
.ndo_init   = geneve_init,
.ndo_uninit = geneve_uninit,
@@ -713,6 +738,7 @@ static const struct net_device_ops geneve_netdev_ops = {
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr  = eth_validate_addr,
.ndo_set_mac_address= eth_mac_addr,
+   .ndo_fill_metadata_dst  = geneve_fill_metadata_dst,
 };
 
 static void geneve_get_drvinfo(struct net_device *dev,
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index afdc65f..c1587ec 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -2337,6 +2337,46 @@ 

Re: [PATCH net v2] openvswitch: Fix egress tunnel info.

2015-10-22 Thread David Miller
From: Pravin B Shelar 
Date: Thu, 22 Oct 2015 14:29:30 -0700

> While transitioning to netdev based vport we broke OVS
> feature which allows user to retrieve tunnel packet egress
> information for lwtunnel devices.  Following patch fixes it
> by introducing ndo operation to get the tunnel egress info.
> Same ndo operation can be used for lwtunnel devices and compat
> ovs-tnl-vport devices. So after adding such device operation
> we can remove similar operation from ovs-vport.
> 
> Fixes: 614732eaa12d ("openvswitch: Use regular VXLAN net_device device").
> Signed-off-by: Pravin B Shelar 
> ---
> v1-v2:
> - changed ndo operation name to ndo_fill_metadata_dst()
> - Fix geneve stats update

Please kill the unused local variable found by the kbuild test
robot.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html