From 36a1c3bd4a1503ee5561d7c2714b6f0fce049089 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Sun, 11 Mar 2018 09:45:48 +0200 Subject: [PATCH] mlxsw: spectrum: Move mlxsw_sp_span_gretap4_route() Move the function next to the rest of gretap4 functions. Thus the generic functions shared between gretap4 and gretap6 are in one block at the beginning, followed by a gretap4 block, followed by a gretap6 block. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller --- .../net/ethernet/mellanox/mlxsw/spectrum_span.c | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c index f537e1d..e82f5f4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c @@ -133,39 +133,6 @@ struct mlxsw_sp_span_entry_ops mlxsw_sp_span_entry_ops_phys = { .deconfigure = mlxsw_sp_span_entry_phys_deconfigure, }; -static struct net_device * -mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, - __be32 *saddrp, __be32 *daddrp) -{ - struct ip_tunnel *tun = netdev_priv(to_dev); - struct net_device *dev = NULL; - struct ip_tunnel_parm parms; - struct rtable *rt = NULL; - struct flowi4 fl4; - - /* We assume "dev" stays valid after rt is put. */ - ASSERT_RTNL(); - - parms = mlxsw_sp_ipip_netdev_parms4(to_dev); - ip_tunnel_init_flow(&fl4, parms.iph.protocol, *daddrp, *saddrp, - 0, 0, parms.link, tun->fwmark); - - rt = ip_route_output_key(tun->net, &fl4); - if (IS_ERR(rt)) - return NULL; - - if (rt->rt_type != RTN_UNICAST) - goto out; - - dev = rt->dst.dev; - *saddrp = fl4.saddr; - *daddrp = rt->rt_gateway; - -out: - ip_rt_put(rt); - return dev; -} - static int mlxsw_sp_span_dmac(struct neigh_table *tbl, const void *pkey, struct net_device *l3edev, @@ -227,6 +194,39 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev, return 0; } +static struct net_device * +mlxsw_sp_span_gretap4_route(const struct net_device *to_dev, + __be32 *saddrp, __be32 *daddrp) +{ + struct ip_tunnel *tun = netdev_priv(to_dev); + struct net_device *dev = NULL; + struct ip_tunnel_parm parms; + struct rtable *rt = NULL; + struct flowi4 fl4; + + /* We assume "dev" stays valid after rt is put. */ + ASSERT_RTNL(); + + parms = mlxsw_sp_ipip_netdev_parms4(to_dev); + ip_tunnel_init_flow(&fl4, parms.iph.protocol, *daddrp, *saddrp, + 0, 0, parms.link, tun->fwmark); + + rt = ip_route_output_key(tun->net, &fl4); + if (IS_ERR(rt)) + return NULL; + + if (rt->rt_type != RTN_UNICAST) + goto out; + + dev = rt->dst.dev; + *saddrp = fl4.saddr; + *daddrp = rt->rt_gateway; + +out: + ip_rt_put(rt); + return dev; +} + static int mlxsw_sp_span_entry_gretap4_parms(const struct net_device *to_dev, struct mlxsw_sp_span_parms *sparmsp) -- 2.7.4