summaryrefslogtreecommitdiffstats
path: root/net/switchdev/switchdev.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2016-05-17 12:58:08 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-17 13:58:49 -0400
commitda4ed55165d41b1073f9a476f1c18493e9bf8c8e (patch)
tree0971053bdbdb27fe6d0f9e801411ae94f0a8974d /net/switchdev/switchdev.c
parentdc327f8931cb9d66191f489eb9a852fc04530546 (diff)
switchdev: pass pointer to fib_info instead of copy
The problem is that fib_info->nh is [0] so the struct fib_info allocation size depends on number of nexthops. If we just copy fib_info, we do not copy the nexthops info and driver accesses memory which is not ours. Given the fact that fib4 does not defer operations and therefore it does not need copy, just pass the pointer down to drivers as it was done before. Fixes: 850d0cbc91 ("switchdev: remove pointers from switchdev objects") Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/switchdev/switchdev.c')
-rw-r--r--net/switchdev/switchdev.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index b7e01d88bdc5..59658b2e9cdf 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -1188,6 +1188,7 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
1188 .obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB, 1188 .obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB,
1189 .dst = dst, 1189 .dst = dst,
1190 .dst_len = dst_len, 1190 .dst_len = dst_len,
1191 .fi = fi,
1191 .tos = tos, 1192 .tos = tos,
1192 .type = type, 1193 .type = type,
1193 .nlflags = nlflags, 1194 .nlflags = nlflags,
@@ -1196,8 +1197,6 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
1196 struct net_device *dev; 1197 struct net_device *dev;
1197 int err = 0; 1198 int err = 0;
1198 1199
1199 memcpy(&ipv4_fib.fi, fi, sizeof(ipv4_fib.fi));
1200
1201 /* Don't offload route if using custom ip rules or if 1200 /* Don't offload route if using custom ip rules or if
1202 * IPv4 FIB offloading has been disabled completely. 1201 * IPv4 FIB offloading has been disabled completely.
1203 */ 1202 */
@@ -1242,6 +1241,7 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
1242 .obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB, 1241 .obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB,
1243 .dst = dst, 1242 .dst = dst,
1244 .dst_len = dst_len, 1243 .dst_len = dst_len,
1244 .fi = fi,
1245 .tos = tos, 1245 .tos = tos,
1246 .type = type, 1246 .type = type,
1247 .nlflags = 0, 1247 .nlflags = 0,
@@ -1250,8 +1250,6 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
1250 struct net_device *dev; 1250 struct net_device *dev;
1251 int err = 0; 1251 int err = 0;
1252 1252
1253 memcpy(&ipv4_fib.fi, fi, sizeof(ipv4_fib.fi));
1254
1255 if (!(fi->fib_flags & RTNH_F_OFFLOAD)) 1253 if (!(fi->fib_flags & RTNH_F_OFFLOAD))
1256 return 0; 1254 return 0;
1257 1255