]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/mlx5e: Specify out ifindex when looking up encap route
authorChris Mi <cmi@nvidia.com>
Sun, 26 Sep 2021 09:17:49 +0000 (17:17 +0800)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 5 Oct 2021 01:10:54 +0000 (18:10 -0700)
There is a use case that the local and remote VTEPs are in the same
host. Currently, the out ifindex is not specified when looking up the
encap route for offloads. So in this case, a local route is returned
and the route dev is lo.

Actual tunnel interface can be created with a parameter "dev" [1],
which specifies the physical device to use for tunnel endpoint
communication. Pass this parameter to driver when looking up encap
route for offloads. So that a unicast route will be returned.

[1] ip link add name vxlan1 type vxlan id 100 dev enp4s0f0 remote 1.1.1.1 dstport 4789

Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.h
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c

index b4e98681879470a30f93346cb7dc66680228d9de..cc7d7b895b80045b9403d7b600daa2c5325d73cb 100644 (file)
@@ -118,6 +118,11 @@ static int mlx5e_route_lookup_ipv4_get(struct mlx5e_priv *priv,
 
                uplink_dev = mlx5_eswitch_uplink_get_proto_dev(esw, REP_ETH);
                attr->fl.fl4.flowi4_oif = uplink_dev->ifindex;
+       } else {
+               struct mlx5e_tc_tunnel *tunnel = mlx5e_get_tc_tun(mirred_dev);
+
+               if (tunnel && tunnel->get_remote_ifindex)
+                       attr->fl.fl4.flowi4_oif = tunnel->get_remote_ifindex(mirred_dev);
        }
 
        rt = ip_route_output_key(dev_net(mirred_dev), &attr->fl.fl4);
@@ -435,12 +440,15 @@ static int mlx5e_route_lookup_ipv6_get(struct mlx5e_priv *priv,
                                       struct net_device *mirred_dev,
                                       struct mlx5e_tc_tun_route_attr *attr)
 {
+       struct mlx5e_tc_tunnel *tunnel = mlx5e_get_tc_tun(mirred_dev);
        struct net_device *route_dev;
        struct net_device *out_dev;
        struct dst_entry *dst;
        struct neighbour *n;
        int ret;
 
+       if (tunnel && tunnel->get_remote_ifindex)
+               attr->fl.fl6.flowi6_oif = tunnel->get_remote_ifindex(mirred_dev);
        dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(mirred_dev), NULL, &attr->fl.fl6,
                                              NULL);
        if (IS_ERR(dst))
index 9350ca05ce65a9cf81a56960849c51cbefac42d1..aa092eaeaec3e3799817b6c6b5df58e97ab192cb 100644 (file)
@@ -51,6 +51,7 @@ struct mlx5e_tc_tunnel {
                            void *headers_v);
        bool (*encap_info_equal)(struct mlx5e_encap_key *a,
                                 struct mlx5e_encap_key *b);
+       int (*get_remote_ifindex)(struct net_device *mirred_dev);
 };
 
 extern struct mlx5e_tc_tunnel vxlan_tunnel;
index 4267f3a1059e7f4933e2da58d33df186dc3797ee..fd07c4cbfd1d253bfb19fe9ac99feb099fd7b288 100644 (file)
@@ -141,6 +141,14 @@ static int mlx5e_tc_tun_parse_vxlan(struct mlx5e_priv *priv,
        return 0;
 }
 
+static int mlx5e_tc_tun_get_remote_ifindex(struct net_device *mirred_dev)
+{
+       const struct vxlan_dev *vxlan = netdev_priv(mirred_dev);
+       const struct vxlan_rdst *dst = &vxlan->default_dst;
+
+       return dst->remote_ifindex;
+}
+
 struct mlx5e_tc_tunnel vxlan_tunnel = {
        .tunnel_type          = MLX5E_TC_TUNNEL_TYPE_VXLAN,
        .match_level          = MLX5_MATCH_L4,
@@ -151,4 +159,5 @@ struct mlx5e_tc_tunnel vxlan_tunnel = {
        .parse_udp_ports      = mlx5e_tc_tun_parse_udp_ports_vxlan,
        .parse_tunnel         = mlx5e_tc_tun_parse_vxlan,
        .encap_info_equal     = mlx5e_tc_tun_encap_info_equal_generic,
+       .get_remote_ifindex   = mlx5e_tc_tun_get_remote_ifindex,
 };