]> git.proxmox.com Git - mirror_ovs.git/commitdiff
odp-util: refector erspan option parsing.
authorWilliam Tu <u9012063@gmail.com>
Fri, 25 May 2018 13:28:48 +0000 (06:28 -0700)
committerBen Pfaff <blp@ovn.org>
Fri, 25 May 2018 20:56:23 +0000 (13:56 -0700)
Instead of memcpy to a local stack, parse the erspan
metadata in memory.

Suggested-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/odp-util.c

index 105ac809073e85e498d430e652cf339ed4fdcfb4..5e858f0f9797392daf962e7392e556f4e1ee7156 100644 (file)
@@ -2781,17 +2781,14 @@ odp_tun_key_from_attr__(const struct nlattr *attr, bool is_mask,
             tun_metadata_from_geneve_nlattr(a, is_mask, tun);
             break;
         case OVS_TUNNEL_KEY_ATTR_ERSPAN_OPTS: {
-            int attr_len = nl_attr_get_size(a);
-            struct erspan_metadata opts;
+            const struct erspan_metadata *opts = nl_attr_get(a);
 
-            memcpy(&opts, nl_attr_get(a), attr_len);
-
-            tun->erspan_ver = opts.version;
+            tun->erspan_ver = opts->version;
             if (tun->erspan_ver == 1) {
-                tun->erspan_idx = ntohl(opts.u.index);
+                tun->erspan_idx = ntohl(opts->u.index);
             } else if (tun->erspan_ver == 2) {
-                tun->erspan_dir = opts.u.md2.dir;
-                tun->erspan_hwid = get_hwid(&opts.u.md2);
+                tun->erspan_dir = opts->u.md2.dir;
+                tun->erspan_hwid = get_hwid(&opts->u.md2);
             } else {
                 VLOG_WARN("%s invalid erspan version\n", __func__);
             }