Skip to content

Commit

Permalink
odp-util: refector erspan option parsing.
Browse files Browse the repository at this point in the history
Instead of memcpy to a local stack, parse the erspan
metadata in memory.

Suggested-by: Ben Pfaff <[email protected]>
Signed-off-by: William Tu <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
williamtu authored and blp committed May 25, 2018
1 parent 4ee9f05 commit 5062a04
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
}
Expand Down

0 comments on commit 5062a04

Please sign in to comment.